stream: Check sample spec validity before abiding PULSE_LATENCY_MSEC
authorDavid Henningsson <david.henningsson@canonical.com>
Wed, 10 Jun 2015 15:29:54 +0000 (17:29 +0200)
committerArun Raghavan <git@arunraghavan.net>
Fri, 12 Jun 2015 07:13:14 +0000 (12:43 +0530)
In case the sample spec is not known, as can be the case when
pa_stream_new_extended is used, we cannot satisfy the PULSE_LATENCY_MSEC
request.

As a workaround disable being able to use PULSE_LATENCY_MSEC in this case.

Reported-by: Fritsch <fritsch@xbmc.org>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
src/pulse/stream.c

index d4ad505..c301b8e 100644 (file)
@@ -990,16 +990,18 @@ static void patch_buffer_attr(pa_stream *s, pa_buffer_attr *attr, pa_stream_flag
 
         if (pa_atou(e, &ms) < 0 || ms <= 0)
             pa_log_debug("Failed to parse $PULSE_LATENCY_MSEC: %s", e);
+        else if (!pa_sample_spec_valid(&s->sample_spec))
+            pa_log_debug("Ignoring $PULSE_LATENCY_MSEC: %s (invalid sample spec)", e);
         else {
             attr->maxlength = (uint32_t) -1;
             attr->tlength = pa_usec_to_bytes(ms * PA_USEC_PER_MSEC, &s->sample_spec);
             attr->minreq = (uint32_t) -1;
             attr->prebuf = (uint32_t) -1;
             attr->fragsize = attr->tlength;
-        }
 
-        if (flags)
-            *flags |= PA_STREAM_ADJUST_LATENCY;
+            if (flags)
+                *flags |= PA_STREAM_ADJUST_LATENCY;
+        }
     }
 
     if (s->context->version >= 13)