d3d11: Use std::call_once()

g_once_init_enter() always takes global mutex for non-GCC build.
Use C++ once call implementation

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2843>
This commit is contained in:
Seungha Yang 2022-08-06 00:03:43 +09:00
parent b7e662f400
commit 74f56632c3
12 changed files with 117 additions and 157 deletions

View file

@ -145,6 +145,8 @@ gboolean gst_d3d11_color_primaries_matrix_unorm (const GstVideoColorPrima
G_END_DECLS G_END_DECLS
#ifdef __cplusplus #ifdef __cplusplus
#include <mutex>
class GstD3D11DeviceLockGuard class GstD3D11DeviceLockGuard
{ {
public: public:
@ -162,6 +164,13 @@ public:
GstD3D11DeviceLockGuard& operator=(const GstD3D11DeviceLockGuard&) = delete; GstD3D11DeviceLockGuard& operator=(const GstD3D11DeviceLockGuard&) = delete;
private: private:
GstD3D11Device *device_; GstD3D11Device *device_;
}; };
#endif
#define GST_D3D11_CALL_ONCE_BEGIN \
static std::once_flag __once_flag; \
std::call_once (__once_flag, [&]()
#define GST_D3D11_CALL_ONCE_END )
#endif /* __cplusplus */

View file

@ -24,6 +24,7 @@
#include "gstd3d11compile.h" #include "gstd3d11compile.h"
#include "gstd3d11device.h" #include "gstd3d11device.h"
#include "gstd3d11utils.h" #include "gstd3d11utils.h"
#include "gstd3d11_private.h"
#include <gmodule.h> #include <gmodule.h>
#include <wrl.h> #include <wrl.h>
#include <string.h> #include <string.h>
@ -37,18 +38,13 @@ using namespace Microsoft::WRL;
static GstDebugCategory * static GstDebugCategory *
ensure_debug_category (void) ensure_debug_category (void)
{ {
static gsize cat_gonce = 0; static GstDebugCategory *cat = nullptr;
if (g_once_init_enter (&cat_gonce)) { GST_D3D11_CALL_ONCE_BEGIN {
gsize cat_done; cat = _gst_debug_category_new ("d3d11compile", 0, "d3d11compile");
} GST_D3D11_CALL_ONCE_END;
cat_done = (gsize) _gst_debug_category_new ("d3d11compile", 0, return cat;
"d3d11compile");
g_once_init_leave (&cat_gonce, cat_done);
}
return (GstDebugCategory *) cat_gonce;
} }
#else #else
#define ensure_debug_category() /* NOOP */ #define ensure_debug_category() /* NOOP */
@ -67,9 +63,7 @@ static pD3DCompile GstD3DCompileFunc = nullptr;
gboolean gboolean
gst_d3d11_compile_init (void) gst_d3d11_compile_init (void)
{ {
static gsize init_once = 0; GST_D3D11_CALL_ONCE_BEGIN {
if (g_once_init_enter (&init_once)) {
#if GST_D3D11_WINAPI_ONLY_APP #if GST_D3D11_WINAPI_ONLY_APP
/* Assuming that d3d compiler library is available */ /* Assuming that d3d compiler library is available */
GstD3DCompileFunc = D3DCompile; GstD3DCompileFunc = D3DCompile;
@ -103,9 +97,8 @@ gst_d3d11_compile_init (void)
if (!GstD3DCompileFunc) if (!GstD3DCompileFunc)
GST_WARNING ("D3D11 compiler library is unavailable"); GST_WARNING ("D3D11 compiler library is unavailable");
#endif #endif
g_once_init_leave (&init_once, 1);
} }
GST_D3D11_CALL_ONCE_END;
if (!GstD3DCompileFunc) if (!GstD3DCompileFunc)
return FALSE; return FALSE;

View file

@ -42,7 +42,7 @@ DEFINE_ENUM_FLAG_OPERATORS (GstD3D11ConverterBackend);
GType GType
gst_d3d11_converter_backend_get_type (void) gst_d3d11_converter_backend_get_type (void)
{ {
static gsize type = 0; static GType type = 0;
static const GFlagsValue values[] = { static const GFlagsValue values[] = {
{GST_D3D11_CONVERTER_BACKEND_SHADER, "GST_D3D11_CONVERTER_BACKEND_SHADER", {GST_D3D11_CONVERTER_BACKEND_SHADER, "GST_D3D11_CONVERTER_BACKEND_SHADER",
"shader"}, "shader"},
@ -51,12 +51,11 @@ gst_d3d11_converter_backend_get_type (void)
{0, nullptr, nullptr} {0, nullptr, nullptr}
}; };
if (g_once_init_enter (&type)) { GST_D3D11_CALL_ONCE_BEGIN {
GType tmp = g_flags_register_static ("GstD3D11ConverterBackend", values); type = g_flags_register_static ("GstD3D11ConverterBackend", values);
g_once_init_leave (&type, tmp); } GST_D3D11_CALL_ONCE_END;
}
return (GType) type; return type;
} }
/* *INDENT-OFF* */ /* *INDENT-OFF* */

View file

@ -54,7 +54,6 @@ using namespace Microsoft::WRL;
#if HAVE_D3D11SDKLAYERS_H #if HAVE_D3D11SDKLAYERS_H
#include <d3d11sdklayers.h> #include <d3d11sdklayers.h>
static GModule *d3d11_debug_module = NULL;
/* mingw header does not define D3D11_RLDO_IGNORE_INTERNAL /* mingw header does not define D3D11_RLDO_IGNORE_INTERNAL
* D3D11_RLDO_SUMMARY = 0x1, * D3D11_RLDO_SUMMARY = 0x1,
@ -68,8 +67,7 @@ static GModule *d3d11_debug_module = NULL;
#include <dxgidebug.h> #include <dxgidebug.h>
typedef HRESULT (WINAPI * DXGIGetDebugInterface_t) (REFIID riid, typedef HRESULT (WINAPI * DXGIGetDebugInterface_t) (REFIID riid,
void **ppDebug); void **ppDebug);
static GModule *dxgi_debug_module = NULL; static DXGIGetDebugInterface_t GstDXGIGetDebugInterface = nullptr;
static DXGIGetDebugInterface_t GstDXGIGetDebugInterface = NULL;
#endif #endif
@ -134,17 +132,14 @@ struct _GstD3D11DevicePrivate
static void static void
debug_init_once (void) debug_init_once (void)
{ {
static gsize init_once = 0; GST_D3D11_CALL_ONCE_BEGIN {
if (g_once_init_enter (&init_once)) {
GST_DEBUG_CATEGORY_INIT (gst_d3d11_device_debug, GST_DEBUG_CATEGORY_INIT (gst_d3d11_device_debug,
"d3d11device", 0, "d3d11 device object"); "d3d11device", 0, "d3d11 device object");
#if defined(HAVE_D3D11SDKLAYERS_H) || defined(HAVE_DXGIDEBUG_H) #if defined(HAVE_D3D11SDKLAYERS_H) || defined(HAVE_DXGIDEBUG_H)
GST_DEBUG_CATEGORY_INIT (gst_d3d11_debug_layer_debug, GST_DEBUG_CATEGORY_INIT (gst_d3d11_debug_layer_debug,
"d3d11debuglayer", 0, "native d3d11 and dxgi debug"); "d3d11debuglayer", 0, "native d3d11 and dxgi debug");
#endif #endif
g_once_init_leave (&init_once, 1); } GST_D3D11_CALL_ONCE_END;
}
} }
#define gst_d3d11_device_parent_class parent_class #define gst_d3d11_device_parent_class parent_class
@ -160,26 +155,24 @@ static void gst_d3d11_device_finalize (GObject * object);
static gboolean static gboolean
gst_d3d11_device_enable_d3d11_debug (void) gst_d3d11_device_enable_d3d11_debug (void)
{ {
static gsize _init = 0; static GModule *d3d11_debug_module = nullptr;
/* If all below libraries are unavailable, d3d11 device would fail with /* If all below libraries are unavailable, d3d11 device would fail with
* D3D11_CREATE_DEVICE_DEBUG flag */ * D3D11_CREATE_DEVICE_DEBUG flag */
if (g_once_init_enter (&_init)) { static const gchar *sdk_dll_names[] = {
d3d11_debug_module = "d3d11sdklayers.dll",
g_module_open ("d3d11sdklayers.dll", G_MODULE_BIND_LAZY); "d3d11_1sdklayers.dll",
"d3d11_2sdklayers.dll",
"d3d11_3sdklayers.dll",
};
if (!d3d11_debug_module) GST_D3D11_CALL_ONCE_BEGIN {
d3d11_debug_module = for (guint i = 0; i < G_N_ELEMENTS (sdk_dll_names); i++) {
g_module_open ("d3d11_1sdklayers.dll", G_MODULE_BIND_LAZY); d3d11_debug_module = g_module_open (sdk_dll_names[i], G_MODULE_BIND_LAZY);
if (!d3d11_debug_module) if (d3d11_debug_module)
d3d11_debug_module = return;
g_module_open ("d3d11_2sdklayers.dll", G_MODULE_BIND_LAZY); }
if (!d3d11_debug_module)
d3d11_debug_module =
g_module_open ("d3d11_3sdklayers.dll", G_MODULE_BIND_LAZY);
g_once_init_leave (&_init, 1);
} }
GST_D3D11_CALL_ONCE_END;
if (d3d11_debug_module) if (d3d11_debug_module)
return TRUE; return TRUE;
@ -265,27 +258,24 @@ gst_d3d11_device_d3d11_debug (GstD3D11Device * device,
static gboolean static gboolean
gst_d3d11_device_enable_dxgi_debug (void) gst_d3d11_device_enable_dxgi_debug (void)
{ {
static gsize _init = 0; static GModule *dxgi_debug_module = nullptr;
gboolean ret = FALSE;
/* If all below libraries are unavailable, d3d11 device would fail with GST_D3D11_CALL_ONCE_BEGIN {
* D3D11_CREATE_DEVICE_DEBUG flag */
if (g_once_init_enter (&_init)) {
#if (!GST_D3D11_WINAPI_ONLY_APP) #if (!GST_D3D11_WINAPI_ONLY_APP)
dxgi_debug_module = g_module_open ("dxgidebug.dll", G_MODULE_BIND_LAZY); dxgi_debug_module = g_module_open ("dxgidebug.dll", G_MODULE_BIND_LAZY);
if (dxgi_debug_module) if (dxgi_debug_module)
g_module_symbol (dxgi_debug_module, g_module_symbol (dxgi_debug_module,
"DXGIGetDebugInterface", (gpointer *) & GstDXGIGetDebugInterface); "DXGIGetDebugInterface", (gpointer *) & GstDXGIGetDebugInterface);
if (GstDXGIGetDebugInterface)
ret = TRUE;
#else #else
ret = TRUE; GstDXGIGetDebugInterface = DXGIGetDebugInterface1;
#endif #endif
g_once_init_leave (&_init, 1); } GST_D3D11_CALL_ONCE_END;
}
return ret; if (!GstDXGIGetDebugInterface)
return FALSE;
return TRUE;
} }
static HRESULT static HRESULT
@ -429,19 +419,16 @@ gst_d3d11_device_init (GstD3D11Device * self)
static gboolean static gboolean
is_windows_8_or_greater (void) is_windows_8_or_greater (void)
{ {
static gsize version_once = 0;
static gboolean ret = FALSE; static gboolean ret = FALSE;
if (g_once_init_enter (&version_once)) { GST_D3D11_CALL_ONCE_BEGIN {
#if (!GST_D3D11_WINAPI_ONLY_APP) #if (!GST_D3D11_WINAPI_ONLY_APP)
if (IsWindows8OrGreater ()) if (IsWindows8OrGreater ())
ret = TRUE; ret = TRUE;
#else #else
ret = TRUE; ret = TRUE;
#endif #endif
} GST_D3D11_CALL_ONCE_END;
g_once_init_leave (&version_once, 1);
}
return ret; return ret;
} }

View file

@ -34,18 +34,13 @@
static GstDebugCategory * static GstDebugCategory *
ensure_debug_category (void) ensure_debug_category (void)
{ {
static gsize cat_gonce = 0; static GstDebugCategory *cat = nullptr;
if (g_once_init_enter (&cat_gonce)) { GST_D3D11_CALL_ONCE_BEGIN {
gsize cat_done; cat = _gst_debug_category_new ("d3d11format", 0, "d3d11 specific formats");
} GST_D3D11_CALL_ONCE_END;
cat_done = (gsize) _gst_debug_category_new ("d3d11format", 0, return cat;
"d3d11 specific formats");
g_once_init_leave (&cat_gonce, cat_done);
}
return (GstDebugCategory *) cat_gonce;
} }
#else #else
#define ensure_debug_category() /* NOOP */ #define ensure_debug_category() /* NOOP */
@ -54,7 +49,7 @@ ensure_debug_category (void)
GType GType
gst_d3d11_format_support_get_type (void) gst_d3d11_format_support_get_type (void)
{ {
static gsize support_type = 0; static GType support_type = 0;
static const GFlagsValue support_values[] = { static const GFlagsValue support_values[] = {
{D3D11_FORMAT_SUPPORT_BUFFER, "BUFFER", "buffer"}, {D3D11_FORMAT_SUPPORT_BUFFER, "BUFFER", "buffer"},
{D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER, "IA_VERTEX_BUFFER", {D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER, "IA_VERTEX_BUFFER",
@ -103,13 +98,12 @@ gst_d3d11_format_support_get_type (void)
{0, nullptr, nullptr} {0, nullptr, nullptr}
}; };
if (g_once_init_enter (&support_type)) { GST_D3D11_CALL_ONCE_BEGIN {
GType tmp = g_flags_register_static ("GstD3D11FormatSupport", support_type = g_flags_register_static ("GstD3D11FormatSupport",
support_values); support_values);
g_once_init_leave (&support_type, tmp); } GST_D3D11_CALL_ONCE_END;
}
return (GType) support_type; return support_type;
} }
/** /**

View file

@ -36,7 +36,7 @@ static GstAllocator *_d3d11_memory_allocator;
GType GType
gst_d3d11_allocation_flags_get_type (void) gst_d3d11_allocation_flags_get_type (void)
{ {
static gsize type = 0; static GType type = 0;
static const GFlagsValue values[] = { static const GFlagsValue values[] = {
{GST_D3D11_ALLOCATION_FLAG_DEFAULT, "GST_D3D11_ALLOCATION_FLAG_DEFAULT", {GST_D3D11_ALLOCATION_FLAG_DEFAULT, "GST_D3D11_ALLOCATION_FLAG_DEFAULT",
"default"}, "default"},
@ -45,18 +45,17 @@ gst_d3d11_allocation_flags_get_type (void)
{0, nullptr, nullptr} {0, nullptr, nullptr}
}; };
if (g_once_init_enter (&type)) { GST_D3D11_CALL_ONCE_BEGIN {
GType tmp = g_flags_register_static ("GstD3D11AllocationFlags", values); type = g_flags_register_static ("GstD3D11AllocationFlags", values);
g_once_init_leave (&type, tmp); } GST_D3D11_CALL_ONCE_END;
}
return (GType) type; return type;
} }
GType GType
gst_d3d11_memory_transfer_get_type (void) gst_d3d11_memory_transfer_get_type (void)
{ {
static gsize type = 0; static GType type = 0;
static const GFlagsValue values[] = { static const GFlagsValue values[] = {
{GST_D3D11_MEMORY_TRANSFER_NEED_DOWNLOAD, {GST_D3D11_MEMORY_TRANSFER_NEED_DOWNLOAD,
"GST_D3D11_MEMORY_TRANSFER_NEED_DOWNLOAD", "need-download"}, "GST_D3D11_MEMORY_TRANSFER_NEED_DOWNLOAD", "need-download"},
@ -65,18 +64,17 @@ gst_d3d11_memory_transfer_get_type (void)
{0, nullptr, nullptr} {0, nullptr, nullptr}
}; };
if (g_once_init_enter (&type)) { GST_D3D11_CALL_ONCE_BEGIN {
GType tmp = g_flags_register_static ("GstD3D11MemoryTransfer", values); type = g_flags_register_static ("GstD3D11MemoryTransfer", values);
g_once_init_leave (&type, tmp); } GST_D3D11_CALL_ONCE_END;
}
return (GType) type; return type;
} }
GType GType
gst_d3d11_memory_native_type_get_type (void) gst_d3d11_memory_native_type_get_type (void)
{ {
static gsize type = 0; static GType type = 0;
static const GEnumValue values[] = { static const GEnumValue values[] = {
{GST_D3D11_MEMORY_NATIVE_TYPE_INVALID, {GST_D3D11_MEMORY_NATIVE_TYPE_INVALID,
"GST_D3D11_MEMORY_NATIVE_TYPE_INVALID", "invalid"}, "GST_D3D11_MEMORY_NATIVE_TYPE_INVALID", "invalid"},
@ -87,12 +85,11 @@ gst_d3d11_memory_native_type_get_type (void)
{0, nullptr, nullptr} {0, nullptr, nullptr}
}; };
if (g_once_init_enter (&type)) { GST_D3D11_CALL_ONCE_BEGIN {
GType tmp = g_enum_register_static ("GstD3D11MemoryNativeType", values); type = g_enum_register_static ("GstD3D11MemoryNativeType", values);
g_once_init_leave (&type, tmp); } GST_D3D11_CALL_ONCE_END;
}
return (GType) type; return type;
} }
/* GstD3D11AllocationParams */ /* GstD3D11AllocationParams */
@ -650,10 +647,7 @@ gst_d3d11_memory_get_native_type (GstD3D11Memory * mem)
void void
gst_d3d11_memory_init_once (void) gst_d3d11_memory_init_once (void)
{ {
static gsize _init = 0; GST_D3D11_CALL_ONCE_BEGIN {
if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (gst_d3d11_allocator_debug, "d3d11allocator", 0, GST_DEBUG_CATEGORY_INIT (gst_d3d11_allocator_debug, "d3d11allocator", 0,
"Direct3D11 Texture Allocator"); "Direct3D11 Texture Allocator");
@ -662,8 +656,7 @@ gst_d3d11_memory_init_once (void)
gst_object_ref_sink (_d3d11_memory_allocator); gst_object_ref_sink (_d3d11_memory_allocator);
gst_allocator_register (GST_D3D11_MEMORY_NAME, _d3d11_memory_allocator); gst_allocator_register (GST_D3D11_MEMORY_NAME, _d3d11_memory_allocator);
g_once_init_leave (&_init, 1); } GST_D3D11_CALL_ONCE_END;
}
} }
/** /**

View file

@ -39,18 +39,13 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_CONTEXT);
static GstDebugCategory * static GstDebugCategory *
ensure_debug_category (void) ensure_debug_category (void)
{ {
static gsize cat_gonce = 0; static GstDebugCategory *cat = nullptr;
if (g_once_init_enter (&cat_gonce)) { GST_D3D11_CALL_ONCE_BEGIN {
gsize cat_done; cat = _gst_debug_category_new ("d3d11utils", 0, "d3d11 utility functions");
} GST_D3D11_CALL_ONCE_END;
cat_done = (gsize) _gst_debug_category_new ("d3d11utils", 0, return cat;
"d3d11 utility functions");
g_once_init_leave (&cat_gonce, cat_done);
}
return (GstDebugCategory *) cat_gonce;
} }
#else #else
#define ensure_debug_category() /* NOOP */ #define ensure_debug_category() /* NOOP */
@ -59,12 +54,9 @@ ensure_debug_category (void)
static void static void
_init_context_debug (void) _init_context_debug (void)
{ {
static gsize _init = 0; GST_D3D11_CALL_ONCE_BEGIN {
if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_GET (GST_CAT_CONTEXT, "GST_CONTEXT"); GST_DEBUG_CATEGORY_GET (GST_CAT_CONTEXT, "GST_CONTEXT");
g_once_init_leave (&_init, 1); } GST_D3D11_CALL_ONCE_END;
}
} }
/** /**

View file

@ -387,14 +387,13 @@ gst_d3d11_decoder_is_configured (GstD3D11Decoder * decoder)
static GQuark static GQuark
gst_d3d11_decoder_view_id_quark (void) gst_d3d11_decoder_view_id_quark (void)
{ {
static gsize id_quark = 0; static GQuark id_quark = 0;
if (g_once_init_enter (&id_quark)) { GST_D3D11_CALL_ONCE_BEGIN {
GQuark quark = g_quark_from_string ("GstD3D11DecoderViewId"); id_quark = g_quark_from_string ("GstD3D11DecoderViewId");
g_once_init_leave (&id_quark, quark); } GST_D3D11_CALL_ONCE_END;
}
return (GQuark) id_quark; return id_quark;
} }
static gboolean static gboolean

View file

@ -106,9 +106,9 @@ typedef enum
static GType static GType
gst_d3d11_deinterlace_method_type (void) gst_d3d11_deinterlace_method_type (void)
{ {
static gsize method_type = 0; static GType method_type = 0;
if (g_once_init_enter (&method_type)) { GST_D3D11_CALL_ONCE_BEGIN {
static const GFlagsValue method_types[] = { static const GFlagsValue method_types[] = {
{GST_D3D11_DEINTERLACE_METHOD_BLEND, {GST_D3D11_DEINTERLACE_METHOD_BLEND,
"Blend: Blending top/bottom field pictures into one frame. " "Blend: Blending top/bottom field pictures into one frame. "
@ -123,14 +123,14 @@ gst_d3d11_deinterlace_method_type (void)
{GST_D3D11_DEINTERLACE_METHOD_MOTION_COMPENSATION, {GST_D3D11_DEINTERLACE_METHOD_MOTION_COMPENSATION,
"Motion Compensation: Recreating missing lines by using motion vector. " "Motion Compensation: Recreating missing lines by using motion vector. "
"Framerate will be doubled (e,g, 60i -> 60p)", "mocomp"}, "Framerate will be doubled (e,g, 60i -> 60p)", "mocomp"},
{0, NULL, NULL}, {0, nullptr, nullptr},
}; };
GType tmp = g_flags_register_static ("GstD3D11DeinterlaceMethod",
method_types);
g_once_init_leave (&method_type, tmp);
}
return (GType) method_type; method_type = g_flags_register_static ("GstD3D11DeinterlaceMethod",
method_types);
} GST_D3D11_CALL_ONCE_END;
return method_type;
} }
typedef struct typedef struct

View file

@ -36,9 +36,7 @@ static guint _gst_d3d11_texture_max_dimension = 16384;
void void
gst_d3d11_plugin_utils_init (D3D_FEATURE_LEVEL feature_level) gst_d3d11_plugin_utils_init (D3D_FEATURE_LEVEL feature_level)
{ {
static gsize _init_once = 0; GST_D3D11_CALL_ONCE_BEGIN {
if (g_once_init_enter (&_init_once)) {
/* https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-devices-downlevel-intro */ /* https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-devices-downlevel-intro */
if (feature_level >= D3D_FEATURE_LEVEL_11_0) if (feature_level >= D3D_FEATURE_LEVEL_11_0)
_gst_d3d11_texture_max_dimension = 16384; _gst_d3d11_texture_max_dimension = 16384;
@ -46,9 +44,8 @@ gst_d3d11_plugin_utils_init (D3D_FEATURE_LEVEL feature_level)
_gst_d3d11_texture_max_dimension = 8192; _gst_d3d11_texture_max_dimension = 8192;
else else
_gst_d3d11_texture_max_dimension = 4096; _gst_d3d11_texture_max_dimension = 4096;
g_once_init_leave (&_init_once, 1);
} }
GST_D3D11_CALL_ONCE_END;
} }
GstCaps * GstCaps *
@ -75,19 +72,16 @@ gst_d3d11_get_updated_template_caps (GstStaticCaps * template_caps)
gboolean gboolean
gst_d3d11_is_windows_8_or_greater (void) gst_d3d11_is_windows_8_or_greater (void)
{ {
static gsize version_once = 0;
static gboolean ret = FALSE; static gboolean ret = FALSE;
if (g_once_init_enter (&version_once)) { GST_D3D11_CALL_ONCE_BEGIN {
#if (!GST_D3D11_WINAPI_ONLY_APP) #if (!GST_D3D11_WINAPI_ONLY_APP)
if (IsWindows8OrGreater ()) if (IsWindows8OrGreater ())
ret = TRUE; ret = TRUE;
#else #else
ret = TRUE; ret = TRUE;
#endif #endif
} GST_D3D11_CALL_ONCE_END;
g_once_init_leave (&version_once, 1);
}
return ret; return ret;
} }

View file

@ -72,9 +72,9 @@ typedef enum
static GType static GType
gst_d3d11_test_src_pattern_get_type (void) gst_d3d11_test_src_pattern_get_type (void)
{ {
static gsize pattern_type = 0; static GType pattern_type = 0;
if (g_once_init_enter (&pattern_type)) { GST_D3D11_CALL_ONCE_BEGIN {
static const GEnumValue pattern_types[] = { static const GEnumValue pattern_types[] = {
{GST_D3D11_TEST_SRC_SMPTE, "SMPTE 100% color bars", "smpte"}, {GST_D3D11_TEST_SRC_SMPTE, "SMPTE 100% color bars", "smpte"},
{GST_D3D11_TEST_SRC_SNOW, "Random (television snow)", "snow"}, {GST_D3D11_TEST_SRC_SNOW, "Random (television snow)", "snow"},
@ -89,12 +89,12 @@ gst_d3d11_test_src_pattern_get_type (void)
{GST_D3D11_TEST_SRC_CHECKERS8, "Checkers 8px", "checkers-8"}, {GST_D3D11_TEST_SRC_CHECKERS8, "Checkers 8px", "checkers-8"},
{0, nullptr, nullptr}, {0, nullptr, nullptr},
}; };
GType tmp = g_enum_register_static ("GstD3D11TestSrcPattern",
pattern_types);
g_once_init_leave (&pattern_type, tmp);
}
return (GType) pattern_type; pattern_type = g_enum_register_static ("GstD3D11TestSrcPattern",
pattern_types);
} GST_D3D11_CALL_ONCE_END;
return pattern_type;
} }
typedef struct typedef struct

View file

@ -74,9 +74,9 @@ static guint d3d11_window_signals[SIGNAL_LAST] = { 0, };
GType GType
gst_d3d11_window_fullscreen_toggle_mode_type (void) gst_d3d11_window_fullscreen_toggle_mode_type (void)
{ {
static gsize mode_type = 0; static GType mode_type = 0;
if (g_once_init_enter (&mode_type)) { GST_D3D11_CALL_ONCE_BEGIN {
static const GFlagsValue mode_types[] = { static const GFlagsValue mode_types[] = {
{GST_D3D11_WINDOW_FULLSCREEN_TOGGLE_MODE_NONE, {GST_D3D11_WINDOW_FULLSCREEN_TOGGLE_MODE_NONE,
"GST_D3D11_WINDOW_FULLSCREEN_TOGGLE_MODE_NONE", "none"}, "GST_D3D11_WINDOW_FULLSCREEN_TOGGLE_MODE_NONE", "none"},
@ -84,14 +84,14 @@ gst_d3d11_window_fullscreen_toggle_mode_type (void)
"GST_D3D11_WINDOW_FULLSCREEN_TOGGLE_MODE_ALT_ENTER", "alt-enter"}, "GST_D3D11_WINDOW_FULLSCREEN_TOGGLE_MODE_ALT_ENTER", "alt-enter"},
{GST_D3D11_WINDOW_FULLSCREEN_TOGGLE_MODE_PROPERTY, {GST_D3D11_WINDOW_FULLSCREEN_TOGGLE_MODE_PROPERTY,
"GST_D3D11_WINDOW_FULLSCREEN_TOGGLE_MODE_PROPERTY", "property"}, "GST_D3D11_WINDOW_FULLSCREEN_TOGGLE_MODE_PROPERTY", "property"},
{0, NULL, NULL}, {0, nullptr, nullptr},
}; };
GType tmp = g_flags_register_static ("GstD3D11WindowFullscreenToggleMode",
mode_types);
g_once_init_leave (&mode_type, tmp);
}
return (GType) mode_type; mode_type = g_flags_register_static ("GstD3D11WindowFullscreenToggleMode",
mode_types);
} GST_D3D11_CALL_ONCE_END;
return mode_type;
} }
#define gst_d3d11_window_parent_class parent_class #define gst_d3d11_window_parent_class parent_class