i-rinat / apulse

PulseAudio emulation for ALSA
MIT License
609 stars 35 forks source link

apulse can't open playback device when alsaequal is used #55

Open worldowner opened 7 years ago

worldowner commented 7 years ago

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.

SoniEx2 commented 7 years ago
$ APULSE_PLAYBACK_DEVICE=plugequal apulse firefox

Worked for me until I did a system upgrade.*

i-rinat commented 7 years ago

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/"?

SoniEx2 commented 7 years ago

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 commented 7 years ago

This seems to only happen with firefox...

SoniEx2 commented 7 years ago

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...

worldowner commented 7 years ago

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.

i-rinat commented 7 years ago

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?

SoniEx2 commented 7 years ago

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

memeplex commented 7 years ago

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 commented 7 years ago

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

SoniEx2 commented 7 years ago

@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.

memeplex commented 7 years ago

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
SoniEx2 commented 7 years ago

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

memeplex commented 7 years ago

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

but to no avail...

SoniEx2 commented 7 years ago

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

memeplex commented 7 years ago

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

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

worldowner commented 7 years ago

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?

eisnerd commented 5 years ago

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.