summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2015-04-21 12:19:46 +1000
committerMatthew Waters <matthew@centricular.com>2015-04-21 12:55:24 +1000
commit6cb6d8f9e8585d12b50731d4431d9ab467c5a67d (patch)
tree1b92ea03a88f8050039ea00ba52d8026747e8191 /ext
parent8ba1fbbe6480ff7f8b5a451cb10c7d5c76ec1bad (diff)
downloadgstreamer-plugins-bad-6cb6d8f9e8585d12b50731d4431d9ab467c5a67d.tar.gz
gldisplay: synchronize the searching and creation of GstGLContext's
Ootherwise we could end up with multiple elements in different chains each creating a context. Fixes context creation with glvideomixer.
Diffstat (limited to 'ext')
-rw-r--r--ext/gl/gstglbasemixer.c2
-rw-r--r--ext/gl/gstglimagesink.c5
-rw-r--r--ext/gl/gstgltestsrc.c2
3 files changed, 9 insertions, 0 deletions
diff --git a/ext/gl/gstglbasemixer.c b/ext/gl/gstglbasemixer.c
index 64c019ca3..448c6a6b7 100644
--- a/ext/gl/gstglbasemixer.c
+++ b/ext/gl/gstglbasemixer.c
@@ -484,6 +484,7 @@ gst_gl_base_mixer_decide_allocation (GstGLBaseMixer * mix, GstQuery * query)
_find_local_gl_context (mix);
if (!mix->context) {
+ GST_OBJECT_LOCK (mix->display);
do {
if (mix->context)
gst_object_unref (mix->context);
@@ -497,6 +498,7 @@ gst_gl_base_mixer_decide_allocation (GstGLBaseMixer * mix, GstQuery * query)
goto context_error;
}
} while (!gst_gl_display_add_context (mix->display, mix->context));
+ GST_OBJECT_UNLOCK (mix->display);
}
if (mix_class->decide_allocation)
diff --git a/ext/gl/gstglimagesink.c b/ext/gl/gstglimagesink.c
index a7347fda5..104761672 100644
--- a/ext/gl/gstglimagesink.c
+++ b/ext/gl/gstglimagesink.c
@@ -698,6 +698,7 @@ _ensure_gl_setup (GstGLImageSink * gl_sink)
GST_DEBUG_OBJECT (gl_sink, "Ensuring setup");
if (!gl_sink->context) {
+ GST_OBJECT_LOCK (gl_sink->display);
do {
GstGLContext *other_context;
GstGLWindow *window;
@@ -770,6 +771,7 @@ _ensure_gl_setup (GstGLImageSink * gl_sink)
gst_object_unref (other_context);
gst_object_unref (window);
} while (!gst_gl_display_add_context (gl_sink->display, gl_sink->context));
+ GST_OBJECT_UNLOCK (gl_sink->display);
} else
GST_DEBUG_OBJECT (gl_sink, "Already have a context");
@@ -908,6 +910,9 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition)
gst_gl_display_filter_gl_api (glimage_sink->display, SUPPORTED_GL_APIS);
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
+ if (!_ensure_gl_setup (glimage_sink))
+ return GST_STATE_CHANGE_FAILURE;
+
g_atomic_int_set (&glimage_sink->to_quit, 0);
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
diff --git a/ext/gl/gstgltestsrc.c b/ext/gl/gstgltestsrc.c
index dbd5610f1..788fd86ff 100644
--- a/ext/gl/gstgltestsrc.c
+++ b/ext/gl/gstgltestsrc.c
@@ -816,6 +816,7 @@ gst_gl_test_src_decide_allocation (GstBaseSrc * basesrc, GstQuery * query)
_find_local_gl_context (src);
if (!src->context) {
+ GST_OBJECT_LOCK (src->display);
do {
if (src->context)
gst_object_unref (src->context);
@@ -828,6 +829,7 @@ gst_gl_test_src_decide_allocation (GstBaseSrc * basesrc, GstQuery * query)
goto context_error;
}
} while (!gst_gl_display_add_context (src->display, src->context));
+ GST_OBJECT_UNLOCK (src->display);
}
out_width = GST_VIDEO_INFO_WIDTH (&src->out_info);