diff options
author | Chris Robinson <[email protected]> | 2012-03-08 17:42:16 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-03-08 17:42:16 -0800 |
commit | 1a4a0abd1a1fd9a20345db54efef6587bec67197 (patch) | |
tree | 36be0e37fb89ca39a25f6d64fa6c484c7d03c931 /Alc | |
parent | dddacc25a53e12b036b3599fd045b9eab942d5af (diff) |
Pin the DLL for Windows
The mmdevapi backend does not react well to being unloaded dynamically. It has
a message-handling thread running in the background which can't quit before
DllMain is called with DLL_PROCESS_DETACH, at which point it's too late to
safely message and wait for it shutddown, thus it can continue running after
the DLL is unloaded from memory.
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -418,15 +418,17 @@ static void alc_deinit_safe(void); UIntMap TlsDestructor; #ifndef AL_LIBTYPE_STATIC -BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) +BOOL APIENTRY DllMain(HINSTANCE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) { ALsizei i; - (void)hModule; // Perform actions based on the reason for calling. switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: + /* Pin the DLL so we won't get unloaded until the process terminates */ + GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, + (WCHAR*)hModule, &hModule); InitUIntMap(&TlsDestructor, ~0); alc_init(); break; |