summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sf.net>2009-12-03 16:44:28 +0200
committerStefan Kost <ensonic@users.sf.net>2009-12-03 16:44:28 +0200
commitc92178827bc4d0f9d7e539ef3f66421199a4cae4 (patch)
treecf39ea354d1c8ce2f0661025856987acdcd32478
parent15bac7df00fbf5c0c3c3632f8bb8f66ffef9914b (diff)
tee: add special case for only one pad conected
It is not easy to setup a tee on the fly, thus apps need to add them always if they might need them. This changes the code so, that if only one src-pad is active, we push buffers directly. In the normal code path all buffers are pushed with an extra ref, that forces followup inplace elements to copy the data.
-rw-r--r--plugins/elements/gsttee.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c
index a7df2ba988..1e4b5ac855 100644
--- a/plugins/elements/gsttee.c
+++ b/plugins/elements/gsttee.c
@@ -643,9 +643,25 @@ gst_tee_handle_data (GstTee * tee, gpointer data, gboolean is_list)
gst_tee_do_message (tee, tee->sinkpad, data, is_list);
GST_OBJECT_LOCK (tee);
+ pads = GST_ELEMENT_CAST (tee)->srcpads;
+
+ /* special case for just one pad that avoids reffing the buffer */
+ if (!pads->next) {
+ GstPad *pad = GST_PAD_CAST (pads->data);
+
+ GST_OBJECT_UNLOCK (tee);
+ if (pad == tee->pull_pad) {
+ ret = GST_FLOW_OK;
+ } else if (!is_list) {
+ ret = gst_pad_push (pad, GST_BUFFER_CAST (data));
+ } else {
+ ret = gst_pad_push_list (pad, GST_BUFFER_LIST_CAST (data));
+ }
+ return ret;
+ }
/* mark all pads as 'not pushed on yet' */
- g_list_foreach (GST_ELEMENT_CAST (tee)->srcpads, (GFunc) clear_pads, tee);
+ g_list_foreach (pads, (GFunc) clear_pads, tee);
restart:
cret = GST_FLOW_NOT_LINKED;