mmdevapi: Initialize global driver data at DLL load time.

This commit is contained in:
Andrew Eikum 2011-05-02 08:21:29 -05:00 committed by Alexandre Julliard
parent cefcadcc38
commit 4a37f2f093
4 changed files with 35 additions and 19 deletions

View File

@ -72,7 +72,7 @@ static BOOL load_driver(const WCHAR *name)
}
#define LDFC(n) do { drvs.p##n = (void*)GetProcAddress(drvs.module, #n);\
if(!drvs.p##n) return FALSE; } while(0);
if(!drvs.p##n) { FreeLibrary(drvs.module); return FALSE; } } while(0);
LDFC(GetEndpointIDs);
LDFC(GetAudioEndpoint);
#undef LDFC

View File

@ -140,6 +140,18 @@ static inline ACImpl *impl_from_IAudioClock2(IAudioClock2 *iface)
return CONTAINING_RECORD(iface, ACImpl, IAudioClock2_iface);
}
BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved)
{
if(reason == DLL_PROCESS_ATTACH){
g_timer_q = CreateTimerQueue();
if(!g_timer_q)
return FALSE;
}
return TRUE;
}
HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, void ***keys,
UINT *num, UINT *def_index)
{
@ -175,12 +187,6 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(void *key, IMMDevice *dev,
TRACE("%p %p %d %p\n", key, dev, dataflow, out);
if(!g_timer_q){
g_timer_q = CreateTimerQueue();
if(!g_timer_q)
return E_FAIL;
}
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ACImpl));
if(!This)
return E_OUTOFMEMORY;

View File

@ -159,6 +159,17 @@ static inline ACImpl *impl_from_IAudioClock2(IAudioClock2 *iface)
return CONTAINING_RECORD(iface, ACImpl, IAudioClock2_iface);
}
BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved)
{
if(reason == DLL_PROCESS_ATTACH){
g_timer_q = CreateTimerQueue();
if(!g_timer_q)
return FALSE;
}
return TRUE;
}
HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
AudioDeviceID ***keys, UINT *num, UINT *def_index)
{
@ -344,12 +355,6 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(AudioDeviceID *adevid, IMMDevice *dev,
TRACE("%p %d %p\n", dev, dataflow, out);
if(!g_timer_q){
g_timer_q = CreateTimerQueue();
if(!g_timer_q)
return E_FAIL;
}
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ACImpl));
if(!This)
return E_OUTOFMEMORY;

View File

@ -151,6 +151,17 @@ static inline ACImpl *impl_from_IAudioClock2(IAudioClock2 *iface)
return CONTAINING_RECORD(iface, ACImpl, IAudioClock2_iface);
}
BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved)
{
if(reason == DLL_PROCESS_ATTACH){
g_timer_q = CreateTimerQueue();
if(!g_timer_q)
return FALSE;
}
return TRUE;
}
HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, void ***keys,
UINT *num, UINT *def_index)
{
@ -268,12 +279,6 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(char *devnode, IMMDevice *dev,
TRACE("%s %p %d %p\n", devnode, dev, dataflow, out);
if(!g_timer_q){
g_timer_q = CreateTimerQueue();
if(!g_timer_q)
return E_UNEXPECTED;
}
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ACImpl));
if(!This)
return E_OUTOFMEMORY;