From 0cc35946235bd356db2836b77a842c7363bdde5c Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 5 Jul 2014 16:58:48 +0200 Subject: dvd: flush buffers properly on seek Suggested by tholin on github issue #882. This is not entirely clean, but the fields we're accessing might be considered internal to libavformat. On the other hand, existence of the fields is guaranteed by the ABI, and nothing in the libavformat doxygen suggestes they're not allowed to be accessed. CC: @mpv-player/stable --- demux/demux_lavf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 3c18866312..1a16eecaf9 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -983,11 +983,12 @@ redo: * call the new API instead of relying on av_seek_frame() to do this * for us. */ - stream_drop_buffers(demuxer->stream); - avio_flush(priv->avfc->pb); av_seek_frame(priv->avfc, 0, stream_tell(demuxer->stream), AVSEEK_FLAG_BYTE); - avio_flush(priv->avfc->pb); + // avio_flush() is designed for write-only streams, and does the wrong + // thing when reading. Flush it manually instead. + priv->avfc->pb->buf_ptr = priv->avfc->pb->buf_end; + stream_drop_buffers(demuxer->stream); return DEMUXER_CTRL_OK; default: return DEMUXER_CTRL_NOTIMPL; -- cgit v1.2.3