From 68c6da69f79b3c1ac781df56a63b3aeb0621fa47 Mon Sep 17 00:00:00 2001
From: wm4 <wm4@nowhere>
Date: Fri, 4 Dec 2015 16:55:55 +0100
Subject: [PATCH] player: resync audio only on larger timestamp discontinuities

Helps with files that have occasional broken timestamps. For larger
discontinuities, e.g. caused by actual timestamp resets, we still want
to realign audio.

(I guess in general, this should be removed and replaced by a more
general resync-on-desync logic, but not now.)
---
 player/video.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/player/video.c b/player/video.c
index 91899dc451..563e573eb7 100644
--- a/player/video.c
+++ b/player/video.c
@@ -579,9 +579,9 @@ static void handle_new_frame(struct MPContext *mpctx)
             // Assume a discontinuity.
             MP_WARN(mpctx, "Invalid video timestamp: %f -> %f\n",
                     mpctx->video_pts, pts);
-            frame_time = 0;
-            if (mpctx->d_audio)
+            if (mpctx->d_audio && fabs(frame_time) > 1.0)
                 mpctx->audio_status = STATUS_SYNCING;
+            frame_time = 0;
         }
     }
     mpctx->video_next_pts = pts;