From 878d4ea2ee22cc8d11652aee0fe144ca3f6ae131 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 27 May 2019 01:33:35 +0200 Subject: player: remove some duplication between normal looping and ab-loops Not sure if this is better or worse. Some minor behavior changes. --- player/playloop.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/player/playloop.c b/player/playloop.c index 0d5e9c1779..4067e13459 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -814,25 +814,30 @@ static void handle_loop_file(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; + if (mpctx->stop_play != AT_END_OF_FILE) + return; + + double target = MP_NOPTS_VALUE; + enum seek_precision prec = MPSEEK_DEFAULT; + double ab[2]; - if (mpctx->stop_play == AT_END_OF_FILE && get_ab_loop_times(mpctx, ab) && - mpctx->ab_loop_clip) - { - // Assumes execute_queued_seek() happens before next audio/video is - // attempted to be decoded or filtered. - mpctx->stop_play = KEEP_PLAYING; - mark_seek(mpctx); - queue_seek(mpctx, MPSEEK_ABSOLUTE, ab[0], MPSEEK_EXACT, - MPSEEK_FLAG_NOFLUSH); + if (get_ab_loop_times(mpctx, ab) && mpctx->ab_loop_clip) { + target = ab[0]; + prec = MPSEEK_EXACT; + } else if (opts->loop_file) { + if (opts->loop_file > 0) + opts->loop_file--; + target = 0; } - // Do not attempt to loop-file if --ab-loop is active. - else if (opts->loop_file && mpctx->stop_play == AT_END_OF_FILE) { + if (target != MP_NOPTS_VALUE) { mpctx->stop_play = KEEP_PLAYING; set_osd_function(mpctx, OSD_FFW); - queue_seek(mpctx, MPSEEK_ABSOLUTE, 0, MPSEEK_DEFAULT, MPSEEK_FLAG_NOFLUSH); - if (opts->loop_file > 0) - opts->loop_file--; + mark_seek(mpctx); + + // Assumes execute_queued_seek() happens before next audio/video is + // attempted to be decoded or filtered. + queue_seek(mpctx, MPSEEK_ABSOLUTE, target, prec, MPSEEK_FLAG_NOFLUSH); } } -- cgit v1.2.3