gl: don't deadlock on context creation failure

https://bugzilla.gnome.org/show_bug.cgi?id=749284
This commit is contained in:
Matthew Waters 2015-05-13 23:54:52 +10:00 committed by Tim-Philipp Müller
parent 9336d8fa80
commit 50d3161ac5
4 changed files with 18 additions and 6 deletions

View file

@ -477,8 +477,10 @@ gst_gl_base_mixer_decide_allocation (GstGLBaseMixer * mix, GstQuery * query)
if (!mix->context) { if (!mix->context) {
mix->context = gst_gl_context_new (mix->display); mix->context = gst_gl_context_new (mix->display);
if (!gst_gl_context_create (mix->context, mix->priv->other_context, if (!gst_gl_context_create (mix->context, mix->priv->other_context,
&error)) &error)) {
GST_OBJECT_UNLOCK (mix->display);
goto context_error; goto context_error;
}
} }
} while (!gst_gl_display_add_context (mix->display, mix->context)); } while (!gst_gl_display_add_context (mix->display, mix->context));
GST_OBJECT_UNLOCK (mix->display); GST_OBJECT_UNLOCK (mix->display);

View file

@ -703,8 +703,10 @@ _ensure_gl_setup (GstGLImageSink * gl_sink)
gl_sink->display); gl_sink->display);
gl_sink->context = gst_gl_context_new (gl_sink->display); gl_sink->context = gst_gl_context_new (gl_sink->display);
if (!gl_sink->context) if (!gl_sink->context) {
GST_OBJECT_UNLOCK (gl_sink->display);
goto context_creation_error; goto context_creation_error;
}
window = gst_gl_context_get_window (gl_sink->context); window = gst_gl_context_get_window (gl_sink->context);
@ -738,6 +740,7 @@ _ensure_gl_setup (GstGLImageSink * gl_sink)
if (other_context) if (other_context)
gst_object_unref (other_context); gst_object_unref (other_context);
gst_object_unref (window); gst_object_unref (window);
GST_OBJECT_UNLOCK (gl_sink->display);
goto context_error; goto context_error;
} }

View file

@ -786,8 +786,10 @@ gst_gl_test_src_decide_allocation (GstBaseSrc * basesrc, GstQuery * query)
gst_gl_display_get_gl_context_for_thread (src->display, NULL); gst_gl_display_get_gl_context_for_thread (src->display, NULL);
if (!src->context) { if (!src->context) {
src->context = gst_gl_context_new (src->display); src->context = gst_gl_context_new (src->display);
if (!gst_gl_context_create (src->context, src->other_context, &error)) if (!gst_gl_context_create (src->context, src->other_context, &error)) {
GST_OBJECT_UNLOCK (src->display);
goto context_error; goto context_error;
}
} }
} while (!gst_gl_display_add_context (src->display, src->context)); } while (!gst_gl_display_add_context (src->display, src->context));
GST_OBJECT_UNLOCK (src->display); GST_OBJECT_UNLOCK (src->display);
@ -849,7 +851,8 @@ context_error:
{ {
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, ("%s", error->message), GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, ("%s", error->message),
(NULL)); (NULL));
gst_object_unref (src->context); if (src->context)
gst_object_unref (src->context);
src->context = NULL; src->context = NULL;
return FALSE; return FALSE;
} }

View file

@ -333,12 +333,16 @@ gst_gl_base_filter_decide_allocation (GstBaseTransform * trans,
gst_gl_display_get_gl_context_for_thread (filter->display, NULL); gst_gl_display_get_gl_context_for_thread (filter->display, NULL);
if (!filter->context) { if (!filter->context) {
filter->context = gst_gl_context_new (filter->display); filter->context = gst_gl_context_new (filter->display);
if (!filter->context) if (!filter->context) {
GST_OBJECT_UNLOCK (filter->display);
goto context_null_error; goto context_null_error;
}
if (!gst_gl_context_create (filter->context, if (!gst_gl_context_create (filter->context,
filter->priv->other_context, &error)) filter->priv->other_context, &error)) {
GST_OBJECT_UNLOCK (filter->display);
goto context_error; goto context_error;
}
} }
} while (!gst_gl_display_add_context (filter->display, filter->context)); } while (!gst_gl_display_add_context (filter->display, filter->context));
GST_OBJECT_UNLOCK (filter->display); GST_OBJECT_UNLOCK (filter->display);