summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Henningsson <david.henningsson@canonical.com>2013-03-25 09:20:15 +0100
committerTanu Kaskinen <tanuk@iki.fi>2013-03-25 15:44:34 +0200
commit5f326b705d8f7f0c14e7e0c7d7c2751f3a5ebe43 (patch)
tree9f07c29d79d3847dae4649184cf0584a084f978e
parent2026c41be6f4e1a526c94c1368e5e528597df03a (diff)
protocol-native: Lower default minreq in low-latency scenarios
If minreq is not explicitly specified, it was always initialized to 20 ms (DEFAULT_PROCESS_MSEC). However when the total latency is not much higher than 20 ms, this is way too high. Instead use tlength/4 as a measure: this will give a decent sink_usec in all modes (both traditional, adjust latency and early request modes). This greatly improves PulseAudio's ability to ask for data in time in low-latency scenarios. Signed-off-by: David Henningsson <david.henningsson@canonical.com>
-rw-r--r--src/pulsecore/protocol-native.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index e8aa13cdd..9523e7aec 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -939,8 +939,14 @@ static void fix_playback_buffer_attr(playback_stream *s) {
if (s->buffer_attr.tlength > s->buffer_attr.maxlength)
s->buffer_attr.tlength = s->buffer_attr.maxlength;
- if (s->buffer_attr.minreq == (uint32_t) -1)
- s->buffer_attr.minreq = (uint32_t) pa_usec_to_bytes_round_up(DEFAULT_PROCESS_MSEC*PA_USEC_PER_MSEC, &s->sink_input->sample_spec);
+ if (s->buffer_attr.minreq == (uint32_t) -1) {
+ uint32_t process = (uint32_t) pa_usec_to_bytes_round_up(DEFAULT_PROCESS_MSEC*PA_USEC_PER_MSEC, &s->sink_input->sample_spec);
+ /* With low-latency, tlength/4 gives a decent default in all of traditional, adjust latency and early request modes. */
+ uint32_t m = s->buffer_attr.tlength / 4;
+ if (frame_size)
+ m -= m % frame_size;
+ s->buffer_attr.minreq = PA_MIN(process, m);
+ }
if (s->buffer_attr.minreq <= 0)
s->buffer_attr.minreq = (uint32_t) frame_size;