raster pushed a commit to branch master.

commit f9f0b717e641b651c18109d56968ae97dd37e73a
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Thu Jul 18 19:59:41 2013 +0900

    emotion - fix shutdown to ensure all pending async calls are gone too.
---
 src/lib/emotion/emotion_main.c                    | 39 ++++++++++++++++------
 src/lib/emotion/emotion_modules.h                 |  4 +++
 src/modules/emotion/gstreamer/emotion_gstreamer.c | 23 ++++++++++---
 src/modules/emotion/gstreamer/emotion_sink.c      | 40 ++++++++++++++++++-----
 4 files changed, 83 insertions(+), 23 deletions(-)

diff --git a/src/lib/emotion/emotion_main.c b/src/lib/emotion/emotion_main.c
index c99a139..23f6c7f 100644
--- a/src/lib/emotion/emotion_main.c
+++ b/src/lib/emotion/emotion_main.c
@@ -130,7 +130,6 @@ emotion_object_extension_may_play_get(const char *file)
 
 static int _emotion_init_count = 0;
 
-
 EAPI Eina_Bool
 emotion_init(void)
 {
@@ -188,6 +187,20 @@ emotion_init(void)
    return EINA_FALSE;
 }
 
+static int emotion_pendig_events = 0;
+
+EAPI void
+_emotion_pending_ecore_begin(void)
+{
+   emotion_pendig_events++;
+}
+
+EAPI void
+_emotion_pending_ecore_end(void)
+{
+   emotion_pendig_events--;
+}
+
 EAPI Eina_Bool
 emotion_shutdown(void)
 {
@@ -200,6 +213,21 @@ emotion_shutdown(void)
      }
    if (--_emotion_init_count) return EINA_TRUE;
 
+   start = ecore_time_get();
+   while (((emotion_pending_objects > 0) ||
+           (emotion_pendig_events > 0)) &&
+          ((ecore_time_get() - start) < 0.5))
+     ecore_main_loop_iterate();
+
+   if (emotion_pending_objects > 0)
+     {
+        EINA_LOG_ERR("There is still %i Emotion pipeline running", 
emotion_pending_objects);
+     }
+   if (emotion_pendig_events > 0)
+     {
+        EINA_LOG_ERR("There is still %i Emotion events queued", 
emotion_pendig_events);
+     }
+
    emotion_modules_shutdown();
 
    emotion_webcam_shutdown();
@@ -211,15 +239,6 @@ emotion_shutdown(void)
         _emotion_config_file = NULL;
      }
 
-   start = ecore_time_get();
-   while (emotion_pending_objects && ecore_time_get() - start < 0.5)
-     ecore_main_loop_iterate();
-
-   if (emotion_pending_objects)
-     {
-        EINA_LOG_ERR("There is still %i Emotion pipeline running", 
emotion_pending_objects);
-     }
-
    eet_shutdown();
    ecore_shutdown();
 
diff --git a/src/lib/emotion/emotion_modules.h 
b/src/lib/emotion/emotion_modules.h
index 0ece2c1..03fb7db 100644
--- a/src/lib/emotion/emotion_modules.h
+++ b/src/lib/emotion/emotion_modules.h
@@ -127,6 +127,10 @@ EAPI void  _emotion_image_reset(Evas_Object *obj);
 EAPI void _emotion_pending_object_ref(void);
 EAPI void _emotion_pending_object_unref(void);
 
+EAPI void _emotion_pending_ecore_begin(void);
+EAPI void _emotion_pending_ecore_end(void);
+
+
 EAPI const char *emotion_webcam_custom_get(const char *device);
 
 EAPI Eina_Bool _emotion_module_register(const Emotion_Engine *api);
diff --git a/src/modules/emotion/gstreamer/emotion_gstreamer.c 
b/src/modules/emotion/gstreamer/emotion_gstreamer.c
index 9fe6543..f678bf0 100644
--- a/src/modules/emotion/gstreamer/emotion_gstreamer.c
+++ b/src/modules/emotion/gstreamer/emotion_gstreamer.c
@@ -1220,7 +1220,7 @@ gstreamer_module_init(void)
 
    if (_emotion_init_count > 0)
      {
-        _emotion_init_count++;
+        _emotion_pending_ecore_begin();
         return EINA_TRUE;
      }
 
@@ -1525,6 +1525,7 @@ _main_frame_resize(void *data)
 
    ratio = (double)ev->src_width / (double)ev->src_height;
    _emotion_frame_resize(ev->obj, ev->src_width, ev->src_height, ratio);
+   _emotion_pending_ecore_end();
 }
 
 static void
@@ -1539,6 +1540,7 @@ _no_more_pads(GstElement *decodebin, gpointer data)
      {
         if(_video_size_get(GST_ELEMENT(elem), &ev->src_width, &ev->src_height))
           {
+             _emotion_pending_ecore_begin();
              ecore_main_loop_thread_safe_call_async(_main_frame_resize, ev);
              gst_object_unref(elem);
              break;
@@ -1622,6 +1624,7 @@ _eos_main_fct(void *data)
      }
 
    emotion_gstreamer_message_free(send);
+   _emotion_pending_ecore_end();
 }
 
 static GstBusSyncReply
@@ -1642,7 +1645,11 @@ _eos_sync_fct(GstBus *bus EINA_UNUSED, GstMessage *msg, 
gpointer data)
             GST_MESSAGE_TYPE_NAME(msg));
          send = emotion_gstreamer_message_alloc(ev, msg);
 
-         if (send) ecore_main_loop_thread_safe_call_async(_eos_main_fct, send);
+        if (send)
+          {
+             _emotion_pending_ecore_begin();
+             ecore_main_loop_thread_safe_call_async(_eos_main_fct, send);
+          }
 
          break;
 
@@ -1660,7 +1667,11 @@ _eos_sync_fct(GstBus *bus EINA_UNUSED, GstMessage *msg, 
gpointer data)
              {
                 send = emotion_gstreamer_message_alloc(ev, msg);
 
-                if (send) 
ecore_main_loop_thread_safe_call_async(_eos_main_fct, send);
+                if (send)
+                  {
+                     _emotion_pending_ecore_begin();
+                     ecore_main_loop_thread_safe_call_async(_eos_main_fct, 
send);
+                  }
              }
            break;
         }
@@ -1679,7 +1690,11 @@ _eos_sync_fct(GstBus *bus EINA_UNUSED, GstMessage *msg, 
gpointer data)
              {
                 send = emotion_gstreamer_message_alloc(ev, msg);
 
-                if (send) 
ecore_main_loop_thread_safe_call_async(_eos_main_fct, send);
+                if (send)
+                  {
+                     _emotion_pending_ecore_begin();
+                     ecore_main_loop_thread_safe_call_async(_eos_main_fct, 
send);
+                  }
              }
           break;
        }
diff --git a/src/modules/emotion/gstreamer/emotion_sink.c 
b/src/modules/emotion/gstreamer/emotion_sink.c
index 1a1199f..9920d93 100644
--- a/src/modules/emotion/gstreamer/emotion_sink.c
+++ b/src/modules/emotion/gstreamer/emotion_sink.c
@@ -237,7 +237,7 @@ gboolean evas_video_sink_set_caps(GstBaseSink *bsink, 
GstCaps *caps)
                DBG("Found '%s'", colorspace_fourcc_convertion[i].name);
                priv->eformat = colorspace_fourcc_convertion[i].eformat;
                priv->func = colorspace_fourcc_convertion[i].func;
-               if (colorspace_fourcc_convertion[i].force_height)
+              if (colorspace_fourcc_convertion[i].force_height)
                  {
                     priv->height = (priv->height >> 1) << 1;
                  }
@@ -388,11 +388,14 @@ evas_video_sink_preroll(GstBaseSink* bsink, GstBuffer* 
buffer)
                   else
                     priv->func = _evas_video_st12;
                }
-
+             _emotion_pending_ecore_begin();
              
ecore_main_loop_thread_safe_call_async(evas_video_sink_samsung_main_render, 
send);
           }
         else
-          ecore_main_loop_thread_safe_call_async(evas_video_sink_main_render, 
send);
+          {
+             _emotion_pending_ecore_begin();
+             
ecore_main_loop_thread_safe_call_async(evas_video_sink_main_render, send);
+          }
      }
 
    return GST_FLOW_OK;
@@ -442,11 +445,14 @@ evas_video_sink_render(GstBaseSink* bsink, GstBuffer* 
buffer)
              else
                priv->func = _evas_video_st12;
           }
-
+        _emotion_pending_ecore_begin();
         
ecore_main_loop_thread_safe_call_async(evas_video_sink_samsung_main_render, 
send);
      }
    else
-     ecore_main_loop_thread_safe_call_async(evas_video_sink_main_render, send);
+     {
+        _emotion_pending_ecore_begin();
+        ecore_main_loop_thread_safe_call_async(evas_video_sink_main_render, 
send);
+     }
 
    eina_condition_wait(&priv->c);
    eina_lock_release(&priv->m);
@@ -612,11 +618,16 @@ evas_video_sink_samsung_main_render(void *data)
  exit_stream:
    if (priv)
      {
-        if (preroll || !priv->o) return;
+        if (preroll || !priv->o)
+          {
+             _emotion_pending_ecore_end();
+             return;
+          }
         
         if (!priv->unlocked)
           eina_condition_signal(&priv->c);
      }
+   _emotion_pending_ecore_end();
 }
 
 static void
@@ -723,11 +734,16 @@ evas_video_sink_main_render(void *data)
  exit_stream:
    if (priv)
      {
-        if (preroll || !priv->o) return;
+        if (preroll || !priv->o)
+          {
+             _emotion_pending_ecore_end();
+             return;
+          }
         
         if (!priv->unlocked)
           eina_condition_signal(&priv->c);
      }
+   _emotion_pending_ecore_end();
 }
 
 static void
@@ -976,9 +992,15 @@ _video_update_pixels(void *data, Evas_Object *obj 
EINA_UNUSED, const Evas_Video_
    ev->send = NULL;
 
    if (priv->samsung)
-      evas_video_sink_samsung_main_render(send);
+     {
+        _emotion_pending_ecore_begin();
+        evas_video_sink_samsung_main_render(send);
+     }
    else
-      evas_video_sink_main_render(send);
+     {
+        _emotion_pending_ecore_begin();
+        evas_video_sink_main_render(send);
+     }
 }
 
 static void

-- 

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk

Reply via email to