From 7498fa0b3d50d9a8b0f63568b5c5dd88795b596d Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 11 Jan 2019 11:02:23 +0100 Subject: video: fix player not exiting if no video frame was rendered E.g. "mpv null:// --demuxer=rawvideo" will "hang" by waiting for video EOF forever. It's not signalled correctly because of the last-frame corner case, which attempts to wait until the current frame is finally displayed (which is signalled by whether a new frame can be queued, see commit 1a339fa09d for some details). If no frame was ever queued, the VO is not configured, and vo_is_ready_for_frame() never returns true. Fix this by using vo_has_frame(), which seems to be exactly the correct thing we need. --- player/video.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'player/video.c') diff --git a/player/video.c b/player/video.c index ab8490542d..4d8d5d0260 100644 --- a/player/video.c +++ b/player/video.c @@ -1030,12 +1030,13 @@ void write_video(struct MPContext *mpctx) // Wait for the VO to signal actual EOF, then exit if the frame timer // has expired. + bool has_frame = vo_has_frame(vo); // maybe not configured if (mpctx->video_status == STATUS_DRAINING && - vo_is_ready_for_frame(vo, -1)) + (vo_is_ready_for_frame(vo, -1) || !has_frame)) { mpctx->time_frame -= get_relative_time(mpctx); mp_set_timeout(mpctx, mpctx->time_frame); - if (mpctx->time_frame <= 0) { + if (mpctx->time_frame <= 0 || !has_frame) { MP_VERBOSE(mpctx, "video EOF reached\n"); mpctx->video_status = STATUS_EOF; encode_lavc_stream_eof(mpctx->encode_lavc_ctx, STREAM_VIDEO); -- cgit v1.2.3