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

no sound on many games on a pure alsa system #20

Open
Francesco149 opened this issue Jul 17, 2017 · 34 comments
Open

no sound on many games on a pure alsa system #20

Francesco149 opened this issue Jul 17, 2017 · 34 comments

Comments

@Francesco149
Copy link

I'm running with no pulseaudio on a pure alsa setup, 64-bit flatpak built with --disable-system-helper.

McOsu plays audio just fine, except I had to manually select the sound device which was nil by default.

Every other game I've tried (Hotline Miami, Duke Nukem 3D: Megaton Edition, World of Goo, Terraria) is just silent.

I inspected the console output for Hotline Miami (https://gist.github.com/Francesco149/69c238cadbc3a701a33c60f019da2526#file-steam-nosound-hotline-miami-log-L104) and saw that it was correctly trying to use alsa but failed with connection refused, but I already know alsa works inside flatpak, as McOsu can play audio just fine.

I thought the issue was that it wasn't picking up my default sound device so I tried allowing it to see ~/.asoundrc and /etc/asound.conf with --filesystem but that didn't help.

I tried disabling all my virtual sound devices so my default sound device was card0, device0 but still no dice.

I realize this is a niche setup I'm on, but flatpak is a great tool to bring software that's tied to complex dependencies and GNU libc such as steam on minimalistic distros such as musl-based ones like void or sabotage where people often use pure alsa and it would be cool to have this fixed.

I can provide logs for more games if you want.

@TingPing
Copy link
Member

I would ask does the sound work when ran on the host but I guess you can't run steam with your libc? This flatpak passes all devices through so in theory its just up to the games how they behave.

@Francesco149
Copy link
Author

yeah, I doubt I can run steam installer outside of flatpak on my musl-based system (unless steam runtime comes with glibc and the installer doesn't rely on glibc), but I will try

well I wouldn't be surprised if the games I tested had poor alsa support, it's just puzzling how McOsu works perfectly, maybe the sound library it uses (bass iirc) just has a better alsa implementation

I will try to come up with more tests, lemme know if you can think of anything else

@Francesco149
Copy link
Author

just set up a 32-bit glibc chroot with steam and sound works fine for Hotline Miami, so I don't think it's an issue with the game's ALSA support

seeing how McOsu had nil as a default device in flatpak steam, this leads me to believe that there's something wrong with the default device when pulse is missing

@Francesco149
Copy link
Author

I just noticed, /dev/snd seems to be owned by "nfsnobody" inside the flatpak, is that normal?

 $ flatpak run --command=ls com.valvesoftware.Steam -l /dev/snd
total 0
drwxr-xr-x 2 nfsnobody nfsnobody      80 Jul 17 13:52 by-id
drwxr-xr-x 2 nfsnobody nfsnobody     120 Jul 17 13:52 by-path
crw-rw---- 1 nfsnobody nfsnobody 116,  9 Jul 17 13:52 controlC0
crw-rw---- 1 nfsnobody nfsnobody 116,  2 Jul 17 13:52 controlC1
crw-rw---- 1 nfsnobody nfsnobody 116, 14 Jul 17 13:52 controlC2
crw-rw---- 1 nfsnobody nfsnobody 116, 16 Jul 17 13:52 controlC3
crw-rw---- 1 nfsnobody nfsnobody 116, 11 Jul 17 13:55 pcmC0D0c
crw-rw---- 1 nfsnobody nfsnobody 116, 10 Jul 17 14:29 pcmC0D0p
crw-rw---- 1 nfsnobody nfsnobody 116, 12 Jul 17 13:52 pcmC0D1p
crw-rw---- 1 nfsnobody nfsnobody 116, 13 Jul 17 13:52 pcmC0D2c
crw-rw---- 1 nfsnobody nfsnobody 116,  7 Jul 17 13:52 pcmC1D10p
crw-rw---- 1 nfsnobody nfsnobody 116,  8 Jul 17 13:52 pcmC1D11p
crw-rw---- 1 nfsnobody nfsnobody 116,  3 Jul 17 13:52 pcmC1D3p
crw-rw---- 1 nfsnobody nfsnobody 116,  4 Jul 17 13:52 pcmC1D7p
crw-rw---- 1 nfsnobody nfsnobody 116,  5 Jul 17 13:52 pcmC1D8p
crw-rw---- 1 nfsnobody nfsnobody 116,  6 Jul 17 13:52 pcmC1D9p
crw-rw---- 1 nfsnobody nfsnobody 116, 15 Jul 17 13:52 pcmC2D0c
crw-rw---- 1 nfsnobody nfsnobody 116, 18 Jul 17 13:52 pcmC3D0c
crw-rw---- 1 nfsnobody nfsnobody 116, 17 Jul 17 13:52 pcmC3D0p
crw-rw---- 1 nfsnobody nfsnobody 116,  1 Jul 17 13:52 seq
crw-rw---- 1 nfsnobody nfsnobody 116, 33 Jul 17 13:52 timer

@nanonyme
Copy link
Collaborator

Flatpak spec says Pulseaudio is expected on target platforms and Flatpak authors are encouraged to rely on it FWIW

@TingPing
Copy link
Member

Pulseaudio will be sandboxable at some point, so yea it is certainly recommended. This specific flatpak does pass all devices through though so this usage of alsa should work in that case. Might be worth discussing in the flatpak/flatpak repo.

@nanonyme
Copy link
Collaborator

@TingPing I meant as the spec expects PA, submitter is expected to run into issues with other flatpaks later even if Steam flatpak can be made to work without.

@Francesco149
Copy link
Author

looking forward to sandboxed pulseadio! :)

but yeah, since audio works fine from a regular glibc chroot with steam and no pulseaudio, there's probably a way to fix this flatpak. I still haven't found any more clues as to what could be wrong other than somehow incorrect default device.

@nanonyme
Copy link
Collaborator

Just in case there might be some id/gid peculiarities with regards to the sandbox, I'd personally try to run id inside and outside the sandbox to make sure you are who you think you are

@Francesco149
Copy link
Author

uid and gid appear to be right

$ flatpak run --command=id com.valvesoftware.Steam 
uid=1000(loli) gid=1000(loli) groups=1000(loli),65534(nfsnobody)
$ id
uid=1000(loli) gid=1000(loli) groups=3(tty),4(kvm),7(video),8(audio),10(users),1000(loli)

in the manual glibc chroot I had to change audio gid (it's 8 on my host system which did not match) to get audio working, but flatpak doesn't seem to have an audio group so it should be fine

@Francesco149
Copy link
Author

is there any easy way to get alsa-utils inside the flatpak so I can do aplay -l and speaker-test?

@nanonyme
Copy link
Collaborator

@Francesco149 except apparently inside the flatpak you belong into group nfsnobody which incidentally has write access to the devices.

@nanonyme
Copy link
Collaborator

@Francesco149 there were some workarounds added for ALSA, can you please retest?

@dariox86
Copy link

I experience the same issue with the latest version. Without PulseAudio there is no sound for video playback inside the Steam client and Proton games simply crash. Installing PulseAudio everything works as expected, but I would like to be able to use it without PulseAudio.

@nanonyme
Copy link
Collaborator

nanonyme commented Jun 6, 2019

Note for sandboxing since the comments here are quite obsolete: PipeWire is the sandbox-friendly soluton which is likely to replace PulseAudio and Jack and will provide low-latency sound. It's not here yet though, it will apparently first do Jack compat.

@amak79
Copy link

amak79 commented Jun 15, 2020

Does flatpak/flatpak#3663 resolve this issue?

@dariox86
Copy link

Maybe I am missing something. It does not work for me. I have built and installed Flatpak 1.7.3 from sources and uninstalled Pulseaudio. I have issued the following command:
$ flatpak --user override --device=snd com.valvesoftware.Steam
I got: "error: Unknown device type snd, valid types are: dri, all, kvm, shm".
Then I tried with:
$ flatpak --user override --device=all com.valvesoftware.Steam
I get no sound without Pulseaudio whatever I do.

@amak79
Copy link

amak79 commented Jun 16, 2020

From my understanding of this change, an application that has access to PulseAudio (which com.valvesoftware.Steam has) is now also given access to the ALSA device. You shouldn't need to override access to any resources.

Unfortunately I don't have Flatpak 1.7.3 yet so I'm unable to test it.

@dariox86
Copy link

Let me know if it works for you.

@amak79
Copy link

amak79 commented Jun 26, 2020

It doesn't work with Flatpak 1.8.0.

[0626/165033.782532:WARNING:audio_manager_linux.cc(52)] Falling back to ALSA for audio output. PulseAudio is not available or could not be initialized.
ALSA lib ../../pulse/pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

[0626/165033.795602:ERROR:alsa_util.cc(204)] PcmOpen: default,Connection refused
ALSA lib ../../src/dlmisc.c:170:(snd_dlsym_verify) unable to verify version for symbol _snd_pcm_plug_open
ALSA lib ../../src/dlmisc.c:295:(snd1_dlobj_cache_get) symbol _snd_pcm_plug_open is not defined inside [builtin]
[0626/165033.795750:ERROR:alsa_util.cc(204)] PcmOpen: plug:default,No such device or address

@amak79
Copy link

amak79 commented Jun 27, 2020

I got it to work by copying the system ALSA config file to the app data directory.

$ cp /usr/share/alsa/alsa.conf ~/.var/app/com.valvesoftware.Steam/.asoundrc

This also works with Flatpak 1.6.x.

@dariox86
Copy link

I got it to work by copying the system ALSA config file to the app data directory.

$ cp /usr/share/alsa/alsa.conf ~/.var/app/com.valvesoftware.Steam/.asoundrc

This also works with Flatpak 1.6.x.

It is not working for me. I don't know if this is related, but in /etc/modprobe.d/alsa-base.conf I need the following line to have sound working on a pure ALSA system:
options snd_hda_intel index=1,0

@amak79
Copy link

amak79 commented Jun 27, 2020

I'm not sure. I build my kernel with the modules built-in.

If you haven't done so already, run Steam from the terminal then watch the output for any clues as to why it doesn't work.

@ony
Copy link

ony commented Jul 12, 2020

@amak79 org.freedesktop.Platform indeed sets up /etc/alsa/conf.d/99-pulseaudio-default.conf which override ALSA default output to use pulse. Unfortunately putting ~/.var/app/com.valvesoftware.Steam/.asoundrc with:

pcm.!default cards.pcm.default

Did not helped me. As well as figuring out with findmnt location of that 99-pulseaudio-default.conf and commenting out everything there (works for host system though).
(flatpak v1.6.3)

It is weird that I've got this issue after recent update of host ALSA libs to v1.2.3.2 and then updating Flatpak. I think I have alsa-lib v1.1.9 for runtime/org.freedesktop.Platform/x86_64/19.08 v19.08.12.
What I noticed as well is that my host system uses dmix. I.e. aplay -D plug:hw fails with "resource busy" on host, but aplay -D plug:pcm.dmix works.

Also I found flatpak/flatpak#3593 which was closed with saying that dmix is not supported. If I understood correctly it would require tight ABI compatibility between ALSA libs in sandbox and host. I suspect that closing all apps from lsof /dev/snd/* will helps running Steam with sound.

@amak79
Copy link

amak79 commented Jul 13, 2020

@ony
I only copied the unmodified host ALSA config to the app data directory. The host ALSA config on my system is installed by alsa-lib 1.2.2. The idea of copying the host ALSA config came from here: https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/issues/857#note_277403747.

Running aplay -D plug:hw or aplay -D plug:pcm.dmix works for me. I can only assume that your host ALSA setup differs from mine.

@EchedelleLR
Copy link

EchedelleLR commented Jul 19, 2021

I know this thread has some time but, since I am having the same issues with Flatpak applications in general in a pure ALSA system, I want to ask if this have been reported to upstream or similar being either Flatpak itself or Flathub.

@EchedelleLR
Copy link

I think that the main issue to be pointed is https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/issues/1135 which is in the org.freedesktop.Platform development repository.

@dariox86
Copy link

I was randomly thinking about this longstanding issue just minutes before you commented on this. Telepathy. 😄

@nanonyme
Copy link
Collaborator

nanonyme commented Sep 1, 2021

@dariox86 the hilarious bit here is I originally commented at the beginning of thread that this will probably become non-issue because PulseAudio will be so prevalent. It has now been prevalent for many many years, yet people seem to try to get games running on pure ALSA systems...

@EchedelleLR
Copy link

People with custom settings, WMs and alternative desktop environments such as TDE (which use aRTS which is other sound server) will have to rely always on ALSA.

@nanonyme
Copy link
Collaborator

nanonyme commented Sep 1, 2021

Right. And on those systems I'm expecting this app will continue being a hit or miss when it comes to sound.

@EchedelleLR
Copy link

EchedelleLR commented Sep 1, 2021

This bug also affect some other apps.

It is common to be exact.

I am just here because of that. Not a Steam user.

Any FlatHub application which needs sound that I use, is without sound.

@nanonyme
Copy link
Collaborator

nanonyme commented Sep 1, 2021

Sure. Any further comments please to https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/issues/1135 though.

@dariox86
Copy link

dariox86 commented Sep 1, 2021

@nanonyme, I think many do not need PulseAudio at all. For me everything works just fine on pure ALSA with no additional layer.

@flathub flathub locked and limited conversation to collaborators Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants