[clutter-gst] plugin: return error on state change if Clutter is not initialized



commit a39564ed057da0f075a45854467037280ba81773
Author: Lionel Landwerlin <llandwerlin gmail com>
Date:   Tue Nov 19 15:51:01 2013 +0000

    plugin: return error on state change if Clutter is not initialized

 clutter-gst/clutter-gst-auto-video-sink.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/clutter-gst/clutter-gst-auto-video-sink.c b/clutter-gst/clutter-gst-auto-video-sink.c
index 089170b..0b82e7e 100644
--- a/clutter-gst/clutter-gst-auto-video-sink.c
+++ b/clutter-gst/clutter-gst-auto-video-sink.c
@@ -65,11 +65,14 @@ static GstStaticPadTemplate sink_template =
                            GST_PAD_ALWAYS,
                            GST_STATIC_CAPS_ANY);
 
+static ClutterInitError _clutter_initialized = CLUTTER_INIT_ERROR_UNKNOWN;
+
 static void
 _clutter_init (void)
 {
   /* We must ensure that clutter is initialized */
-  if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
+  _clutter_initialized = clutter_init (NULL, NULL);
+  if (_clutter_initialized != CLUTTER_INIT_SUCCESS)
     g_critical ("Unable to initialize Clutter");
 }
 
@@ -228,6 +231,9 @@ clutter_gst_auto_video_sink_change_state (GstElement     *element,
 
   switch (transition) {
   case GST_STATE_CHANGE_NULL_TO_READY:
+    if (_clutter_initialized != CLUTTER_INIT_SUCCESS)
+      return GST_STATE_CHANGE_FAILURE;
+
     if (!sink->content)
       {
         ClutterActor *stage = clutter_stage_new ();
@@ -253,13 +259,5 @@ clutter_gst_auto_video_sink_change_state (GstElement     *element,
 
   ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
 
-  /* switch (transition) { */
-  /* case GST_STATE_CHANGE_READY_TO_NULL: */
-  /*   gst_auto_video_sink_reset (sink); */
-  /*   break; */
-  /* default: */
-  /*   break; */
-  /* } */
-
   return ret;
 }


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