BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) { (void)lpReserved; // Perform actions based on the reason for calling. switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls(hModule); break; case DLL_PROCESS_DETACH: if(!init_done) break; ReleaseALC(); ReleaseALBuffers(); ReleaseALEffects(); ReleaseALFilters(); FreeALConfig(); ALTHUNK_EXIT(); DeleteCriticalSection(&g_csMutex); break; } return TRUE; }
static void my_deinit() { static ALenum once = AL_FALSE; if(once || !init_done) return; once = AL_TRUE; ReleaseALC(); ReleaseALBuffers(); ReleaseALEffects(); ReleaseALFilters(); FreeALConfig(); ALTHUNK_EXIT(); DeleteCriticalSection(&g_csMutex); }
/* alcCloseDevice Close the specified Device */ ALCAPI ALCboolean ALCAPIENTRY alcCloseDevice(ALCdevice *pDevice) { ALCboolean bReturn = ALC_FALSE; ALCdevice **list; if(IsDevice(pDevice) && !pDevice->IsCaptureDevice) { SuspendContext(NULL); list = &g_pDeviceList; while(*list != pDevice) list = &(*list)->next; *list = (*list)->next; g_ulDeviceCount--; ProcessContext(NULL); if(pDevice->NumContexts > 0) { #ifdef _DEBUG AL_PRINT("alcCloseDevice(): destroying %u Context(s)\n", pDevice->NumContexts); #endif while(pDevice->NumContexts > 0) alcDestroyContext(pDevice->Contexts[0]); } ALCdevice_ClosePlayback(pDevice); if(pDevice->BufferCount > 0) { #ifdef _DEBUG AL_PRINT("alcCloseDevice(): deleting %d Buffer(s)\n", pDevice->BufferCount); #endif ReleaseALBuffers(pDevice); } if(pDevice->EffectCount > 0) { #ifdef _DEBUG AL_PRINT("alcCloseDevice(): deleting %d Effect(s)\n", pDevice->EffectCount); #endif ReleaseALEffects(pDevice); } if(pDevice->FilterCount > 0) { #ifdef _DEBUG AL_PRINT("alcCloseDevice(): deleting %d Filter(s)\n", pDevice->FilterCount); #endif ReleaseALFilters(pDevice); } if(pDevice->DatabufferCount > 0) { #ifdef _DEBUG AL_PRINT("alcCloseDevice(): deleting %d Databuffer(s)\n", pDevice->DatabufferCount); #endif ReleaseALDatabuffers(pDevice); } free(pDevice->Bs2b); pDevice->Bs2b = NULL; free(pDevice->szDeviceName); pDevice->szDeviceName = NULL; free(pDevice->Contexts); pDevice->Contexts = NULL; //Release device structure memset(pDevice, 0, sizeof(ALCdevice)); free(pDevice); bReturn = ALC_TRUE; } else alcSetError(ALC_INVALID_DEVICE); return bReturn; }