1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-03 12:47:49 +00:00

player: some minor code golf

This commit is contained in:
wm4 2020-09-10 23:47:59 +02:00
parent 4b9d80644d
commit 98f9d50b30

View File

@ -507,24 +507,19 @@ double get_start_time(struct MPContext *mpctx, int dir)
double get_current_time(struct MPContext *mpctx) double get_current_time(struct MPContext *mpctx)
{ {
struct demuxer *demuxer = mpctx->demuxer; if (!mpctx->demuxer)
if (demuxer) { return MP_NOPTS_VALUE;
if (mpctx->playback_pts != MP_NOPTS_VALUE) if (mpctx->playback_pts != MP_NOPTS_VALUE)
return mpctx->playback_pts * mpctx->play_dir; return mpctx->playback_pts * mpctx->play_dir;
if (mpctx->last_seek_pts != MP_NOPTS_VALUE) return mpctx->last_seek_pts;
return mpctx->last_seek_pts;
}
return MP_NOPTS_VALUE;
} }
double get_playback_time(struct MPContext *mpctx) double get_playback_time(struct MPContext *mpctx)
{ {
double cur = get_current_time(mpctx); double cur = get_current_time(mpctx);
if (cur == MP_NOPTS_VALUE)
return cur;
// During seeking, the time corresponds to the last seek time - apply some // During seeking, the time corresponds to the last seek time - apply some
// cosmetics to it. // cosmetics to it.
if (mpctx->playback_pts == MP_NOPTS_VALUE) { if (cur != MP_NOPTS_VALUE && mpctx->playback_pts == MP_NOPTS_VALUE) {
double length = get_time_length(mpctx); double length = get_time_length(mpctx);
if (length >= 0) if (length >= 0)
cur = MPCLAMP(cur, 0, length); cur = MPCLAMP(cur, 0, length);