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/5437>
This commit is contained in:
Jan Schmidt 2023-10-05 13:49:16 +11:00 committed by GStreamer Marge Bot
parent 41f478e97d
commit 23097e35e6

View file

@ -804,7 +804,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;
@ -844,22 +849,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;
}
}
@ -867,7 +876,6 @@ config_failed:
static gboolean
gst_gl_filter_decide_allocation (GstBaseTransform * trans, GstQuery * query)
{
GstGLContext *context;
GstBufferPool *pool = NULL;
GstStructure *config;
GstCaps *caps;
@ -883,7 +891,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);
@ -921,6 +933,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;
}