apulse icon indicating copy to clipboard operation
apulse copied to clipboard

apulse can't open playback device when alsaequal is used

Open worldowner opened this issue 8 years ago • 18 comments

I use alsaequal (https://aur.archlinux.org/packages/alsaequal/) to have system-wide alsa equalizer.

Configuration is simple:

$ cat .asoundrc ctl.equal { type equal; }

pcm.plugequal { type equal; slave.pcm "plug:dmix";
}

pcm.!default { type plug; slave.pcm plugequal; }

It doesn't work with apulse:

$ apulse firefox [apulse] [error] do_connect_pcm: can't open playback device "default". Error code -1 (Permission deined) [apulse] [error] do_connect_pcm: failed to open ALSA device. Apulse does no resampling or format conversion, leaving that task to ALSA plugins. Ensure that selected device is capable of playing a particular sample format at a particular rate. They have to be supported by either hardware directly, or by "plug" and "dmix" ALSA plugins which will perform required conversions on CPU.

I think that sample rate of a signal sent to equalizer doesn't matter. After equalizer does its job signal is sent further to dmix which handles conversion.

worldowner avatar Jun 16 '17 10:06 worldowner

$ APULSE_PLAYBACK_DEVICE=plugequal apulse firefox

Worked for me until I did a system upgrade.*

SoniEx2 avatar Jun 19 '17 17:06 SoniEx2

until I did a system upgrade

Hmm.

@worldowner, @SoniEx2, have you tried to set "security.sandbox.content.write_path_whitelist" parameter (on about:config page) to "/dev/snd/"?

i-rinat avatar Jun 19 '17 18:06 i-rinat

I did.

Right after the system upgrade, I was getting EACCES (-13 I think), then I set that, now I'm getting EPERM (-1) [apulse] [error] do_connect_pcm: can't open playback device "plugequal". Error code -1 (Operation not permitted)...

SoniEx2 avatar Jun 19 '17 18:06 SoniEx2

This seems to only happen with firefox...

SoniEx2 avatar Jun 19 '17 21:06 SoniEx2

Added all these to security.sandbox.content.write_path_whitelist:

/dev/snd/,/usr/share/alsa/alsa.conf,/usr/share/alsa/cards/,/usr/share/alsa/pcm/,/etc/asound.conf,/usr/share/alsa/alsa.conf.d/,/usr/lib/alsa-lib/libasound_module_pcm_equal.so,/home/soniex2/.alsaequal.bin,/home/soniex2/.asoundrc

And it worked. Sadly no way to filter write path whitelist and read-only path whitelist so this risks my asoundrc...

SoniEx2 avatar Jun 20 '17 01:06 SoniEx2

Before sandbox Firefox had rw access to all the files that your user has. So it's still better. If your're concerned about your files just run Firefox in container. I run it in LXC and works fine.

worldowner avatar Jun 20 '17 07:06 worldowner

Sadly no way to filter write path whitelist and read-only path whitelist so this risks my asoundrc...

@SoniEx2, as far as I understand, that particular sandbox in Firefox allows accesses to all files for reading. And you only need add paths which need to be writable to the exception list. So, maybe "/dev/snd/,/home/soniex2/.alsaequal.bin" would be enough?

i-rinat avatar Jun 20 '17 10:06 i-rinat

Nope. I had to add my asoundrc or else it wouldn't work.

SoniEx2 avatar Jun 20 '17 13:06 SoniEx2

I would like to say that I'm in (very up-to-date) arch using dmix+alsaequal+plug and apulse works out of the box with latest firefox, no need to tweak any settings. Has anything changed since you last discussed about this?

memeplex avatar Jul 09 '17 05:07 memeplex

Also notice alsa is not enabled https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/firefox.

memeplex avatar Jul 09 '17 05:07 memeplex

@memeplex Please visit about:support and tell me what you see under Application Basics -> Multiprocess Windows.

Edit: Also tell me what you see under Sandbox.

SoniEx2 avatar Jul 09 '17 15:07 SoniEx2

Sure @SoniEx2

Multiprocess Windows 	0/1 (Disabled by add-ons)

Sandbox
---
Seccomp-BPF (System Call Filtering)	true
Seccomp Thread Synchronization	true
User Namespaces	false
Content Process Sandboxing	true
Media Plugin Sandboxing	true
Content Process Sandbox Level	2

memeplex avatar Jul 09 '17 16:07 memeplex

@memeplex sandbox doesn't work if multiprocess windows is disabled.

SoniEx2 avatar Jul 09 '17 16:07 SoniEx2

You're right @SoniEx2. It was an autoreload addon that was disabling multiprocess windows. Now that I have paused that addon I get not sound anymore. I have set the sandbox whitelist to

  • /dev/snd
  • /usr/share/alsa
  • /usr/lib/alsa-lib
  • /etc/asound.conf (not in my system anyway)
  • /home/carlos/.alsaequal.bin
  • /home/carlos/.asoundrc

but to no avail...

memeplex avatar Jul 09 '17 16:07 memeplex

needs to be /dev/snd/, /usr/share/alsa/ and same for alsa-lib.

SoniEx2 avatar Jul 09 '17 16:07 SoniEx2

Ahh, ok, shame on me. By trial and error I concluded that I just need to add

  • /dev/snd/
  • /home/carlos/.alsaequal.bin

to get it working. In particular, there was no need of adding ~/.asoundrc.

memeplex avatar Jul 09 '17 16:07 memeplex

Today I tried on Ubuntu Xenial:

ALSA lib dlmisc.c:254:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_equal.so [apulse] [error] do_connect_pcm: can't open playback device "default". Error code -6 (No such device or address)

The library exists: $ ls /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_equal.so /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_equal.so

Any ideas?

worldowner avatar Aug 16 '17 09:08 worldowner

I currently get exactly the same two pulseaudio log lines when trying to load module-alsa-sink for an alsaequal device on 18.04.3. The library exists, ldd shows no missing libs and arch matches, so I have no idea why it doesn't load. It works from other alsa programs, like aplay and mpd.

eisnerd avatar Nov 24 '19 15:11 eisnerd