Use the resampled rate to calculate the slack threshold rather than just 48kHz (...
authorCarl Hetherington <cth@carlh.net>
Sun, 19 Jun 2022 20:45:18 +0000 (22:45 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 29 Jun 2022 22:53:20 +0000 (00:53 +0200)
src/lib/audio_decoder.cc

index 664a56c2a08a08dcaaba00632268eca9c08dc39c..ca1faa0100492b5e76363cde68b0aa4dbed1e9ab 100644 (file)
@@ -58,17 +58,16 @@ AudioDecoder::emit (shared_ptr<const Film> film, AudioStreamPtr stream, shared_p
                return;
        }
 
-       /* Amount of error we will tolerate on audio timestamps; see comment below.
-        * We'll use 1 24fps video frame at 48kHz as this seems to be roughly how
-        * ffplay does it.
-        */
-       static Frame const slack_frames = 48000 / 24;
-
        int const resampled_rate = _content->resampled_frame_rate(film);
        if (!time_already_delayed) {
                time += ContentTime::from_seconds (_content->delay() / 1000.0);
        }
 
+       /* Amount of error we will tolerate on audio timestamps; see comment below.
+        * We'll use 1 24fps video frame as this seems to be roughly how ffplay does it.
+        */
+       Frame const slack_frames = resampled_rate / 24;
+
        /* first_since_seek is set to true if this is the first data we have
           received since initialisation or seek.  We'll set the position based
           on the ContentTime that was given.  After this first time we just