[410/906] gstglmixer: inactivate shared gl context before to release ours
authorJulien Isorce <julien.isorce@gmail.com>
Wed, 16 Dec 2009 00:33:39 +0000 (01:33 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:31:23 +0000 (19:31 +0000)
First, inactivate shared gl contexts known by each sink pad.
Then, destroy the gl context known by the glmixer.
Finally, re-activate shared gl contexts.
This is to satisfy the fact that no shared gl context must be current
when an opengl context is destroyed.
Moreover the application may hang or crash without those steps.

gst-libs/gst/gl/gstglmixer.c

index f43a649..a206e1a 100644 (file)
@@ -1274,10 +1274,8 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition)
       while (walk) {
         GstGLMixerPad *sink_pad = GST_GL_MIXER_PAD (walk->data);
         walk = g_slist_next (walk);
-        if (sink_pad->display) {
-          g_object_unref (sink_pad->display);
-          sink_pad->display = NULL;
-        }
+        if (sink_pad->display)
+          gst_gl_display_activate_gl_context (sink_pad->display, FALSE);
       }
       if (mixer_class->reset)
         mixer_class->reset (mix);
@@ -1290,6 +1288,15 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition)
         g_object_unref (mix->display);
         mix->display = NULL;
       }
+      while (walk) {
+        GstGLMixerPad *sink_pad = GST_GL_MIXER_PAD (walk->data);
+        walk = g_slist_next (walk);
+        if (sink_pad->display) {
+          gst_gl_display_activate_gl_context (sink_pad->display, TRUE);
+          g_object_unref (sink_pad->display);
+          sink_pad->display = NULL;
+        }
+      }
       break;
     }
     default: