From 8b14eea6eca2395d4afd19ce3e79a25ca554eb8a Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Thu, 10 Jul 2008 23:53:36 +0000 Subject: [PATCH] [119/906] git-svn-id: svn://svn.wobow.com/GStreamer_playground/gst-plugins-gl@579 93df14bb-0f41-7a43-8087-d3e2a2f0e464 --- gst-libs/gst/gl/gstgldisplay.c | 26 ++++++++++++++++++++++++-- gst-libs/gst/gl/gstgldisplay.h | 2 ++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c index 582925d6bc..a1e9ad1911 100644 --- a/gst-libs/gst/gl/gstgldisplay.c +++ b/gst-libs/gst/gl/gstgldisplay.c @@ -37,6 +37,7 @@ static gboolean gst_gl_display_thread_check_msg_validity (GstGLDisplayMsg *msg); /* Called in the gl thread, protected by lock and unlock */ static void gst_gl_display_thread_create_context (GstGLDisplay* display); static void gst_gl_display_thread_destroy_context (GstGLDisplay* display); +static void gst_gl_display_thread_change_context (GstGLDisplay* display); static void gst_gl_display_thread_set_visible_context (GstGLDisplay* display); static void gst_gl_display_thread_resize_context (GstGLDisplay* display); static void gst_gl_display_thread_redisplay (GstGLDisplay* display); @@ -126,6 +127,7 @@ gst_gl_display_init (GstGLDisplay *display, GstGLDisplayClass *klass) //conditions display->cond_create_context = g_cond_new (); display->cond_destroy_context = g_cond_new (); + display->cond_change_context = g_cond_new (); display->cond_gen_texture = g_cond_new (); display->cond_del_texture = g_cond_new (); display->cond_init_upload = g_cond_new (); @@ -414,6 +416,10 @@ gst_gl_display_finalize (GObject* object) g_cond_free (display->cond_gen_texture); display->cond_gen_texture = NULL; } + if (display->cond_change_context) { + g_cond_free (display->cond_change_context); + display->cond_change_context = NULL; + } if (display->cond_destroy_context) { g_cond_free (display->cond_destroy_context); display->cond_destroy_context = NULL; @@ -515,6 +521,9 @@ gst_gl_display_thread_dispatch_action (GstGLDisplayMsg* msg) break; case GST_GL_DISPLAY_ACTION_DESTROY_CONTEXT: gst_gl_display_thread_destroy_context (msg->display); + break; + case GST_GL_DISPLAY_ACTION_CHANGE_CONTEXT: + gst_gl_display_thread_change_context (msg->display); break; case GST_GL_DISPLAY_ACTION_VISIBLE_CONTEXT: gst_gl_display_thread_set_visible_context (msg->display); @@ -576,9 +585,11 @@ gst_gl_display_thread_check_msg_validity (GstGLDisplayMsg *msg) switch (msg->action) { case GST_GL_DISPLAY_ACTION_CREATE_CONTEXT: + //display is not in the map only when we want create one valid = TRUE; break; case GST_GL_DISPLAY_ACTION_DESTROY_CONTEXT: + case GST_GL_DISPLAY_ACTION_CHANGE_CONTEXT: case GST_GL_DISPLAY_ACTION_VISIBLE_CONTEXT: case GST_GL_DISPLAY_ACTION_RESIZE_CONTEXT: case GST_GL_DISPLAY_ACTION_REDISPLAY_CONTEXT: @@ -748,6 +759,16 @@ gst_gl_display_thread_destroy_context (GstGLDisplay *display) } +/* Called in the gl thread */ +static void +gst_gl_display_thread_change_context (GstGLDisplay *display) +{ + glutSetWindow (display->glutWinId); + glutChangeWindow (display->winId); + g_cond_signal (display->cond_change_context); +} + + /* Called in the gl thread */ static void gst_gl_display_thread_set_visible_context (GstGLDisplay *display) @@ -1884,8 +1905,9 @@ gst_gl_display_set_window_id (GstGLDisplay* display, gulong winId) static gint y_pos = 0; gst_gl_display_lock (display); - gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_DESTROY_CONTEXT, display); - g_cond_wait (display->cond_destroy_context, display->mutex); + //display->winId = winId; + gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_CHANGE_CONTEXT, display); + g_cond_wait (display->cond_change_context, display->mutex); gst_gl_display_unlock (display); if (g_hash_table_size (gst_gl_display_map) == 0) diff --git a/gst-libs/gst/gl/gstgldisplay.h b/gst-libs/gst/gl/gstgldisplay.h index 208b0f1e6b..d22296b07d 100644 --- a/gst-libs/gst/gl/gstgldisplay.h +++ b/gst-libs/gst/gl/gstgldisplay.h @@ -60,6 +60,7 @@ typedef enum { typedef enum { GST_GL_DISPLAY_ACTION_CREATE_CONTEXT, GST_GL_DISPLAY_ACTION_DESTROY_CONTEXT, + GST_GL_DISPLAY_ACTION_CHANGE_CONTEXT, GST_GL_DISPLAY_ACTION_VISIBLE_CONTEXT, GST_GL_DISPLAY_ACTION_RESIZE_CONTEXT, GST_GL_DISPLAY_ACTION_REDISPLAY_CONTEXT, @@ -118,6 +119,7 @@ struct _GstGLDisplay { //conditions GCond* cond_create_context; GCond* cond_destroy_context; + GCond* cond_change_context; GCond* cond_gen_texture; GCond* cond_del_texture; GCond* cond_init_upload;