i-rinat / apulse

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

apulse with firefox 68.6.esr (devuan) #109

Open mrkapqa opened 4 years ago

mrkapqa commented 4 years ago

Hello ,

i am trying to use the site

www.gaia.com

on my desktop computer with devuan linux. i have uninstalled pulseaudio and the distro should now be alsa-only.

when invoking

apulse firefox

i get the following outcome

when trying to visit the site for video/audio playback

[Parent 12543, Gecko_IOThread] WARNING: pipe error: Broken pipe: file /build/firefox-esr-MzCYU7/firefox-esr-68.6.0esr/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 727
[apulse] [error] do_connect_pcm: can't set sample format 14 ("FLOAT_LE") for playback device "default". Error code -22 (Invalid argument)
[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.
[Child 12599, MediaPlayback #3] WARNING: 7fe728d35bb0 OpenCubeb() failed to init cubeb: file /build/firefox-esr-MzCYU7/firefox-esr-68.6.0esr/dom/media/AudioStream.cpp, line 382
[Child 12599, MediaPlayback #3] WARNING: Decoder=7fe723749200 [OnMediaSinkAudioError]: file /build/firefox-esr-MzCYU7/firefox-esr-68.6.0esr/dom/media/MediaDecoderStateMachine.cpp, line 3639
[apulse] [error] do_connect_pcm: can't open playback device "default". Error code -16 (Device or resource busy)
[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.
[Child 12599, MediaPlayback #3] WARNING: 7fe715fd7ef0 OpenCubeb() failed to init cubeb: file /build/firefox-esr-MzCYU7/firefox-esr-68.6.0esr/dom/media/AudioStream.cpp, line 382
[Child 12599, MediaPlayback #3] WARNING: Decoder=7fe723749200 [OnMediaSinkAudioError]: file /build/firefox-esr-MzCYU7/firefox-esr-68.6.0esr/dom/media/MediaDecoderStateMachine.cpp, line 3639
mrkapqa commented 4 years ago

/etc/asound.conf

pcm.!default {
    type hw
    card 1
}

ctl.!default {
    type hw           
    card 1
}
i-rinat commented 4 years ago

As error message said,

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.

In your case, custom ALSA configuration wires "default" device to the hw device without plug and dmix plugins. So when apulse, which is an ALSA client, tries to open "default" device with some parameters, hardware driver says that these parameters are not supported. It's typical for the simple embedded audio adapters to support, say, only 48000 Hz. It relies on the host software to resample audio to fit supported sampling rates. Same with sample formats. As far as I know, Firefox likes to output FLOAT32LE, while simple audio adapters usually support only 16-bit signed (S16LE).

As for the fixing it, you have several options: 1) use default ALSA configuration. It uses dmix and plug since about 2005. Most probably your ALSA version is recent enough to have them enabled by default; 2) enhance your custom configuration to use dmix and plug for mixing and resampling; 3) use a hardware audio adapter which supports wide range of sampling rates and formats.

Any of the three should suffice.

mrkapqa commented 4 years ago

Thank you very much for your help!

Could resolve this by deleting /etc/asound.conf and then fixing the sound card order so that the right soundcard gets loaded into alsa. https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture#Set_the_default_sound_card

mrkapqa commented 4 years ago

then there was no need for apulse for my use-case anymore. however, there are some flatpak apps that seem to rely on pulseaudio. could i use apulse for those aswell?

i-rinat commented 4 years ago

flatpak apps could i use apulse for those aswell?

As far as I know, it's not possible. Flatpak and other containerized app technologies tend to isolate apps. Moreover, they run in a different file tree, so even if one manages to pass LD_LIBRARY_PATH into the container itself, there are no libpulse.so.0 from apulse to load, since that library is in the host filesystem.

However, if one bundles apulse libraries when application is packaged, it may work. But then, if you are building application anyway, why not to enable ALSA in it directly?

Snow-W commented 4 years ago

I am also having an issue. When I updated from Firefox 60.x-esr to 68.6.0-esr, Firefox is not detecting the sound input device. This worked fine before updating. Did not update anything else. Sound input device is still detected by Audacity and works.

When I tried https://www.onlinemictest.com/ Firefox did not ask me for permission to access the input device. Also, the test claimed there was no input device.

A Mozilla person says this must be an incompatibility in apulse.

Is there a way to make this work or do I need to install PulseAudio?

Installed apulse is 0.1.12 Audio device is Device-1: Intel 82801I HD Audio driver: snd_hda_intel Linux kernel is 4.9.193-amd64-smp

i-rinat commented 4 years ago

When I updated from Firefox 60.x-esr to 68.6.0-esr, Firefox is not detecting the sound input device.

I've just tried to run Firefox 68.6.0-esr (binary from https://ftp.mozilla.org) with apulse 0.1.12, and found no issues with audio playback. Microphone on https://www.onlinemictest.com/ is also detected, and I can clearly see waveforms appear in the sample box when I speak to the microphone. So, can't reproduce.

Is there a way to make this work or do I need to install PulseAudio?

Sorry, can't say anything definite about that. If PulseAudio works, why not?