d3d11window: Protect registration/creation of WIN32 window

Querying existing window class info and creation of window object
should be protected since they are not thread safe.
This commit is contained in:
Seungha Yang 2019-09-17 19:56:23 +09:00
parent 44cb5b4ff7
commit 5e8755cf07

View file

@ -29,6 +29,8 @@
#include <windows.h>
G_LOCK_DEFINE_STATIC (create_lock);
enum
{
PROP_0,
@ -411,6 +413,7 @@ _create_window (GstD3D11Window * self, GError ** error)
GST_LOG_OBJECT (self, "Attempting to create a win32 window");
G_LOCK (create_lock);
atom = GetClassInfoEx (hinstance, "GSTD3D11", &wc);
if (atom == 0) {
GST_LOG_OBJECT (self, "Register internal window class");
@ -428,6 +431,7 @@ _create_window (GstD3D11Window * self, GError ** error)
atom = RegisterClassEx (&wc);
if (atom == 0) {
G_UNLOCK (create_lock);
GST_ERROR_OBJECT (self, "Failed to register window class 0x%x",
(unsigned int) GetLastError ());
g_set_error (error, GST_RESOURCE_ERROR,
@ -450,6 +454,8 @@ _create_window (GstD3D11Window * self, GError ** error)
CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, (HWND) NULL, (HMENU) NULL, hinstance, self);
G_UNLOCK (create_lock);
if (!self->internal_win_id) {
GST_ERROR_OBJECT (self, "Failed to create d3d11 window");
g_set_error (error, GST_RESOURCE_ERROR,