+static void aout_DecSynchronize (audio_output_t *aout, mtime_t dec_pts,
+ int input_rate)
+{
+ aout_owner_t *owner = aout_owner (aout);
+ mtime_t drift;
+
+ /**
+ * Depending on the drift between the actual and intended playback times,
+ * the audio core may ignore the drift, trigger upsampling or downsampling,
+ * insert silence or even discard samples.
+ * Future VLC versions may instead adjust the input rate.
+ *
+ * The audio output plugin is responsible for estimating its actual
+ * playback time, or rather the estimated time when the next sample will
+ * be played. (The actual playback time is always the current time, that is
+ * to say mdate(). It is not an useful statistic.)
+ *
+ * Most audio output plugins can estimate the delay until playback of
+ * the next sample to be written to the buffer, or equally the time until
+ * all samples in the buffer will have been played. Then:
+ * pts = mdate() + delay
+ */
+ if (aout_OutputTimeGet (aout, &drift) != 0)
+ return; /* nothing can be done if timing is unknown */
+ drift += mdate () - dec_pts;
+
+ /* Late audio output.
+ * This can happen due to insufficient caching, scheduling jitter
+ * or bug in the decoder. Ideally, the output would seek backward. But that
+ * is not portable, not supported by some hardware and often unsafe/buggy
+ * where supported. The other alternative is to flush the buffers
+ * completely. */
+ if (drift > (owner->sync.discontinuity ? 0
+ : +3 * input_rate * AOUT_MAX_PTS_DELAY / INPUT_RATE_DEFAULT))