0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 20:03:10 +02:00

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.
This commit is contained in:
wm4 2016-01-31 22:10:11 +01:00
parent c440ee99a4
commit a9dfd8d557

View File

@ -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;
}