From 104185052362fc196e4dd676b72f092ff63c6ba2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 22 Jul 2014 21:08:42 +0200 Subject: video: fix corner case with accidental EOF The video flushing logic was broken: if there are no more packets, decode_image() will feed flush packets to the decoder. Even if an image was produced, it will return the demuxer EOF state, and since commit 7083f88c, this EOF state is returned to the caller, which is incorrect. Revert this part of the change, and explicitly check for VD_WAIT (the bogus change was intended to forward this error code to the caller). Also, turn the "r < 1" into something equivalent that doesn't rely on the exact value of VD_EOF. "r < 0" is ok, because at least here, errors are always negative. --- player/video.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'player/video.c') diff --git a/player/video.c b/player/video.c index eef7153fd8..81f45ec3d8 100644 --- a/player/video.c +++ b/player/video.c @@ -389,19 +389,19 @@ static int video_decode_and_filter(struct MPContext *mpctx) return VD_PROGRESS; } - int r = VD_PROGRESS; - if (!d_video->waiting_decoded_mpi) { // Decode a new image, or at least feed the decoder a packet. - r = decode_image(mpctx); + int r = decode_image(mpctx); + if (r == VD_WAIT) + return r; if (d_video->waiting_decoded_mpi) d_video->decoder_output = d_video->waiting_decoded_mpi->params; - if (!d_video->waiting_decoded_mpi && r < 1) + if (!d_video->waiting_decoded_mpi && (r == VD_EOF || r < 0)) return VD_EOF; // true EOF } // Image will be filtered on the next iteration. - return r; + return VD_PROGRESS; } static void init_vo(struct MPContext *mpctx) -- cgit v1.2.3