diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index a1f201c6f4e..85659c4bd9b 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -43,7 +43,7 @@ IUnknown * CALLBACK Gstreamer_YUV2RGB_create(IUnknown *pUnkOuter, HRESULT *phr); IUnknown * CALLBACK Gstreamer_YUV2ARGB_create(IUnknown *pUnkOuter, HRESULT *phr); IUnknown * CALLBACK Gstreamer_Splitter_create(IUnknown *pUnkOuter, HRESULT *phr); -DWORD Gstreamer_init(void); +BOOL init_gstreamer(void) DECLSPEC_HIDDEN; GstFlowReturn got_data(GstPad *pad, GstObject *parent, GstBuffer *buf) DECLSPEC_HIDDEN; GstFlowReturn request_buffer(GstPad *pad, guint64 ofs, guint size, GstCaps *caps, GstBuffer **buf) DECLSPEC_HIDDEN; diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index 0d9ab8ded74..200913f2491 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -1230,7 +1230,7 @@ IUnknown * CALLBACK Gstreamer_Splitter_create(IUnknown *pUnkOuter, HRESULT *phr) TRACE("%p %p\n", pUnkOuter, phr); - if (!Gstreamer_init()) + if (!init_gstreamer()) { *phr = E_FAIL; return NULL; diff --git a/dlls/winegstreamer/gsttffilter.c b/dlls/winegstreamer/gsttffilter.c index d2d36b694f4..7a1d4930fc0 100644 --- a/dlls/winegstreamer/gsttffilter.c +++ b/dlls/winegstreamer/gsttffilter.c @@ -626,7 +626,7 @@ IUnknown * CALLBACK Gstreamer_Mp3_create(IUnknown *punkouter, HRESULT *phr) TRACE("%p %p\n", punkouter, phr); - if (!Gstreamer_init()) + if (!init_gstreamer()) { *phr = E_FAIL; return NULL; @@ -769,7 +769,7 @@ IUnknown * CALLBACK Gstreamer_YUV2RGB_create(IUnknown *punkouter, HRESULT *phr) TRACE("%p %p\n", punkouter, phr); - if (!Gstreamer_init()) + if (!init_gstreamer()) { *phr = E_FAIL; return NULL; @@ -871,7 +871,7 @@ IUnknown * CALLBACK Gstreamer_YUV2ARGB_create(IUnknown *punkouter, HRESULT *phr) TRACE("%p %p\n", punkouter, phr); - if (!Gstreamer_init()) + if (!init_gstreamer()) { *phr = E_FAIL; return NULL; @@ -1004,7 +1004,7 @@ IUnknown * CALLBACK Gstreamer_AudioConvert_create(IUnknown *punkouter, HRESULT * TRACE("%p %p\n", punkouter, phr); - if (!Gstreamer_init()) + if (!init_gstreamer()) { *phr = E_FAIL; return NULL; diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c index b9cddcbc3ed..a1b1648d9d9 100644 --- a/dlls/winegstreamer/main.c +++ b/dlls/winegstreamer/main.c @@ -257,41 +257,49 @@ void dump_AM_MEDIA_TYPE(const AM_MEDIA_TYPE * pmt) TRACE("\t%s\n\t%s\n\t...\n\t%s\n", debugstr_guid(&pmt->majortype), debugstr_guid(&pmt->subtype), debugstr_guid(&pmt->formattype)); } -DWORD Gstreamer_init(void) +static BOOL CALLBACK init_gstreamer_proc(INIT_ONCE *once, void *param, void **ctx) { - static int inited; + BOOL *status = param; + char argv0[] = "wine"; + char argv1[] = "--gst-disable-registry-fork"; + char **argv = HeapAlloc(GetProcessHeap(), 0, sizeof(char *)*3); + int argc = 2; + GError *err = NULL; - if (!inited) { - char argv0[] = "wine"; - char argv1[] = "--gst-disable-registry-fork"; - char **argv = HeapAlloc(GetProcessHeap(), 0, sizeof(char *)*3); - int argc = 2; - GError *err = NULL; + TRACE("initializing\n"); - TRACE("initializing\n"); - - argv[0] = argv0; - argv[1] = argv1; - argv[2] = NULL; - inited = gst_init_check(&argc, &argv, &err); - HeapFree(GetProcessHeap(), 0, argv); - if (err) { - ERR("Failed to initialize gstreamer: %s\n", err->message); - g_error_free(err); - } - if (inited) { - HINSTANCE newhandle; - /* 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, - (LPCWSTR)hInst, &newhandle); - if (!newhandle) - ERR("Could not pin module %p\n", hInst); - - start_dispatch_thread(); - } + argv[0] = argv0; + argv[1] = argv1; + argv[2] = NULL; + *status = gst_init_check(&argc, &argv, &err); + HeapFree(GetProcessHeap(), 0, argv); + if (err) { + ERR("Failed to initialize gstreamer: %s\n", err->message); + g_error_free(err); } - return inited; + if (*status) { + HINSTANCE newhandle; + /* 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, + (LPCWSTR)hInst, &newhandle); + if (!newhandle) + ERR("Could not pin module %p\n", hInst); + + start_dispatch_thread(); + } + + return TRUE; +} + +BOOL init_gstreamer(void) +{ + static INIT_ONCE once = INIT_ONCE_STATIC_INIT; + static BOOL status; + + InitOnceExecuteOnce(&once, init_gstreamer_proc, &status, NULL); + + return status; } #define INF_SET_ID(id) \