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>
This commit is contained in:
Mengkejiergeli Ba 2024-09-24 23:43:07 -07:00 committed by GStreamer Marge Bot
parent be6eba3e9e
commit 5bf85229e5

View file

@ -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);