aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/portaudio.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-04-14 02:16:42 -0700
committerChris Robinson <[email protected]>2019-04-14 04:05:07 -0700
commit61f7e7716c6743b16051d8c3ea4cea3b27d0197b (patch)
tree61b486a606cb2e3bac66b274fed8c75dbfad1d0a /Alc/backends/portaudio.cpp
parent7f526780994f44793fe56a426c01fcebfb64a75a (diff)
Remove the backend factory deinit method
It was never actually called anywhere, and there's no safe place where it can be called. It's probably better to let the individual backends worry about cleaning themselves up anyway.
Diffstat (limited to 'Alc/backends/portaudio.cpp')
-rw-r--r--Alc/backends/portaudio.cpp119
1 files changed, 51 insertions, 68 deletions
diff --git a/Alc/backends/portaudio.cpp b/Alc/backends/portaudio.cpp
index 5cfee278..07f2b2d5 100644
--- a/Alc/backends/portaudio.cpp
+++ b/Alc/backends/portaudio.cpp
@@ -69,66 +69,6 @@ MAKE_FUNC(Pa_GetStreamInfo);
#endif
#endif
-bool pa_load()
-{
- PaError err;
-
-#ifdef HAVE_DYNLOAD
- if(!pa_handle)
- {
-#ifdef _WIN32
-# define PALIB "portaudio.dll"
-#elif defined(__APPLE__) && defined(__MACH__)
-# define PALIB "libportaudio.2.dylib"
-#elif defined(__OpenBSD__)
-# define PALIB "libportaudio.so"
-#else
-# define PALIB "libportaudio.so.2"
-#endif
-
- pa_handle = LoadLib(PALIB);
- if(!pa_handle)
- return false;
-
-#define LOAD_FUNC(f) do { \
- p##f = reinterpret_cast<decltype(p##f)>(GetSymbol(pa_handle, #f)); \
- if(p##f == nullptr) \
- { \
- CloseLib(pa_handle); \
- pa_handle = nullptr; \
- return false; \
- } \
-} while(0)
- LOAD_FUNC(Pa_Initialize);
- LOAD_FUNC(Pa_Terminate);
- LOAD_FUNC(Pa_GetErrorText);
- LOAD_FUNC(Pa_StartStream);
- LOAD_FUNC(Pa_StopStream);
- LOAD_FUNC(Pa_OpenStream);
- LOAD_FUNC(Pa_CloseStream);
- LOAD_FUNC(Pa_GetDefaultOutputDevice);
- LOAD_FUNC(Pa_GetDefaultInputDevice);
- LOAD_FUNC(Pa_GetStreamInfo);
-#undef LOAD_FUNC
-
- if((err=Pa_Initialize()) != paNoError)
- {
- ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err));
- CloseLib(pa_handle);
- pa_handle = nullptr;
- return false;
- }
- }
-#else
- if((err=Pa_Initialize()) != paNoError)
- {
- ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err));
- return false;
- }
-#endif
- return true;
-}
-
struct PortPlayback final : public BackendBase {
PortPlayback(ALCdevice *device) noexcept : BackendBase{device} { }
@@ -436,20 +376,63 @@ ALCenum PortCapture::captureSamples(ALCvoid *buffer, ALCuint samples)
bool PortBackendFactory::init()
-{ return pa_load(); }
-
-void PortBackendFactory::deinit()
{
+ PaError err;
+
#ifdef HAVE_DYNLOAD
- if(pa_handle)
+ if(!pa_handle)
{
- Pa_Terminate();
- CloseLib(pa_handle);
- pa_handle = nullptr;
+#ifdef _WIN32
+# define PALIB "portaudio.dll"
+#elif defined(__APPLE__) && defined(__MACH__)
+# define PALIB "libportaudio.2.dylib"
+#elif defined(__OpenBSD__)
+# define PALIB "libportaudio.so"
+#else
+# define PALIB "libportaudio.so.2"
+#endif
+
+ pa_handle = LoadLib(PALIB);
+ if(!pa_handle)
+ return false;
+
+#define LOAD_FUNC(f) do { \
+ p##f = reinterpret_cast<decltype(p##f)>(GetSymbol(pa_handle, #f)); \
+ if(p##f == nullptr) \
+ { \
+ CloseLib(pa_handle); \
+ pa_handle = nullptr; \
+ return false; \
+ } \
+} while(0)
+ LOAD_FUNC(Pa_Initialize);
+ LOAD_FUNC(Pa_Terminate);
+ LOAD_FUNC(Pa_GetErrorText);
+ LOAD_FUNC(Pa_StartStream);
+ LOAD_FUNC(Pa_StopStream);
+ LOAD_FUNC(Pa_OpenStream);
+ LOAD_FUNC(Pa_CloseStream);
+ LOAD_FUNC(Pa_GetDefaultOutputDevice);
+ LOAD_FUNC(Pa_GetDefaultInputDevice);
+ LOAD_FUNC(Pa_GetStreamInfo);
+#undef LOAD_FUNC
+
+ if((err=Pa_Initialize()) != paNoError)
+ {
+ ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err));
+ CloseLib(pa_handle);
+ pa_handle = nullptr;
+ return false;
+ }
}
#else
- Pa_Terminate();
+ if((err=Pa_Initialize()) != paNoError)
+ {
+ ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err));
+ return false;
+ }
#endif
+ return true;
}
bool PortBackendFactory::querySupport(BackendType type)