diff options
Diffstat (limited to 'indra/media_plugins/winmmshim/winmm_shim.cpp')
-rw-r--r-- | indra/media_plugins/winmmshim/winmm_shim.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/indra/media_plugins/winmmshim/winmm_shim.cpp b/indra/media_plugins/winmmshim/winmm_shim.cpp index 9563a3b664..6ba95e565e 100644 --- a/indra/media_plugins/winmmshim/winmm_shim.cpp +++ b/indra/media_plugins/winmmshim/winmm_shim.cpp @@ -32,14 +32,21 @@ using std::wstring; static float sVolumeLevel = 1.f; static bool sMute = false; +static CRITICAL_SECTION sCriticalSection; BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { + InitializeCriticalSectionAndSpinCount(&sCriticalSection, 0x00000400); + return TRUE; +} + +void ll_winmm_shim_initialize(){ static bool initialized = false; // do this only once + EnterCriticalSection(&sCriticalSection); if (!initialized) { // bind to original winmm.dll TCHAR system_path[MAX_PATH]; @@ -54,13 +61,14 @@ BOOL APIENTRY DllMain( HMODULE hModule, { // we have a dll, let's get out pointers! initialized = true; init_function_pointers(winmm_handle); - return true; + ::OutputDebugStringA("WINMM_SHIM.DLL: real winmm.dll initialized successfully\n"); + return; } // failed to initialize real winmm.dll - return false; + ::OutputDebugStringA("WINMM_SHIM.DLL: Failed to initialize real winmm.dll\n"); } - return true; + LeaveCriticalSection(&sCriticalSection); } @@ -79,6 +87,7 @@ extern "C" MMRESULT WINAPI waveOutOpen( LPHWAVEOUT phwo, UINT uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen) { + ll_winmm_shim_initialize(); if (pwfx->wFormatTag != WAVE_FORMAT_PCM || (pwfx->wBitsPerSample != 8 && pwfx->wBitsPerSample != 16)) { // uncompressed 8 and 16 bit sound are the only types we support @@ -97,6 +106,7 @@ extern "C" MMRESULT WINAPI waveOutClose( HWAVEOUT hwo) { + ll_winmm_shim_initialize(); wave_out_map_t::iterator found_it = sWaveOuts.find(hwo); if (found_it != sWaveOuts.end()) { // forget what we know about this handle @@ -108,6 +118,7 @@ extern "C" MMRESULT WINAPI waveOutWrite( HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh) { + ll_winmm_shim_initialize(); MMRESULT result = MMSYSERR_NOERROR; if (sMute) |