summaryrefslogtreecommitdiffstats
path: root/player/playloop.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-10-16 16:16:10 +0200
committerwm4 <wm4@nowhere>2015-10-16 16:16:10 +0200
commit8d414e2fe7f79f1bbf9158e8aa034e9ac9cf2222 (patch)
tree6c5d512e3d79f882e8a5b16599f91b02109cfb6c /player/playloop.c
parent2483dab54d77288db218030910f6b1b4b08292e5 (diff)
downloadmpv-8d414e2fe7f79f1bbf9158e8aa034e9ac9cf2222.tar.bz2
mpv-8d414e2fe7f79f1bbf9158e8aa034e9ac9cf2222.tar.xz
command: make time properties unavailable if timestamp is unknown
Let's hope this doesn't confuse client API users too much. It's still the best solution to get rid of corner cases where it actually return the wrong timestamp on start, and then suddenly jump.
Diffstat (limited to 'player/playloop.c')
-rw-r--r--player/playloop.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/player/playloop.c b/player/playloop.c
index 2972593050..f5463e2622 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -199,7 +199,8 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek,
break;
case MPSEEK_RELATIVE:
direction = seek.amount > 0 ? 1 : -1;
- target_time = seek.amount + get_current_time(mpctx);
+ double cur = get_current_time(mpctx);
+ target_time = seek.amount + (cur == MP_NOPTS_VALUE ? 0 : cur);
break;
case MPSEEK_FACTOR: ;
double len = get_time_length(mpctx);
@@ -390,18 +391,20 @@ double get_time_length(struct MPContext *mpctx)
double get_current_time(struct MPContext *mpctx)
{
struct demuxer *demuxer = mpctx->demuxer;
- if (!demuxer)
- return 0;
- if (mpctx->playback_pts != MP_NOPTS_VALUE)
- return mpctx->playback_pts;
- if (mpctx->last_seek_pts != MP_NOPTS_VALUE)
- return mpctx->last_seek_pts;
- return 0;
+ if (demuxer) {
+ if (mpctx->playback_pts != MP_NOPTS_VALUE)
+ return mpctx->playback_pts;
+ if (mpctx->last_seek_pts != MP_NOPTS_VALUE)
+ return mpctx->last_seek_pts;
+ }
+ return MP_NOPTS_VALUE;
}
double get_playback_time(struct MPContext *mpctx)
{
double cur = get_current_time(mpctx);
+ if (cur == MP_NOPTS_VALUE)
+ return cur;
double start = get_start_time(mpctx);
// During seeking, the time corresponds to the last seek time - apply some
// cosmetics to it.