ALSA equalizer not working Topic is solved

Having issues with your DietPi installation or found a bug? Post it here.
shao
Posts: 11
Joined: Sun May 23, 2021 9:27 am

Re: ALSA equalizer not working

Post by shao »

Nope that's hw 1,0 but i've been aware of that and made the change.

Tried to delete that channels thing and add default to raspotify. No progress.

With
OPTIONS=--device hw:1,0
i have sound again but it bypass eq obviously...
shao
Posts: 11
Joined: Sun May 23, 2021 9:27 am

Re: ALSA equalizer not working

Post by shao »

Hi again,
Here is journactl return.
Some permission trouble ?

Code: Select all

DietPi librespot[6260]: [2021-05-26T13:02:42Z ERROR librespot_playback::audio_backend::alsa] Alsa error PCM open ALSA function 'snd_pcm_open' failed with error 'EPERM: Opera
tion not permitted'
mai 26 15:02:42 DietPi librespot[6260]: [2021-05-26T13:02:42Z ERROR librespot_playback::player] Could not start audio: Alsa error: PCM open failed
mai 26 15:02:42 DietPi librespot[6260]: [2021-05-26T13:02:42Z ERROR librespot_playback::audio_backend::alsa] Alsa error PCM open ALSA function 'snd_pcm_open' failed with error 'EBUSY: Devic
e or resource busy'
mai 26 15:02:42 DietPi librespot[6260]: [2021-05-26T13:02:42Z ERROR librespot_playback::player] Could not start audio: Alsa error: PCM open failed
mai 26 15:02:42 DietPi librespot[6260]: [2021-05-26T13:02:42Z ERROR librespot_playback::audio_backend::alsa] Alsa error PCM open ALSA function 'snd_pcm_open' failed with error 'EBUSY: Devic
e or resource busy'
mai 26 15:02:42 DietPi librespot[6260]: [2021-05-26T13:02:42Z ERROR librespot_playback::player] Could not start audio: Alsa error: PCM open failed
mai 26 15:02:42 DietPi librespot[6260]: thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', playback/src/audio_backend/alsa.rs:138:45
mai 26 15:02:42 DietPi librespot[6260]: stack backtrace:
mai 26 15:02:42 DietPi librespot[6260]:    0:   0x8c2278 - std::backtrace_rs::backtrace::libunwind::trace::h9c6af82ecb947420
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/../../backtrace/src/backtrace/libunwind.rs:96
mai 26 15:02:42 DietPi librespot[6260]:    1:   0x8c2278 - std::backtrace_rs::backtrace::trace_unsynchronized::h80561bf66e637b12
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/../../backtrace/src/backtrace/mod.rs:66
mai 26 15:02:42 DietPi librespot[6260]:    2:   0x8c2278 - std::sys_common::backtrace::_print_fmt::h8904fddc87bf6b5e
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:79
mai 26 15:02:42 DietPi librespot[6260]:    3:   0x8c2278 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc883ceb7a13219f2
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:58
mai 26 15:02:42 DietPi librespot[6260]:    4:   0x8ea290 - core::fmt::write::ha75209c8e86bef45
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/fmt/mod.rs:1080
mai 26 15:02:42 DietPi librespot[6260]:    5:   0x8bae18 - std::io::Write::write_fmt::h4cce8be81a41c537
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/io/mod.rs:1516
mai 26 15:02:42 DietPi librespot[6260]:    6:   0x8c51c0 - std::sys_common::backtrace::_print::hdc9e28891c09ab0b
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:61
mai 26 15:02:42 DietPi librespot[6260]:    7:   0x8c51c0 - std::sys_common::backtrace::print::h85895381379b4dc1
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:48
mai 26 15:02:42 DietPi librespot[6260]:    8:   0x8c51c0 - std::panicking::default_hook::{{closure}}::h6b4de484f2428118
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:208
mai 26 15:02:42 DietPi librespot[6260]:    9:   0x8c4dbc - std::panicking::default_hook::h3966366a200b03f1
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:227
mai 26 15:02:42 DietPi librespot[6260]:   10:   0x8c5910 - std::panicking::rust_panic_with_hook::h068b5368b0949ced
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:577
mai 26 15:02:42 DietPi librespot[6260]:   11:   0x8c54c4 - std::panicking::begin_panic_handler::{{closure}}::hde463ebfc6f96538
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:484
mai 26 15:02:42 DietPi librespot[6260]:   12:   0x8c27f8 - std::sys_common::backtrace::__rust_end_short_backtrace::hb945924c40726c97
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys_common/backtrace.rs:153
mai 26 15:02:42 DietPi librespot[6260]:   13:   0x8c547c - rust_begin_unwind
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
mai 26 15:02:42 DietPi librespot[6260]:   14:   0x8e7960 - core::panicking::panic_fmt::h27b19d6e6dedd33e
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
mai 26 15:02:42 DietPi librespot[6260]:   15:   0x8e78bc - core::panicking::panic::h2a6f9b05d102de10
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:50
mai 26 15:02:42 DietPi librespot[6260]:   16:   0x54e020 - <librespot_playback::audio_backend::alsa::AlsaSink as librespot_playback::audio_backend::Sink>::write::hfb124b87fed1cc15
mai 26 15:02:42 DietPi librespot[6260]:   17:   0x52b304 - <librespot_playback::player::PlayerInternal as futures::future::Future>::poll::he6e04a5bccf94e34
mai 26 15:02:42 DietPi librespot[6260]:   18:   0x48f300 - futures::task_impl::std::set::hab1c1811473e3998
mai 26 15:02:42 DietPi librespot[6260]:   19:   0x485838 - std::sys_common::backtrace::__rust_begin_short_backtrace::h8286c5a0fd04a387
mai 26 15:02:42 DietPi librespot[6260]:   20:   0x4a04f4 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h76e6c7604d7daced
mai 26 15:02:42 DietPi librespot[6260]:   21:   0x8cc940 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h6b7ad05f87ff90ae
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
mai 26 15:02:42 DietPi librespot[6260]:   22:   0x8cc940 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::he9130e675b8d97ee
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042
mai 26 15:02:42 DietPi librespot[6260]:   23:   0x8cc940 - std::sys::unix::thread::Thread::new::thread_start::h7a3f6590d8e03e95
mai 26 15:02:42 DietPi librespot[6260]:                        at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/sys/unix/thread.rs:87
User avatar
MichaIng
Site Admin
Posts: 2987
Joined: Sat Nov 18, 2017 6:21 pm

Re: ALSA equalizer not working

Post by MichaIng »

--device hw:1,0 bypasses the equalizer indeed, as this is the name of the final raw PCM. With equalizer enabled, audio should go this way:

Code: Select all

Source => plug software conversion ("default") => equalizer ("eq") => plug software conversion => PCM ("hw:1,0")
When you use "hw:1,0", it's:

Code: Select all

Source => PCM ("hw:1,0")
:)

I see many "resource busy" logs, like multiple players try to concurrently access the audio device, while by default ALSA allows only one connection at a time, blocking the others. Probably "stopping" the audio stream and starting it again is somehow too much delayed, overlapping or so.

But also "'snd_pcm_open' failed with error 'EPERM: Operation not permitted'". The raspotify user is member of the "audio" group, right?

Code: Select all

groups raspotify
else

Code: Select all

usermod -aG audio raspotify
shao
Posts: 11
Joined: Sun May 23, 2021 9:27 am

Re: ALSA equalizer not working

Post by shao »

Yup Raspotify is in audio group .

Don't really know where to look now.

Anychance with dmix ?

I tried that : https://linustechtips.com/topic/1137168 ... raspotify/

But just like you said for putting hw1 into raspotify conf, it bypass eq if i undestand asound.conf.

I tried to adapt that procedure with plugequal part but with no success cause i'm not good with that :D .
User avatar
MichaIng
Site Admin
Posts: 2987
Joined: Sat Nov 18, 2017 6:21 pm

Re: ALSA equalizer not working

Post by MichaIng »

The dmix plugin indeed allows multiple players to play audio concurrently, hence should solve the "device busy" error. I personally would have a look into why Raspotify alone does concurrent audio device accesses, as it is/should be a single application player, but let's see if dmix does the magic when adding it after the final hardware PCM. The "dmix:1,0" is one of the pre-defined PCMs, which is a dmix stage with a hw slave one card 1 device 0.

Code: Select all

cat << '_EOF_' > /etc/asound.conf
pcm.!default {
	type plug
	slave.pcm {
		type equal
		slave.pcm {
			type plug
			slave.pcm "dmix:1,0"
		}
		controls "/var/lib/dietpi/dietpi-config/.alsaequal.bin"
	}
}
ctl.eq {
	type equal
	controls "/var/lib/dietpi/dietpi-config/.alsaequal.bin"
}
ctl.!default {
	type hw
	card 1
}
_EOF_
shao
Posts: 11
Joined: Sun May 23, 2021 9:27 am

Re: ALSA equalizer not working

Post by shao »

Too bad the magic didn't happen.

Code: Select all

 Alsa error PCM open ALSA function 'snd_pcm_open' failed with error 'EPERM: Opera
tion not permitted'
User avatar
MichaIng
Site Admin
Posts: 2987
Joined: Sat Nov 18, 2017 6:21 pm

Re: ALSA equalizer not working

Post by MichaIng »

Just to rule it our, please try:

Code: Select all

chmod 0666 /var/lib/dietpi/dietpi-config/.alsaequal.bin
chmod 0775 /var/lib/dietpi/dietpi-config /var/lib/dietpi
shao
Posts: 11
Joined: Sun May 23, 2021 9:27 am

Re: ALSA equalizer not working

Post by shao »

Love you man.

It works now. Even with default justboom script ( so without dmix)

Just a strange thing : equalizer is on but appears off in justboom and i can't acces eq menu. If i launch alsamixer -D eq, menu is here and changes affect sound just like it's suppose to.
User avatar
MichaIng
Site Admin
Posts: 2987
Joined: Sat Nov 18, 2017 6:21 pm

Re: ALSA equalizer not working

Post by MichaIng »

Auuu, you're right, the equalizer status is not detected correctly. This should fix it: https://github.com/MichaIng/DietPi/pull/4448/files

Good that it works now. So I guess that either /var/lib/dietpi/dietpi-config or /var/lib/dietpi had permissions that didn't allow users other than root and dietpi from reading the content. I think we set it that way a whole ago. Just to be sure:

Code: Select all

chmod 0644 /var/lib/dietpi/dietpi-config/.alsaequal.bin
This does not break it, right? Just to rule out that Raspotify is trying to change something at the control/mixer device.
shao
Posts: 11
Joined: Sun May 23, 2021 9:27 am

Re: ALSA equalizer not working

Post by shao »

Huhu it does break it !
No sound with 644.
Back with 666, doesn't really know if that is a good thing :lol:
Post Reply