Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/winegstreamer/gst_private.h | 2 +- dlls/winegstreamer/gstdemux.c | 2 +- dlls/winegstreamer/gsttffilter.c | 8 ++-- dlls/winegstreamer/main.c | 74 ++++++++++++++++++-------------- 4 files changed, 47 insertions(+), 39 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index a1f201c6f4..85659c4bd9 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 0d9ab8ded7..200913f249 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 d2d36b694f..7a1d4930fc 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 b9cddcbc3e..a1b1648d9d 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; - - 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"); - - 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(); - } + 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; + + TRACE("initializing\n"); + + 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) \
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/winegstreamer/main.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c index a1b1648d9d..18154fb423 100644 --- a/dlls/winegstreamer/main.c +++ b/dlls/winegstreamer/main.c @@ -262,7 +262,8 @@ static BOOL CALLBACK init_gstreamer_proc(INIT_ONCE *once, void *param, void **ct BOOL *status = param; char argv0[] = "wine"; char argv1[] = "--gst-disable-registry-fork"; - char **argv = HeapAlloc(GetProcessHeap(), 0, sizeof(char *)*3); + char *args[3]; + char **argv = args; int argc = 2; GError *err = NULL;
@@ -272,12 +273,8 @@ static BOOL CALLBACK init_gstreamer_proc(INIT_ONCE *once, void *param, void **ct 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); - } - if (*status) { + if (*status) + { HINSTANCE newhandle; /* Unloading glib is a bad idea.. it installs atexit handlers, * so never unload the dll after loading */ @@ -288,6 +285,11 @@ static BOOL CALLBACK init_gstreamer_proc(INIT_ONCE *once, void *param, void **ct
start_dispatch_thread(); } + else if (err) + { + ERR("Failed to initialize gstreamer: %s\n", debugstr_a(err->message)); + g_error_free(err); + }
return TRUE; }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/winegstreamer/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c index 18154fb423..fdc8966037 100644 --- a/dlls/winegstreamer/main.c +++ b/dlls/winegstreamer/main.c @@ -267,7 +267,7 @@ static BOOL CALLBACK init_gstreamer_proc(INIT_ONCE *once, void *param, void **ct int argc = 2; GError *err = NULL;
- TRACE("initializing\n"); + TRACE("Initializing...\n");
argv[0] = argv0; argv[1] = argv1; @@ -276,6 +276,10 @@ static BOOL CALLBACK init_gstreamer_proc(INIT_ONCE *once, void *param, void **ct if (*status) { HINSTANCE newhandle; + + TRACE("Inititialized, 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,
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/winegstreamer/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c index fdc8966037..2a5dbd1455 100644 --- a/dlls/winegstreamer/main.c +++ b/dlls/winegstreamer/main.c @@ -275,17 +275,17 @@ static BOOL CALLBACK init_gstreamer_proc(INIT_ONCE *once, void *param, void **ct *status = gst_init_check(&argc, &argv, &err); if (*status) { - HINSTANCE newhandle; + HINSTANCE handle;
TRACE("Inititialized, 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, - (LPCWSTR)hInst, &newhandle); - if (!newhandle) - ERR("Could not pin module %p\n", hInst); + GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN, + (LPCWSTR)hInst, &handle); + if (!handle) + ERR("Failed to pin module %p.\n", hInst);
start_dispatch_thread(); }