[PATCH 2/2] protocol-native: Lower default minreq in low-latency scenarios

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 at canonical.com>
---
 src/pulsecore/protocol-native.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 38c66c5..da705eb 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -938,8 +938,13 @@ static void fix_playback_buffer_attr(playback_stream *s) {
     if (s->buffer_attr.tlength <= 0)
         s->buffer_attr.tlength = (uint32_t) frame_size;
 
-    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);
+        uint32_t period = s->buffer_attr.tlength / 4; /* In low-latency, ask for data in four periods by default */
+        if (frame_size)
+            period -= period % frame_size;
+        s->buffer_attr.minreq = PA_MIN(period, process);
+    }
     if (s->buffer_attr.minreq <= 0)
         s->buffer_attr.minreq = (uint32_t) frame_size;
 
-- 
1.7.9.5



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux