[Cogl] [PATCH] cogl-gst: emit ready signal on sink only after the first frame is uploaded
Lionel Landwerlin
llandwerlin at gmail.com
Fri Aug 9 14:44:51 PDT 2013
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.
---
cogl-gst/cogl-gst-video-sink.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 6fd69f8..8bc5f78 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -965,6 +965,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);
@@ -986,9 +987,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;
@@ -1001,14 +1000,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;
--
1.8.4.rc1
More information about the Cogl
mailing list