aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/portaudio.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-05-28 02:22:17 -0700
committerChris Robinson <[email protected]>2010-05-28 02:22:17 -0700
commit96cf5b728269915e24fdfde09eb4b9e3091a0980 (patch)
tree7a3f9ef73c594ef566378306979071a8c36e7887 /Alc/portaudio.c
parentf89c9f7ea4cf1cb05dedb61355873c51e80fddef (diff)
Avoid constantly loading and unloading PortAudio
It seems this triggers a bug in the lib, causing a crash. It may not be a bad idea to remove dynamic unloading/reloading all through-out.
Diffstat (limited to 'Alc/portaudio.c')
-rw-r--r--Alc/portaudio.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/Alc/portaudio.c b/Alc/portaudio.c
index e54abec7..c75c2a53 100644
--- a/Alc/portaudio.c
+++ b/Alc/portaudio.c
@@ -48,12 +48,11 @@ MAKE_FUNC(Pa_GetStreamInfo);
static const ALCchar pa_device[] = "PortAudio Software";
static const ALCchar pa_capture[] = "PortAudio Capture";
-static volatile ALuint load_count;
void *pa_load(void)
{
- if(load_count == 0)
+ if(!pa_handle)
{
PaError err;
@@ -123,23 +122,11 @@ LOAD_FUNC(Pa_GetStreamInfo);
return NULL;
}
}
- ++load_count;
-
return pa_handle;
}
void pa_unload(void)
{
- if(load_count == 0 || --load_count > 0)
- return;
-
- pPa_Terminate();
-#ifdef _WIN32
- FreeLibrary(pa_handle);
-#elif defined(HAVE_DLFCN_H)
- dlclose(pa_handle);
-#endif
- pa_handle = NULL;
}
@@ -438,6 +425,16 @@ void alc_pa_init(BackendFuncs *func_list)
void alc_pa_deinit(void)
{
+ if(pa_handle)
+ {
+ pPa_Terminate();
+#ifdef _WIN32
+ FreeLibrary(pa_handle);
+#elif defined(HAVE_DLFCN_H)
+ dlclose(pa_handle);
+#endif
+ pa_handle = NULL;
+ }
}
void alc_pa_probe(int type)