From a62471700f5e871205e005927062a10398a3a478 Mon Sep 17 00:00:00 2001 From: Xavi Artigas Date: Mon, 22 Oct 2012 18:17:31 +0200 Subject: [PATCH] Code cleanup: only call gst_x_overlay_set_window_handle from one place. --- .../android-tutorial-3/jni/tutorial-3.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/gst-sdk/tutorials/android-tutorial-3/jni/tutorial-3.c b/gst-sdk/tutorials/android-tutorial-3/jni/tutorial-3.c index 24169623f1..04bd09b7fc 100644 --- a/gst-sdk/tutorials/android-tutorial-3/jni/tutorial-3.c +++ b/gst-sdk/tutorials/android-tutorial-3/jni/tutorial-3.c @@ -128,6 +128,10 @@ static void check_initialization_complete (CustomData *data) { JNIEnv *env = get_jni_env (); if (!data->initialized && data->native_window && data->main_loop) { GST_DEBUG ("Initialization complete, notifying application. native_window:%p main_loop:%p", data->native_window, data->main_loop); + + /* The main loop is running and we received a native window, inform the sink about it */ + gst_x_overlay_set_window_handle (GST_X_OVERLAY (data->video_sink), (guintptr)data->native_window); + (*env)->CallVoidMethod (env, data->app, on_gstreamer_initialized_method_id); if ((*env)->ExceptionCheck (env)) { GST_ERROR ("Failed to call Java method"); @@ -170,11 +174,6 @@ static void *app_function (void *userdata) { return NULL; } - if (data->native_window) { - GST_DEBUG ("Native window already received, notifying the pipeline about it."); - gst_x_overlay_set_window_handle (GST_X_OVERLAY (data->video_sink), (guintptr)data->native_window); - } - /* Instruct the bus to emit signals for each received message, and connect to the interesting signals */ bus = gst_element_get_bus (data->pipeline); bus_source = gst_bus_create_watch (bus); @@ -289,14 +288,6 @@ static void gst_native_surface_init (JNIEnv *env, jobject thiz, jobject surface) } data->native_window = new_native_window; - if (data->video_sink) { - GST_DEBUG ("Pipeline already created, notifying it about the native window."); - gst_element_set_state (data->pipeline, GST_STATE_READY); - gst_x_overlay_set_window_handle (GST_X_OVERLAY (data->video_sink), (guintptr)data->native_window); - } else { - GST_DEBUG ("Pipeline not created yet, it will later be notified about the native window."); - } - check_initialization_complete (data); }