mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
gluploadelement: Avoid race condition in propose_allocation().
The inside upload and context may have race condition in the function of propose_allocation(). They may be destroyed while this function is stilling using it. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/916>
This commit is contained in:
parent
e8bb524278
commit
297a1555bf
1 changed files with 19 additions and 6 deletions
|
@ -212,19 +212,32 @@ _gst_gl_upload_element_propose_allocation (GstBaseTransform * bt,
|
||||||
GstQuery * decide_query, GstQuery * query)
|
GstQuery * decide_query, GstQuery * query)
|
||||||
{
|
{
|
||||||
GstGLUploadElement *upload = GST_GL_UPLOAD_ELEMENT (bt);
|
GstGLUploadElement *upload = GST_GL_UPLOAD_ELEMENT (bt);
|
||||||
GstGLContext *context = GST_GL_BASE_FILTER (bt)->context;
|
GstGLUpload *ul;
|
||||||
|
GstGLContext *context;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
if (!upload->upload)
|
GST_OBJECT_LOCK (upload);
|
||||||
return FALSE;
|
if (!upload->upload) {
|
||||||
if (!context)
|
GST_OBJECT_UNLOCK (upload);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
ul = gst_object_ref (upload->upload);
|
||||||
|
GST_OBJECT_UNLOCK (upload);
|
||||||
|
|
||||||
gst_gl_upload_set_context (upload->upload, context);
|
context = gst_gl_base_filter_get_gl_context (GST_GL_BASE_FILTER (bt));
|
||||||
|
if (!context) {
|
||||||
|
gst_object_unref (ul);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_gl_upload_set_context (ul, context);
|
||||||
|
|
||||||
ret = GST_BASE_TRANSFORM_CLASS (parent_class)->propose_allocation (bt,
|
ret = GST_BASE_TRANSFORM_CLASS (parent_class)->propose_allocation (bt,
|
||||||
decide_query, query);
|
decide_query, query);
|
||||||
gst_gl_upload_propose_allocation (upload->upload, decide_query, query);
|
gst_gl_upload_propose_allocation (ul, decide_query, query);
|
||||||
|
|
||||||
|
gst_object_unref (ul);
|
||||||
|
gst_object_unref (context);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue