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

David Henningsson david.henningsson at canonical.com
Tue Mar 19 05:51:56 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 a4ee920..38c66c5 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -931,8 +931,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