From f045c1552e94cb2bf8380b19a73ae50e9aff0593 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 5 Apr 2012 00:04:01 +0300 Subject: core: fix problems in video EOF detection Fix a missing check that could sometimes result in video frames being shown after specified end pts (end of timeline segment or --endpos). Fix mistaken video EOF detection after aspect change in video stream, when there is no current valid visible frame but the next frame is already buffered in VO. --- mplayer.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index eb278353e3..cc56cc802b 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3452,12 +3452,12 @@ static void run_playloop(struct MPContext *mpctx) double buffered_audio = -1; while (mpctx->sh_video) { // never loops, for "break;" only + struct vo *vo = mpctx->video_out; vo_pts = mpctx->sh_video->timer * 90000.0; vo_fps = mpctx->sh_video->fps; - video_left = mpctx->video_out->hasframe; - if (!mpctx->video_out->frame_loaded - && (!mpctx->paused || mpctx->restart_playback)) { + video_left = vo->hasframe || vo->frame_loaded; + if (!vo->frame_loaded && (!mpctx->paused || mpctx->restart_playback)) { double frame_time = update_video(mpctx); mp_dbg(MSGT_AVSYNC, MSGL_DBG2, "*** ftime=%5.3f ***\n", frame_time); if (mpctx->sh_video->vf_initialized < 0) { @@ -3468,18 +3468,19 @@ static void run_playloop(struct MPContext *mpctx) return; } video_left = frame_time >= 0; - if (endpts != MP_NOPTS_VALUE) - video_left &= mpctx->sh_video->pts < endpts; if (video_left && !mpctx->restart_playback) { mpctx->time_frame += frame_time / opts->playback_speed; adjust_sync(mpctx, frame_time); } } + if (endpts != MP_NOPTS_VALUE) + video_left &= mpctx->sh_video->pts < endpts; + // ================================================================ current_module = "vo_check_events"; - vo_check_events(mpctx->video_out); + vo_check_events(vo); #ifdef CONFIG_X11 if (stop_xscreensaver) { @@ -3498,7 +3499,7 @@ static void run_playloop(struct MPContext *mpctx) if (!video_left || (mpctx->paused && !mpctx->restart_playback)) break; - if (!mpctx->video_out->frame_loaded) { + if (!vo->frame_loaded) { sleeptime = 0; break; } @@ -3536,7 +3537,7 @@ static void run_playloop(struct MPContext *mpctx) mpctx->time_frame = 0; } - double vsleep = mpctx->time_frame - mpctx->video_out->flip_queue_offset; + double vsleep = mpctx->time_frame - vo->flip_queue_offset; if (vsleep > 0.050) { sleeptime = FFMIN(sleeptime, vsleep - 0.040); break; @@ -3546,7 +3547,7 @@ static void run_playloop(struct MPContext *mpctx) //=================== FLIP PAGE (VIDEO BLT): ====================== current_module = "flip_page"; - vo_new_frame_imminent(mpctx->video_out); + vo_new_frame_imminent(vo); struct sh_video *sh_video = mpctx->sh_video; mpctx->video_pts = sh_video->pts; update_subtitles(mpctx, sh_video->pts, false); @@ -3558,12 +3559,12 @@ static void run_playloop(struct MPContext *mpctx) vf->control(vf, VFCTRL_DRAW_OSD, mpctx->osd); vo_osd_changed(0); - mpctx->time_frame -= mpctx->video_out->flip_queue_offset; + mpctx->time_frame -= vo->flip_queue_offset; float aq_sleep_time = mpctx->time_frame; if (mpctx->time_frame > 0.001 && !(mpctx->sh_video->output_flags & VFCAP_TIMER)) mpctx->time_frame = timing_sleep(mpctx, mpctx->time_frame); - mpctx->time_frame += mpctx->video_out->flip_queue_offset; + mpctx->time_frame += vo->flip_queue_offset; unsigned int t2 = GetTimer(); /* Playing with playback speed it's possible to get pathological @@ -3572,7 +3573,7 @@ static void run_playloop(struct MPContext *mpctx) double time_frame = FFMAX(mpctx->time_frame, -1); unsigned int pts_us = mpctx->last_time + time_frame * 1e6; int duration = -1; - double pts2 = mpctx->video_out->next_pts2; + double pts2 = vo->next_pts2; if (pts2 != MP_NOPTS_VALUE && opts->correct_pts && !mpctx->restart_playback) { // expected A/V sync correction is ignored @@ -3586,11 +3587,11 @@ static void run_playloop(struct MPContext *mpctx) diff = 10; duration = diff * 1e6; } - vo_flip_page(mpctx->video_out, pts_us | 1, duration); + vo_flip_page(vo, pts_us | 1, duration); mpctx->last_vo_flip_duration = (GetTimer() - t2) * 0.000001; vout_time_usage += mpctx->last_vo_flip_duration; - if (mpctx->video_out->driver->flip_page_timed) { + if (vo->driver->flip_page_timed) { // No need to adjust sync based on flip speed mpctx->last_vo_flip_duration = 0; // For print_status - VO call finishing early is OK for sync -- cgit v1.2.3 From 87ae9d3e45ef6e331b34fa92ac1d0c68495f5379 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 5 Apr 2012 00:23:32 +0300 Subject: core: in VO flip timing, recheck time after OSD draw Make the code read current real time again after drawing OSD. This ensures time taken in OSD drawing is properly deducted from the duration of the following sleep. The main practical effect is to avoid the A-V field on the status line staying at a value a couple of milliseconds above 0 (depending on VO). --- mplayer.c | 1 + 1 file changed, 1 insertion(+) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index cc56cc802b..edeffef9e4 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3559,6 +3559,7 @@ static void run_playloop(struct MPContext *mpctx) vf->control(vf, VFCTRL_DRAW_OSD, mpctx->osd); vo_osd_changed(0); + mpctx->time_frame -= get_relative_time(mpctx); mpctx->time_frame -= vo->flip_queue_offset; float aq_sleep_time = mpctx->time_frame; if (mpctx->time_frame > 0.001 -- cgit v1.2.3 From b93ed278362185ff980e0ce8f4ab3029f8fe395f Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Fri, 6 Apr 2012 14:24:26 +0300 Subject: input: stop trying to read terminal input on EOF Stop trying to read terminal input if a read attempt returns EOF. The most important case where this matters is when someone runs the player with stdin redirected from /dev/null and without specifying --no-consolecontrols. This used to cause 100% CPU load while paused, as select() would continuously trigger on stdin (the need for --no-consolecontrols was not apparent to people with older mplayer versions, as input reading was less efficient and latencies like hardcoded sleeps kept CPU use well below 100%). Now this will only cause a "Dead key input" error message. --- mplayer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index edeffef9e4..26555e3c20 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3798,8 +3798,9 @@ static void run_playloop(struct MPContext *mpctx) static int read_keys(void *ctx, int fd) { - getch2(ctx); - return MP_INPUT_NOTHING; + if (getch2(ctx)) + return MP_INPUT_NOTHING; + return MP_INPUT_DEAD; } static bool attachment_is_font(struct demux_attachment *att) -- cgit v1.2.3 From e2fc1f640fdf473fdf8f1de6fd1212731b8ffa13 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Fri, 6 Apr 2012 16:58:39 +0300 Subject: build: remove OS/2 support --- mplayer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 26555e3c20..d410008dff 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1247,7 +1247,7 @@ static void print_status(struct MPContext *mpctx, double a_pos, bool at_frame) width = screen_width; else width = 80; -#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__OS2__) +#if defined(__MINGW32__) || defined(__CYGWIN__) /* Windows command line is broken (MinGW's rxvt works, but we * should not depend on that). */ width--; -- cgit v1.2.3