Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio device not detected on Linux with SDL2_jll #1432

Open
dalum opened this issue Aug 8, 2020 · 18 comments
Open

Audio device not detected on Linux with SDL2_jll #1432

dalum opened this issue Aug 8, 2020 · 18 comments

Comments

@dalum
Copy link

dalum commented Aug 8, 2020

Cross-ref: JuliaMultimedia/SimpleDirectMediaLayer.jl#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. ☺️

@aviks
Copy link
Contributor

aviks commented Aug 16, 2020

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

@dalum
Copy link
Author

dalum commented Aug 17, 2020

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 added a commit that referenced this issue Aug 25, 2020
SDL2 needs to link against some kind of backing sound library to output on Linux; let's use `alsa` for that.

X-ref: #1432
staticfloat added a commit that referenced this issue Aug 25, 2020
SDL2 needs to link against some kind of backing sound library to output on Linux; let's use `alsa` for that.

X-ref: #1432
@staticfloat
Copy link
Member

@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
Copy link
Author

dalum commented Aug 25, 2020

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

@staticfloat
Copy link
Member

staticfloat commented Aug 25, 2020 via email

@dalum
Copy link
Author

dalum commented Aug 25, 2020

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
Copy link
Member

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
Copy link
Author

dalum commented Aug 26, 2020

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
Copy link
Author

dalum commented Aug 26, 2020

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
Copy link
Member

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 😕

@staticfloat
Copy link
Member

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
Copy link
Author

dalum commented Aug 26, 2020

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
Copy link
Member

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
Copy link

ma-laforge commented May 4, 2021

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
Copy link
Member

giordano commented May 5, 2021

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
Copy link
Member

giordano commented May 5, 2021

Wait, they do support relocation with environment variables now: alsa-project/alsa-lib@8580c08. 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
Copy link

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
Copy link
Contributor

aviks commented May 30, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants