protocol-native: Ensure tlength is not set higher than maxlength
authorDavid Henningsson <david.henningsson@canonical.com>
Mon, 25 Mar 2013 08:20:14 +0000 (09:20 +0100)
committerTanu Kaskinen <tanuk@iki.fi>
Mon, 25 Mar 2013 13:43:33 +0000 (15:43 +0200)
Tlength should never be set higher than maxlength. While this is
corrected by memblockq later, we still need a correct tlength for
the subsequent calculations.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
src/pulsecore/protocol-native.c

index 7095519d449eb15b497916b8f007d9f3b2fefd03..e8aa13cddfe6c8715132557d10a2cfc7bcfda78b 100644 (file)
@@ -936,6 +936,8 @@ static void fix_playback_buffer_attr(playback_stream *s) {
         s->buffer_attr.tlength = (uint32_t) pa_usec_to_bytes_round_up(DEFAULT_TLENGTH_MSEC*PA_USEC_PER_MSEC, &s->sink_input->sample_spec);
     if (s->buffer_attr.tlength <= 0)
         s->buffer_attr.tlength = (uint32_t) frame_size;
+    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);