basesrc: Only renegotiate once after receiving a renegotiate event
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 26 Apr 2011 14:39:56 +0000 (16:39 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 5 May 2011 13:04:16 +0000 (15:04 +0200)
Also make this threadsafe.

libs/gst/base/gstbasesrc.c

index 4416454..8b312dc 100644 (file)
@@ -1739,7 +1739,7 @@ gst_base_src_default_event (GstBaseSrc * src, GstEvent * event)
     }
     case GST_EVENT_RENEGOTIATE:
     {
-      src->priv->renegotiate = TRUE;
+      g_atomic_int_set (&src->priv->renegotiate, TRUE);
       result = TRUE;
       break;
     }
@@ -2375,11 +2375,9 @@ gst_base_src_loop (GstPad * pad)
   src = GST_BASE_SRC (GST_OBJECT_PARENT (pad));
 
   /* check if we need to renegotiate */
-  if (src->priv->renegotiate) {
+  if (g_atomic_int_compare_and_exchange (&src->priv->renegotiate, TRUE, FALSE)) {
     if (!gst_base_src_negotiate (src))
       GST_DEBUG_OBJECT (src, "Failed to renegotiate");
-    else
-      src->priv->renegotiate = TRUE;
   }
 
   GST_LIVE_LOCK (src);