soloud icon indicating copy to clipboard operation
soloud copied to clipboard

Fails when running with sudo

Open andrewdavidmackenzie opened this issue 2 months ago • 2 comments

Expected behavior:

soloud (via rust wrappings) loads and runs normally. This is the case when run as a normal user (on raspberry pi).

However, it fails when run using sudo

Actual behavior:

RUST_BACKTRACE=1 sudo ./ringr 
ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1075:(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
thread 'main' panicked at src/main.rs:44:32:
Could not get Soloud: Internal(UnknownError)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Steps to reproduce the problem:

On PiOs (and I assume on other Linux, but can't be sure...), have a short program that loads SoLoud and speaks or plays a sound, and run it using sudo.

SoLoud version, operating system, backend used, any other potentially useful information:

uname -a
Linux pizero2w0 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux

soloud = { version = "1" } resolves thus in Cargo.lock:

[[package]]
name = "soloud"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40cbdc64b205d53f861657923d4f94bd56ffa81e11b8ad920ac79447ececb47"
dependencies = [
 "bitflags",
 "paste",
 "soloud-sys",
]

Based on the error, I'm guessing that it's the loading of the original lib that is the source of the issue, and that's it's not the rust wrapper, hence I'm reporting here not https://github.com/MoAlyousef/soloud-rs

andrewdavidmackenzie avatar Apr 21 '24 17:04 andrewdavidmackenzie

Googling meanwhile....

I wondered if this behaviour is affected by the contents of /etc/security/limits.conf?

andrewdavidmackenzie avatar Apr 21 '24 18:04 andrewdavidmackenzie

Could be related to this: https://unix.stackexchange.com/questions/231941/cant-run-aplay-as-root

I've often had trouble playing audio as root, and it seems to be due either to the environment or how the audio server is setup per-user.

nmielcarek avatar Apr 22 '24 17:04 nmielcarek