From f1bb6fde3288cbbaf01175b980b9704f9406ce80 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sat, 30 Jul 2011 21:05:59 +0300 Subject: core: audio: if audio pts is missing return MP_NOPTS_VALUE Change written_audio_pts() and playing_audio_pts() to return MP_NOPTS_VALUE if no reasonable pts estimate is available. Before they returned some incorrect value typically around zero (but not necessarily exactly that). --- mplayer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 23a2636989..7f22b328b0 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1855,6 +1855,9 @@ static double written_audio_pts(struct MPContext *mpctx) // but not accurately known in sh_audio->i_bps. a_pts = d_audio->pts; + if (a_pts == MP_NOPTS_VALUE) + return a_pts; + // ds_tell_pts returns bytes read after last timestamp from // demuxing layer, decoder might use sh_audio->a_in_buffer for bytes // it has read but not decoded @@ -1885,8 +1888,10 @@ static double written_audio_pts(struct MPContext *mpctx) // Return pts value corresponding to currently playing audio. double playing_audio_pts(struct MPContext *mpctx) { - return written_audio_pts(mpctx) - mpctx->opts.playback_speed * - ao_get_delay(mpctx->ao); + double pts = written_audio_pts(mpctx); + if (pts == MP_NOPTS_VALUE) + return pts; + return pts - mpctx->opts.playback_speed * ao_get_delay(mpctx->ao); } static bool is_av_sub(int type) -- cgit v1.2.3