1
mirror of https://github.com/mpv-player/mpv synced 2024-10-06 14:54:02 +02:00

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.
This commit is contained in:
Uoti Urpala 2010-12-16 21:26:12 +02:00
parent f0649f13d6
commit b4564c2d4f

View File

@ -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)