From cec2a428087103bb180f95d260a7cd1dff1fb1b3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 3 Dec 2010 11:19:27 +0100 Subject: [PATCH] pad: add push cache to bufferlists Add the push cahce for the bufferlist push code path as well. --- gst/gstpad.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/gst/gstpad.c b/gst/gstpad.c index 4d55d4b..7412a09 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -4715,11 +4715,69 @@ slow_path: GstFlowReturn gst_pad_push_list (GstPad * pad, GstBufferList * list) { + GstBuffer *buf; + GstPadPushCache *cache; + GstFlowReturn ret; + gpointer *cache_ptr; + GstPad *peer; + GstCaps *caps; + g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR); g_return_val_if_fail (GST_PAD_IS_SRC (pad), GST_FLOW_ERROR); g_return_val_if_fail (GST_IS_BUFFER_LIST (list), GST_FLOW_ERROR); - return gst_pad_push_data (pad, FALSE, list, NULL); + cache_ptr = (gpointer *) & pad->abidata.ABI.priv->cache_ptr; + + cache = pad_take_cache (pad, cache_ptr); + + if (G_UNLIKELY (cache == NULL)) + goto slow_path; + + /* check caps */ + if ((buf = gst_buffer_list_get (list, 0, 0))) + caps = GST_BUFFER_CAPS (buf); + else + caps = NULL; + + if (G_UNLIKELY (caps && caps != cache->caps)) { + pad_free_cache (cache); + goto slow_path; + } + + peer = cache->peer; + + GST_PAD_STREAM_LOCK (peer); + + ret = GST_PAD_CHAINLISTFUNC (peer) (peer, list); + + GST_PAD_STREAM_UNLOCK (peer); + + pad_put_cache (pad, cache, cache_ptr); + + return ret; + + /* slow path */ +slow_path: + { + GstPadPushCache scache = { NULL, }; + + GST_LOG_OBJECT (pad, "Taking slow path"); + + ret = gst_pad_push_data (pad, FALSE, list, &scache); + + if (scache.peer) { + GstPadPushCache *ncache; + + GST_LOG_OBJECT (pad, "Caching push data"); + + /* make cache structure */ + ncache = g_slice_new (GstPadPushCache); + *ncache = scache; + + pad_put_cache (pad, ncache, cache_ptr); + } + return ret; + } } /** -- 2.7.4