From a9dfd8d557b1651e6d9ae7a374426dbcd856da99 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 31 Jan 2016 22:10:11 +0100 Subject: audio: use brutal resync only on larger PTS discontinuities Let's fix broken samples with questionable heuristic without real reasoning. Until this gets fixed properly, this is a good compromise, though. A proper fix would properly resync audio and video without brutally resetting the decoders, but on the other hand not doing the brutal reset would cause issues in other obscure corner cases such resyncing might cause. --- player/audio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/player/audio.c b/player/audio.c index a4c43a0e93..b6a3134230 100644 --- a/player/audio.c +++ b/player/audio.c @@ -634,10 +634,12 @@ static int filter_audio(struct ao_chain *ao_c, struct mp_audio_buffer *outbuf, // Attempt to detect jumps in PTS. Even for the lowest sample rates // and with worst container rounded timestamp, this should be a // margin more than enough. - if (ao_c->pts != MP_NOPTS_VALUE && fabs(mpa->pts - ao_c->pts) > 0.1) { + double desync = fabs(mpa->pts - ao_c->pts); + if (ao_c->pts != MP_NOPTS_VALUE && desync > 0.1) { MP_WARN(ao_c, "Invalid audio PTS: %f -> %f\n", ao_c->pts, mpa->pts); - ao_c->pts_reset = true; + if (desync >= 5) + ao_c->pts_reset = true; } ao_c->pts = mpa->pts + mpa->samples / (double)mpa->rate; } -- cgit v1.2.3