summaryrefslogtreecommitdiffstats
path: root/player
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
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')
-rw-r--r--player/core.h3
-rw-r--r--player/loadfile.c10
-rw-r--r--player/misc.c15
-rw-r--r--player/playloop.c3
4 files changed, 15 insertions, 16 deletions
diff --git a/player/core.h b/player/core.h
index bda0309f9d..55c526b4cc 100644
--- a/player/core.h
+++ b/player/core.h
@@ -411,8 +411,7 @@ void mp_print_version(struct mp_log *log, int always);
// misc.c
double get_start_time(struct MPContext *mpctx);
double get_main_demux_pts(struct MPContext *mpctx);
-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 get_play_end_pts(struct MPContext *mpctx);
double get_relative_time(struct MPContext *mpctx);
void merge_playlist_files(struct playlist *pl);
diff --git a/player/loadfile.c b/player/loadfile.c
index 948142fb45..e90c3b6200 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1331,18 +1331,18 @@ goto_reopen_demuxer: ;
mpctx->seek = (struct seek_params){ 0 };
// If there's a timeline force an absolute seek to initialize state
- double startpos = rel_time_to_abs(mpctx, opts->play_start, -1);
- if (startpos == -1 && mpctx->resolve_result &&
+ double startpos = rel_time_to_abs(mpctx, opts->play_start);
+ if (startpos == MP_NOPTS_VALUE && mpctx->resolve_result &&
mpctx->resolve_result->start_time > 0)
startpos = mpctx->resolve_result->start_time;
- if (startpos == -1 && opts->chapterrange[0] > 0) {
+ if (startpos == MP_NOPTS_VALUE && opts->chapterrange[0] > 0) {
double start = chapter_start_time(mpctx, opts->chapterrange[0] - 1);
if (start != MP_NOPTS_VALUE)
startpos = start;
}
- if (startpos == -1 && mpctx->timeline)
+ if (startpos == MP_NOPTS_VALUE && mpctx->timeline)
startpos = 0;
- if (startpos != -1) {
+ if (startpos != MP_NOPTS_VALUE) {
queue_seek(mpctx, MPSEEK_ABSOLUTE, startpos, 0, true);
execute_queued_seek(mpctx);
}
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;
diff --git a/player/playloop.c b/player/playloop.c
index bbcc9a3df7..dd3762d36b 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -461,8 +461,7 @@ double get_current_pos_ratio(struct MPContext *mpctx, bool use_range)
double start = get_start_time(mpctx);
double len = get_time_length(mpctx);
if (use_range) {
- double startpos = rel_time_to_abs(mpctx, mpctx->opts->play_start,
- MP_NOPTS_VALUE);
+ double startpos = rel_time_to_abs(mpctx, mpctx->opts->play_start);
double endpos = get_play_end_pts(mpctx);
if (endpos == MP_NOPTS_VALUE || endpos > start + len)
endpos = start + len;