[gst-devel] [PATCH] checks in gst_pad_connect()
Andy Wingo
wingo at pobox.com
Wed Jan 16 19:29:03 CET 2002
ok to commit?
wingo.
Index: gstpad.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstpad.c,v
retrieving revision 1.135
diff -u -r1.135 gstpad.c
--- gstpad.c 2002/01/13 22:22:42 1.135
+++ gstpad.c 2002/01/17 03:25:58
@@ -587,6 +587,7 @@
{
GstRealPad *realsrc, *realsink;
gboolean negotiated = FALSE;
+ gint num_decoupled = 0;
/* generic checks */
g_return_val_if_fail (srcpad != NULL, FALSE);
@@ -607,6 +608,22 @@
g_return_val_if_fail (GST_RPAD_PEER (realsrc) == NULL, FALSE);
g_return_val_if_fail (GST_RPAD_PEER (realsink) == NULL, FALSE);
+ g_return_val_if_fail (GST_PAD_PARENT (realsrc) != NULL, FALSE);
+ g_return_val_if_fail (GST_PAD_PARENT (realsink) != NULL, FALSE);
+ g_return_val_if_fail (realsrc->sched && realsink->sched, FALSE);
+
+ if (GST_FLAG_IS_SET (GST_PAD_PARENT (realsrc), GST_ELEMENT_DECOUPLED))
+ num_decoupled++;
+ if (GST_FLAG_IS_SET (GST_PAD_PARENT (realsink), GST_ELEMENT_DECOUPLED))
+ num_decoupled++;
+
+ if (realsrc->sched == realsink->sched && num_decoupled != 0) {
+ g_warning ("cannot connect pads from decoupled elements with the same sched\n");
+ return FALSE;
+ } else if (realsrc->sched != realsink->sched && num_decoupled != 1) {
+ g_warning ("connecting pads with different scheds requires one decoupled element (queue)\n");
+ return FALSE;
+ }
/* check for reversed directions and swap if necessary */
if ((GST_RPAD_DIRECTION (realsrc) == GST_PAD_SINK) &&
Index: gstparse.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstparse.c,v
retrieving revision 1.38
diff -u -r1.38 gstparse.c
--- gstparse.c 2002/01/14 04:09:56 1.38
+++ gstparse.c 2002/01/17 03:25:59
@@ -68,7 +68,9 @@
if (!strcmp (gst_pad_get_name (newpad), connect->srcpadname)) {
gst_element_set_state (connect->pipeline, GST_STATE_PAUSED);
- gst_pad_connect (newpad, connect->target);
+ if (!gst_pad_connect (newpad, connect->target))
+ g_warning ("could not connect %s:%s to %s:%s", GST_DEBUG_PAD_NAME (newpad),
+ GST_DEBUG_PAD_NAME (connect->target));
gst_element_set_state (connect->pipeline, GST_STATE_PLAYING);
}
}
@@ -422,8 +424,13 @@
GST_DEBUG (0, "CONNECTING %s:%s and %s:%s\n",
GST_DEBUG_PAD_NAME (GST_PARSE_LISTPAD (g_slist_nth (srcpads, j))),
GST_DEBUG_PAD_NAME (GST_PARSE_LISTPAD (g_slist_nth (sinkpads, j))));
- gst_pad_connect (GST_PARSE_LISTPAD (g_slist_nth (srcpads, j)),
- GST_PARSE_LISTPAD (g_slist_nth (sinkpads, j)));
+ if (!gst_pad_connect (GST_PARSE_LISTPAD (g_slist_nth (srcpads, j)),
+ GST_PARSE_LISTPAD (g_slist_nth (sinkpads, j)))) {
+ g_warning ("could not connect %s:%s to %s:%s",
+ GST_DEBUG_PAD_NAME (GST_PARSE_LISTPAD (g_slist_nth (srcpads, j))),
+ GST_DEBUG_PAD_NAME (GST_PARSE_LISTPAD (g_slist_nth (sinkpads, j))));
+ return GST_PARSE_ERROR_CONNECT;
+ }
}
}
Index: gstparse.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstparse.h,v
retrieving revision 1.9
diff -u -r1.9 gstparse.h
--- gstparse.h 2002/01/14 04:09:56 1.9
+++ gstparse.h 2002/01/17 03:25:59
@@ -35,7 +35,8 @@
GST_PARSE_ERROR_SYNTAX = -1,
GST_PARSE_ERROR_CREATING_ELEMENT = -2,
GST_PARSE_ERROR_NOSUCH_ELEMENT = -3,
- GST_PARSE_ERROR_INTERNAL = -4
+ GST_PARSE_ERROR_INTERNAL = -4,
+ GST_PARSE_ERROR_CONNECT = -5,
} GstParseErrors;
GstPipeline* gst_parse_launch (const gchar *pipeline_description);
More information about the gstreamer-devel
mailing list