From 54e8e0a50207283d1cbe595e69e5cd10c346ed40 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 25 Mar 2013 22:57:24 +0100 Subject: mplayer: make --frames=1 work for audio This has the same (useless) definition as frame stepping in audio-only mode: one frame means one playloop iteration. (It's relatively useless, because one playloop iteration has a random duration. But it makes --frames=1 work, which is useful again.) --- core/mplayer.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'core') diff --git a/core/mplayer.c b/core/mplayer.c index eeb875173b..ed8505251a 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -3158,7 +3158,7 @@ static void run_playloop(struct MPContext *mpctx) bool end_is_chapter = false; double sleeptime = get_wakeup_period(mpctx); bool was_restart = mpctx->restart_playback; - bool new_video_frame_shown = false; + bool new_frame_shown = false; #ifdef CONFIG_ENCODING if (encode_lavc_didfail(mpctx->encode_lavc_ctx)) { @@ -3342,20 +3342,25 @@ static void run_playloop(struct MPContext *mpctx) update_avsync(mpctx); print_status(mpctx); screenshot_flip(mpctx); - new_video_frame_shown = true; + new_frame_shown = true; - if (mpctx->max_frames >= 0) { - mpctx->max_frames--; - if (mpctx->max_frames <= 0) - mpctx->stop_play = PT_NEXT_ENTRY; - } break; } // video + // If no more video is available, one frame means one playloop iteration. + // Otherwise, one frame means one video frame. + if (!video_left) + new_frame_shown = true; + + if (mpctx->max_frames >= 0) { + if (new_frame_shown) + mpctx->max_frames--; + if (mpctx->max_frames <= 0) + mpctx->stop_play = PT_NEXT_ENTRY; + } + if (mpctx->step_frames > 0 && !mpctx->paused) { - // If no more video is available, one frame means one playloop iteration. - // Otherwise, one frame means one video frame. - if (!video_left || new_video_frame_shown) + if (new_frame_shown) mpctx->step_frames--; if (mpctx->step_frames == 0) pause_player(mpctx); -- cgit v1.2.3