mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Dynamically load libpulse.so.0 and libasound.so.1 on Linux
By generating stubs using https://github.com/hpvb/dynload-wrapper we can dynamically load libpulse and libasound on systems where it is available. Both are still a build-time requirement but no longer a run-time dependency. For maintenance purposes the wrappers should not need to be re-generated unless we want to bump pulse or asound to an incompatible version. It is unlikely we will want to do this any time soon. This closes #20978
This commit is contained in:
@@ -37,6 +37,12 @@
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef PULSEAUDIO_ENABLED
|
||||
extern "C" {
|
||||
extern int initialize_pulse();
|
||||
}
|
||||
#endif
|
||||
|
||||
Error AudioDriverALSA::init_device() {
|
||||
mix_rate = GLOBAL_GET("audio/mix_rate");
|
||||
speaker_mode = SPEAKER_MODE_STEREO;
|
||||
@@ -147,6 +153,16 @@ Error AudioDriverALSA::init_device() {
|
||||
}
|
||||
|
||||
Error AudioDriverALSA::init() {
|
||||
#ifdef PULSEAUDIO_ENABLED
|
||||
// On pulse enabled systems Alsa will silently use pulse.
|
||||
// It doesn't matter if this fails as that likely means there is no pulse
|
||||
initialize_pulse();
|
||||
#endif
|
||||
|
||||
if (initialize_asound()) {
|
||||
return ERR_CANT_OPEN;
|
||||
}
|
||||
|
||||
active = false;
|
||||
thread_exited = false;
|
||||
exit_thread = false;
|
||||
|
||||
Reference in New Issue
Block a user