winegstreamer: Use init-once API to initialize library.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c46bdc9473
commit
f5908390a7
|
@ -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_YUV2ARGB_create(IUnknown *pUnkOuter, HRESULT *phr);
|
||||||
IUnknown * CALLBACK Gstreamer_Splitter_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 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;
|
GstFlowReturn request_buffer(GstPad *pad, guint64 ofs, guint size, GstCaps *caps, GstBuffer **buf) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -1230,7 +1230,7 @@ IUnknown * CALLBACK Gstreamer_Splitter_create(IUnknown *pUnkOuter, HRESULT *phr)
|
||||||
|
|
||||||
TRACE("%p %p\n", pUnkOuter, phr);
|
TRACE("%p %p\n", pUnkOuter, phr);
|
||||||
|
|
||||||
if (!Gstreamer_init())
|
if (!init_gstreamer())
|
||||||
{
|
{
|
||||||
*phr = E_FAIL;
|
*phr = E_FAIL;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -626,7 +626,7 @@ IUnknown * CALLBACK Gstreamer_Mp3_create(IUnknown *punkouter, HRESULT *phr)
|
||||||
|
|
||||||
TRACE("%p %p\n", punkouter, phr);
|
TRACE("%p %p\n", punkouter, phr);
|
||||||
|
|
||||||
if (!Gstreamer_init())
|
if (!init_gstreamer())
|
||||||
{
|
{
|
||||||
*phr = E_FAIL;
|
*phr = E_FAIL;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -769,7 +769,7 @@ IUnknown * CALLBACK Gstreamer_YUV2RGB_create(IUnknown *punkouter, HRESULT *phr)
|
||||||
|
|
||||||
TRACE("%p %p\n", punkouter, phr);
|
TRACE("%p %p\n", punkouter, phr);
|
||||||
|
|
||||||
if (!Gstreamer_init())
|
if (!init_gstreamer())
|
||||||
{
|
{
|
||||||
*phr = E_FAIL;
|
*phr = E_FAIL;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -871,7 +871,7 @@ IUnknown * CALLBACK Gstreamer_YUV2ARGB_create(IUnknown *punkouter, HRESULT *phr)
|
||||||
|
|
||||||
TRACE("%p %p\n", punkouter, phr);
|
TRACE("%p %p\n", punkouter, phr);
|
||||||
|
|
||||||
if (!Gstreamer_init())
|
if (!init_gstreamer())
|
||||||
{
|
{
|
||||||
*phr = E_FAIL;
|
*phr = E_FAIL;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1004,7 +1004,7 @@ IUnknown * CALLBACK Gstreamer_AudioConvert_create(IUnknown *punkouter, HRESULT *
|
||||||
|
|
||||||
TRACE("%p %p\n", punkouter, phr);
|
TRACE("%p %p\n", punkouter, phr);
|
||||||
|
|
||||||
if (!Gstreamer_init())
|
if (!init_gstreamer())
|
||||||
{
|
{
|
||||||
*phr = E_FAIL;
|
*phr = E_FAIL;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -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));
|
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) {
|
TRACE("initializing\n");
|
||||||
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[0] = argv0;
|
argv[2] = NULL;
|
||||||
argv[1] = argv1;
|
*status = gst_init_check(&argc, &argv, &err);
|
||||||
argv[2] = NULL;
|
HeapFree(GetProcessHeap(), 0, argv);
|
||||||
inited = gst_init_check(&argc, &argv, &err);
|
if (err) {
|
||||||
HeapFree(GetProcessHeap(), 0, argv);
|
ERR("Failed to initialize gstreamer: %s\n", err->message);
|
||||||
if (err) {
|
g_error_free(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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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) \
|
#define INF_SET_ID(id) \
|
||||||
|
|
Loading…
Reference in New Issue