[cogl/cogl-1.16] cogl-gst: emit ready signal on sink only after the first frame is uploaded



commit 69247c10f3bdc3ad4da9f9ea876256d3b74a2ae9
Author: Lionel Landwerlin <llandwerlin gmail com>
Date:   Fri Aug 9 22:44:51 2013 +0100

    cogl-gst: emit ready signal on sink only after the first frame is uploaded
    
    Developers listening to the 'ready' signal on CoglGstVideoSink might
    call process the current frame once the signal is triggered. We need
    to ensure the first frame has been uploaded before letting people know
    that the sink is ready.
    
    Reviewed-by: Robert Bragg <robert linux intel com>
    
    (cherry picked from commit 53882aa0728c5540d8452045006a763e29d4306d)

 cogl-gst/cogl-gst-video-sink.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 073a398..4feb724 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -1027,6 +1027,7 @@ cogl_gst_source_dispatch (GSource *source,
   CoglGstSource *gst_source= (CoglGstSource*) source;
   CoglGstVideoSinkPrivate *priv = gst_source->sink->priv;
   GstBuffer *buffer;
+  gboolean pipeline_ready = FALSE;
 
   g_mutex_lock (&gst_source->buffer_lock);
 
@@ -1048,9 +1049,7 @@ cogl_gst_source_dispatch (GSource *source,
        * the application requests it so we can emit the signal.
        * However we'll actually generate the pipeline lazily only if
        * the application actually asks for it. */
-      g_signal_emit (gst_source->sink,
-                     video_sink_signals[PIPELINE_READY_SIGNAL],
-                     0 /* detail */);
+      pipeline_ready = TRUE;
     }
 
   buffer = gst_source->buffer;
@@ -1063,14 +1062,19 @@ cogl_gst_source_dispatch (GSource *source,
       if (!priv->renderer->upload (gst_source->sink, buffer))
         goto fail_upload;
 
-      g_signal_emit (gst_source->sink,
-                     video_sink_signals[NEW_FRAME_SIGNAL], 0,
-                     NULL);
       gst_buffer_unref (buffer);
     }
   else
     GST_WARNING_OBJECT (gst_source->sink, "No buffers available for display");
 
+  if (G_UNLIKELY (pipeline_ready))
+    g_signal_emit (gst_source->sink,
+                   video_sink_signals[PIPELINE_READY_SIGNAL],
+                   0 /* detail */);
+  g_signal_emit (gst_source->sink,
+                 video_sink_signals[NEW_FRAME_SIGNAL], 0,
+                 NULL);
+
   return TRUE;
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]