gst/gstbus.c: Don't leak a mutex unlock in case of an error.
authorWim Taymans <wim.taymans@gmail.com>
Fri, 4 Nov 2005 12:08:19 +0000 (12:08 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Fri, 4 Nov 2005 12:08:19 +0000 (12:08 +0000)
Original commit message from CVS:
* gst/gstbus.c: (gst_bus_post), (gst_bus_set_sync_handler):
Don't leak a mutex unlock in case of an error.

* gst/gstbus.h:
Doc fixes.

ChangeLog
gst/gstbus.c
gst/gstbus.h

index db4a093..5045c70 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2005-11-04  Wim Taymans  <wim@fluendo.com>
 
+       * gst/gstbus.c: (gst_bus_post), (gst_bus_set_sync_handler):
+       Don't leak a mutex unlock in case of an error.
+
+       * gst/gstbus.h:
+       Doc fixes.
+
+2005-11-04  Wim Taymans  <wim@fluendo.com>
+
        * gst/gstbus.c: (gst_bus_class_init), (gst_bus_init),
        (gst_bus_post):
        Get the context to wake up only once.
index 27127ce..dcc1d4b 100644 (file)
@@ -522,6 +522,9 @@ gst_bus_peek (GstBus * bus)
  * function is usually only called by the creator of the bus. Applications
  * should handle messages asynchronously using the gst_bus watch and poll
  * functions.
+ *
+ * You cannot replace an existing sync_handler. You can pass NULL to this
+ * function, which will clear the existing handler.
  */
 void
 gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func, gpointer data)
@@ -532,11 +535,21 @@ gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func, gpointer data)
 
   /* Assert if the user attempts to replace an existing sync_handler,
    * other than to clear it */
-  g_assert (func == NULL || bus->sync_handler == NULL);
+  if (func != NULL && bus->sync_handler != NULL)
+    goto no_replace;
 
   bus->sync_handler = func;
   bus->sync_handler_data = data;
   GST_UNLOCK (bus);
+
+  return;
+
+no_replace:
+  {
+    GST_UNLOCK (bus);
+    g_warning ("cannot replace existing sync handler");
+    return;
+  }
 }
 
 /* GSource for the bus
index a9c8a0b..5493013 100644 (file)
@@ -77,6 +77,9 @@ typedef enum
  * into the bus. This function is mostly used internally. Only one sync handler
  * can be attached to a given bus.
  *
+ * If the handler returns GST_BUS_DROP, it should unref the message, else the
+ * message should not be unreffed by the sync handler.
+ *
  * Returns: #GstBusSyncReply stating what to do with the message
  */
 typedef GstBusSyncReply (*GstBusSyncHandler)   (GstBus * bus, GstMessage * message, gpointer data);