2005-10-05 Thomas Vander Stichele <thomas at apestaart dot org>
+ * gst/gstutils.c: (gst_element_link_pads):
+ fix a bug in the case where neither element has a pad
+ * check/gst/gstelement.c: (GST_START_TEST), (gst_element_suite):
+ add a test for that case
+
+2005-10-05 Thomas Vander Stichele <thomas at apestaart dot org>
+
* gst/gstpad.c: (gst_pad_push), (gst_pad_push_event):
emit have-data before checking for peers. This allows
for probe handlers to connect elements. This helps autopluggers.
GST_END_TEST;
-/* link and run two elements without putting them in a
- * pipeline */
+/* link and run two elements without putting them in a pipeline */
GST_START_TEST (test_link)
{
GstElement *src, *sink;
GST_END_TEST;
+/* linking two elements without pads should fail */
+GST_START_TEST (test_link_no_pads)
+{
+ GstElement *src, *sink;
+
+ src = gst_bin_new ("src");
+ sink = gst_bin_new ("sink");
+
+ fail_if (gst_element_link (src, sink));
+
+ gst_object_unref (src);
+ gst_object_unref (sink);
+}
+
+GST_END_TEST;
+
Suite *
gst_element_suite (void)
{
tcase_add_test (tc_chain, test_add_pad_unref_element);
tcase_add_test (tc_chain, test_error_no_bus);
tcase_add_test (tc_chain, test_link);
+ tcase_add_test (tc_chain, test_link_no_pads);
return s;
}
* @src: a #GstElement containing the source pad.
* @srcpadname: the name of the #GstPad in source element or NULL for any pad.
* @dest: the #GstElement containing the destination pad.
- * @destpadname: the name of the #GstPad in destination element or NULL for any pad.
+ * @destpadname: the name of the #GstPad in destination element,
+ * or NULL for any pad.
*
* Links the two named pads of the source and destination elements.
* Side effect is that if one of the pads has no parent, it becomes a
srcpadname ? srcpadname : "(any)", GST_ELEMENT_NAME (dest),
destpadname ? destpadname : "(any)");
- /* now get the pads we're trying to link and a list of all remaining pads */
+ /* get a src pad */
if (srcpadname) {
+ /* name specified, look it up */
srcpad = gst_element_get_pad (src, srcpadname);
if (!srcpad) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s",
}
srcpads = NULL;
} else {
+ /* no name given, get the first available pad */
GST_LOCK (src);
srcpads = GST_ELEMENT_PADS (src);
srcpad = srcpads ? GST_PAD_CAST (srcpads->data) : NULL;
gst_object_ref (srcpad);
GST_UNLOCK (src);
}
+
+ /* get a destination pad */
if (destpadname) {
+ /* name specified, look it up */
destpad = gst_element_get_pad (dest, destpadname);
if (!destpad) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s",
}
destpads = NULL;
} else {
+ /* no name given, get the first available pad */
GST_LOCK (dest);
destpads = GST_ELEMENT_PADS (dest);
destpad = destpads ? GST_PAD_CAST (destpads->data) : NULL;
return result;
}
+
if (srcpad) {
/* loop through the allowed pads in the source, trying to find a
* compatible destination pad */
if (srcpadname) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s:%s to %s",
GST_DEBUG_PAD_NAME (srcpad), GST_ELEMENT_NAME (dest));
- gst_object_unref (srcpad);
+ if (srcpad)
+ gst_object_unref (srcpad);
+ srcpad = NULL;
if (destpad)
gst_object_unref (destpad);
- return FALSE;
+ destpad = NULL;
} else {
if (srcpad)
gst_object_unref (srcpad);
srcpad = NULL;
}
+
if (destpad) {
/* loop through the existing pads in the destination */
do {
}
} while (destpads);
}
+
if (destpadname) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s to %s:%s",
GST_ELEMENT_NAME (src), GST_DEBUG_PAD_NAME (destpad));
gst_object_unref (srcpad);
return FALSE;
} else {
- gst_object_unref (destpad);
if (srcpad)
gst_object_unref (srcpad);
srcpad = NULL;
+ if (destpad)
+ gst_object_unref (destpad);
destpad = NULL;
}
GST_END_TEST;
-/* link and run two elements without putting them in a
- * pipeline */
+/* link and run two elements without putting them in a pipeline */
GST_START_TEST (test_link)
{
GstElement *src, *sink;
GST_END_TEST;
+/* linking two elements without pads should fail */
+GST_START_TEST (test_link_no_pads)
+{
+ GstElement *src, *sink;
+
+ src = gst_bin_new ("src");
+ sink = gst_bin_new ("sink");
+
+ fail_if (gst_element_link (src, sink));
+
+ gst_object_unref (src);
+ gst_object_unref (sink);
+}
+
+GST_END_TEST;
+
Suite *
gst_element_suite (void)
{
tcase_add_test (tc_chain, test_add_pad_unref_element);
tcase_add_test (tc_chain, test_error_no_bus);
tcase_add_test (tc_chain, test_link);
+ tcase_add_test (tc_chain, test_link_no_pads);
return s;
}