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.
cherry-pick from 09f82fa6ea
This commit is contained in:
parent
30c69c296b
commit
228803e9db
12 changed files with 19776 additions and 5 deletions
|
@ -2,4 +2,7 @@
|
|||
|
||||
Import("env")
|
||||
|
||||
if "alsa" in env and env["alsa"]:
|
||||
env.add_source_files(env.drivers_sources, "asound-so_wrap.c")
|
||||
|
||||
env.add_source_files(env.drivers_sources, "*.cpp")
|
||||
|
|
11565
drivers/alsa/asound-so_wrap.c
Normal file
11565
drivers/alsa/asound-so_wrap.c
Normal file
File diff suppressed because it is too large
Load diff
3864
drivers/alsa/asound-so_wrap.h
Normal file
3864
drivers/alsa/asound-so_wrap.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -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,15 @@ 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;
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "core/os/thread.h"
|
||||
#include "servers/audio_server.h"
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
#include "asound-so_wrap.h"
|
||||
|
||||
class AudioDriverALSA : public AudioDriver {
|
||||
|
||||
|
|
|
@ -2,4 +2,7 @@
|
|||
|
||||
Import("env")
|
||||
|
||||
if "pulseaudio" in env and env["pulseaudio"]:
|
||||
env.add_source_files(env.drivers_sources, "pulse-so_wrap.c")
|
||||
|
||||
env.add_source_files(env.drivers_sources, "*.cpp")
|
||||
|
|
|
@ -236,6 +236,9 @@ Error AudioDriverPulseAudio::init_device() {
|
|||
}
|
||||
|
||||
Error AudioDriverPulseAudio::init() {
|
||||
if (initialize_pulse()) {
|
||||
return ERR_CANT_OPEN;
|
||||
}
|
||||
|
||||
active = false;
|
||||
thread_exited = false;
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "core/os/thread.h"
|
||||
#include "servers/audio_server.h"
|
||||
|
||||
#include <pulse/pulseaudio.h>
|
||||
#include "pulse-so_wrap.h"
|
||||
|
||||
class AudioDriverPulseAudio : public AudioDriver {
|
||||
|
||||
|
|
3231
drivers/pulseaudio/pulse-so_wrap.c
Normal file
3231
drivers/pulseaudio/pulse-so_wrap.c
Normal file
File diff suppressed because it is too large
Load diff
1086
drivers/pulseaudio/pulse-so_wrap.h
Normal file
1086
drivers/pulseaudio/pulse-so_wrap.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -16,6 +16,8 @@ while IFS= read -rd '' f; do
|
|||
continue
|
||||
elif [[ "$f" == "platform/android/java/lib/src/com/google"* ]]; then
|
||||
continue
|
||||
elif [[ "$f" == *"-so_wrap."* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
for extension in ${CLANG_FORMAT_FILE_EXTS[@]}; do
|
||||
|
|
|
@ -309,9 +309,8 @@ def configure(env):
|
|||
|
||||
if os.system("pkg-config --exists alsa") == 0: # 0 means found
|
||||
print("Enabling ALSA")
|
||||
env["alsa"] = True
|
||||
env.Append(CPPDEFINES=["ALSA_ENABLED", "ALSAMIDI_ENABLED"])
|
||||
# Don't parse --cflags, we don't need to add /usr/include/alsa to include path
|
||||
env.ParseConfig("pkg-config alsa --libs")
|
||||
else:
|
||||
print("ALSA libraries not found, disabling driver")
|
||||
|
||||
|
@ -319,7 +318,7 @@ def configure(env):
|
|||
if os.system("pkg-config --exists libpulse") == 0: # 0 means found
|
||||
print("Enabling PulseAudio")
|
||||
env.Append(CPPDEFINES=["PULSEAUDIO_ENABLED"])
|
||||
env.ParseConfig("pkg-config --cflags --libs libpulse")
|
||||
env.ParseConfig("pkg-config --cflags libpulse")
|
||||
else:
|
||||
print("PulseAudio development libraries not found, disabling driver")
|
||||
|
||||
|
|
Loading…
Reference in a new issue