Code cleanup: only call gst_x_overlay_set_window_handle from one place.

This commit is contained in:
Xavi Artigas 2012-10-22 18:17:31 +02:00
parent 1c4d79835a
commit a62471700f

View file

@ -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);
}