diff options
author | Chris Robinson <[email protected]> | 2008-07-17 18:45:21 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2008-07-17 18:45:21 -0700 |
commit | eba60c30c5e1676786b33be38c3845d850e96bcb (patch) | |
tree | 7726cfd300f3531c7afe38427d763271665a99cf /Alc/ALc.c | |
parent | e66bb09156bb69725f91b249a6cdf0082f7fad74 (diff) |
Don't force initialization when shutting down
Thanks to Michael Simms
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r-- | Alc/ALc.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -192,6 +192,8 @@ static ALCuint g_ulContextCount = 0; // Context Error static ALCenum g_eLastContextError = ALC_NO_ERROR; +static ALboolean init_done = AL_FALSE; + /////////////////////////////////////////////////////// @@ -210,6 +212,8 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) break; case DLL_PROCESS_DETACH: + if(!init_done) + break; ReleaseALC(); ReleaseALBuffers(); ReleaseALEffects(); @@ -227,7 +231,7 @@ static void my_deinit() __attribute__((destructor)); static void my_deinit() { static ALenum once = AL_FALSE; - if(once) return; + if(once || !init_done) return; once = AL_TRUE; ReleaseALC(); @@ -243,13 +247,12 @@ static void my_deinit() static void InitAL(void) { - static int done = 0; - if(!done) + if(!init_done) { int i; const char *devs, *str; - done = 1; + init_done = AL_TRUE; InitializeCriticalSection(&g_csMutex); ALTHUNK_INIT(); @@ -1294,8 +1297,6 @@ ALCAPI ALCboolean ALCAPIENTRY alcCloseDevice(ALCdevice *pDevice) ALCvoid ReleaseALC(ALCvoid) { - InitAL(); - #ifdef _DEBUG if(g_ulContextCount > 0) AL_PRINT("exit() %u device(s) and %u context(s) NOT deleted\n", g_ulDeviceCount, g_ulContextCount); |