Commit 28007d89 authored by Rémi Denis-Courmont's avatar 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)
parent ee23b36b
...@@ -179,23 +179,24 @@ static void Play(aout_instance_t *aout) ...@@ -179,23 +179,24 @@ static void Play(aout_instance_t *aout)
/* This function should be called by the LibVLC core a header of time, /* 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 * 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 * 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 * of audio output hardware). So we may need to trigger playback early,
* to keep audio and video in sync. */ * (that is to say, short cut the PulseAudio prebuffering). Otherwise,
* audio and video may be out of synchronization. */
pa_usec_t latency; pa_usec_t latency;
int negative; int negative;
if (pa_stream_get_latency(s, &latency, &negative) < 0) { if (pa_stream_get_latency(s, &latency, &negative) < 0) {
/* Especially at start of stream, latency may not be known (yet). */ /* Especially at start of stream, latency may not be known (yet). */
if (pa_context_errno(sys->context) != PA_ERR_NODATA) if (pa_context_errno(sys->context) != PA_ERR_NODATA)
error(aout, "cannot determine latency", sys->context); error(aout, "cannot determine latency", sys->context);
latency = 0; } else {
}
mtime_t gap = aout_FifoFirstDate(aout, &aout->output.fifo) - mdate() mtime_t gap = aout_FifoFirstDate(aout, &aout->output.fifo) - mdate()
- latency; - latency;
if (gap > AOUT_PTS_TOLERANCE) if (gap > AOUT_PTS_TOLERANCE)
msg_Dbg(aout, "buffer too early (%"PRId64" us)", gap); msg_Dbg(aout, "buffer too early (%"PRId64" us)", gap);
else if (latency != 0 && gap < -AOUT_PTS_TOLERANCE) else if (gap < -AOUT_PTS_TOLERANCE)
msg_Err(aout, "buffer too late (%"PRId64" us)", -gap); msg_Err(aout, "buffer too late (%"PRId64" us)", -gap);
}
#endif #endif
#if 0 /* Fault injector to test underrun recovery */ #if 0 /* Fault injector to test underrun recovery */
static unsigned u = 0; static unsigned u = 0;
...@@ -356,9 +357,9 @@ static int Open(vlc_object_t *obj) ...@@ -356,9 +357,9 @@ static int Open(vlc_object_t *obj)
const uint32_t byterate = pa_bytes_per_second(&ss); const uint32_t byterate = pa_bytes_per_second(&ss);
struct pa_buffer_attr attr; struct pa_buffer_attr attr;
/* no point in larger buffers on PA side than VLC */ /* no point in larger buffers on PA side than VLC */
attr.maxlength = byterate * AOUT_MAX_ADVANCE_TIME / CLOCK_FREQ; attr.maxlength = -1;
attr.tlength = byterate * AOUT_MAX_PREPARE_TIME / CLOCK_FREQ; attr.tlength = byterate * AOUT_MAX_ADVANCE_TIME / CLOCK_FREQ;
attr.prebuf = byterate * AOUT_MIN_PREPARE_TIME / CLOCK_FREQ; attr.prebuf = byterate * AOUT_MAX_PREPARE_TIME / CLOCK_FREQ;
attr.minreq = -1; attr.minreq = -1;
attr.fragsize = 0; /* not used for output */ attr.fragsize = 0; /* not used for output */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment