summaryrefslogtreecommitdiffstats
path: root/player/misc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-25 02:32:24 +0100
committerwm4 <wm4@nowhere>2014-03-25 02:32:24 +0100
commitd2e4938c78014f182e0dce0458cb2a45d2f3c418 (patch)
treed41d7250b38daa93ebe1fb929c24b0a7ef3f0353 /player/misc.c
parent6c2cd08afffa6d4fe5c16144b0c883f6997d0399 (diff)
downloadmpv-d2e4938c78014f182e0dce0458cb2a45d2f3c418.tar.bz2
mpv-d2e4938c78014f182e0dce0458cb2a45d2f3c418.tar.xz
player: use MP_NOPTS_VALUE as rel_time_to_abs() error value
And consistently use MP_NOPTS_VALUE as error value for the users of this function. This is better than using -1, especially because negative values can be valid timestamps.
Diffstat (limited to 'player/misc.c')
-rw-r--r--player/misc.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/player/misc.c b/player/misc.c
index 1bfca9df92..1a52be6a82 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -50,8 +50,7 @@ double get_relative_time(struct MPContext *mpctx)
return delta * 0.000001;
}
-double rel_time_to_abs(struct MPContext *mpctx, struct m_rel_time t,
- double fallback_time)
+double rel_time_to_abs(struct MPContext *mpctx, struct m_rel_time t)
{
double length = get_time_length(mpctx);
switch (t.type) {
@@ -70,19 +69,21 @@ double rel_time_to_abs(struct MPContext *mpctx, struct m_rel_time t,
return chapter_start_time(mpctx, t.pos);
break;
}
- return fallback_time;
+ return MP_NOPTS_VALUE;
}
double get_play_end_pts(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
if (opts->play_end.type) {
- return rel_time_to_abs(mpctx, opts->play_end, MP_NOPTS_VALUE);
+ return rel_time_to_abs(mpctx, opts->play_end);
} else if (opts->play_length.type) {
double startpts = get_start_time(mpctx);
- double start = rel_time_to_abs(mpctx, opts->play_start, startpts);
- double length = rel_time_to_abs(mpctx, opts->play_length, -1);
- if (start != -1 && length != -1)
+ double start = rel_time_to_abs(mpctx, opts->play_start);
+ if (start == MP_NOPTS_VALUE)
+ start = startpts;
+ double length = rel_time_to_abs(mpctx, opts->play_length);
+ if (start != MP_NOPTS_VALUE && length != MP_NOPTS_VALUE)
return start + length;
}
return MP_NOPTS_VALUE;