gst/base/gstbasesink.c: We are actually prerolling before commiting the state change.
authorWim Taymans <wim.taymans@gmail.com>
Wed, 29 Jun 2005 10:24:08 +0000 (10:24 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Wed, 29 Jun 2005 10:24:08 +0000 (10:24 +0000)
Original commit message from CVS:
* gst/base/gstbasesink.c: (gst_base_sink_handle_object):
We are actually prerolling before commiting the state
change.

ChangeLog
gst/base/gstbasesink.c
libs/gst/base/gstbasesink.c

index 27cf1ff..848573e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-06-29  Wim Taymans  <wim@fluendo.com>
+
+       * gst/base/gstbasesink.c: (gst_base_sink_handle_object):
+       We are actually prerolling before commiting the state
+       change. 
+
 2005-06-29  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
 
        * docs/manual/advanced-clocks.xml:
index 27a0c2f..d7f53dc 100644 (file)
@@ -461,6 +461,7 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
   }
   /* we are prerolling */
   GST_DEBUG ("finish preroll %p >", basesink);
+  basesink->have_preroll = TRUE;
   GST_PREROLL_UNLOCK (pad);
 
   /* have to release STREAM_LOCK as we cannot take the STATE_LOCK
@@ -483,13 +484,14 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
   if (t > 0)
     GST_STREAM_LOCK_FULL (pad, t);
 
+  /* and wait if needed */
+  GST_PREROLL_LOCK (pad);
+
   GST_LOCK (pad);
   if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
     goto flushing;
   GST_UNLOCK (pad);
 
-  /* and wait if needed */
-  GST_PREROLL_LOCK (pad);
   /* it is possible that the application set the state to PLAYING
    * now in which case we don't need to block anymore. */
   if (!basesink->need_preroll)
@@ -504,18 +506,17 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
     /* block until the state changes, or we get a flush, or something */
     GST_DEBUG ("element %s waiting to finish preroll",
         GST_ELEMENT_NAME (basesink));
-    basesink->have_preroll = TRUE;
     GST_PREROLL_WAIT (pad);
     GST_DEBUG ("done preroll");
     basesink->have_preroll = FALSE;
   }
-  GST_PREROLL_UNLOCK (pad);
-
   GST_LOCK (pad);
   if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
     goto flushing;
   GST_UNLOCK (pad);
 
+  GST_PREROLL_UNLOCK (pad);
+
   return GST_FLOW_OK;
 
 no_preroll:
@@ -525,6 +526,7 @@ no_preroll:
     GST_DEBUG ("no preroll needed");
     /* maybe it was another sink that blocked in preroll, need to check for
        buffers to drain */
+    basesink->have_preroll = FALSE;
     ret = gst_base_sink_preroll_queue_empty (basesink, pad);
     GST_PREROLL_UNLOCK (pad);
 
@@ -533,6 +535,8 @@ no_preroll:
 flushing:
   {
     GST_UNLOCK (pad);
+    basesink->have_preroll = FALSE;
+    GST_PREROLL_UNLOCK (pad);
     GST_DEBUG ("pad is flushing");
     return GST_FLOW_WRONG_STATE;
   }
index 27a0c2f..d7f53dc 100644 (file)
@@ -461,6 +461,7 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
   }
   /* we are prerolling */
   GST_DEBUG ("finish preroll %p >", basesink);
+  basesink->have_preroll = TRUE;
   GST_PREROLL_UNLOCK (pad);
 
   /* have to release STREAM_LOCK as we cannot take the STATE_LOCK
@@ -483,13 +484,14 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
   if (t > 0)
     GST_STREAM_LOCK_FULL (pad, t);
 
+  /* and wait if needed */
+  GST_PREROLL_LOCK (pad);
+
   GST_LOCK (pad);
   if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
     goto flushing;
   GST_UNLOCK (pad);
 
-  /* and wait if needed */
-  GST_PREROLL_LOCK (pad);
   /* it is possible that the application set the state to PLAYING
    * now in which case we don't need to block anymore. */
   if (!basesink->need_preroll)
@@ -504,18 +506,17 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
     /* block until the state changes, or we get a flush, or something */
     GST_DEBUG ("element %s waiting to finish preroll",
         GST_ELEMENT_NAME (basesink));
-    basesink->have_preroll = TRUE;
     GST_PREROLL_WAIT (pad);
     GST_DEBUG ("done preroll");
     basesink->have_preroll = FALSE;
   }
-  GST_PREROLL_UNLOCK (pad);
-
   GST_LOCK (pad);
   if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
     goto flushing;
   GST_UNLOCK (pad);
 
+  GST_PREROLL_UNLOCK (pad);
+
   return GST_FLOW_OK;
 
 no_preroll:
@@ -525,6 +526,7 @@ no_preroll:
     GST_DEBUG ("no preroll needed");
     /* maybe it was another sink that blocked in preroll, need to check for
        buffers to drain */
+    basesink->have_preroll = FALSE;
     ret = gst_base_sink_preroll_queue_empty (basesink, pad);
     GST_PREROLL_UNLOCK (pad);
 
@@ -533,6 +535,8 @@ no_preroll:
 flushing:
   {
     GST_UNLOCK (pad);
+    basesink->have_preroll = FALSE;
+    GST_PREROLL_UNLOCK (pad);
     GST_DEBUG ("pad is flushing");
     return GST_FLOW_WRONG_STATE;
   }