libs/gst/base/gstbasesink.c: Some cleanups.
authorWim Taymans <wim.taymans@gmail.com>
Wed, 18 Jan 2006 17:18:39 +0000 (17:18 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Wed, 18 Jan 2006 17:18:39 +0000 (17:18 +0000)
Original commit message from CVS:
* libs/gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_do_sync):
Some cleanups.
When the sink finishes blocking on the preroll buffer, it can
immediatly render it instead of rendering when the next buffer
arrives.

libs/gst/base/gstbasesink.c

index bed8916..328f1f1 100644 (file)
@@ -728,36 +728,36 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad,
   /* see if we need to block now. We cannot block on events, only
    * on buffers, the reason is that events can be sent from the
    * application thread and we don't want to block there. */
-  if (length > basesink->preroll_queue_max_len && !have_event) {
-    /* block until the state changes, or we get a flush, or something */
-    GST_DEBUG_OBJECT (basesink, "waiting to finish preroll");
-    GST_PAD_PREROLL_WAIT (pad);
-    GST_DEBUG_OBJECT (basesink, "done preroll");
-    GST_OBJECT_LOCK (pad);
-    if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
-      goto flushing;
-    GST_OBJECT_UNLOCK (pad);
-  }
+  if (length <= basesink->preroll_queue_max_len || have_event)
+    goto more_preroll;
+
+  /* block until the state changes, or we get a flush, or something */
+  GST_DEBUG_OBJECT (basesink, "waiting to finish preroll");
+  GST_PAD_PREROLL_WAIT (pad);
+  GST_DEBUG_OBJECT (basesink, "done preroll");
+  GST_OBJECT_LOCK (pad);
+  if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
+    goto flushing;
+  GST_OBJECT_UNLOCK (pad);
+
+  /* we can start rendering the data now */
+no_preroll:
+  GST_DEBUG_OBJECT (basesink, "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_PAD_PREROLL_UNLOCK (pad);
 
-  return GST_FLOW_OK;
-
-no_preroll:
-  {
-    GST_DEBUG_OBJECT (basesink, "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_PAD_PREROLL_UNLOCK (pad);
+  return ret;
 
-    return ret;
-  }
+  /* special cases */
 dropping:
   {
     GstBuffer *buf;
 
     GST_DEBUG_OBJECT (basesink, "dropping buffer");
+    /* take the buffer off the queue again */
     buf = GST_BUFFER (g_queue_pop_tail (basesink->preroll_queue));
 
     gst_buffer_unref (buf);
@@ -792,6 +792,12 @@ preroll_failed:
 
     return ret;
   }
+more_preroll:
+  {
+    GST_DEBUG_OBJECT (basesink, "need more preroll data");
+    GST_PAD_PREROLL_UNLOCK (pad);
+    return GST_FLOW_OK;
+  }
 }
 
 static gboolean