summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-31 22:10:11 +0100
committerwm4 <wm4@nowhere>2016-01-31 22:10:11 +0100
commita9dfd8d557b1651e6d9ae7a374426dbcd856da99 (patch)
tree4f580c422f3a6b7b191e524534db3fe9763f89e8
parentc440ee99a4dddb5458c75339cf8cef947a55edef (diff)
downloadmpv-a9dfd8d557b1651e6d9ae7a374426dbcd856da99.tar.bz2
mpv-a9dfd8d557b1651e6d9ae7a374426dbcd856da99.tar.xz
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.
-rw-r--r--player/audio.c6
1 files 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;
}