[gst-cvs] gstreamer: multiqueue: avoid lock for taking the counter
Wim Taymans
wtay at kemper.freedesktop.org
Wed Oct 21 12:57:41 PDT 2009
Module: gstreamer
Branch: master
Commit: b95cc5031b86549e955aa1fd981a3e8a68e73e60
URL: http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=b95cc5031b86549e955aa1fd981a3e8a68e73e60
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date: Wed Oct 21 13:38:57 2009 -0400
multiqueue: avoid lock for taking the counter
The counter for incomming data is already protected with the STREAM_LOCK so we
don't need to add another lock around it.
---
plugins/elements/gstmultiqueue.c | 7 ++-----
plugins/elements/gstmultiqueue.h | 2 +-
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/plugins/elements/gstmultiqueue.c b/plugins/elements/gstmultiqueue.c
index 938825a..30b7bc6 100644
--- a/plugins/elements/gstmultiqueue.c
+++ b/plugins/elements/gstmultiqueue.c
@@ -1014,9 +1014,7 @@ gst_multi_queue_chain (GstPad * pad, GstBuffer * buffer)
mq = sq->mqueue;
/* Get a unique incrementing id */
- GST_MULTI_QUEUE_MUTEX_LOCK (mq);
curid = mq->counter++;
- GST_MULTI_QUEUE_MUTEX_UNLOCK (mq);
GST_LOG_OBJECT (mq, "SingleQueue %d : about to enqueue buffer %p with id %d",
sq->id, buffer, curid);
@@ -1112,10 +1110,9 @@ gst_multi_queue_sink_event (GstPad * pad, GstEvent * event)
break;
}
- /* Get an unique incrementing id */
- GST_MULTI_QUEUE_MUTEX_LOCK (mq);
+ /* Get an unique incrementing id. protected with the STREAM_LOCK, unserialized
+ * events already got pushed and don't end up in the queue. */
curid = mq->counter++;
- GST_MULTI_QUEUE_MUTEX_UNLOCK (mq);
item = gst_multi_queue_event_item_new ((GstMiniObject *) event, curid);
diff --git a/plugins/elements/gstmultiqueue.h b/plugins/elements/gstmultiqueue.h
index 7a96d77..088b431 100644
--- a/plugins/elements/gstmultiqueue.h
+++ b/plugins/elements/gstmultiqueue.h
@@ -59,7 +59,7 @@ struct _GstMultiQueue {
GstDataQueueSize max_size, extra_size;
- guint32 counter; /* incoming object counter */
+ guint32 counter; /* incoming object counter, protected with STREAM_LOCK */
guint32 highid; /* contains highest id of last outputted object */
GMutex * qlock; /* Global queue lock (vs object lock or individual */
More information about the Gstreamer-commits
mailing list