glfiter: Protect GstGLContext access

The propose and decide allocation vfuncs are called directly from
basetransform and need to use the locked accessor function for
retrieving a reliable reference to the GstGLContext (if available)

Fixes spurious crashes on shutdown during pad reconfiguration

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5518>
This commit is contained in:
Jan Schmidt 2023-10-05 13:49:16 +11:00 committed by Tim-Philipp Müller
parent 4299be47ab
commit 970eb963c7

View file

@ -803,7 +803,12 @@ gst_gl_filter_propose_allocation (GstBaseTransform * trans,
GstQuery * decide_query, GstQuery * query)
{
GstGLFilter *filter = GST_GL_FILTER (trans);
GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
GstGLContext *context =
gst_gl_base_filter_get_gl_context (GST_GL_BASE_FILTER (filter));
if (context == NULL) {
return FALSE;
}
GstCaps *caps;
GstVideoInfo info;
guint size;
@ -843,22 +848,26 @@ gst_gl_filter_propose_allocation (GstBaseTransform * trans,
if (context->gl_vtable->FenceSync)
gst_query_add_allocation_meta (query, GST_GL_SYNC_META_API_TYPE, 0);
gst_object_unref (context);
return TRUE;
/* ERRORS */
no_caps:
{
GST_DEBUG_OBJECT (trans, "no caps specified");
gst_object_unref (context);
return FALSE;
}
invalid_caps:
{
GST_DEBUG_OBJECT (trans, "invalid caps specified");
gst_object_unref (context);
return FALSE;
}
config_failed:
{
GST_DEBUG_OBJECT (trans, "failed setting config");
gst_object_unref (context);
return FALSE;
}
}
@ -866,7 +875,6 @@ config_failed:
static gboolean
gst_gl_filter_decide_allocation (GstBaseTransform * trans, GstQuery * query)
{
GstGLContext *context;
GstBufferPool *pool = NULL;
GstStructure *config;
GstCaps *caps;
@ -882,7 +890,11 @@ gst_gl_filter_decide_allocation (GstBaseTransform * trans, GstQuery * query)
query))
return FALSE;
context = GST_GL_BASE_FILTER (trans)->context;
GstGLContext *context =
gst_gl_base_filter_get_gl_context (GST_GL_BASE_FILTER (trans));
if (context == NULL) {
return FALSE;
}
if (gst_query_get_n_allocation_pools (query) > 0) {
gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
@ -920,6 +932,7 @@ gst_gl_filter_decide_allocation (GstBaseTransform * trans, GstQuery * query)
gst_query_add_allocation_pool (query, pool, size, min, max);
gst_object_unref (pool);
gst_object_unref (context);
return TRUE;
}