bus: also allow popping a message without timeout if no poll available
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Wed, 20 Apr 2011 13:39:16 +0000 (15:39 +0200)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Thu, 21 Apr 2011 11:29:34 +0000 (12:29 +0100)
... which happens in particular flushing a bus, possibly as part
of a state change, e.g. when having a pipeline in a pipeline
and then changing state back to NULL. The interior pipeline
will/might then flush the bus, which is a child bus from the
parent which does not have a poll anymore these days.

https://bugzilla.gnome.org/show_bug.cgi?id=648297

gst/gstbus.c

index 2cc41af..caff420 100644 (file)
@@ -499,7 +499,7 @@ gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout,
 
   g_return_val_if_fail (GST_IS_BUS (bus), NULL);
   g_return_val_if_fail (types != 0, NULL);
-  g_return_val_if_fail (bus->priv->poll != NULL, NULL);
+  g_return_val_if_fail (timeout == 0 || bus->priv->poll != NULL, NULL);
 
   g_mutex_lock (bus->queue_lock);
 
@@ -510,7 +510,8 @@ gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout,
         gst_atomic_queue_length (bus->queue));
 
     while ((message = gst_atomic_queue_pop (bus->queue))) {
-      gst_poll_read_control (bus->priv->poll);
+      if (bus->priv->poll)
+        gst_poll_read_control (bus->priv->poll);
       GST_DEBUG_OBJECT (bus, "got message %p, %s, type mask is %u",
           message, GST_MESSAGE_TYPE_NAME (message), (guint) types);
       if ((GST_MESSAGE_TYPE (message) & types) != 0) {
@@ -544,6 +545,8 @@ gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout,
       }
     }
 
+    /* only here in timeout case */
+    g_assert (bus->priv->poll);
     g_mutex_unlock (bus->queue_lock);
     ret = gst_poll_wait (bus->priv->poll, timeout);
     g_mutex_lock (bus->queue_lock);