From: Seungha Yang Date: Thu, 7 Jul 2022 16:30:13 +0000 (+0900) Subject: d3d11: Serialize ensure_element_data() call X-Git-Tag: 1.22.0~1301 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f3d51ef2350ca405437e35dc3c2833844364754c;p=platform%2Fupstream%2Fgstreamer.git d3d11: Serialize ensure_element_data() call It can be called any time from random thread. Thus, multiple device objects can be created for the same physical device if the call is not serialized, that's not a scenario we expect. Part-of: --- diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11utils.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11utils.cpp index f6f7728..f5fe77e 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11utils.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11utils.cpp @@ -27,6 +27,11 @@ #include #include +#include + +/* *INDENT-OFF* */ +static std::recursive_mutex _context_lock; +/* *INDENT-ON* */ GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT); #ifndef GST_DISABLE_GST_DEBUG @@ -380,6 +385,9 @@ gst_d3d11_ensure_element_data (GstElement * element, gint adapter, GstD3D11Device ** device) { guint target_adapter = 0; + /* *INDENT-OFF* */ + std::lock_guard lk (_context_lock); + /* *INDENT-ON* */ g_return_val_if_fail (element != NULL, FALSE); g_return_val_if_fail (device != NULL, FALSE); @@ -447,6 +455,10 @@ gboolean gst_d3d11_ensure_element_data_for_adapter_luid (GstElement * element, gint64 adapter_luid, GstD3D11Device ** device) { + /* *INDENT-OFF* */ + std::lock_guard lk (_context_lock); + /* *INDENT-ON* */ + g_return_val_if_fail (element != NULL, FALSE); g_return_val_if_fail (device != NULL, FALSE);