just_playback icon indicating copy to clipboard operation
just_playback copied to clipboard

ALSA dmix error on Linux sudo when non-root user uses ALSA

Open Chasyxx opened this issue 4 months ago • 5 comments

Arch linux x86_64. Pulseaudio and pulseaudio-alsa.

By running the test code from #12 as sudo, stderror logs

ALSA lib pcm_dmix.c:1000:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1000:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1000:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1000:(snd_pcm_dmix_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock

and no sound plays. I do not use jack.

Chasyxx avatar Feb 26 '24 06:02 Chasyxx

I did some more testing, and managed to find out that when a non-root user starts using ALSA, running the script as sudo runs into the errors from then on using the TTY/VT that the user's audio played on. This issue was first found here on another repo, where a different library needs you to use sudo.

Chasyxx avatar Feb 26 '24 07:02 Chasyxx

Hi @Chasyxx,

What happens if your run the example as a non-root user?

cheofusi avatar Feb 26 '24 07:02 cheofusi

What happens if your run the example as a non-root user?

The script always seems to work without running into the errors if i don't run with sudo

Chasyxx avatar Feb 26 '24 10:02 Chasyxx

For clarification, when a non-root user runs the script, from that point on- even if python is closed- running the script again with sudo runs into the ALSA errors and the sound doesn't actually play. I did upgrade my arch system today, and i did recently install this package into my venv, so i don't think an out of date program or library is the issue.

% uname -vorm
6.7.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 23 Feb 2024 16:31:48 +0000 x86_64 GNU/Linux

Chasyxx avatar Feb 26 '24 10:02 Chasyxx

Running into the same issue, however I can't ever get audio to play myself

Scattered-Faith avatar Mar 10 '24 00:03 Scattered-Faith