diff options
author | Mengkejiergeli Ba <mengkejiergeli.ba@intel.com> | 2024-09-24 23:43:07 -0700 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2024-09-29 01:07:39 +0000 |
commit | 5bf85229e5745a474101ba64b1b2fcbadcc4d608 (patch) | |
tree | c8c55329b732f30faecb4edab089c3bbfdc137c4 | |
parent | be6eba3e9e792dd5c64d3ffdbf444ebef70ac87a (diff) |
msdkenc: Guard the read of thiz->initialized with the modification of this value
This is to avoid wrongly read/write thiz->initialized when multi-thread
invoking encoder init function, it is possible when user apps deploy
multi-thread to dynamically change encoder's settings.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7578>
-rw-r--r-- | subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c index 38dec1fa8b..c32f6f6e57 100644 --- a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c +++ b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c @@ -500,11 +500,6 @@ gst_msdkenc_init_encoder (GstMsdkEnc * thiz) guint i; mfxExtVideoSignalInfo ext_vsi; - if (thiz->initialized) { - GST_DEBUG_OBJECT (thiz, "Already initialized"); - return TRUE; - } - if (!thiz->context) { GST_WARNING_OBJECT (thiz, "No MSDK Context"); return FALSE; @@ -522,6 +517,12 @@ gst_msdkenc_init_encoder (GstMsdkEnc * thiz) } GST_OBJECT_LOCK (thiz); + if (thiz->initialized) { + GST_DEBUG_OBJECT (thiz, "Already initialized"); + GST_OBJECT_UNLOCK (thiz); + return TRUE; + } + session = gst_msdk_context_get_session (thiz->context); thiz->codename = msdk_get_platform_codename (session); |