[pulseaudio-discuss] [PATCH v2 1/3] protocol-native: Ensure tlength is not set higher than maxlength

David Henningsson david.henningsson at canonical.com
Thu Mar 21 11:10:40 PDT 2013


If tlength is not specified and maxlength is, tlength should never
be set higher than maxlength by default.

Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
 src/pulsecore/protocol-native.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 00c56a6..519a0f2 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -932,8 +932,10 @@ static void fix_playback_buffer_attr(playback_stream *s) {
     if (s->buffer_attr.maxlength <= 0)
         s->buffer_attr.maxlength = (uint32_t) frame_size;
 
-    if (s->buffer_attr.tlength == (uint32_t) -1)
+    if (s->buffer_attr.tlength == (uint32_t) -1) {
         s->buffer_attr.tlength = (uint32_t) pa_usec_to_bytes_round_up(DEFAULT_TLENGTH_MSEC*PA_USEC_PER_MSEC, &s->sink_input->sample_spec);
+        s->buffer_attr.tlength = PA_MIN(s->buffer_attr.tlength, s->buffer_attr.maxlength);
+    }
     if (s->buffer_attr.tlength <= 0)
         s->buffer_attr.tlength = (uint32_t) frame_size;
 
-- 
1.7.9.5



More information about the pulseaudio-discuss mailing list