aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2007-08-23 19:31:14 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2007-08-23 19:31:14 +0000
commit75c896e00f9b6de7843e53eb495657dad59b4370 (patch)
treeeefa5e8edf938320d24c687b79747792c3a510fc /lib
parented3828f0df1bcef66b036ce1831a0aed87ed5482 (diff)
downloadqmmp-75c896e00f9b6de7843e53eb495657dad59b4370.tar.gz
qmmp-75c896e00f9b6de7843e53eb495657dad59b4370.tar.bz2
qmmp-75c896e00f9b6de7843e53eb495657dad59b4370.zip
fixed seeking bug in the ffmpeg plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@120 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'lib')
-rw-r--r--lib/qmmp/Input/ffmpeg/decoder_ffmpeg.cpp24
-rw-r--r--lib/qmmp/Input/ffmpeg/decoder_ffmpeg.h2
2 files changed, 12 insertions, 14 deletions
diff --git a/lib/qmmp/Input/ffmpeg/decoder_ffmpeg.cpp b/lib/qmmp/Input/ffmpeg/decoder_ffmpeg.cpp
index d5edb1ae2..ac674dcd0 100644
--- a/lib/qmmp/Input/ffmpeg/decoder_ffmpeg.cpp
+++ b/lib/qmmp/Input/ffmpeg/decoder_ffmpeg.cpp
@@ -42,7 +42,6 @@ DecoderFFmpeg::DecoderFFmpeg(QObject *parent, DecoderFactory *d, QIODevice *i, O
bks = 0;
done = FALSE;
finish = FALSE;
- len = 0;
freq = 0;
bitrate = 0;
seekTime = -1.0;
@@ -70,7 +69,7 @@ DecoderFFmpeg::~DecoderFFmpeg()
delete [] output_buf;
output_buf = 0;
- if(ic)
+ if (ic)
av_close_input_file(ic);
}
@@ -125,7 +124,7 @@ bool DecoderFFmpeg::initialize()
{
bks = blockSize();
inited = user_stop = done = finish = FALSE;
- len = freq = bitrate = 0;
+ freq = bitrate = 0;
stat = chan = 0;
output_size = 0;
seekTime = -1.0;
@@ -213,9 +212,8 @@ void DecoderFFmpeg::seek(double pos)
void DecoderFFmpeg::deinit()
{
- //FLAC__stream_decoder_finish (data()->decoder);
inited = user_stop = done = finish = FALSE;
- len = freq = bitrate = 0;
+ freq = bitrate = 0;
stat = chan = 0;
output_size = 0;
}
@@ -225,7 +223,7 @@ void DecoderFFmpeg::run()
// mpc_uint32_t vbrAcc = 0;
// mpc_uint32_t vbrUpd = 0;
uint8_t *inbuf_ptr;
- int out_size, size, len;
+ int out_size, size;
AVPacket pkt;
mutex()->lock ();
@@ -253,12 +251,12 @@ void DecoderFFmpeg::run()
timestamp = int64_t(seekTime)*AV_TIME_BASE;
if (ic->start_time != AV_NOPTS_VALUE)
timestamp += ic->start_time;
- av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_ANY);
+ av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD);
+ avcodec_flush_buffers(c);
seekTime = -1.0;
}
int l = 0;
- len = 0;
if (av_read_frame(ic, &pkt) < 0)
{
finish = TRUE;
@@ -267,22 +265,22 @@ void DecoderFFmpeg::run()
size = pkt.size;
inbuf_ptr = pkt.data;
- len = 0;
out_size = 0;
while (size > 0)
{
- //mutex()->lock();
l = avcodec_decode_audio(c, (int16_t *)(wma_outbuf), &out_size, inbuf_ptr, size);
+ if(l < 0)
+ goto end;
ffmpeg_out(out_size);
size -= l;
inbuf_ptr += l;
- if (pkt.data) av_free_packet(&pkt);
- len = out_size;
+ if (pkt.data)
+ av_free_packet(&pkt);
}
bitrate = c->bit_rate/1024;
end:
- if (len == 0 || finish)
+ if (finish)
{
flush(TRUE);
diff --git a/lib/qmmp/Input/ffmpeg/decoder_ffmpeg.h b/lib/qmmp/Input/ffmpeg/decoder_ffmpeg.h
index 86a415a8d..412d43f0f 100644
--- a/lib/qmmp/Input/ffmpeg/decoder_ffmpeg.h
+++ b/lib/qmmp/Input/ffmpeg/decoder_ffmpeg.h
@@ -68,7 +68,7 @@ private:
unsigned int bks;
bool done, finish;
- long len, freq, bitrate;
+ long freq, bitrate;
int chan;
unsigned long output_size;
double totalTime, seekTime;