From b4564c2d4fdc14f1fcb6987b8f57a2c27a08bf54 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 16 Dec 2010 21:26:12 +0200 Subject: core: audio: make ogg missing audio timing workaround more complex After the addition of exact seeking the code to work around missing audio timestamps with ogg/ogm needs improvement. Now it's normal to need adjustment at stream start time 0 (seeking to a position after start of video but before second keyframe) with any video format, and for exact seeks with ogg it's now more important not to skip the sync. Make the check to detect the problem case more precise to avoid affecting most other formats, and try to decode a second of audio (hoping to get timestamps for those packets) before giving up. --- mplayer.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index f209ca0214..87490152af 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2129,6 +2129,7 @@ static int audio_start_sync(struct MPContext *mpctx, int playsize) return res; int bytes; + bool did_retry = false; while (1) { double written_pts = written_audio_pts(mpctx); double ptsdiff = written_pts - mpctx->video_pts - mpctx->delay @@ -2136,8 +2137,20 @@ static int audio_start_sync(struct MPContext *mpctx, int playsize) bytes = ptsdiff * ao_data.bps / mpctx->opts.playback_speed; bytes -= bytes % (ao_data.channels * af_fmt2bits(ao_data.format) / 8); - if (fabs(ptsdiff) > 300 // pts reset or just broken? - || written_pts <= 0) // ogg demuxers give packets without timing + // ogg demuxers give packets without timing + if (written_pts <= 1 && sh_audio->pts == MP_NOPTS_VALUE) { + if (!did_retry) { + // Try to read more data to see packets that have pts + int res = decode_audio(sh_audio, ao_data.bps); + if (res < 0) + return res; + did_retry = true; + continue; + } + bytes = 0; + } + + if (fabs(ptsdiff) > 300) // pts reset or just broken? bytes = 0; if (bytes > 0) -- cgit v1.2.3