aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-06-19 17:45:05 +0200
committerMax Kellermann <max@duempel.org>2015-06-20 14:29:42 +0200
commitd11e2724c4f1dbe3447b3e81d0a0e71bcc504a0b (patch)
tree0965e89812d646a60a79c89fa8a47e2b18b6fdf4 /src
parentf768ca3a2d20cc839e25ca3c95438909d54afd77 (diff)
downloadmpd-d11e2724c4f1dbe3447b3e81d0a0e71bcc504a0b.tar.gz
mpd-d11e2724c4f1dbe3447b3e81d0a0e71bcc504a0b.tar.xz
mpd-d11e2724c4f1dbe3447b3e81d0a0e71bcc504a0b.zip
decoder/ffmpeg: use AVSEEK_FLAG_BACKWARD for seeking
Ask FFmpeg to seek to the next packet boundary *before* the seek position, so we don't miss audio data. Now we get too much, but we'll solve that in the next commit.
Diffstat (limited to '')
-rw-r--r--src/decoder/plugins/FfmpegDecoderPlugin.cxx6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx
index 586a1ef41..f5c0e0a36 100644
--- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx
+++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx
@@ -597,8 +597,12 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
av_stream->time_base) +
start_time_fallback(*av_stream);
+ /* AVSEEK_FLAG_BACKWARD asks FFmpeg to seek to
+ the packet boundary before the seek time
+ stamp, not after */
+
if (av_seek_frame(format_context, audio_stream, where,
- AVSEEK_FLAG_ANY) < 0)
+ AVSEEK_FLAG_ANY|AVSEEK_FLAG_BACKWARD) < 0)
decoder_seek_error(decoder);
else {
avcodec_flush_buffers(codec_context);