fix request pad
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 3 Nov 2011 16:49:45 +0000 (17:49 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 3 Nov 2011 16:49:45 +0000 (17:49 +0100)
Make all request pads take _%u in the template.
Fix up unit tests.

12 files changed:
plugins/elements/gstfunnel.c
plugins/elements/gstinputselector.c
plugins/elements/gstmultiqueue.c
plugins/elements/gstoutputselector.c
plugins/elements/gsttee.c
plugins/elements/gsttee.h
tests/check/elements/funnel.c
tests/check/elements/multiqueue.c
tests/check/elements/selector.c
tests/check/elements/tee.c
tests/check/gst/gstutils.c
tests/check/pipelines/parse-launch.c

index 5b37e72..24f4feb 100644 (file)
@@ -94,7 +94,7 @@ gst_funnel_pad_init (GstFunnelPad * pad)
 }
 
 static GstStaticPadTemplate funnel_sink_template =
-GST_STATIC_PAD_TEMPLATE ("sink%d",
+GST_STATIC_PAD_TEMPLATE ("sink_%u",
     GST_PAD_SINK,
     GST_PAD_REQUEST,
     GST_STATIC_CAPS_ANY);
index 7235a47..f5036d3 100644 (file)
@@ -80,7 +80,7 @@ static GStaticRecMutex notify_mutex = G_STATIC_REC_MUTEX_INIT;
 #define GST_INPUT_SELECTOR_BROADCAST(sel) (g_cond_broadcast (GST_INPUT_SELECTOR_GET_COND(sel)))
 
 static GstStaticPadTemplate gst_input_selector_sink_factory =
-GST_STATIC_PAD_TEMPLATE ("sink%d",
+GST_STATIC_PAD_TEMPLATE ("sink_%u",
     GST_PAD_SINK,
     GST_PAD_REQUEST,
     GST_STATIC_CAPS_ANY);
@@ -1286,7 +1286,7 @@ gst_input_selector_request_new_pad (GstElement * element,
   GST_INPUT_SELECTOR_LOCK (sel);
 
   GST_LOG_OBJECT (sel, "Creating new pad %d", sel->padcount);
-  name = g_strdup_printf ("sink%d", sel->padcount++);
+  name = g_strdup_printf ("sink_%u", sel->padcount++);
   sinkpad = g_object_new (GST_TYPE_SELECTOR_PAD,
       "name", name, "direction", templ->direction, "template", templ, NULL);
   g_free (name);
index 73fec6c..e7842ca 100644 (file)
@@ -177,7 +177,7 @@ struct _GstMultiQueueItem
   guint32 posid;
 };
 
-static GstSingleQueue *gst_single_queue_new (GstMultiQueue * mqueue, gint id);
+static GstSingleQueue *gst_single_queue_new (GstMultiQueue * mqueue, guint id);
 static void gst_single_queue_free (GstSingleQueue * squeue);
 
 static void wake_up_next_non_linked (GstMultiQueue * mq);
@@ -186,12 +186,12 @@ static void compute_high_time (GstMultiQueue * mq);
 static void single_queue_overrun_cb (GstDataQueue * dq, GstSingleQueue * sq);
 static void single_queue_underrun_cb (GstDataQueue * dq, GstSingleQueue * sq);
 
-static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink%d",
+static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink_%u",
     GST_PAD_SINK,
     GST_PAD_REQUEST,
     GST_STATIC_CAPS_ANY);
 
-static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src%d",
+static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src_%u",
     GST_PAD_SRC,
     GST_PAD_SOMETIMES,
     GST_STATIC_CAPS_ANY);
@@ -620,10 +620,10 @@ gst_multi_queue_request_new_pad (GstElement * element, GstPadTemplate * temp,
 {
   GstMultiQueue *mqueue = GST_MULTI_QUEUE (element);
   GstSingleQueue *squeue;
-  gint temp_id = -1;
+  guint temp_id = -1;
 
   if (name) {
-    sscanf (name + 4, "%d", &temp_id);
+    sscanf (name + 4, "_%u", &temp_id);
     GST_LOG_OBJECT (element, "name : %s (id %d)", GST_STR_NULL (name), temp_id);
   }
 
@@ -1871,12 +1871,12 @@ gst_single_queue_free (GstSingleQueue * sq)
 }
 
 static GstSingleQueue *
-gst_single_queue_new (GstMultiQueue * mqueue, gint id)
+gst_single_queue_new (GstMultiQueue * mqueue, guint id)
 {
   GstSingleQueue *sq;
   gchar *name;
   GList *tmp;
-  gint temp_id = (id == -1) ? 0 : id;
+  guint temp_id = (id == -1) ? 0 : id;
 
   GST_MULTI_QUEUE_MUTEX_LOCK (mqueue);
 
@@ -1937,7 +1937,7 @@ gst_single_queue_new (GstMultiQueue * mqueue, gint id)
   sq->sink_tainted = TRUE;
   sq->src_tainted = TRUE;
 
-  name = g_strdup_printf ("sink%d", sq->id);
+  name = g_strdup_printf ("sink_%u", sq->id);
   sq->sinkpad = gst_pad_new_from_static_template (&sinktemplate, name);
   g_free (name);
 
@@ -1954,7 +1954,7 @@ gst_single_queue_new (GstMultiQueue * mqueue, gint id)
   gst_pad_set_iterate_internal_links_function (sq->sinkpad,
       GST_DEBUG_FUNCPTR (gst_multi_queue_iterate_internal_links));
 
-  name = g_strdup_printf ("src%d", sq->id);
+  name = g_strdup_printf ("src_%u", sq->id);
   sq->srcpad = gst_pad_new_from_static_template (&srctemplate, name);
   g_free (name);
 
index 2db7660..a5797cc 100644 (file)
@@ -44,7 +44,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     GST_STATIC_CAPS_ANY);
 
 static GstStaticPadTemplate gst_output_selector_src_factory =
-GST_STATIC_PAD_TEMPLATE ("src%d",
+GST_STATIC_PAD_TEMPLATE ("src_%u",
     GST_PAD_SRC,
     GST_PAD_REQUEST,
     GST_STATIC_CAPS_ANY);
@@ -347,7 +347,7 @@ gst_output_selector_request_new_pad (GstElement * element,
   GST_DEBUG_OBJECT (osel, "requesting pad");
 
   GST_OBJECT_LOCK (osel);
-  padname = g_strdup_printf ("src%d", osel->nb_srcpads++);
+  padname = g_strdup_printf ("src_%u", osel->nb_srcpads++);
   srcpad = gst_pad_new_from_template (templ, padname);
   GST_OBJECT_UNLOCK (osel);
 
index 4b36ab1..ce5f91c 100644 (file)
@@ -100,7 +100,8 @@ enum
   PROP_ALLOC_PAD,
 };
 
-static GstStaticPadTemplate tee_src_template = GST_STATIC_PAD_TEMPLATE ("src%d",
+static GstStaticPadTemplate tee_src_template =
+GST_STATIC_PAD_TEMPLATE ("src_%u",
     GST_PAD_SRC,
     GST_PAD_REQUEST,
     GST_STATIC_CAPS_ANY);
@@ -298,7 +299,7 @@ gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ,
   GST_DEBUG_OBJECT (tee, "requesting pad");
 
   GST_OBJECT_LOCK (tee);
-  name = g_strdup_printf ("src%d", tee->pad_counter++);
+  name = g_strdup_printf ("src_%u", tee->pad_counter++);
 
   srcpad = gst_pad_new_from_template (templ, name);
   g_free (name);
index fba0a3e..f72a9db 100644 (file)
@@ -71,7 +71,7 @@ struct _GstTee {
 
   GstPad         *sinkpad;
   GstPad         *allocpad;
-  gint            pad_counter;
+  guint           pad_counter;
 
   gboolean        has_chain;
   gboolean        has_sink_loop;
index 94ff792..3869380 100644 (file)
@@ -43,13 +43,13 @@ setup_test_objects (struct TestData *td, GstPadChainFunction chain_func)
   td->funnelsrc = gst_element_get_static_pad (td->funnel, "src");
   fail_unless (td->funnelsrc != NULL);
 
-  td->funnelsink11 = gst_element_get_request_pad (td->funnel, "sink11");
+  td->funnelsink11 = gst_element_get_request_pad (td->funnel, "sink_11");
   fail_unless (td->funnelsink11 != NULL);
-  fail_unless (!strcmp (GST_OBJECT_NAME (td->funnelsink11), "sink11"));
+  fail_unless (!strcmp (GST_OBJECT_NAME (td->funnelsink11), "sink_11"));
 
-  td->funnelsink22 = gst_element_get_request_pad (td->funnel, "sink22");
+  td->funnelsink22 = gst_element_get_request_pad (td->funnel, "sink_22");
   fail_unless (td->funnelsink22 != NULL);
-  fail_unless (!strcmp (GST_OBJECT_NAME (td->funnelsink22), "sink22"));
+  fail_unless (!strcmp (GST_OBJECT_NAME (td->funnelsink22), "sink_22"));
 
   fail_unless (gst_element_set_state (td->funnel, GST_STATE_PLAYING) ==
       GST_STATE_CHANGE_SUCCESS);
index 34a3380..d56902f 100644 (file)
@@ -41,7 +41,7 @@ setup_multiqueue (GstElement * pipe, GstElement * inputs[],
     GstPad *srcpad = NULL;
 
     /* create multiqueue sink (and source) pad */
-    sinkpad = gst_element_get_request_pad (mq, "sink%d");
+    sinkpad = gst_element_get_request_pad (mq, "sink_%u");
     fail_unless (sinkpad != NULL,
         "failed to create multiqueue request pad #%u", i);
 
@@ -66,10 +66,10 @@ setup_multiqueue (GstElement * pipe, GstElement * inputs[],
 
       /* only the sink pads are by request, the source pads are sometimes pads,
        * so this should return NULL */
-      srcpad = gst_element_get_request_pad (mq, "src%d");
+      srcpad = gst_element_get_request_pad (mq, "src_%u");
       fail_unless (srcpad == NULL);
 
-      g_snprintf (padname, sizeof (padname), "src%d", i);
+      g_snprintf (padname, sizeof (padname), "src_%u", i);
       srcpad = gst_element_get_static_pad (mq, padname);
       fail_unless (srcpad != NULL, "failed to get multiqueue src pad #%u", i);
       fail_unless (GST_PAD_IS_SRC (srcpad),
@@ -193,21 +193,21 @@ GST_START_TEST (test_request_pads)
 
   mq = gst_element_factory_make ("multiqueue", NULL);
 
-  sink1 = gst_element_get_request_pad (mq, "foo%d");
+  sink1 = gst_element_get_request_pad (mq, "foo_%u");
   fail_unless (sink1 == NULL,
-      "Expected NULL pad, as there is no request pad template for 'foo%%d'");
+      "Expected NULL pad, as there is no request pad template for 'foo_%%u'");
 
-  sink1 = gst_element_get_request_pad (mq, "src%d");
+  sink1 = gst_element_get_request_pad (mq, "src_%u");
   fail_unless (sink1 == NULL,
-      "Expected NULL pad, as there is no request pad template for 'src%%d'");
+      "Expected NULL pad, as there is no request pad template for 'src_%%u'");
 
-  sink1 = gst_element_get_request_pad (mq, "sink%d");
+  sink1 = gst_element_get_request_pad (mq, "sink_%u");
   fail_unless (sink1 != NULL);
   fail_unless (GST_IS_PAD (sink1));
   fail_unless (GST_PAD_IS_SINK (sink1));
   GST_LOG ("Got pad %s:%s", GST_DEBUG_PAD_NAME (sink1));
 
-  sink2 = gst_element_get_request_pad (mq, "sink%d");
+  sink2 = gst_element_get_request_pad (mq, "sink_%u");
   fail_unless (sink2 != NULL);
   fail_unless (GST_IS_PAD (sink2));
   fail_unless (GST_PAD_IS_SINK (sink2));
@@ -233,7 +233,7 @@ mq_sinkpad_to_srcpad (GstElement * mq, GstPad * sink)
 
   mq_sinkpad_name = gst_pad_get_name (sink);
   fail_unless (g_str_has_prefix (mq_sinkpad_name, "sink"));
-  mq_srcpad_name = g_strdup_printf ("src%s", mq_sinkpad_name + 4);
+  mq_srcpad_name = g_strdup_printf ("src_%s", mq_sinkpad_name + 5);
   srcpad = gst_element_get_static_pad (mq, mq_srcpad_name);
   fail_unless (srcpad != NULL);
 
@@ -250,33 +250,33 @@ GST_START_TEST (test_request_pads_named)
 
   mq = gst_element_factory_make ("multiqueue", NULL);
 
-  sink1 = gst_element_get_request_pad (mq, "sink1");
+  sink1 = gst_element_get_request_pad (mq, "sink_1");
   fail_unless (sink1 != NULL);
   fail_unless (GST_IS_PAD (sink1));
   fail_unless (GST_PAD_IS_SINK (sink1));
-  fail_unless_equals_string (GST_PAD_NAME (sink1), "sink1");
+  fail_unless_equals_string (GST_PAD_NAME (sink1), "sink_1");
   GST_LOG ("Got pad %s:%s", GST_DEBUG_PAD_NAME (sink1));
 
-  sink3 = gst_element_get_request_pad (mq, "sink3");
+  sink3 = gst_element_get_request_pad (mq, "sink_3");
   fail_unless (sink3 != NULL);
   fail_unless (GST_IS_PAD (sink3));
   fail_unless (GST_PAD_IS_SINK (sink3));
-  fail_unless_equals_string (GST_PAD_NAME (sink3), "sink3");
+  fail_unless_equals_string (GST_PAD_NAME (sink3), "sink_3");
   GST_LOG ("Got pad %s:%s", GST_DEBUG_PAD_NAME (sink3));
 
-  sink2 = gst_element_get_request_pad (mq, "sink2");
+  sink2 = gst_element_get_request_pad (mq, "sink_2");
   fail_unless (sink2 != NULL);
   fail_unless (GST_IS_PAD (sink2));
   fail_unless (GST_PAD_IS_SINK (sink2));
-  fail_unless_equals_string (GST_PAD_NAME (sink2), "sink2");
+  fail_unless_equals_string (GST_PAD_NAME (sink2), "sink_2");
   GST_LOG ("Got pad %s:%s", GST_DEBUG_PAD_NAME (sink2));
 
   /* This gets us the first unused id, sink0 */
-  sink4 = gst_element_get_request_pad (mq, "sink%d");
+  sink4 = gst_element_get_request_pad (mq, "sink_%u");
   fail_unless (sink4 != NULL);
   fail_unless (GST_IS_PAD (sink4));
   fail_unless (GST_PAD_IS_SINK (sink4));
-  fail_unless_equals_string (GST_PAD_NAME (sink4), "sink0");
+  fail_unless_equals_string (GST_PAD_NAME (sink4), "sink_0");
   GST_LOG ("Got pad %s:%s", GST_DEBUG_PAD_NAME (sink4));
 
   GST_LOG ("Cleaning up");
@@ -434,7 +434,7 @@ run_output_order_test (gint n_linked)
     g_free (name);
     gst_pad_set_getcaps_function (inputpads[i], mq_dummypad_getcaps);
 
-    mq_sinkpad = gst_element_get_request_pad (mq, "sink%d");
+    mq_sinkpad = gst_element_get_request_pad (mq, "sink_%u");
     fail_unless (mq_sinkpad != NULL);
     gst_pad_link (inputpads[i], mq_sinkpad);
 
@@ -590,7 +590,7 @@ GST_START_TEST (test_sparse_stream)
     g_free (name);
     gst_pad_set_getcaps_function (inputpads[i], mq_dummypad_getcaps);
 
-    mq_sinkpad = gst_element_get_request_pad (mq, "sink%d");
+    mq_sinkpad = gst_element_get_request_pad (mq, "sink_%u");
     fail_unless (mq_sinkpad != NULL);
     gst_pad_link (inputpads[i], mq_sinkpad);
 
index e938dfa..f84a6ad 100644 (file)
@@ -82,7 +82,7 @@ setup_output_pad (GstElement * element, GstStaticPadTemplate * tmpl)
       GINT_TO_POINTER (probe_id));
 
   /* request src pad */
-  srcpad = gst_element_get_request_pad (element, "src%d");
+  srcpad = gst_element_get_request_pad (element, "src_%u");
   fail_if (srcpad == NULL, "Could not get source pad from %s",
       GST_ELEMENT_NAME (element));
 
@@ -278,7 +278,7 @@ setup_input_pad (GstElement * element)
   fail_if (input_pad == NULL, "Could not create a input_pad");
 
   /* request sink pad */
-  sinkpad = gst_element_get_request_pad (element, "sink%d");
+  sinkpad = gst_element_get_request_pad (element, "sink_%u");
   fail_if (sinkpad == NULL, "Could not get sink pad from %s",
       GST_ELEMENT_NAME (element));
 
index a0eaeb9..d2d54c5 100644 (file)
@@ -78,7 +78,7 @@ GST_START_TEST (test_num_buffers)
     g_object_set (sinks[i], "signal-handoffs", TRUE, NULL);
     g_signal_connect (sinks[i], "handoff", (GCallback) handoff, &counts[i]);
 
-    req_pads[i] = gst_element_get_request_pad (tee, "src%d");
+    req_pads[i] = gst_element_get_request_pad (tee, "src_%u");
     fail_unless (req_pads[i] != NULL);
 
     qpad = gst_element_get_static_pad (queues[i], "sink");
@@ -144,7 +144,7 @@ GST_START_TEST (test_stress)
   for (i = 0; i < 50000; i++) {
     GstPad *pad;
 
-    pad = gst_element_get_request_pad (tee, "src%d");
+    pad = gst_element_get_request_pad (tee, "src_%u");
     gst_element_release_request_pad (tee, pad);
     gst_object_unref (pad);
 
@@ -203,7 +203,7 @@ buffer_alloc_harness_setup (BufferAllocHarness * h, gint countdown)
   h->tee_sinkpad = gst_element_get_static_pad (h->tee, "sink");
   fail_if (h->tee_sinkpad == NULL);
 
-  h->tee_srcpad = gst_element_get_request_pad (h->tee, "src%d");
+  h->tee_srcpad = gst_element_get_request_pad (h->tee, "src_%u");
   fail_if (h->tee_srcpad == NULL);
 
   h->final_sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
@@ -355,7 +355,7 @@ GST_START_TEST (test_internal_links)
   fail_unless (res == GST_ITERATOR_DONE);
   fail_unless (g_value_get_object (&val1) == NULL);
 
-  srcpad1 = gst_element_get_request_pad (tee, "src%d");
+  srcpad1 = gst_element_get_request_pad (tee, "src_%u");
   fail_unless (srcpad1 != NULL);
 
   /* iterator should resync */
@@ -375,7 +375,7 @@ GST_START_TEST (test_internal_links)
   fail_unless (res == GST_ITERATOR_DONE);
   fail_unless (g_value_get_object (&val1) == NULL);
 
-  srcpad2 = gst_element_get_request_pad (tee, "src%d");
+  srcpad2 = gst_element_get_request_pad (tee, "src_%u");
   fail_unless (srcpad2 != NULL);
 
   /* iterator should resync */
@@ -468,9 +468,9 @@ GST_START_TEST (test_flow_aggregation)
   fail_unless (tee != NULL);
   teesink = gst_element_get_static_pad (tee, "sink");
   fail_unless (teesink != NULL);
-  teesrc1 = gst_element_get_request_pad (tee, "src%d");
+  teesrc1 = gst_element_get_request_pad (tee, "src_%u");
   fail_unless (teesrc1 != NULL);
-  teesrc2 = gst_element_get_request_pad (tee, "src%d");
+  teesrc2 = gst_element_get_request_pad (tee, "src_%u");
   fail_unless (teesrc2 != NULL);
 
   GST_DEBUG ("Creating mysink1");
index a703216..7cb11f9 100644 (file)
@@ -985,12 +985,12 @@ GST_START_TEST (test_pad_proxy_getcaps_aggregation)
   tee = gst_element_factory_make ("tee", "tee");
 
   sink1 = gst_element_factory_make ("fakesink", "sink1");
-  tee_src1 = gst_element_get_request_pad (tee, "src%d");
+  tee_src1 = gst_element_get_request_pad (tee, "src_%u");
   sink1_sink = gst_element_get_static_pad (sink1, "sink");
   fail_unless_equals_int (gst_pad_link (tee_src1, sink1_sink), GST_PAD_LINK_OK);
 
   sink2 = gst_element_factory_make ("fakesink", "sink2");
-  tee_src2 = gst_element_get_request_pad (tee, "src%d");
+  tee_src2 = gst_element_get_request_pad (tee, "src_%u");
   sink2_sink = gst_element_get_static_pad (sink2, "sink");
   fail_unless_equals_int (gst_pad_link (tee_src2, sink2_sink), GST_PAD_LINK_OK);
 
index 6c894f9..bfb2250 100644 (file)
@@ -135,7 +135,7 @@ GST_END_TEST;
 #define PIPELINE4  "fakesrc num-buffers=4 .src ! identity silent=true !.sink identity silent=true .src ! .sink fakesink silent=true"
 #define PIPELINE5  "fakesrc num-buffers=4 name=src identity silent=true name=id1 identity silent=true name = id2 fakesink silent=true name =sink src. ! id1. id1.! id2.sink id2.src!sink.sink"
 #define PIPELINE6  "pipeline.(name=\"john\" fakesrc num-buffers=4 ( bin. ( ! queue ! identity silent=true !( queue ! fakesink silent=true )) ))"
-#define PIPELINE7  "fakesrc num-buffers=4 ! tee name=tee .src%d! queue ! fakesink silent=true tee.src%d ! queue ! fakesink silent=true queue name =\"foo\" ! fakesink silent=true tee.src%d ! foo."
+#define PIPELINE7  "fakesrc num-buffers=4 ! tee name=tee .src_%u! queue ! fakesink silent=true tee.src_%u ! queue ! fakesink silent=true queue name =\"foo\" ! fakesink silent=true tee.src_%u ! foo."
 /* aggregator is borked
  * #define PIPELINE8  "fakesrc num-buffers=4 ! tee name=tee1 .src0,src1 ! .sink0, sink1 aggregator ! fakesink silent=true"
  * */