mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-26 02:00:33 +00:00
queue/queue2: Protect against spurious condition variable wakeups
Make sure that we only wake up when we have to flush, or when this specific query was handled. https://bugzilla.gnome.org/show_bug.cgi?id=776039
This commit is contained in:
parent
33c239828b
commit
3fab00b46a
4 changed files with 12 additions and 2 deletions
|
@ -1045,7 +1045,10 @@ gst_queue_handle_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||||
qitem.size = 0;
|
qitem.size = 0;
|
||||||
gst_queue_array_push_tail_struct (queue->queue, &qitem);
|
gst_queue_array_push_tail_struct (queue->queue, &qitem);
|
||||||
GST_QUEUE_SIGNAL_ADD (queue);
|
GST_QUEUE_SIGNAL_ADD (queue);
|
||||||
g_cond_wait (&queue->query_handled, &queue->qlock);
|
while (queue->srcresult == GST_FLOW_OK &&
|
||||||
|
queue->last_handled_query != query)
|
||||||
|
g_cond_wait (&queue->query_handled, &queue->qlock);
|
||||||
|
queue->last_handled_query = NULL;
|
||||||
if (queue->srcresult != GST_FLOW_OK)
|
if (queue->srcresult != GST_FLOW_OK)
|
||||||
goto out_flushing;
|
goto out_flushing;
|
||||||
res = queue->last_query;
|
res = queue->last_query;
|
||||||
|
@ -1443,6 +1446,7 @@ next:
|
||||||
ret = gst_pad_peer_query (queue->srcpad, query);
|
ret = gst_pad_peer_query (queue->srcpad, query);
|
||||||
GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing_query);
|
GST_QUEUE_MUTEX_LOCK_CHECK (queue, out_flushing_query);
|
||||||
queue->last_query = ret;
|
queue->last_query = ret;
|
||||||
|
queue->last_handled_query = query;
|
||||||
g_cond_signal (&queue->query_handled);
|
g_cond_signal (&queue->query_handled);
|
||||||
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
||||||
"did query %p, return %d", query, queue->last_query);
|
"did query %p, return %d", query, queue->last_query);
|
||||||
|
|
|
@ -135,6 +135,7 @@ struct _GstQueue {
|
||||||
|
|
||||||
GCond query_handled;
|
GCond query_handled;
|
||||||
gboolean last_query;
|
gboolean last_query;
|
||||||
|
GstQuery *last_handled_query;
|
||||||
|
|
||||||
gboolean flush_on_eos; /* flush on EOS */
|
gboolean flush_on_eos; /* flush on EOS */
|
||||||
};
|
};
|
||||||
|
|
|
@ -2642,7 +2642,10 @@ gst_queue2_handle_sink_query (GstPad * pad, GstObject * parent,
|
||||||
GST_QUEUE2_ITEM_TYPE_QUERY);
|
GST_QUEUE2_ITEM_TYPE_QUERY);
|
||||||
|
|
||||||
STATUS (queue, queue->sinkpad, "wait for QUERY");
|
STATUS (queue, queue->sinkpad, "wait for QUERY");
|
||||||
g_cond_wait (&queue->query_handled, &queue->qlock);
|
while (queue->sinkresult == GST_FLOW_OK &&
|
||||||
|
queue->last_handled_query != query)
|
||||||
|
g_cond_wait (&queue->query_handled, &queue->qlock);
|
||||||
|
queue->last_handled_query = NULL;
|
||||||
if (queue->sinkresult != GST_FLOW_OK)
|
if (queue->sinkresult != GST_FLOW_OK)
|
||||||
goto out_flushing;
|
goto out_flushing;
|
||||||
res = queue->last_query;
|
res = queue->last_query;
|
||||||
|
@ -2970,6 +2973,7 @@ next:
|
||||||
GstQuery *query = GST_QUERY_CAST (data);
|
GstQuery *query = GST_QUERY_CAST (data);
|
||||||
|
|
||||||
GST_LOG_OBJECT (queue->srcpad, "Peering query %p", query);
|
GST_LOG_OBJECT (queue->srcpad, "Peering query %p", query);
|
||||||
|
queue->last_handled_query = query;
|
||||||
queue->last_query = gst_pad_peer_query (queue->srcpad, query);
|
queue->last_query = gst_pad_peer_query (queue->srcpad, query);
|
||||||
GST_LOG_OBJECT (queue->srcpad, "Peered query");
|
GST_LOG_OBJECT (queue->srcpad, "Peered query");
|
||||||
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
||||||
|
|
|
@ -102,6 +102,7 @@ struct _GstQueue2
|
||||||
|
|
||||||
GCond query_handled;
|
GCond query_handled;
|
||||||
gboolean last_query; /* result of last serialized query */
|
gboolean last_query; /* result of last serialized query */
|
||||||
|
GstQuery *last_handled_query;
|
||||||
|
|
||||||
GstQueue2Size cur_level; /* currently in the queue */
|
GstQueue2Size cur_level; /* currently in the queue */
|
||||||
GstQueue2Size max_level; /* max. amount of data allowed in the queue */
|
GstQueue2Size max_level; /* max. amount of data allowed in the queue */
|
||||||
|
|
Loading…
Reference in a new issue