aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
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
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')
-rw-r--r--Alc/backends/alsa.cpp80
-rw-r--r--Alc/backends/alsa.h1
-rw-r--r--Alc/backends/base.h1
-rw-r--r--Alc/backends/coreaudio.h1
-rw-r--r--Alc/backends/dsound.cpp66
-rw-r--r--Alc/backends/dsound.h1
-rw-r--r--Alc/backends/jack.cpp9
-rw-r--r--Alc/backends/jack.h1
-rw-r--r--Alc/backends/loopback.h1
-rw-r--r--Alc/backends/null.h1
-rw-r--r--Alc/backends/opensl.h1
-rw-r--r--Alc/backends/oss.cpp6
-rw-r--r--Alc/backends/oss.h1
-rw-r--r--Alc/backends/portaudio.cpp119
-rw-r--r--Alc/backends/portaudio.h1
-rw-r--r--Alc/backends/pulseaudio.cpp278
-rw-r--r--Alc/backends/pulseaudio.h1
-rw-r--r--Alc/backends/qsa.cpp13
-rw-r--r--Alc/backends/qsa.h1
-rw-r--r--Alc/backends/sdl2.cpp9
-rw-r--r--Alc/backends/sdl2.h1
-rw-r--r--Alc/backends/sndio.h1
-rw-r--r--Alc/backends/solaris.h1
-rw-r--r--Alc/backends/wasapi.cpp9
-rw-r--r--Alc/backends/wasapi.h1
-rw-r--r--Alc/backends/wave.h1
-rw-r--r--Alc/backends/winmm.cpp6
-rw-r--r--Alc/backends/winmm.h1
28 files changed, 239 insertions, 374 deletions
diff --git a/Alc/backends/alsa.cpp b/Alc/backends/alsa.cpp
index 1a287565..9f036a01 100644
--- a/Alc/backends/alsa.cpp
+++ b/Alc/backends/alsa.cpp
@@ -204,46 +204,6 @@ ALSA_FUNCS(MAKE_FUNC);
#endif
-bool alsa_load()
-{
- bool error{false};
-
-#ifdef HAVE_DYNLOAD
- if(!alsa_handle)
- {
- std::string missing_funcs;
-
- alsa_handle = LoadLib("libasound.so.2");
- if(!alsa_handle)
- {
- WARN("Failed to load %s\n", "libasound.so.2");
- return ALC_FALSE;
- }
-
- error = ALC_FALSE;
-#define LOAD_FUNC(f) do { \
- p##f = reinterpret_cast<decltype(p##f)>(GetSymbol(alsa_handle, #f)); \
- if(p##f == nullptr) { \
- error = true; \
- missing_funcs += "\n" #f; \
- } \
-} while(0)
- ALSA_FUNCS(LOAD_FUNC);
-#undef LOAD_FUNC
-
- if(error)
- {
- WARN("Missing expected functions:%s\n", missing_funcs.c_str());
- CloseLib(alsa_handle);
- alsa_handle = nullptr;
- }
- }
-#endif
-
- return !error;
-}
-
-
struct DevMap {
std::string name;
std::string device_name;
@@ -1249,18 +1209,42 @@ ClockLatency AlsaCapture::getClockLatency()
bool AlsaBackendFactory::init()
-{ return !!alsa_load(); }
-
-void AlsaBackendFactory::deinit()
{
- PlaybackDevices.clear();
- CaptureDevices.clear();
+ bool error{false};
#ifdef HAVE_DYNLOAD
- if(alsa_handle)
- CloseLib(alsa_handle);
- alsa_handle = nullptr;
+ if(!alsa_handle)
+ {
+ std::string missing_funcs;
+
+ alsa_handle = LoadLib("libasound.so.2");
+ if(!alsa_handle)
+ {
+ WARN("Failed to load %s\n", "libasound.so.2");
+ return ALC_FALSE;
+ }
+
+ error = ALC_FALSE;
+#define LOAD_FUNC(f) do { \
+ p##f = reinterpret_cast<decltype(p##f)>(GetSymbol(alsa_handle, #f)); \
+ if(p##f == nullptr) { \
+ error = true; \
+ missing_funcs += "\n" #f; \
+ } \
+} while(0)
+ ALSA_FUNCS(LOAD_FUNC);
+#undef LOAD_FUNC
+
+ if(error)
+ {
+ WARN("Missing expected functions:%s\n", missing_funcs.c_str());
+ CloseLib(alsa_handle);
+ alsa_handle = nullptr;
+ }
+ }
#endif
+
+ return !error;
}
bool AlsaBackendFactory::querySupport(BackendType type)
diff --git a/Alc/backends/alsa.h b/Alc/backends/alsa.h
index 5730ba9a..fb9de006 100644
--- a/Alc/backends/alsa.h
+++ b/Alc/backends/alsa.h
@@ -6,7 +6,6 @@
struct AlsaBackendFactory final : public BackendFactory {
public:
bool init() override;
- void deinit() override;
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/base.h b/Alc/backends/base.h
index 2498bcd2..7a9232a6 100644
--- a/Alc/backends/base.h
+++ b/Alc/backends/base.h
@@ -67,7 +67,6 @@ enum class DevProbe {
struct BackendFactory {
virtual bool init() = 0;
- virtual void deinit() { }
virtual bool querySupport(BackendType type) = 0;
diff --git a/Alc/backends/coreaudio.h b/Alc/backends/coreaudio.h
index fd6dd4fc..37b9ebe5 100644
--- a/Alc/backends/coreaudio.h
+++ b/Alc/backends/coreaudio.h
@@ -6,7 +6,6 @@
struct CoreAudioBackendFactory final : public BackendFactory {
public:
bool init() override;
- /*void deinit() override;*/
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/dsound.cpp b/Alc/backends/dsound.cpp
index 8b181d0d..00deafc1 100644
--- a/Alc/backends/dsound.cpp
+++ b/Alc/backends/dsound.cpp
@@ -99,38 +99,6 @@ HRESULT (WINAPI *pDirectSoundCaptureEnumerateW)(LPDSENUMCALLBACKW pDSEnumCallbac
#endif
-bool DSoundLoad(void)
-{
-#ifdef HAVE_DYNLOAD
- if(!ds_handle)
- {
- ds_handle = LoadLib("dsound.dll");
- if(!ds_handle)
- {
- ERR("Failed to load dsound.dll\n");
- return false;
- }
-
-#define LOAD_FUNC(f) do { \
- p##f = reinterpret_cast<decltype(p##f)>(GetSymbol(ds_handle, #f)); \
- if(!p##f) \
- { \
- CloseLib(ds_handle); \
- ds_handle = nullptr; \
- return false; \
- } \
-} while(0)
- LOAD_FUNC(DirectSoundCreate);
- LOAD_FUNC(DirectSoundEnumerateW);
- LOAD_FUNC(DirectSoundCaptureCreate);
- LOAD_FUNC(DirectSoundCaptureEnumerateW);
-#undef LOAD_FUNC
- }
-#endif
- return true;
-}
-
-
#define MAX_UPDATES 128
struct DevMap {
@@ -892,18 +860,34 @@ BackendFactory &DSoundBackendFactory::getFactory()
}
bool DSoundBackendFactory::init()
-{ return DSoundLoad(); }
-
-void DSoundBackendFactory::deinit()
{
- PlaybackDevices.clear();
- CaptureDevices.clear();
-
#ifdef HAVE_DYNLOAD
- if(ds_handle)
- CloseLib(ds_handle);
- ds_handle = nullptr;
+ if(!ds_handle)
+ {
+ ds_handle = LoadLib("dsound.dll");
+ if(!ds_handle)
+ {
+ ERR("Failed to load dsound.dll\n");
+ return false;
+ }
+
+#define LOAD_FUNC(f) do { \
+ p##f = reinterpret_cast<decltype(p##f)>(GetSymbol(ds_handle, #f)); \
+ if(!p##f) \
+ { \
+ CloseLib(ds_handle); \
+ ds_handle = nullptr; \
+ return false; \
+ } \
+} while(0)
+ LOAD_FUNC(DirectSoundCreate);
+ LOAD_FUNC(DirectSoundEnumerateW);
+ LOAD_FUNC(DirectSoundCaptureCreate);
+ LOAD_FUNC(DirectSoundCaptureEnumerateW);
+#undef LOAD_FUNC
+ }
#endif
+ return true;
}
bool DSoundBackendFactory::querySupport(BackendType type)
diff --git a/Alc/backends/dsound.h b/Alc/backends/dsound.h
index 89484b4d..6bef0bfc 100644
--- a/Alc/backends/dsound.h
+++ b/Alc/backends/dsound.h
@@ -6,7 +6,6 @@
struct DSoundBackendFactory final : public BackendFactory {
public:
bool init() override;
- void deinit() override;
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/jack.cpp b/Alc/backends/jack.cpp
index 9fc5ac4a..77d5fea0 100644
--- a/Alc/backends/jack.cpp
+++ b/Alc/backends/jack.cpp
@@ -532,15 +532,6 @@ bool JackBackendFactory::init()
return true;
}
-void JackBackendFactory::deinit()
-{
-#ifdef HAVE_DYNLOAD
- if(jack_handle)
- CloseLib(jack_handle);
- jack_handle = nullptr;
-#endif
-}
-
bool JackBackendFactory::querySupport(BackendType type)
{ return (type == BackendType::Playback); }
diff --git a/Alc/backends/jack.h b/Alc/backends/jack.h
index 0948213f..10beebfb 100644
--- a/Alc/backends/jack.h
+++ b/Alc/backends/jack.h
@@ -6,7 +6,6 @@
struct JackBackendFactory final : public BackendFactory {
public:
bool init() override;
- void deinit() override;
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/loopback.h b/Alc/backends/loopback.h
index e40ce963..09c085b8 100644
--- a/Alc/backends/loopback.h
+++ b/Alc/backends/loopback.h
@@ -6,7 +6,6 @@
struct LoopbackBackendFactory final : public BackendFactory {
public:
bool init() override;
- /*void deinit() override;*/
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/null.h b/Alc/backends/null.h
index 1488e1d0..f19d5b4d 100644
--- a/Alc/backends/null.h
+++ b/Alc/backends/null.h
@@ -6,7 +6,6 @@
struct NullBackendFactory final : public BackendFactory {
public:
bool init() override;
- /*void deinit() override;*/
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/opensl.h b/Alc/backends/opensl.h
index cf694f01..809aa339 100644
--- a/Alc/backends/opensl.h
+++ b/Alc/backends/opensl.h
@@ -6,7 +6,6 @@
struct OSLBackendFactory final : public BackendFactory {
public:
bool init() override;
- /*void deinit() override;*/
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/oss.cpp b/Alc/backends/oss.cpp
index 09a170e4..ccc59c39 100644
--- a/Alc/backends/oss.cpp
+++ b/Alc/backends/oss.cpp
@@ -709,12 +709,6 @@ bool OSSBackendFactory::init()
return true;
}
-void OSSBackendFactory::deinit()
-{
- PlaybackDevices.clear();
- CaptureDevices.clear();
-}
-
bool OSSBackendFactory::querySupport(BackendType type)
{ return (type == BackendType::Playback || type == BackendType::Capture); }
diff --git a/Alc/backends/oss.h b/Alc/backends/oss.h
index e07cd573..9e63d7b6 100644
--- a/Alc/backends/oss.h
+++ b/Alc/backends/oss.h
@@ -6,7 +6,6 @@
struct OSSBackendFactory final : public BackendFactory {
public:
bool init() override;
- void deinit() override;
bool querySupport(BackendType type) override;
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)
diff --git a/Alc/backends/portaudio.h b/Alc/backends/portaudio.h
index 1fd45ff3..082e9020 100644
--- a/Alc/backends/portaudio.h
+++ b/Alc/backends/portaudio.h
@@ -6,7 +6,6 @@
struct PortBackendFactory final : public BackendFactory {
public:
bool init() override;
- void deinit() override;
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp
index f6e528fd..bbff6796 100644
--- a/Alc/backends/pulseaudio.cpp
+++ b/Alc/backends/pulseaudio.cpp
@@ -186,115 +186,6 @@ MAKE_FUNC(pa_stream_begin_write);
#endif
-ALCboolean pulse_load()
-{
- ALCboolean ret{ALC_TRUE};
-#ifdef HAVE_DYNLOAD
- if(!pa_handle)
- {
- std::string missing_funcs;
-
-#ifdef _WIN32
-#define PALIB "libpulse-0.dll"
-#elif defined(__APPLE__) && defined(__MACH__)
-#define PALIB "libpulse.0.dylib"
-#else
-#define PALIB "libpulse.so.0"
-#endif
- pa_handle = LoadLib(PALIB);
- if(!pa_handle)
- {
- WARN("Failed to load %s\n", PALIB);
- return ALC_FALSE;
- }
-
-#define LOAD_FUNC(x) do { \
- p##x = reinterpret_cast<decltype(p##x)>(GetSymbol(pa_handle, #x)); \
- if(!(p##x)) { \
- ret = ALC_FALSE; \
- missing_funcs += "\n" #x; \
- } \
-} while(0)
- LOAD_FUNC(pa_context_unref);
- LOAD_FUNC(pa_sample_spec_valid);
- LOAD_FUNC(pa_stream_drop);
- LOAD_FUNC(pa_frame_size);
- LOAD_FUNC(pa_strerror);
- LOAD_FUNC(pa_context_get_state);
- LOAD_FUNC(pa_stream_get_state);
- LOAD_FUNC(pa_threaded_mainloop_signal);
- LOAD_FUNC(pa_stream_peek);
- LOAD_FUNC(pa_threaded_mainloop_wait);
- LOAD_FUNC(pa_threaded_mainloop_unlock);
- LOAD_FUNC(pa_threaded_mainloop_in_thread);
- LOAD_FUNC(pa_context_new);
- LOAD_FUNC(pa_threaded_mainloop_stop);
- LOAD_FUNC(pa_context_disconnect);
- LOAD_FUNC(pa_threaded_mainloop_start);
- LOAD_FUNC(pa_threaded_mainloop_get_api);
- LOAD_FUNC(pa_context_set_state_callback);
- LOAD_FUNC(pa_stream_write);
- LOAD_FUNC(pa_xfree);
- LOAD_FUNC(pa_stream_connect_record);
- LOAD_FUNC(pa_stream_connect_playback);
- LOAD_FUNC(pa_stream_readable_size);
- LOAD_FUNC(pa_stream_writable_size);
- LOAD_FUNC(pa_stream_is_corked);
- LOAD_FUNC(pa_stream_cork);
- LOAD_FUNC(pa_stream_is_suspended);
- LOAD_FUNC(pa_stream_get_device_name);
- LOAD_FUNC(pa_stream_get_latency);
- LOAD_FUNC(pa_path_get_filename);
- LOAD_FUNC(pa_get_binary_name);
- LOAD_FUNC(pa_threaded_mainloop_free);
- LOAD_FUNC(pa_context_errno);
- LOAD_FUNC(pa_xmalloc);
- LOAD_FUNC(pa_stream_unref);
- LOAD_FUNC(pa_threaded_mainloop_accept);
- LOAD_FUNC(pa_stream_set_write_callback);
- LOAD_FUNC(pa_threaded_mainloop_new);
- LOAD_FUNC(pa_context_connect);
- LOAD_FUNC(pa_stream_set_buffer_attr);
- LOAD_FUNC(pa_stream_get_buffer_attr);
- LOAD_FUNC(pa_stream_get_sample_spec);
- LOAD_FUNC(pa_stream_get_time);
- LOAD_FUNC(pa_stream_set_read_callback);
- LOAD_FUNC(pa_stream_set_state_callback);
- LOAD_FUNC(pa_stream_set_moved_callback);
- LOAD_FUNC(pa_stream_set_underflow_callback);
- LOAD_FUNC(pa_stream_new_with_proplist);
- LOAD_FUNC(pa_stream_disconnect);
- LOAD_FUNC(pa_threaded_mainloop_lock);
- LOAD_FUNC(pa_channel_map_init_auto);
- LOAD_FUNC(pa_channel_map_parse);
- LOAD_FUNC(pa_channel_map_snprint);
- LOAD_FUNC(pa_channel_map_equal);
- LOAD_FUNC(pa_context_get_server_info);
- LOAD_FUNC(pa_context_get_sink_info_by_name);
- LOAD_FUNC(pa_context_get_sink_info_list);
- LOAD_FUNC(pa_context_get_source_info_by_name);
- LOAD_FUNC(pa_context_get_source_info_list);
- LOAD_FUNC(pa_operation_get_state);
- LOAD_FUNC(pa_operation_unref);
- LOAD_FUNC(pa_proplist_new);
- LOAD_FUNC(pa_proplist_free);
- LOAD_FUNC(pa_proplist_set);
- LOAD_FUNC(pa_channel_map_superset);
- LOAD_FUNC(pa_stream_set_buffer_attr_callback);
- LOAD_FUNC(pa_stream_begin_write);
-#undef LOAD_FUNC
-
- if(ret == ALC_FALSE)
- {
- WARN("Missing expected functions:%s\n", missing_funcs.c_str());
- CloseLib(pa_handle);
- pa_handle = nullptr;
- }
- }
-#endif /* HAVE_DYNLOAD */
- return ret;
-}
-
/* *grumble* Don't use enums for bitflags. */
inline pa_stream_flags_t operator|(pa_stream_flags_t lhs, pa_stream_flags_t rhs)
@@ -1599,54 +1490,145 @@ void PulseCapture::unlock()
bool PulseBackendFactory::init()
{
- bool ret{false};
-
- if(pulse_load())
+#ifdef HAVE_DYNLOAD
+ if(!pa_handle)
{
- pulse_ctx_flags = PA_CONTEXT_NOFLAGS;
- if(!GetConfigValueBool(nullptr, "pulse", "spawn-server", 1))
- pulse_ctx_flags |= PA_CONTEXT_NOAUTOSPAWN;
+ bool ret{false};
+ std::string missing_funcs;
- pa_threaded_mainloop *loop{pa_threaded_mainloop_new()};
- if(loop && pa_threaded_mainloop_start(loop) >= 0)
+#ifdef _WIN32
+#define PALIB "libpulse-0.dll"
+#elif defined(__APPLE__) && defined(__MACH__)
+#define PALIB "libpulse.0.dylib"
+#else
+#define PALIB "libpulse.so.0"
+#endif
+ pa_handle = LoadLib(PALIB);
+ if(!pa_handle)
{
- unique_palock palock{loop};
- pa_context *context{connect_context(loop, AL_TRUE)};
- if(context)
- {
- ret = true;
-
- /* Some libraries (Phonon, Qt) set some pulseaudio properties
- * through environment variables, which causes all streams in
- * the process to inherit them. This attempts to filter those
- * properties out by setting them to 0-length data. */
- prop_filter = pa_proplist_new();
- pa_proplist_set(prop_filter, PA_PROP_MEDIA_ROLE, nullptr, 0);
- pa_proplist_set(prop_filter, "phonon.streamid", nullptr, 0);
-
- pa_context_disconnect(context);
- pa_context_unref(context);
- }
- palock.unlock();
- pa_threaded_mainloop_stop(loop);
+ WARN("Failed to load %s\n", PALIB);
+ return false;
+ }
+
+#define LOAD_FUNC(x) do { \
+ p##x = reinterpret_cast<decltype(p##x)>(GetSymbol(pa_handle, #x)); \
+ if(!(p##x)) { \
+ ret = false; \
+ missing_funcs += "\n" #x; \
+ } \
+} while(0)
+ LOAD_FUNC(pa_context_unref);
+ LOAD_FUNC(pa_sample_spec_valid);
+ LOAD_FUNC(pa_stream_drop);
+ LOAD_FUNC(pa_frame_size);
+ LOAD_FUNC(pa_strerror);
+ LOAD_FUNC(pa_context_get_state);
+ LOAD_FUNC(pa_stream_get_state);
+ LOAD_FUNC(pa_threaded_mainloop_signal);
+ LOAD_FUNC(pa_stream_peek);
+ LOAD_FUNC(pa_threaded_mainloop_wait);
+ LOAD_FUNC(pa_threaded_mainloop_unlock);
+ LOAD_FUNC(pa_threaded_mainloop_in_thread);
+ LOAD_FUNC(pa_context_new);
+ LOAD_FUNC(pa_threaded_mainloop_stop);
+ LOAD_FUNC(pa_context_disconnect);
+ LOAD_FUNC(pa_threaded_mainloop_start);
+ LOAD_FUNC(pa_threaded_mainloop_get_api);
+ LOAD_FUNC(pa_context_set_state_callback);
+ LOAD_FUNC(pa_stream_write);
+ LOAD_FUNC(pa_xfree);
+ LOAD_FUNC(pa_stream_connect_record);
+ LOAD_FUNC(pa_stream_connect_playback);
+ LOAD_FUNC(pa_stream_readable_size);
+ LOAD_FUNC(pa_stream_writable_size);
+ LOAD_FUNC(pa_stream_is_corked);
+ LOAD_FUNC(pa_stream_cork);
+ LOAD_FUNC(pa_stream_is_suspended);
+ LOAD_FUNC(pa_stream_get_device_name);
+ LOAD_FUNC(pa_stream_get_latency);
+ LOAD_FUNC(pa_path_get_filename);
+ LOAD_FUNC(pa_get_binary_name);
+ LOAD_FUNC(pa_threaded_mainloop_free);
+ LOAD_FUNC(pa_context_errno);
+ LOAD_FUNC(pa_xmalloc);
+ LOAD_FUNC(pa_stream_unref);
+ LOAD_FUNC(pa_threaded_mainloop_accept);
+ LOAD_FUNC(pa_stream_set_write_callback);
+ LOAD_FUNC(pa_threaded_mainloop_new);
+ LOAD_FUNC(pa_context_connect);
+ LOAD_FUNC(pa_stream_set_buffer_attr);
+ LOAD_FUNC(pa_stream_get_buffer_attr);
+ LOAD_FUNC(pa_stream_get_sample_spec);
+ LOAD_FUNC(pa_stream_get_time);
+ LOAD_FUNC(pa_stream_set_read_callback);
+ LOAD_FUNC(pa_stream_set_state_callback);
+ LOAD_FUNC(pa_stream_set_moved_callback);
+ LOAD_FUNC(pa_stream_set_underflow_callback);
+ LOAD_FUNC(pa_stream_new_with_proplist);
+ LOAD_FUNC(pa_stream_disconnect);
+ LOAD_FUNC(pa_threaded_mainloop_lock);
+ LOAD_FUNC(pa_channel_map_init_auto);
+ LOAD_FUNC(pa_channel_map_parse);
+ LOAD_FUNC(pa_channel_map_snprint);
+ LOAD_FUNC(pa_channel_map_equal);
+ LOAD_FUNC(pa_context_get_server_info);
+ LOAD_FUNC(pa_context_get_sink_info_by_name);
+ LOAD_FUNC(pa_context_get_sink_info_list);
+ LOAD_FUNC(pa_context_get_source_info_by_name);
+ LOAD_FUNC(pa_context_get_source_info_list);
+ LOAD_FUNC(pa_operation_get_state);
+ LOAD_FUNC(pa_operation_unref);
+ LOAD_FUNC(pa_proplist_new);
+ LOAD_FUNC(pa_proplist_free);
+ LOAD_FUNC(pa_proplist_set);
+ LOAD_FUNC(pa_channel_map_superset);
+ LOAD_FUNC(pa_stream_set_buffer_attr_callback);
+ LOAD_FUNC(pa_stream_begin_write);
+#undef LOAD_FUNC
+
+ if(!ret)
+ {
+ WARN("Missing expected functions:%s\n", missing_funcs.c_str());
+ CloseLib(pa_handle);
+ pa_handle = nullptr;
+ return false;
}
- if(loop)
- pa_threaded_mainloop_free(loop);
}
+#endif /* HAVE_DYNLOAD */
- return ret;
-}
+ pulse_ctx_flags = PA_CONTEXT_NOFLAGS;
+ if(!GetConfigValueBool(nullptr, "pulse", "spawn-server", 1))
+ pulse_ctx_flags |= PA_CONTEXT_NOAUTOSPAWN;
-void PulseBackendFactory::deinit()
-{
- PlaybackDevices.clear();
- CaptureDevices.clear();
+ bool ret{false};
+ pa_threaded_mainloop *loop{pa_threaded_mainloop_new()};
+ if(loop && pa_threaded_mainloop_start(loop) >= 0)
+ {
+ unique_palock palock{loop};
+ pa_context *context{connect_context(loop, AL_TRUE)};
+ if(context)
+ {
+ ret = true;
- if(prop_filter)
- pa_proplist_free(prop_filter);
- prop_filter = nullptr;
+ /* Some libraries (Phonon, Qt) set some pulseaudio properties
+ * through environment variables, which causes all streams in the
+ * process to inherit them. This attempts to filter those
+ * properties out by setting them to 0-length data.
+ */
+ prop_filter = pa_proplist_new();
+ pa_proplist_set(prop_filter, PA_PROP_MEDIA_ROLE, nullptr, 0);
+ pa_proplist_set(prop_filter, "phonon.streamid", nullptr, 0);
+
+ pa_context_disconnect(context);
+ pa_context_unref(context);
+ }
+ palock.unlock();
+ pa_threaded_mainloop_stop(loop);
+ }
+ if(loop)
+ pa_threaded_mainloop_free(loop);
- /* PulseAudio doesn't like being CloseLib'd sometimes */
+ return ret;
}
bool PulseBackendFactory::querySupport(BackendType type)
diff --git a/Alc/backends/pulseaudio.h b/Alc/backends/pulseaudio.h
index 336276e6..40f3e305 100644
--- a/Alc/backends/pulseaudio.h
+++ b/Alc/backends/pulseaudio.h
@@ -6,7 +6,6 @@
class PulseBackendFactory final : public BackendFactory {
public:
bool init() override;
- void deinit() override;
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/qsa.cpp b/Alc/backends/qsa.cpp
index d1171339..ab5bef9a 100644
--- a/Alc/backends/qsa.cpp
+++ b/Alc/backends/qsa.cpp
@@ -914,19 +914,6 @@ ALCuint CaptureWrapper::availableSamples()
bool QSABackendFactory::init()
{ return true; }
-void QSABackendFactory::deinit()
-{
- std::for_each(DeviceNameMap.begin(), DeviceNameMap.end(),
- [](DevMap &entry) -> void { free(entry.name); }
- );
- DeviceNameMap.clear();
-
- std::for_each(CaptureNameMap.begin(), CaptureNameMap.end(),
- [](DevMap &entry) -> void { free(entry.name); }
- );
- CaptureNameMap.clear();
-}
-
bool QSABackendFactory::querySupport(BackendType type)
{ return (type == BackendType::Playback || type == BackendType::Capture); }
diff --git a/Alc/backends/qsa.h b/Alc/backends/qsa.h
index fdd81b4f..da548bba 100644
--- a/Alc/backends/qsa.h
+++ b/Alc/backends/qsa.h
@@ -6,7 +6,6 @@
struct QSABackendFactory final : public BackendFactory {
public:
bool init() override;
- void deinit() override;
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/sdl2.cpp b/Alc/backends/sdl2.cpp
index 9699e274..a1011735 100644
--- a/Alc/backends/sdl2.cpp
+++ b/Alc/backends/sdl2.cpp
@@ -193,14 +193,7 @@ BackendFactory &SDL2BackendFactory::getFactory()
}
bool SDL2BackendFactory::init()
-{
- return (SDL_InitSubSystem(SDL_INIT_AUDIO) == 0);
-}
-
-void SDL2BackendFactory::deinit()
-{
- SDL_QuitSubSystem(SDL_INIT_AUDIO);
-}
+{ return (SDL_InitSubSystem(SDL_INIT_AUDIO) == 0); }
bool SDL2BackendFactory::querySupport(BackendType type)
{ return type == BackendType::Playback; }
diff --git a/Alc/backends/sdl2.h b/Alc/backends/sdl2.h
index aefe1ef5..041d47ee 100644
--- a/Alc/backends/sdl2.h
+++ b/Alc/backends/sdl2.h
@@ -6,7 +6,6 @@
struct SDL2BackendFactory final : public BackendFactory {
public:
bool init() override;
- void deinit() override;
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/sndio.h b/Alc/backends/sndio.h
index 5cd4ff8a..1ed63d5e 100644
--- a/Alc/backends/sndio.h
+++ b/Alc/backends/sndio.h
@@ -6,7 +6,6 @@
struct SndIOBackendFactory final : public BackendFactory {
public:
bool init() override;
- /*void deinit() override;*/
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/solaris.h b/Alc/backends/solaris.h
index 99623be4..98b10593 100644
--- a/Alc/backends/solaris.h
+++ b/Alc/backends/solaris.h
@@ -6,7 +6,6 @@
struct SolarisBackendFactory final : public BackendFactory {
public:
bool init() override;
- /*void deinit() override;*/
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/wasapi.cpp b/Alc/backends/wasapi.cpp
index 9dfbd247..aa9341ce 100644
--- a/Alc/backends/wasapi.cpp
+++ b/Alc/backends/wasapi.cpp
@@ -1660,15 +1660,6 @@ bool WasapiBackendFactory::init()
return SUCCEEDED(InitResult) ? ALC_TRUE : ALC_FALSE;
}
-void WasapiBackendFactory::deinit()
-{
- PlaybackDevices.clear();
- CaptureDevices.clear();
-
- TRACE("Sending quit message\n");
- WasapiProxy::pushMessageStatic(MsgType::QuitThread);
-}
-
bool WasapiBackendFactory::querySupport(BackendType type)
{ return type == BackendType::Playback || type == BackendType::Capture; }
diff --git a/Alc/backends/wasapi.h b/Alc/backends/wasapi.h
index ab9f8162e..067dd259 100644
--- a/Alc/backends/wasapi.h
+++ b/Alc/backends/wasapi.h
@@ -6,7 +6,6 @@
struct WasapiBackendFactory final : public BackendFactory {
public:
bool init() override;
- void deinit() override;
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/wave.h b/Alc/backends/wave.h
index f3617b6d..b9b62d7f 100644
--- a/Alc/backends/wave.h
+++ b/Alc/backends/wave.h
@@ -6,7 +6,6 @@
struct WaveBackendFactory final : public BackendFactory {
public:
bool init() override;
- /*void deinit() override;*/
bool querySupport(BackendType type) override;
diff --git a/Alc/backends/winmm.cpp b/Alc/backends/winmm.cpp
index 94cca828..aa8db972 100644
--- a/Alc/backends/winmm.cpp
+++ b/Alc/backends/winmm.cpp
@@ -602,12 +602,6 @@ ALCuint WinMMCapture::availableSamples()
bool WinMMBackendFactory::init()
{ return true; }
-void WinMMBackendFactory::deinit()
-{
- PlaybackDevices.clear();
- CaptureDevices.clear();
-}
-
bool WinMMBackendFactory::querySupport(BackendType type)
{ return type == BackendType::Playback || type == BackendType::Capture; }
diff --git a/Alc/backends/winmm.h b/Alc/backends/winmm.h
index 4d9fe32d..e357ec19 100644
--- a/Alc/backends/winmm.h
+++ b/Alc/backends/winmm.h
@@ -6,7 +6,6 @@
struct WinMMBackendFactory final : public BackendFactory {
public:
bool init() override;
- void deinit() override;
bool querySupport(BackendType type) override;