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.
This commit is contained in:
parent
7f52678099
commit
61f7e7716c
@ -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)
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct AlsaBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
void deinit() override;
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -67,7 +67,6 @@ enum class DevProbe {
|
||||
|
||||
struct BackendFactory {
|
||||
virtual bool init() = 0;
|
||||
virtual void deinit() { }
|
||||
|
||||
virtual bool querySupport(BackendType type) = 0;
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct CoreAudioBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
/*void deinit() override;*/
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct DSoundBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
void deinit() override;
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -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); }
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct JackBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
void deinit() override;
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct LoopbackBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
/*void deinit() override;*/
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct NullBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
/*void deinit() override;*/
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct OSLBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
/*void deinit() override;*/
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -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); }
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct OSSBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
void deinit() override;
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct PortBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
void deinit() override;
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -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,56 +1490,147 @@ 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 */
|
||||
|
||||
pulse_ctx_flags = PA_CONTEXT_NOFLAGS;
|
||||
if(!GetConfigValueBool(nullptr, "pulse", "spawn-server", 1))
|
||||
pulse_ctx_flags |= PA_CONTEXT_NOAUTOSPAWN;
|
||||
|
||||
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;
|
||||
|
||||
/* 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);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void PulseBackendFactory::deinit()
|
||||
{
|
||||
PlaybackDevices.clear();
|
||||
CaptureDevices.clear();
|
||||
|
||||
if(prop_filter)
|
||||
pa_proplist_free(prop_filter);
|
||||
prop_filter = nullptr;
|
||||
|
||||
/* PulseAudio doesn't like being CloseLib'd sometimes */
|
||||
}
|
||||
|
||||
bool PulseBackendFactory::querySupport(BackendType type)
|
||||
{ return type == BackendType::Playback || type == BackendType::Capture; }
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
class PulseBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
void deinit() override;
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -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); }
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct QSABackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
void deinit() override;
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -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; }
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct SDL2BackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
void deinit() override;
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct SndIOBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
/*void deinit() override;*/
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct SolarisBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
/*void deinit() override;*/
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct WasapiBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
void deinit() override;
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct WaveBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
/*void deinit() override;*/
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
struct WinMMBackendFactory final : public BackendFactory {
|
||||
public:
|
||||
bool init() override;
|
||||
void deinit() override;
|
||||
|
||||
bool querySupport(BackendType type) override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user