From 4113a1dad18432f3768437c4cc5a4f924046e0d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 9 Jun 2010 20:53:06 +0200 Subject: [PATCH] pulsesink: Don't request more shared memory than needed --- ext/pulse/pulsesink.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c index 7772d9278b..991a3e067b 100644 --- a/ext/pulse/pulsesink.c +++ b/ext/pulse/pulsesink.c @@ -1325,6 +1325,15 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample, goto was_paused; } + /* make sure we only buffer up latency-time samples */ + if (pbuf->m_writable > buf->spec.segsize) { + /* limit buffering to latency-time value */ + pbuf->m_writable = buf->spec.segsize; + + GST_LOG_OBJECT (psink, "Limiting buffering to %" G_GSIZE_FORMAT, + pbuf->m_writable); + } + GST_LOG_OBJECT (psink, "requesting %u bytes of shared memory", pbuf->m_writable); if (pa_stream_begin_write (pbuf->stream, &pbuf->m_data, @@ -1334,13 +1343,10 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample, } GST_LOG_OBJECT (psink, "got %u bytes of shared memory", pbuf->m_writable); - /* make sure we only buffer up latency-time samples */ + /* Just to make sure that we didn't get more than requested */ if (pbuf->m_writable > buf->spec.segsize) { /* limit buffering to latency-time value */ pbuf->m_writable = buf->spec.segsize; - - GST_LOG_OBJECT (psink, "Limiting buffering to %" G_GSIZE_FORMAT, - pbuf->m_writable); } }