JuliaPackaging / Yggdrasil

Collection of builder repositories for BinaryBuilder.jl
https://binarybuilder.org
Other
304 stars 535 forks source link

Audio device not detected on Linux with SDL2_jll #1432

Open dalum opened 4 years ago

dalum commented 4 years ago

Cross-ref: https://github.com/jonathanBieler/SimpleDirectMediaLayer.jl/issues/51

Using SDL2_jll on Linux (latest Manjaro) together with SDL2_mixer_jll, no audio device is detected. If I manually copy over the system-provided libSDL2-2.0.so.0.12.0 into the artifacts directory for SDL2_jll, then everything works fine, so I assume something is up with the compiled .so in the JLL.

Would appreciate if someone could help resolve this. :relaxed:

aviks commented 4 years ago

Can you do ldd against the system and the artifact .so's and report the results?

dalum commented 4 years ago

Artifact:

    linux-vdso.so.1 (0x00007ffe2fff9000)
    libm.so.6 => /usr/lib/libm.so.6 (0x00007f1826f48000)
    libiconv.so.2 => not found
    libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f1826f42000)
    libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f1826f20000)
    librt.so.1 => /usr/lib/librt.so.1 (0x00007f1826f15000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007f1826d4e000)
    /usr/lib64/ld-linux-x86-64.so.2 (0x00007f1827446000)

System:

    linux-vdso.so.1 (0x00007ffcde3f6000)
    libm.so.6 => /usr/lib/libm.so.6 (0x00007f1a09fb9000)
    libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f1a09fb3000)
    libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f1a09f91000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007f1a09dca000)
    /usr/lib64/ld-linux-x86-64.so.2 (0x00007f1a0a2b2000)
staticfloat commented 4 years ago

@dalum I just merged a new SDL2_jll that relies on alsa_jll to get Audio output support on Linux. Now that that new version of SDL2_jll has been merged into the registry, can you update and try again to see if your sound works?

dalum commented 4 years ago

Unfortunately, it doesn't work :frowning_face:

I get the following errors, though:

ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /workspace/destdir/share/alsa/alsa.conf
ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /workspace/destdir/share/alsa/alsa.conf
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /workspace/destdir/share/alsa/alsa.conf
ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /workspace/destdir/share/alsa/alsa.conf
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /workspace/destdir/share/alsa/alsa.conf
ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /workspace/destdir/share/alsa/alsa.conf
staticfloat commented 4 years ago

Do you know what sound system your custom SDL library is using?

On Tue, Aug 25, 2020 at 15:17 Sakse notifications@github.com wrote:

Unfortunately, it doesn't work ☹️

I get the following errors, though:

ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /workspace/destdir/share/alsa/alsa.conf

ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /workspace/destdir/share/alsa/alsa.conf

ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default

ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /workspace/destdir/share/alsa/alsa.conf

ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /workspace/destdir/share/alsa/alsa.conf

ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default

ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /workspace/destdir/share/alsa/alsa.conf

ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /workspace/destdir/share/alsa/alsa.conf

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JuliaPackaging/Yggdrasil/issues/1432#issuecomment-680296941, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA762GJK2PNOEQU5VBJ2FDSCQZ6FANCNFSM4PYZZUAQ .

dalum commented 4 years ago

I'm not 100% certain, but it has both libpulse, alsa-lib and jack as optional dependencies, so my guess would be that it's configured to use whichever one is available. My system has PulseAudio running with an ALSA backend.

staticfloat commented 4 years ago

Hmm, then ALSA should work, most likely it's buggered because the configuration file location needs to be set. What happens if you set export ALSA_CONFIG_DIR=/etc before running Julia?

dalum commented 4 years ago

Hmm, then ALSA should work, most likely it's buggered because the configuration file location needs to be set. What happens if you set export ALSA_CONFIG_DIR=/etc before running Julia?

ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /etc/alsa.conf
ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /etc/alsa.conf
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /etc/alsa.conf
ALSA lib conf.c:4048:(snd_config_update_r) Cannot access file /etc/alsa.conf

But /etc/alsa.conf also doesn't exist. Instead there is:

> ls /etc/alsa/conf.d/
10-samplerate.conf@    50-oss.conf@         60-upmix.conf@
10-speexrate.conf@     50-pipewire.conf@    60-vdownmix.conf@
50-arcam-av-ctl.conf@  50-pulseaudio.conf@  98-usb-stream.conf@
50-jack.conf@          60-speex.conf@       99-pulseaudio-default.conf@
dalum commented 4 years ago

What does "work" however, is to set ALSA_CONFIG_DIR to /usr/share/alsa. But in that case I get a new error:

ALSA lib dlmisc.c:285:(snd_dlobj_cache_get0) Cannot open shared library /workspace/destdir/lib/alsa-lib/libasound_module_pcm_pulse.so ((null): /workspace/destdir/lib/alsa-lib/libasound_module_pcm_pulse.so: cannot open shared object file: No such file or directory)

It looks like the builder ends up hardcoding a few too many paths from the build-agent?

giordano commented 4 years ago

maybe alsa_jll should set ALSA_CONFIG_DIR to the its own conf directory, if the variables isn't set already?

ALSA lib dlmisc.c:285:(snd_dlobj_cache_get0) Cannot open shared library /workspace/destdir/lib/alsa-lib/libasound_module_pcm_pulse.so ((null): /workspace/destdir/lib/alsa-lib/libasound_module_pcm_pulse.so: cannot open shared object file: No such file or directory)

Interesting, we don't have lib/alsa-lib/libasound_module_pcm_pulse.so in alsa_jll, nor any lib/alsa-lib directory at all :confused:

staticfloat commented 4 years ago

That looks to me like your alsa config is telling it to use a pulseaudio plugin that it can't find.

Hmmm. There is a default alsa config embedded within the artifact, isn't there? Let's try just using that.

Can you set ALSA_CONFIG_DIR=$(julia -e 'using alsa_jll; println(alsa_jll.artifact_dir)')/share/alsa and see if that works?

dalum commented 4 years ago

I get the exact same error,

ALSA lib dlmisc.c:285:(snd_dlobj_cache_get0) Cannot open shared library /workspace/destdir/lib/alsa-lib/libasound_module_pcm_pulse.so ((null): /workspace/destdir/lib/alsa-lib/libasound_module_pcm_pulse.so: cannot open shared object file: No such file or directory)
staticfloat commented 4 years ago

Fascinating. I am not an expert on how ALSA and pulse audio interact; I may need to do some reading before I can solve this. I kind of assumed that ALSA was lower-level than pulse and as such should be completely oblivious to its influence, but I may be wrong.

ma-laforge commented 3 years ago

Bump.

For what it's worth, I've also encountered the same problem on Linux. I've had to give up the idea of using SimpleDirectMediaLayer.jl.

... or @aviks's GameZero.jl, for that matter :).

giordano commented 3 years ago

Interesting, we don't have lib/alsa-lib/libasound_module_pcm_pulse.so in alsa_jll, nor any lib/alsa-lib directory at all confused

that library is in alsa_plugins_jll. I have no idea how this can possibly work. This looks to me an upstream issue which doesn't support relocation of libraries (and split prefixes)

giordano commented 3 years ago

Wait, they do support relocation with environment variables now: https://github.com/alsa-project/alsa-lib/commit/8580c081c25678d11278efcb61bd15cf44d0a225. Try to set

ENV["ALSA_PLUGIN_DIR"] = joinpath(alsa_plugins_jll.artifact_dir, "lib")

or something like that. Edit: I fixed the name of the variable, it was misspelled before.

mbeltagy commented 3 years ago

No alsa.conf it to be found in the artifact sub-directories for alsa_plugins_jll v1.2.2+0. There is just alsa.conf.d under share/alsa/.

The problem persists.

aviks commented 3 years ago

So I've verfied that the following invocation gets sounds working on my Manjaro linux machine

ENV["ALSA_CONFIG_PATH"] = "/usr/share/alsa/alsa.conf"
using alsa_plugins_jll
ENV["ALSA_PLUGIN_DIR"] = joinpath(alsa_plugins_jll.artifact_dir, "lib", "alsa-lib")

(Check spelling, compared to Mose's comment above)

So that is good news, but there are couple of problems with this. One, the alsa config path may be different on different machines. The internet seems to think that it should live in /etc but it's not, on my machine, and others above. So I'm not sure if we can set this in the package. How widespread is /usr/share/alsa ?? The other side of this story is that the alsa conf will probably depend on the hardware, so I doubt we can ship a conf file with the package,

The second problem is that we need to explicitly install and add alsa_plugins_jll. it is not a dependency of alsa_jll -- in fact it depends on alsa_jll. It is also not a dependency of either SimpleDirectMediaLayer or of SDL2_jll. One problem in making this a dependency of either of these packages is that alsa_plugins_jll seems to have a very long list of its own dependencies. Given that it's used only on linux, it seems unfair to foist that on all OSs. ( I know it won't have artifacts for other OSs, but the dependencies will still get installed, right?)

So anyway, the good news is that I have verified a workaround, but the bad news is that I don't know how to proceed from here.