winmm: Give a name to the critical sections, make them static and delete them when unloading the dll.

This commit is contained in:
Francois Gouget 2011-11-15 14:40:30 +01:00 committed by Alexandre Julliard
parent b6117b6869
commit 814c854fd2
3 changed files with 16 additions and 7 deletions

View File

@ -140,6 +140,13 @@ static UINT g_inmmdevices_count;
static IMMDeviceEnumerator *g_devenum;
static CRITICAL_SECTION g_devthread_lock;
static CRITICAL_SECTION_DEBUG g_devthread_lock_debug =
{
0, 0, &g_devthread_lock,
{ &g_devthread_lock_debug.ProcessLocksList, &g_devthread_lock_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": g_devthread_lock") }
};
static CRITICAL_SECTION g_devthread_lock = { &g_devthread_lock_debug, -1, 0, 0, 0, 0 };
static HANDLE g_devices_thread;
static HWND g_devices_hwnd;
@ -167,10 +174,10 @@ static LRESULT WOD_Close(HWAVEOUT hwave);
static LRESULT WID_Open(WINMM_OpenInfo *info);
static LRESULT WID_Close(HWAVEIN hwave);
BOOL WINMM_InitWaveform(void)
void WINMM_DeleteWaveform(void)
{
InitializeCriticalSection(&g_devthread_lock);
return TRUE;
/* FIXME: Free g_(in,out)_mmdevices? */
DeleteCriticalSection(&g_devthread_lock);
}
static inline HWAVE WINMM_MakeHWAVE(UINT mmdevice, BOOL is_out, UINT device)
@ -193,6 +200,8 @@ static void WINMM_InitDevice(WINMM_Device *device,
WINMM_MMDevice *parent, HWAVE hwave)
{
InitializeCriticalSection(&device->lock);
device->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": WINMM_Device.lock");
device->handle = hwave;
device->parent = parent;
}
@ -449,6 +458,7 @@ static HRESULT WINMM_InitMMDevice(EDataFlow flow, IMMDevice *device,
CoCreateGuid(&dev->session);
InitializeCriticalSection(&dev->lock);
dev->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": WINMM_Device.lock");
return S_OK;
}

View File

@ -152,7 +152,7 @@ void TIME_MMTimeStop(void) DECLSPEC_HIDDEN;
MMRESULT WINMM_CheckCallback(DWORD_PTR dwCallback, DWORD fdwOpen, BOOL mixer) DECLSPEC_HIDDEN;
BOOL WINMM_InitWaveform(void) DECLSPEC_HIDDEN;
void WINMM_DeleteWaveform(void) DECLSPEC_HIDDEN;
/* Global variables */
extern CRITICAL_SECTION WINMM_cs DECLSPEC_HIDDEN;

View File

@ -79,7 +79,7 @@ static BOOL WINMM_CreateIData(HINSTANCE hInstDLL)
{
hWinMM32Instance = hInstDLL;
psLastEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
return WINMM_InitWaveform();
return TRUE;
}
/**************************************************************************
@ -89,8 +89,7 @@ static void WINMM_DeleteIData(void)
{
TIME_MMTimeStop();
/* FIXME: should also free content and resources allocated
* inside WINMM_IData */
WINMM_DeleteWaveform();
CloseHandle(psLastEvent);
DeleteCriticalSection(&WINMM_cs);
}