gst/gstqueue.c (gst_queue_link_sink): Grab the lock only when it is necessary to...
authorMartin Soto <martinsoto@users.sourceforge.net>
Wed, 24 Nov 2004 18:54:35 +0000 (18:54 +0000)
committerMartin Soto <martinsoto@users.sourceforge.net>
Wed, 24 Nov 2004 18:54:35 +0000 (18:54 +0000)
Original commit message from CVS:
2004-11-24  Martin Soto  <martinsoto@users.sourceforge.net>

* gst/gstqueue.c (gst_queue_link_sink): Grab the lock only when
it is necessary to wait.

ChangeLog
gst/gstqueue.c
plugins/elements/gstqueue.c

index 6cbb025..5c3a08d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-11-24  Martin Soto  <martinsoto@users.sourceforge.net>
+
+       * gst/gstqueue.c (gst_queue_link_sink): Grab the lock only when
+       it is necessary to wait.
+
 2004-11-24  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
 
        * docs/pwg/building-boiler.xml:
index 9e4b8d8..c38b12f 100644 (file)
@@ -410,8 +410,6 @@ gst_queue_link_sink (GstPad * pad, const GstCaps * caps)
 
   queue = GST_QUEUE (gst_pad_get_parent (pad));
 
-  GST_QUEUE_MUTEX_LOCK;
-
   if (queue->cur_level.bytes > 0) {
     if (gst_caps_is_equal (caps, queue->negotiated_caps)) {
       GST_QUEUE_MUTEX_UNLOCK;
@@ -420,11 +418,15 @@ gst_queue_link_sink (GstPad * pad, const GstCaps * caps)
 
     /* Wait until the queue is empty before attempting the pad
        negotiation. */
+    GST_QUEUE_MUTEX_LOCK;
+
     STATUS (queue, "waiting for queue to get empty");
     while (queue->cur_level.bytes > 0) {
       g_cond_wait (queue->item_del, queue->qlock);
     }
     STATUS (queue, "queue is now empty");
+
+    GST_QUEUE_MUTEX_UNLOCK;
   }
 
   link_ret = gst_pad_proxy_pad_link (pad, caps);
@@ -435,8 +437,6 @@ gst_queue_link_sink (GstPad * pad, const GstCaps * caps)
     gst_caps_replace (&queue->negotiated_caps, gst_caps_copy (caps));
   }
 
-  GST_QUEUE_MUTEX_UNLOCK;
-
   return link_ret;
 }
 
index 9e4b8d8..c38b12f 100644 (file)
@@ -410,8 +410,6 @@ gst_queue_link_sink (GstPad * pad, const GstCaps * caps)
 
   queue = GST_QUEUE (gst_pad_get_parent (pad));
 
-  GST_QUEUE_MUTEX_LOCK;
-
   if (queue->cur_level.bytes > 0) {
     if (gst_caps_is_equal (caps, queue->negotiated_caps)) {
       GST_QUEUE_MUTEX_UNLOCK;
@@ -420,11 +418,15 @@ gst_queue_link_sink (GstPad * pad, const GstCaps * caps)
 
     /* Wait until the queue is empty before attempting the pad
        negotiation. */
+    GST_QUEUE_MUTEX_LOCK;
+
     STATUS (queue, "waiting for queue to get empty");
     while (queue->cur_level.bytes > 0) {
       g_cond_wait (queue->item_del, queue->qlock);
     }
     STATUS (queue, "queue is now empty");
+
+    GST_QUEUE_MUTEX_UNLOCK;
   }
 
   link_ret = gst_pad_proxy_pad_link (pad, caps);
@@ -435,8 +437,6 @@ gst_queue_link_sink (GstPad * pad, const GstCaps * caps)
     gst_caps_replace (&queue->negotiated_caps, gst_caps_copy (caps));
   }
 
-  GST_QUEUE_MUTEX_UNLOCK;
-
   return link_ret;
 }