mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
multiqueue: Increment unique item counter with atomic operations
Before it was only protected by the stream lock but every pad has its own stream lock, making the protection rather useless.
This commit is contained in:
parent
9e36a51bac
commit
383cac91b1
2 changed files with 4 additions and 5 deletions
|
@ -1229,7 +1229,7 @@ gst_multi_queue_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
goto was_eos;
|
goto was_eos;
|
||||||
|
|
||||||
/* Get a unique incrementing id */
|
/* Get a unique incrementing id */
|
||||||
curid = mq->counter++;
|
curid = g_atomic_int_exchange_and_add ((gint *) & mq->counter, 1);
|
||||||
|
|
||||||
GST_LOG_OBJECT (mq, "SingleQueue %d : about to enqueue buffer %p with id %d",
|
GST_LOG_OBJECT (mq, "SingleQueue %d : about to enqueue buffer %p with id %d",
|
||||||
sq->id, buffer, curid);
|
sq->id, buffer, curid);
|
||||||
|
@ -1334,9 +1334,8 @@ gst_multi_queue_sink_event (GstPad * pad, GstEvent * event)
|
||||||
if (sq->is_eos)
|
if (sq->is_eos)
|
||||||
goto was_eos;
|
goto was_eos;
|
||||||
|
|
||||||
/* Get an unique incrementing id. protected with the STREAM_LOCK, unserialized
|
/* Get an unique incrementing id. */
|
||||||
* events already got pushed and don't end up in the queue. */
|
curid = g_atomic_int_exchange_and_add ((gint *) & mq->counter, 1);
|
||||||
curid = mq->counter++;
|
|
||||||
|
|
||||||
item = gst_multi_queue_event_item_new ((GstMiniObject *) event, curid);
|
item = gst_multi_queue_event_item_new ((GstMiniObject *) event, curid);
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ struct _GstMultiQueue {
|
||||||
gboolean buffering;
|
gboolean buffering;
|
||||||
gint percent;
|
gint percent;
|
||||||
|
|
||||||
guint32 counter; /* incoming object counter, protected with STREAM_LOCK */
|
guint32 counter; /* incoming object counter, use atomic accesses */
|
||||||
guint32 highid; /* contains highest id of last outputted object */
|
guint32 highid; /* contains highest id of last outputted object */
|
||||||
|
|
||||||
GMutex * qlock; /* Global queue lock (vs object lock or individual */
|
GMutex * qlock; /* Global queue lock (vs object lock or individual */
|
||||||
|
|
Loading…
Reference in a new issue