Avoid closing devices and deinitializing backends on process exit
They are still closed and deinitialized when the DLL is simply being detached (via FreeLibrary), however.
This commit is contained in:
parent
b5092a6212
commit
3e2bc847d8
41
Alc/ALc.c
41
Alc/ALc.c
@ -436,19 +436,18 @@ ALdouble ZScale = 1.0;
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
// ALC Related helper functions
|
// ALC Related helper functions
|
||||||
static void ReleaseALC(void);
|
static void ReleaseALC(ALCboolean doclose);
|
||||||
|
|
||||||
static void alc_initconfig(void);
|
static void alc_initconfig(void);
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
static void alc_init(void);
|
static void alc_init(void);
|
||||||
static void alc_deinit(void);
|
static void alc_deinit(void);
|
||||||
|
static void alc_deinit_safe(void);
|
||||||
|
|
||||||
#ifndef AL_LIBTYPE_STATIC
|
#ifndef AL_LIBTYPE_STATIC
|
||||||
BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
|
BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
(void)lpReserved;
|
|
||||||
|
|
||||||
// Perform actions based on the reason for calling.
|
// Perform actions based on the reason for calling.
|
||||||
switch(ul_reason_for_call)
|
switch(ul_reason_for_call)
|
||||||
{
|
{
|
||||||
@ -458,7 +457,10 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
|
if(!lpReserved)
|
||||||
alc_deinit();
|
alc_deinit();
|
||||||
|
else
|
||||||
|
alc_deinit_safe();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -511,15 +513,9 @@ static void alc_init(void)
|
|||||||
ALTHUNK_INIT();
|
ALTHUNK_INIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void alc_deinit(void)
|
static void alc_deinit_safe(void)
|
||||||
{
|
{
|
||||||
int i;
|
ReleaseALC(ALC_FALSE);
|
||||||
|
|
||||||
ReleaseALC();
|
|
||||||
|
|
||||||
for(i = 0;BackendList[i].Deinit;i++)
|
|
||||||
BackendList[i].Deinit();
|
|
||||||
BackendLoopback.Deinit();
|
|
||||||
|
|
||||||
FreeALConfig();
|
FreeALConfig();
|
||||||
ALTHUNK_EXIT();
|
ALTHUNK_EXIT();
|
||||||
@ -531,6 +527,19 @@ static void alc_deinit(void)
|
|||||||
LogFile = NULL;
|
LogFile = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void alc_deinit(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
ReleaseALC(ALC_TRUE);
|
||||||
|
|
||||||
|
for(i = 0;BackendList[i].Deinit;i++)
|
||||||
|
BackendList[i].Deinit();
|
||||||
|
BackendLoopback.Deinit();
|
||||||
|
|
||||||
|
alc_deinit_safe();
|
||||||
|
}
|
||||||
|
|
||||||
static void alc_initconfig(void)
|
static void alc_initconfig(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -2938,7 +2947,7 @@ ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ReleaseALC(void)
|
static void ReleaseALC(ALCboolean doclose)
|
||||||
{
|
{
|
||||||
free(alcDeviceList); alcDeviceList = NULL;
|
free(alcDeviceList); alcDeviceList = NULL;
|
||||||
alcDeviceListSize = 0;
|
alcDeviceListSize = 0;
|
||||||
@ -2954,6 +2963,8 @@ static void ReleaseALC(void)
|
|||||||
free(alcCaptureDefaultDeviceSpecifier);
|
free(alcCaptureDefaultDeviceSpecifier);
|
||||||
alcCaptureDefaultDeviceSpecifier = NULL;
|
alcCaptureDefaultDeviceSpecifier = NULL;
|
||||||
|
|
||||||
|
if(doclose)
|
||||||
|
{
|
||||||
if(g_ulDeviceCount > 0)
|
if(g_ulDeviceCount > 0)
|
||||||
WARN("ReleaseALC(): closing %u Device%s\n", g_ulDeviceCount, (g_ulDeviceCount>1)?"s":"");
|
WARN("ReleaseALC(): closing %u Device%s\n", g_ulDeviceCount, (g_ulDeviceCount>1)?"s":"");
|
||||||
|
|
||||||
@ -2964,6 +2975,12 @@ static void ReleaseALC(void)
|
|||||||
else
|
else
|
||||||
alcCloseDevice(g_pDeviceList);
|
alcCloseDevice(g_pDeviceList);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(g_ulDeviceCount > 0)
|
||||||
|
WARN("ReleaseALC(): %u Device%s not closed\n", g_ulDeviceCount, (g_ulDeviceCount>1)?"s":"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user