summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-08 14:57:45 +0100
committerwm4 <wm4@nowhere>2020-02-08 15:01:33 +0100
commite9fc53a10b889c5add90364ded20d0448b88f93a (patch)
tree772500ffe7bf01a1d4382ae68b3e872379bc9f72 /player
parent3fb0cc203bf0e5595e209e6b3eb3da3bb5e54a3a (diff)
downloadmpv-e9fc53a10b889c5add90364ded20d0448b88f93a.tar.bz2
mpv-e9fc53a10b889c5add90364ded20d0448b88f93a.tar.xz
player: add ab-loop-count option/property
As requested I guess. It behaves quite similar to the --loop* options. Not quite happy with the idea that 1) the option is mutated on each operation (but at least it's consistent with --loop* and doesn't require more properties), and 2) the ab-loop command will do nothing once all loop iterations are done. As a concession, the OSD shows something about "disabled". Fixes: #7360
Diffstat (limited to 'player')
-rw-r--r--player/command.c3
-rw-r--r--player/misc.c3
-rw-r--r--player/playloop.c4
3 files changed, 9 insertions, 1 deletions
diff --git a/player/command.c b/player/command.c
index 3f13c39a02..21c595ce57 100644
--- a/player/command.c
+++ b/player/command.c
@@ -3731,7 +3731,8 @@ static const struct property_osd_display {
{"vf", "Video filters", .msg = "Video filters:\n${vf}"},
{"af", "Audio filters", .msg = "Audio filters:\n${af}"},
{"ab-loop-a", "A-B loop start"},
- {"ab-loop-b", .msg = "A-B loop: ${ab-loop-a} - ${ab-loop-b}"},
+ {"ab-loop-b", .msg = "A-B loop: ${ab-loop-a} - ${ab-loop-b}"
+ "${?=ab-loop-count==0: (disabled)}"},
{"audio-device", "Audio device"},
{"hwdec", .msg = "Hardware decoding: ${hwdec-current}"},
{"video-aspect-override", "Aspect ratio override"},
diff --git a/player/misc.c b/player/misc.c
index c3765e5055..f6a63ec7ef 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -123,6 +123,9 @@ bool get_ab_loop_times(struct MPContext *mpctx, double t[2])
t[0] = opts->ab_loop[0];
t[1] = opts->ab_loop[1];
+ if (!opts->ab_loop_count)
+ return false;
+
if (t[0] == MP_NOPTS_VALUE || t[1] == MP_NOPTS_VALUE || t[0] == t[1])
return false;
diff --git a/player/playloop.c b/player/playloop.c
index 86f19fd79f..4f0efad275 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -885,6 +885,10 @@ static void handle_loop_file(struct MPContext *mpctx)
double ab[2];
if (get_ab_loop_times(mpctx, ab) && mpctx->ab_loop_clip) {
+ if (opts->ab_loop_count > 0) {
+ opts->ab_loop_count--;
+ m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->ab_loop_count);
+ }
target = ab[0];
prec = MPSEEK_EXACT;
} else if (opts->loop_file) {