queue: remove query from queue if queue is flushing
authorAlexander Schrab <alexas@axis.com>
Mon, 28 Jan 2013 10:05:28 +0000 (11:05 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Wed, 30 Jan 2013 12:12:45 +0000 (12:12 +0000)
When querying a queue that is flushing we end up adding
a query to the queuearray without taking a reference to
that query (because the normal functionality is to block
until that query is done and discarded from the queue).
This later causes problem if the query is unreffed outside
of the queue before we discard the queue. There is a check
to avoid unreffing any lingering query-objects, but since
the query has been deleted that check fails.

This commit depends on other fixes done to gst_queue_array_find()
and gst_queue_array_drop_element().

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

plugins/elements/gstqueue.c

index 29898230be608ca92fe489c226848c882c25d718..0cba0338ce23d14accb9cc96852cafd7c81ce466 100644 (file)
@@ -811,7 +811,16 @@ gst_queue_handle_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
   /* ERRORS */
 out_flushing:
   {
+    gint index;
+
     GST_DEBUG_OBJECT (queue, "we are flushing");
+
+    /* Remove query from queue if still there, since we hold no ref to it */
+    index = gst_queue_array_find (&queue->queue, NULL, query);
+
+    if (index >= 0)
+      gst_queue_array_drop_element (&queue->queue, index);
+
     GST_QUEUE_MUTEX_UNLOCK (queue);
     return FALSE;
   }