Add a method to deinitialize backends
This commit is contained in:
@@ -43,33 +43,34 @@
|
||||
static struct {
|
||||
const char *name;
|
||||
void (*Init)(BackendFuncs*);
|
||||
void (*Deinit)(void);
|
||||
BackendFuncs Funcs;
|
||||
} BackendList[] = {
|
||||
#ifdef HAVE_ALSA
|
||||
{ "alsa", alc_alsa_init, EmptyFuncs },
|
||||
{ "alsa", alc_alsa_init, alc_alsa_deinit, EmptyFuncs },
|
||||
#endif
|
||||
#ifdef HAVE_OSS
|
||||
{ "oss", alc_oss_init, EmptyFuncs },
|
||||
{ "oss", alc_oss_init, alc_oss_deinit, EmptyFuncs },
|
||||
#endif
|
||||
#ifdef HAVE_SOLARIS
|
||||
{ "solaris", alc_solaris_init, EmptyFuncs },
|
||||
{ "solaris", alc_solaris_init, alc_solaris_deinit, EmptyFuncs },
|
||||
#endif
|
||||
#ifdef HAVE_DSOUND
|
||||
{ "dsound", alcDSoundInit, EmptyFuncs },
|
||||
{ "dsound", alcDSoundInit, alcDSoundDeinit, EmptyFuncs },
|
||||
#endif
|
||||
#ifdef HAVE_WINMM
|
||||
{ "winmm", alcWinMMInit, EmptyFuncs },
|
||||
{ "winmm", alcWinMMInit, alcWinMMDeinit, EmptyFuncs },
|
||||
#endif
|
||||
#ifdef HAVE_PORTAUDIO
|
||||
{ "port", alc_pa_init, EmptyFuncs },
|
||||
{ "port", alc_pa_init, alc_pa_deinit, EmptyFuncs },
|
||||
#endif
|
||||
#ifdef HAVE_PULSEAUDIO
|
||||
{ "pulse", alc_pulse_init, EmptyFuncs },
|
||||
{ "pulse", alc_pulse_init, alc_pulse_deinit, EmptyFuncs },
|
||||
#endif
|
||||
|
||||
{ "wave", alc_wave_init, EmptyFuncs },
|
||||
{ "wave", alc_wave_init, alc_wave_deinit, EmptyFuncs },
|
||||
|
||||
{ NULL, NULL, EmptyFuncs }
|
||||
{ NULL, NULL, NULL, EmptyFuncs }
|
||||
};
|
||||
#undef EmptyFuncs
|
||||
|
||||
@@ -204,6 +205,8 @@ static ALboolean init_done = AL_FALSE;
|
||||
#ifdef _WIN32
|
||||
BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
|
||||
{
|
||||
int i;
|
||||
|
||||
(void)lpReserved;
|
||||
|
||||
// Perform actions based on the reason for calling.
|
||||
@@ -217,6 +220,10 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
|
||||
if(!init_done)
|
||||
break;
|
||||
ReleaseALC();
|
||||
|
||||
for(i = 0;BackendList[i].Deinit;i++)
|
||||
BackendList[i].Deinit();
|
||||
|
||||
FreeALConfig();
|
||||
ALTHUNK_EXIT();
|
||||
DeleteCriticalSection(&g_csMutex);
|
||||
@@ -230,10 +237,16 @@ static void my_deinit() __attribute__((destructor));
|
||||
static void my_deinit()
|
||||
{
|
||||
static ALenum once = AL_FALSE;
|
||||
int i;
|
||||
|
||||
if(once || !init_done) return;
|
||||
once = AL_TRUE;
|
||||
|
||||
ReleaseALC();
|
||||
|
||||
for(i = 0;BackendList[i].Deinit;i++)
|
||||
BackendList[i].Deinit();
|
||||
|
||||
FreeALConfig();
|
||||
ALTHUNK_EXIT();
|
||||
DeleteCriticalSection(&g_csMutex);
|
||||
|
||||
@@ -996,3 +996,7 @@ next_card:
|
||||
psnd_pcm_info_free(pcminfo);
|
||||
psnd_ctl_card_info_free(info);
|
||||
}
|
||||
|
||||
void alc_alsa_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -505,3 +505,7 @@ LOAD_FUNC(DirectSoundEnumerateA);
|
||||
if(FAILED(hr))
|
||||
AL_PRINT("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr);
|
||||
}
|
||||
|
||||
void alcDSoundDeinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -479,3 +479,7 @@ void alc_oss_init(BackendFuncs *func_list)
|
||||
|
||||
oss_device_capture = AppendCaptureDeviceList("OSS Capture");
|
||||
}
|
||||
|
||||
void alc_oss_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -251,3 +251,7 @@ void alc_pa_init(BackendFuncs *func_list)
|
||||
pa_device = AppendDeviceList("PortAudio Software");
|
||||
AppendAllDeviceList(pa_device);
|
||||
}
|
||||
|
||||
void alc_pa_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -701,4 +701,8 @@ LOAD_FUNC(pa_threaded_mainloop_lock);
|
||||
|
||||
pulse_capture_device = AppendCaptureDeviceList("PulseAudio Capture");
|
||||
} //}}}
|
||||
|
||||
void alc_pulse_deinit(void) //{{{
|
||||
{
|
||||
} //}}}
|
||||
//}}}
|
||||
|
||||
@@ -282,3 +282,7 @@ void alc_solaris_init(BackendFuncs *func_list)
|
||||
solaris_device = AppendDeviceList("Solaris Software");
|
||||
AppendAllDeviceList(solaris_device);
|
||||
}
|
||||
|
||||
void alc_solaris_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -370,3 +370,7 @@ void alc_wave_init(BackendFuncs *func_list)
|
||||
waveDevice = AppendDeviceList("Wave File Writer");
|
||||
AppendAllDeviceList(waveDevice);
|
||||
}
|
||||
|
||||
void alc_wave_deinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -440,3 +440,7 @@ void alcWinMMInit(BackendFuncs *FuncList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void alcWinMMDeinit()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -160,13 +160,21 @@ typedef struct {
|
||||
} BackendFuncs;
|
||||
|
||||
void alc_alsa_init(BackendFuncs *func_list);
|
||||
void alc_alsa_deinit(void);
|
||||
void alc_oss_init(BackendFuncs *func_list);
|
||||
void alc_oss_deinit(void);
|
||||
void alc_solaris_init(BackendFuncs *func_list);
|
||||
void alc_solaris_deinit(void);
|
||||
void alcDSoundInit(BackendFuncs *func_list);
|
||||
void alcDSoundDeinit(void);
|
||||
void alcWinMMInit(BackendFuncs *FuncList);
|
||||
void alcWinMMDeinit(void);
|
||||
void alc_pa_init(BackendFuncs *func_list);
|
||||
void alc_pa_deinit(void);
|
||||
void alc_wave_init(BackendFuncs *func_list);
|
||||
void alc_wave_deinit(void);
|
||||
void alc_pulse_init(BackendFuncs *func_list);
|
||||
void alc_pulse_deinit(void);
|
||||
|
||||
|
||||
struct ALCdevice_struct
|
||||
|
||||
Reference in New Issue
Block a user