[gst-devel] Patch needs approval

Benjamin Otte in7y118 at public.uni-hamburg.de
Wed Feb 6 10:41:02 CET 2002


Hi,

This patch (nearly) completes the removal of vertical events from the
core.
What it does:
- removal of the EVENT signal of GstElement (to be replaced by
g_object_notify)
- changing of the ERROR signal to allow recursive notification (like
deep_notify)
- implementing recursive notification with error events.
- removal of some functions in gstbin.c that are not used anymore.
- The function "gst_element_info" and "gst_element_send_event" now do
nothing but printing a warning, that these functions are gone. This is
done to allow plugins to catch up.
- Some bugfixes in XML saving are included, they simply were in the
file.

Some questions:
- Is the way in which the error signal propagates ok, or should this be
changed? (Currently the default handler is G_SIGNAL_RUN_LAST and calls
emits the error signal of the parent. So you can overwrite it in your
code. I could make gst_element_error handle recursive emission directly,
but for some reason I didn't)
- If the erronous element is removed during the signal emission, do we
have to notify the scheduler of this error? (Currently we do)
- Should the error signal be included in GstObject? I don't know if pads
or so want to generate errors, but why not give them the possibility?


Ok, awaiting approval :)

Benjamin

-------------- next part --------------
? diff
? autoplug/diff
? autoplug/spidertest
? cothreads/acinclude.m4
? cothreads/aclocal.m4
? cothreads/compile
? cothreads/config.log
? cothreads/config.status
? cothreads/configure
? cothreads/depcomp
? cothreads/libtool
? cothreads/pth.h
? cothreads/pth_acdef.h
? cothreads/pth_acdef.h.in
? cothreads/pth_acmac.h
? cothreads/stamp-h.in
? cothreads/stamp-h1
Index: gstbin.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstbin.c,v
retrieving revision 1.117
diff -u -r1.117 gstbin.c
--- gstbin.c	2002/02/03 20:07:09	1.117
+++ gstbin.c	2002/02/06 18:13:58
@@ -48,7 +48,6 @@
 static gboolean			gst_bin_change_state_type	(GstBin *bin,
 								 GstElementState state,
 								 GType type);
-static void 			gst_bin_send_event 		(GstElement *element, GstEvent *event);
 
 static gboolean 		gst_bin_iterate_func 		(GstBin * bin);
 
@@ -124,7 +123,6 @@
 #endif
 
   gstelement_class->change_state 	= GST_DEBUG_FUNCPTR (gst_bin_change_state);
-  gstelement_class->send_event 		= GST_DEBUG_FUNCPTR (gst_bin_send_event);
 
   klass->change_state_type 		= GST_DEBUG_FUNCPTR (gst_bin_change_state_type);
   klass->iterate 			= GST_DEBUG_FUNCPTR (gst_bin_iterate_func);
@@ -489,34 +487,6 @@
     }
   }
   GST_UNLOCK (bin);
-}
-
-/**
- * gst_bin_child_error:
- * @bin: #GstBin with the child
- * @child: #GstElement that signaled an error
- *
- * An internal function to inform the parent bin about a failed child.
- */
-void
-gst_bin_child_error (GstBin *bin, GstElement *child)
-{
-  g_return_if_fail (GST_IS_BIN (bin));
-
-  if (GST_STATE (bin) != GST_STATE_NULL) {
-    gst_element_info (GST_ELEMENT (bin), "bin \"%s\" stopped because child \"%s\" signalled an error",
-		    GST_ELEMENT_NAME (bin), GST_ELEMENT_NAME (child));
-  }
-}
-
-static void
-gst_bin_send_event (GstElement *element, GstEvent *event)
-{
-  GST_DEBUG (GST_CAT_EVENT, "event from %s in %s\n", 
-	   gst_element_get_name (GST_ELEMENT (GST_EVENT_SRC (event))),
-  	   gst_element_get_name (element));
-
-  GST_ELEMENT_CLASS (parent_class)->send_event (element, event);
 }
 
 static GstElementStateReturn
Index: gstelement.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstelement.c,v
retrieving revision 1.110
diff -u -r1.110 gstelement.c
--- gstelement.c	2002/02/06 16:35:16	1.110
+++ gstelement.c	2002/02/06 18:14:02
@@ -38,7 +38,6 @@
   NEW_PAD,
   PAD_REMOVED,
   ERROR,
-  EVENT,
   EOS,
   LAST_SIGNAL
 };
@@ -62,7 +61,7 @@
 static void 			gst_element_dispose 		(GObject *object);
 
 static GstElementStateReturn	gst_element_change_state	(GstElement *element);
-static void 			gst_element_send_event_func 	(GstElement *element, GstEvent *event);
+static void			gst_element_error_func		(GstElement* element, GstElement *source, gchar *errormsg);
 
 #ifndef GST_DISABLE_LOADSAVE
 static xmlNodePtr		gst_element_save_thyself	(GstObject *object, xmlNodePtr parent);
@@ -123,13 +122,8 @@
   gst_element_signals[ERROR] =
     g_signal_new ("error", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
                   G_STRUCT_OFFSET (GstElementClass, error), NULL, NULL,
-                  gst_marshal_VOID__STRING, G_TYPE_NONE,1,
-                  G_TYPE_STRING);
-  gst_element_signals[EVENT] =
-    g_signal_new ("event", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
-                  G_STRUCT_OFFSET (GstElementClass, event), NULL, NULL,
-                  gst_marshal_VOID__POINTER, G_TYPE_NONE,1,
-                  G_TYPE_POINTER);
+                  gst_marshal_VOID__OBJECT_STRING, G_TYPE_NONE, 2,
+                  G_TYPE_OBJECT, G_TYPE_STRING);
   gst_element_signals[EOS] =
     g_signal_new ("eos", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
                   G_STRUCT_OFFSET (GstElementClass,eos), NULL, NULL,
@@ -147,7 +141,7 @@
 #endif
 
   klass->change_state 			= GST_DEBUG_FUNCPTR (gst_element_change_state);
-  klass->send_event 			= GST_DEBUG_FUNCPTR (gst_element_send_event_func);
+  klass->error	 			= GST_DEBUG_FUNCPTR (gst_element_error_func);
   klass->elementfactory 		= NULL;
   klass->padtemplates 			= NULL;
   klass->numpadtemplates 		= 0;
@@ -1024,25 +1018,18 @@
   /* we're satisified they can be disconnected, let's do it */
   gst_pad_disconnect(srcpad,destpad);
 }
-
 static void
-gst_element_message (GstElement *element, const gchar *type, const gchar *info, va_list var_args)
+gst_element_error_func (GstElement* element, GstElement *source, gchar *errormsg)
 {
-  GstEvent *event;
-  GstProps *props;
-  gchar *string;
-  
-  string = g_strdup_vprintf (info, var_args);
-
-  GST_INFO (GST_CAT_EVENT, "%s sends message %s", GST_ELEMENT_NAME (element),
-		  string);
-
-  event = gst_event_new_info (type, GST_PROPS_STRING (string), NULL);
-  gst_element_send_event (element, event);
-
-  g_free (string);
+  /* tell the parent */
+  if (GST_OBJECT_PARENT (element))
+  {
+    GST_DEBUG (GST_CAT_EVENT, "forwarding error \"%s\" from %s to %s\n", errormsg, GST_ELEMENT_NAME (element), GST_OBJECT_NAME (GST_OBJECT_PARENT (element)));
+    gst_object_ref (element);
+    g_signal_emit (G_OBJECT (GST_OBJECT_PARENT (element)), gst_element_signals[ERROR], 0, source, errormsg);
+    gst_object_unref (element);
+  }
 }
-
 /**
  * gst_element_error:
  * @element: Element with the error
@@ -1056,25 +1043,31 @@
 gst_element_error (GstElement *element, const gchar *error, ...)
 {
   va_list var_args;
-  GstObject *parent;
+  gchar *string;
   
+  /* checks */
   g_return_if_fail (GST_IS_ELEMENT (element));
+  g_return_if_fail (element != NULL);
   g_return_if_fail (error != NULL);
 
+  /* create error message */
   va_start (var_args, error);
-  gst_element_message (element, "error", error, var_args);
+  string = g_strdup_vprintf (error, var_args);
   va_end (var_args);
-
-  parent = GST_ELEMENT_PARENT (element);
+  GST_INFO (GST_CAT_EVENT, "ERROR in %s: %s", GST_ELEMENT_NAME (element), string);
 
-  if (parent && GST_IS_BIN (parent)) {
-    gst_bin_child_error (GST_BIN (parent), element);
-  }
-
+  /* emit the signal, make sure the element stays available */
+  gst_object_ref (element);
+  g_signal_emit (G_OBJECT (element), gst_element_signals[ERROR], 0, element, string);
+  
+ /* tell the scheduler */
   if (element->sched) {
     gst_scheduler_error (element->sched, element); 
-  }
+  } 
 
+  /* cleanup */
+  gst_object_unref (element);
+  g_free (string);
 }
 
 /**
@@ -1089,54 +1082,21 @@
 void
 gst_element_info (GstElement *element, const gchar *info, ...)
 {
-  va_list var_args;
-  
-  g_return_if_fail (GST_IS_ELEMENT (element));
-  g_return_if_fail (info != NULL);
-
-  va_start (var_args, info);
-  gst_element_message (element, "info", info, var_args);
-  va_end (var_args);
+  g_warning ("The function gst_element_info is gone. Use g_object_notify instead.");
 }
 
 
-static void
-gst_element_send_event_func (GstElement *element, GstEvent *event)
-{
-  if (GST_OBJECT_PARENT (element)) {
-    gst_element_send_event (GST_ELEMENT (GST_OBJECT_PARENT (element)), event);
-  }
-  else {
-    switch (GST_EVENT_TYPE (event)) {
-      default:
-        g_signal_emit (G_OBJECT (element), gst_element_signals[EVENT], 0, event);
-    }
-    gst_event_free (event);
-  }
-}
-
 /**
  * gst_element_send_event:
  * @element: Element generating the event
  * @event: the event to send
  *
- * This function is used intenally by elements to send an event to 
- * the app. It will result in an "event" signal.
+ * This function is deprecated and doesn't work anymore.
  */
 void
 gst_element_send_event (GstElement *element, GstEvent *event)
 {
-  GstElementClass *oclass = CLASS (element);
-
-  g_return_if_fail (GST_IS_ELEMENT (element));
-  g_return_if_fail (event);
-
-  if (GST_EVENT_SRC (event) == NULL)
-    GST_EVENT_SRC (event) = gst_object_ref (GST_OBJECT (element));
-
-  if (oclass->send_event)
-    (oclass->send_event) (element, event);
-
+  g_warning ("The function gst_element_send_event is gone. Use g_object_notify instead.");
 }
 
 /**
@@ -1461,7 +1421,7 @@
   GstElementClass *oclass;
   GParamSpec **specs, *spec;
   gint nspecs, i;
-  GValue value;
+  GValue value = { 0, };
   GstElement *element;
   gchar *str;
 
@@ -1502,6 +1462,8 @@
         xmlNewChild (param, NULL, "value", g_value_dup_string (&value));
       else if (G_IS_PARAM_SPEC_ENUM (spec))
         xmlNewChild (param, NULL, "value", g_strdup_printf ("%d", g_value_get_enum (&value)));
+      else if (G_IS_PARAM_SPEC_INT64 (spec))
+        xmlNewChild (param, NULL, "value", g_strdup_printf ("%lld", g_value_get_int64 (&value)));
       else
         xmlNewChild (param, NULL, "value", g_strdup_value_contents (&value));
       
Index: gstelement.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstelement.h,v
retrieving revision 1.79
diff -u -r1.79 gstelement.h
--- gstelement.h	2002/02/03 20:07:09	1.79
+++ gstelement.h	2002/02/06 18:14:02
@@ -159,8 +159,7 @@
   void (*state_change)		(GstElement *element, GstElementState old, GstElementState state);
   void (*new_pad)		(GstElement *element, GstPad *pad);
   void (*pad_removed)		(GstElement *element, GstPad *pad);
-  void (*error)			(GstElement *element, gchar *error);
-  void (*event)			(GstElement *element, GstEvent *event);
+  void (*error)			(GstElement *element, GstElement *source, gchar *error);
   void (*eos)			(GstElement *element);
 
   /* local pointers for get/set */
Index: gstmarshal.list
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/gst/gstmarshal.list,v
retrieving revision 1.3
diff -u -r1.3 gstmarshal.list
--- gstmarshal.list	2002/02/05 21:11:43	1.3
+++ gstmarshal.list	2002/02/06 18:14:02
@@ -6,4 +6,5 @@
 VOID:OBJECT
 VOID:OBJECT,PARAM
 VOID:OBJECT,POINTER
+VOID:OBJECT,STRING
 VOID:INT,INT


More information about the gstreamer-devel mailing list