aboutsummaryrefslogtreecommitdiffhomepage
path: root/player
diff options
context:
space:
mode:
authorGravatar Leo Izen <leo.izen@gmail.com>2017-12-04 12:30:22 -0500
committerGravatar Leo Izen <leo.izen@gmail.com>2017-12-04 12:34:02 -0500
commitfdc311625ec016a685143097c3dc5e352c08b5d9 (patch)
treeffe9f14f3a3a2dfc6b30a19c42721528caccc85c /player
parent9abb710afb8e369eeb3104156c731bd3564abfcd (diff)
player/misc.c: allow both --length and --end to control play endpoint
Most options that change the playback endpoint coexist and playback stops when it reaches any of them. (e.g. --ab-loop-b, --end, or --chapter). This patch extends that behavior to --length so it isn't automatically trumped by --end if both are present. These two will interact now as the other options do. This change is also documented in DOCS/man/options.rst.
Diffstat (limited to 'player')
-rw-r--r--player/misc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/player/misc.c b/player/misc.c
index d68ca22138..0284479f49 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -91,12 +91,13 @@ double get_play_end_pts(struct MPContext *mpctx)
double end = MP_NOPTS_VALUE;
if (opts->play_end.type) {
end = rel_time_to_abs(mpctx, opts->play_end);
- } else if (opts->play_length.type) {
+ }
+ if (opts->play_length.type) {
double start = get_play_start_pts(mpctx);
if (start == MP_NOPTS_VALUE)
start = 0;
double length = rel_time_to_abs(mpctx, opts->play_length);
- if (length != MP_NOPTS_VALUE)
+ if (length != MP_NOPTS_VALUE && (end == MP_NOPTS_VALUE || start + length < end))
end = start + length;
}
if (opts->chapterrange[1] > 0) {