From 878621f6f5f3090bea9aa78dc4a399b1cabbefb7 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 30 Jan 2014 12:26:05 +0100 Subject: [PATCH] bufferpool: avoid excessive GstPoll activity Keep an extra write ref on the control socket. This ensures that we avoid a read/write on the socket when going from non-empty->empty->not-empty. We remove the write ref only when we actually are empty and we need to wait for flushing or a new buffer. This makes the bufferpool benchmark about 30% faster than the pure malloc implementation. --- gst/gstbufferpool.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gst/gstbufferpool.c b/gst/gstbufferpool.c index edd9ec9..6e11c72 100644 --- a/gst/gstbufferpool.c +++ b/gst/gstbufferpool.c @@ -178,6 +178,9 @@ gst_buffer_pool_init (GstBufferPool * pool) gst_allocation_params_init (&priv->params); gst_buffer_pool_config_set_allocator (priv->config, priv->allocator, &priv->params); + /* 1 control write for flushing */ + gst_poll_write_control (priv->poll); + /* 1 control write for marking that we are not waiting for poll */ gst_poll_write_control (priv->poll); GST_DEBUG_OBJECT (pool, "created"); @@ -1007,9 +1010,12 @@ default_acquire_buffer (GstBufferPool * pool, GstBuffer ** buffer, break; } - /* now wait */ - GST_LOG_OBJECT (pool, "waiting for free buffers"); + /* now we release the control socket, we wait for a buffer release or + * flushing */ + gst_poll_read_control (pool->priv->poll); + GST_LOG_OBJECT (pool, "waiting for free buffers or flushing"); gst_poll_wait (priv->poll, GST_CLOCK_TIME_NONE); + gst_poll_write_control (pool->priv->poll); } return result; -- 2.7.4