diff options
Diffstat (limited to 'player/misc.c')
-rw-r--r-- | player/misc.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/player/misc.c b/player/misc.c index 9ca1ea9750..d68ca22138 100644 --- a/player/misc.c +++ b/player/misc.c @@ -104,8 +104,11 @@ double get_play_end_pts(struct MPContext *mpctx) if (cend != MP_NOPTS_VALUE && (end == MP_NOPTS_VALUE || cend < end)) end = cend; } + // even though MP_NOPTS_VALUE is currently negative + // it doesn't necessarily have to remain that way + double ab_loop_start_time = get_ab_loop_start_time(mpctx); if (mpctx->ab_loop_clip && opts->ab_loop[1] != MP_NOPTS_VALUE && - opts->ab_loop[1] > opts->ab_loop[0]) + (ab_loop_start_time == MP_NOPTS_VALUE || opts->ab_loop[1] > ab_loop_start_time)) { if (end == MP_NOPTS_VALUE || end > opts->ab_loop[1]) end = opts->ab_loop[1]; @@ -145,6 +148,32 @@ double get_play_start_pts(struct MPContext *mpctx) return play_start_pts; } +/** + * Get the time that an ab-loop seek should seek to. + * The order of priority is as follows: + * 1. --ab-loop-a, if set. + * 2. The Playback Start PTS, if set. + * 3. MP_NOPTS_VALUE. + * If unspecified, return MP_NOPTS_VALUE. + * Does not return zero unless the start time is explicitly set to zero. + */ +double get_ab_loop_start_time(struct MPContext *mpctx) +{ + struct MPOpts *opts = mpctx->opts; + double ab_loop_start_time; + if (opts->ab_loop[0] != MP_NOPTS_VALUE) { + ab_loop_start_time = opts->ab_loop[0]; + } else { + /* + * There is no check for MP_NOPTS_VALUE here + * because that's exactly what we want to return + * if get_play_start_pts comes up empty here. + */ + ab_loop_start_time = get_play_start_pts(mpctx); + } + return ab_loop_start_time; +} + double get_track_seek_offset(struct MPContext *mpctx, struct track *track) { struct MPOpts *opts = mpctx->opts; |