winegstreamer: Move GStreamer library initialization to __wine_init_unix_lib().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-02-11 16:18:57 -06:00 committed by Alexandre Julliard
parent dbd927f4ad
commit 10dde32dc6
2 changed files with 27 additions and 36 deletions

View File

@ -174,41 +174,16 @@ HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out)
static BOOL CALLBACK init_gstreamer_proc(INIT_ONCE *once, void *param, void **ctx)
{
BOOL *status = param;
char argv0[] = "wine";
char argv1[] = "--gst-disable-registry-fork";
char *args[3];
char **argv = args;
int argc = 2;
GError *err = NULL;
HINSTANCE handle;
TRACE("Initializing...\n");
/* Unloading glib is a bad idea.. it installs atexit handlers,
* so never unload the dll after loading */
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN,
(LPCWSTR)winegstreamer_instance, &handle);
if (!handle)
ERR("Failed to pin module %p.\n", winegstreamer_instance);
argv[0] = argv0;
argv[1] = argv1;
argv[2] = NULL;
*status = gst_init_check(&argc, &argv, &err);
if (*status)
{
HINSTANCE handle;
TRACE("Initialized, version %s. Built with %d.%d.%d.\n", gst_version_string(),
GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO);
/* Unloading glib is a bad idea.. it installs atexit handlers,
* so never unload the dll after loading */
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN,
(LPCWSTR)winegstreamer_instance, &handle);
if (!handle)
ERR("Failed to pin module %p.\n", winegstreamer_instance);
start_dispatch_thread();
}
else if (err)
{
ERR("Failed to initialize gstreamer: %s\n", debugstr_a(err->message));
g_error_free(err);
}
start_dispatch_thread();
return TRUE;
}
@ -216,11 +191,10 @@ static BOOL CALLBACK init_gstreamer_proc(INIT_ONCE *once, void *param, void **ct
BOOL init_gstreamer(void)
{
static INIT_ONCE once = INIT_ONCE_STATIC_INIT;
static BOOL status;
InitOnceExecuteOnce(&once, init_gstreamer_proc, &status, NULL);
InitOnceExecuteOnce(&once, init_gstreamer_proc, NULL, NULL);
return status;
return TRUE;
}
static const REGPINTYPES reg_audio_mt = {&MEDIATYPE_Audio, &GUID_NULL};

View File

@ -1023,7 +1023,24 @@ NTSTATUS CDECL __wine_init_unix_lib(HMODULE module, DWORD reason, const void *pt
{
if (reason == DLL_PROCESS_ATTACH)
{
char arg0[] = "wine";
char arg1[] = "--gst-disable-registry-fork";
char *args[] = {arg0, arg1, NULL};
int argc = ARRAY_SIZE(args) - 1;
char **argv = args;
GError *err;
if (!gst_init_check(&argc, &argv, &err))
{
ERR("Failed to initialize GStreamer: %s\n", debugstr_a(err->message));
g_error_free(err);
return STATUS_UNSUCCESSFUL;
}
TRACE("GStreamer library version %s; wine built with %d.%d.%d.\n",
gst_version_string(), GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO);
GST_DEBUG_CATEGORY_INIT(wine, "WINE", GST_DEBUG_FG_RED, "Wine GStreamer support");
*(const struct unix_funcs **)ptr_out = &funcs;
}
return STATUS_SUCCESS;