Pulsesink: Allow chunks up to bufsize instead of segsize
authorDavid Henningsson <david.henningsson@canonical.com>
Mon, 31 Jan 2011 04:58:36 +0000 (05:58 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 31 Jan 2011 16:15:05 +0000 (17:15 +0100)
By allowing larger chunks to be sent, PulseAudio will have a
lower CPU usage. This is especially important on low-end machines,
where PulseAudio can crash if packets are coming in at a higher
rate than PulseAudio can process them.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
ext/pulse/pulsesink.c

index 9bebfec..295d93f 100644 (file)
@@ -1339,11 +1339,11 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
 
     towrite = out_samples * bps;
 
-    /* Only ever write segsize bytes at once. This will
-     * also limit the PA shm buffer to segsize
+    /* Only ever write bufsize bytes at once. This will
+     * also limit the PA shm buffer to bufsize
      */
-    if (towrite > buf->spec.segsize)
-      towrite = buf->spec.segsize;
+    if (towrite > bufsize)
+      towrite = bufsize;
 
     if ((pbuf->m_writable < towrite) || (offset != pbuf->m_lastoffset)) {
       /* if no room left or discontinuity in offset,
@@ -1392,9 +1392,9 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
       }
 
       /* make sure we only buffer up latency-time samples */
-      if (pbuf->m_writable > buf->spec.segsize) {
+      if (pbuf->m_writable > bufsize) {
         /* limit buffering to latency-time value */
-        pbuf->m_writable = buf->spec.segsize;
+        pbuf->m_writable = bufsize;
 
         GST_LOG_OBJECT (psink, "Limiting buffering to %" G_GSIZE_FORMAT,
             pbuf->m_writable);
@@ -1413,9 +1413,9 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
           pbuf->m_writable);
 
       /* Just to make sure that we didn't get more than requested */
-      if (pbuf->m_writable > buf->spec.segsize) {
+      if (pbuf->m_writable > bufsize) {
         /* limit buffering to latency-time value */
-        pbuf->m_writable = buf->spec.segsize;
+        pbuf->m_writable = bufsize;
       }
     }