]> code.delx.au - pulseaudio/blobdiff - src/pulse/stream.c
volume: use PA_VOLUME_MAX instead of (pa_volume_t) -1
[pulseaudio] / src / pulse / stream.c
index bbd01499c3e0d1892915771f8922271d504f75c9..2bc2b1e4ae0fd1dc189ca02ce73ae15147d2550e 100644 (file)
@@ -867,7 +867,7 @@ static void automatic_buffer_attr(pa_stream *s, pa_buffer_attr *attr, const pa_s
 
 void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
     pa_stream *s = userdata;
-    uint32_t requested_bytes;
+    uint32_t requested_bytes = 0;
 
     pa_assert(pd);
     pa_assert(s);
@@ -1207,6 +1207,17 @@ int pa_stream_begin_write(
     PA_CHECK_VALIDITY(s->context, data, PA_ERR_INVALID);
     PA_CHECK_VALIDITY(s->context, nbytes && *nbytes != 0, PA_ERR_INVALID);
 
+    if (*nbytes != (size_t) -1) {
+        size_t m, fs;
+
+        m = pa_mempool_block_size_max(s->context->mempool);
+        fs = pa_frame_size(&s->sample_spec);
+
+        m = (m / fs) * fs;
+        if (*nbytes > m)
+            *nbytes = m;
+    }
+
     if (!s->write_memblock) {
         s->write_memblock = pa_memblock_new(s->context->mempool, *nbytes);
         s->write_data = pa_memblock_acquire(s->write_memblock);