[vlc-commits] PulseAudio: increase buffer size to max VLC can do
Rémi Denis-Courmont
git at videolan.org
Sat May 28 11:56:35 CEST 2011
vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr 3 00:46:06 2011 +0300| [28007d8951da2aa13d28580bb49c982103d3ee6c] | committer: Rémi Denis-Courmont
PulseAudio: increase buffer size to max VLC can do
This suppresses most hiccups. But it also decreases precision to
slightly noticeable levels: about +/-150ms here. For reference, our
audio output core target is +/-40ms.
(cherry picked from commit 39b85ca6ba871a9e66c7d277e2ba4db72cadb8d8)
(cherry picked from commit b26331994843bf2a1a3803eab449d10959815fa3)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=28007d8951da2aa13d28580bb49c982103d3ee6c
---
modules/audio_output/pulse.c | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 712c7cc..3e2e0eb 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -179,23 +179,24 @@ static void Play(aout_instance_t *aout)
/* This function should be called by the LibVLC core a header of time,
* but not more than AOUT_MAX_PREPARE. The PulseAudio latency should be
* shorter than that (though it might not be the case with some evil piece
- * of audio output hardware). So we need to prepend the buffer with zeroes
- * to keep audio and video in sync. */
+ * of audio output hardware). So we may need to trigger playback early,
+ * (that is to say, short cut the PulseAudio prebuffering). Otherwise,
+ * audio and video may be out of synchronization. */
pa_usec_t latency;
int negative;
if (pa_stream_get_latency(s, &latency, &negative) < 0) {
/* Especially at start of stream, latency may not be known (yet). */
if (pa_context_errno(sys->context) != PA_ERR_NODATA)
error(aout, "cannot determine latency", sys->context);
- latency = 0;
- }
-
- mtime_t gap = aout_FifoFirstDate(aout, &aout->output.fifo) - mdate()
+ } else {
+ mtime_t gap = aout_FifoFirstDate(aout, &aout->output.fifo) - mdate()
- latency;
- if (gap > AOUT_PTS_TOLERANCE)
- msg_Dbg(aout, "buffer too early (%"PRId64" us)", gap);
- else if (latency != 0 && gap < -AOUT_PTS_TOLERANCE)
- msg_Err(aout, "buffer too late (%"PRId64" us)", -gap);
+
+ if (gap > AOUT_PTS_TOLERANCE)
+ msg_Dbg(aout, "buffer too early (%"PRId64" us)", gap);
+ else if (gap < -AOUT_PTS_TOLERANCE)
+ msg_Err(aout, "buffer too late (%"PRId64" us)", -gap);
+ }
#endif
#if 0 /* Fault injector to test underrun recovery */
static unsigned u = 0;
@@ -356,9 +357,9 @@ static int Open(vlc_object_t *obj)
const uint32_t byterate = pa_bytes_per_second(&ss);
struct pa_buffer_attr attr;
/* no point in larger buffers on PA side than VLC */
- attr.maxlength = byterate * AOUT_MAX_ADVANCE_TIME / CLOCK_FREQ;
- attr.tlength = byterate * AOUT_MAX_PREPARE_TIME / CLOCK_FREQ;
- attr.prebuf = byterate * AOUT_MIN_PREPARE_TIME / CLOCK_FREQ;
+ attr.maxlength = -1;
+ attr.tlength = byterate * AOUT_MAX_ADVANCE_TIME / CLOCK_FREQ;
+ attr.prebuf = byterate * AOUT_MAX_PREPARE_TIME / CLOCK_FREQ;
attr.minreq = -1;
attr.fragsize = 0; /* not used for output */
More information about the vlc-commits
mailing list