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.
This commit is contained in:
wm4 2019-01-11 11:02:23 +01:00
parent 2bf1862bc1
commit 7498fa0b3d
1 changed files with 3 additions and 2 deletions

View File

@ -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);