View previous topic :: View next topic |
Author |
Message |
NathanZachary Moderator
Joined: 30 Jan 2007 Posts: 2608
|
Posted: Tue Apr 09, 2024 2:33 am Post subject: Firefox, WebRTC, and ALSA playback and capture devices |
|
|
Hello,
For quite some time, I've had to keep Chromium for the single purpose of video calls. I don't use PulseAudio or PipeWire, but instead just ALSA directly. For video calls, I need my output (ALSA playback device) to be one card and my input (ALSA capture device) to be a particular device on my C920 webcam. I thought that I would be able to just create an ~/.asoundrc file for this purpose, but I can't get it to work:
Code: |
pcm.!default {
type asym
playback.pcm {
type hw
card Audio
device 0
}
capture.pcm {
type hw
card C920
device 0
}
}
ctl.!default {
card Audio
device 0
}
|
The names of each "card" are taken from `aplay -L` and `arecord -L`.
In another incantation of my .asoundrc (that is at least working for the playback), I use the same "card" definitions:
Code: |
$ cat .asoundrc_rear
## Name of rear audio panel per `cat /proc/asound/cards`
defaults.pcm.!card Audio
defaults.pcm.!device 0
defaults.ctl.!card Audio
defaults.ctl.!device 0
|
I would appreciate any suggestions on possible methods of getting this type of configuration working in Firefox so that I can finally be rid of Chromium.
Thank you in advance for any help. _________________ “Truth, like infinity, is to be forever approached but never reached.” --Jean Ayres (1972)
---avatar cropped from =AimanStudio--- |
|
Back to top |
|
|
Dominique_71 Veteran
Joined: 17 Aug 2005 Posts: 1886 Location: Switzerland (Romandie)
|
Posted: Tue Apr 09, 2024 8:48 am Post subject: |
|
|
With multiple sound cards, in order to be sure to get the same card between reboot, the best practice is to define the card order in /etc/modprobe.d/alsa.conf, as example:
Code: | options snd-intel index=0
options snd-usb-audio index=1
options snd slots=snd-hda-intel,usb-audio |
After that, You can use the card numbers into ~/.asoundrc:
Code: | pcm.!default {
type asym
playback.pcm {
type hw
card 0
device 0
}
capture.pcm {
type hw
card 1
device 0
}
}
ctl.!default {
card 0
device 0
} |
To find the existing card index:
Code: | cat /proc/asound/cards |
_________________ "Confirm You are a robot." - the singularity |
|
Back to top |
|
|
NathanZachary Moderator
Joined: 30 Jan 2007 Posts: 2608
|
Posted: Tue Apr 09, 2024 5:20 pm Post subject: |
|
|
Thank you for your response. I'm starting to think that Firefox is just stubborn about ALSA.
I have changed my .asoundrc and now I get audio playback in Firefox (and other applications), but Firefox still uses 'default' for my microphone instead of the one that is in the C920 webcam:
Code: |
$ cat .asoundrc
## Name of rear audio panel per `cat /proc/asound/cards`
defaults.pcm.!card Audio
defaults.pcm.!device 0
defaults.ctl.!card Audio
defaults.ctl.!device 0
## Name of webcam microphone per `cat /proc/asound/cards`
defaults.pcm.dsnoop.!card C920
defaults.pcm.dsnoop.!device 0
|
So, this is progress, but without the microphone during a video call, I'm stuck with Chromium. I'm hopeful that there may be some way to get Firefox to honour the default capture device here.
Thanks for any suggestions. _________________ “Truth, like infinity, is to be forever approached but never reached.” --Jean Ayres (1972)
---avatar cropped from =AimanStudio--- |
|
Back to top |
|
|
NathanZachary Moderator
Joined: 30 Jan 2007 Posts: 2608
|
Posted: Wed Apr 10, 2024 4:06 am Post subject: |
|
|
Sadly, I'm starting to think that it may not be possible to get direct ALSA to work for my needs. I have tried various .asoundrc configurations but to no avail; I have audio playback but no input via my webcam microphone. I may have to admit defeat and go the route of:
1. Install media-sound/apulse with the 'sdk' USE flag
2. Rebuild Firefox with the 'pulseaudio' USE flag enabled
It looks like doing so in that order will allow Firefox to build against apulse instead of actually pulling in a full PulseAudio installation:
https://gitweb.gentoo.org/repo/gentoo.git/tree/www-client/firefox/firefox-124.0.2.ebuild#n1392
Code: |
if use pulseaudio && has_version ">=media-sound/apulse-0.1.12-r4" ; then
elog "Apulse was detected at merge time on this system and so it will always be"
elog "used for sound. If you wish to use pulseaudio instead please unmerge"
elog "media-sound/apulse."
elog
fi
|
At least that would be better than the new versions of Chromium which require mesa and libva to be built with Wayland support (and apparently PipeWire too):
Code: |
emerge -pv chromium
These are the packages that would be merged, in order:
Calculating dependencies... done!
Dependency resolution took 1.06 s (backtrack: 0/20).
The following USE changes are necessary to proceed:
(see "package.use" in the portage(5) man page for more details)
# required by www-client/chromium-124.0.6367.29::gentoo[vaapi]
# required by chromium (argument)
>=media-libs/libva-2.21.0 wayland
# required by www-client/chromium-124.0.6367.29::gentoo
# required by chromium (argument)
>=media-libs/mesa-24.0.4 wayland
!!! The ebuild selected to satisfy "media-video/pipewire:=" has unmet requirements.
- media-video/pipewire-1.0.4::gentoo USE="X dbus ffmpeg readline ssl v4l -bluetooth -doc -echo-cancel -extra -flatpak -gsettings -gstreamer -ieee1394 -jack-client -jack-sdk -liblc3 -lv2 -man -modemmanager -pipewire-alsa -roc (-selinux) -sound-server (-system-service) -systemd -test -zeroconf" ABI_X86="(64) -32 (-x32)"
The following REQUIRED_USE flag constraints are unsatisfied:
ffmpeg? ( extra )
The above constraints are a subset of the following complete expression:
ffmpeg? ( extra ) bluetooth? ( dbus ) jack-sdk? ( !jack-client ) modemmanager? ( bluetooth ) system-service? ( systemd ) !sound-server? ( !pipewire-alsa ) jack-client? ( dbus )
(dependency required by "www-client/chromium-124.0.6367.29::gentoo[screencast,wayland]" [ebuild])
(dependency required by "chromium" [argument])
|
One last question before I make this change: it seems like going the apulse route will allow for Firefox to build against it. Does that indicate that it can be started normally instead of with `apulse firefox`? I would assume so.
Thanks again. _________________ “Truth, like infinity, is to be forever approached but never reached.” --Jean Ayres (1972)
---avatar cropped from =AimanStudio--- |
|
Back to top |
|
|
Dominique_71 Veteran
Joined: 17 Aug 2005 Posts: 1886 Location: Switzerland (Romandie)
|
Posted: Wed Apr 10, 2024 10:42 am Post subject: |
|
|
I am using firefox with JACK here. It is very easy to make the ALSA applications to work with JACK, what is needed is a configured loopback (kernel module snd_aloop) default ALSA card, and the jack ALSA plugin (media-plugins/alsa-plugins[jack]) with an .asound file configured to archieve that : (ALSA application -> snd_aloop -> jack plugin -> JACK -> ALSA device (sound card)).
Everything just work fine here with that config. My desktop launch cadence at start-up and cadence start JACK, so I have JACK running all the time. In practice that setup archive the same things than pulseaudio, but with the advantages of jack: a professional sound server with constant latency (don't set it too low when running firefox with audio), and a simpler solution than pulseaudio (all that was needed to do that, in addition to what was already in existence, is the ALSA jack plugin).
If You want to try that way, I can share my config. _________________ "Confirm You are a robot." - the singularity |
|
Back to top |
|
|
Dominique_71 Veteran
Joined: 17 Aug 2005 Posts: 1886 Location: Switzerland (Romandie)
|
|
Back to top |
|
|
pa4wdh l33t
Joined: 16 Dec 2005 Posts: 881
|
Posted: Wed Apr 10, 2024 1:36 pm Post subject: |
|
|
In my experience firefox/webrtc simply doesn't work with alsa. Regular playback like sound samples from wikipedia work fine, but webrtc doesn't.
So, besides you specific setup, maybe it's good to see if it can work without tinkering with the alsa config, just to see if it actually works. If it does you can tune it to your setup so you just have to troubleshoot your alsa config, knowing it can work.
I haven't found a solution (alsa-only system here), but if you found one i'll be happy to give it a try . _________________ The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world
My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com |
|
Back to top |
|
|
Dominique_71 Veteran
Joined: 17 Aug 2005 Posts: 1886 Location: Switzerland (Romandie)
|
Posted: Wed Apr 10, 2024 2:20 pm Post subject: |
|
|
pa4wdh wrote: | I haven't found a solution (alsa-only system here), but if you found one i'll be happy to give it a try . |
It is no solution with ALSA because its support was removed from firefox. The 2 only linux audio back-ends remaining in firefox are pulseaudio and jack. Be aware than to use JACK, only DAW (Digital Audio Workstation) will need a rt enabled kernel. They want an audio latency lower than 20 msec., and firefox will not work fine with JACK and a so low latency anyway. But with a latency of 46.4 ms and the gentoo-sources, it work just fine here. _________________ "Confirm You are a robot." - the singularity |
|
Back to top |
|
|
NathanZachary Moderator
Joined: 30 Jan 2007 Posts: 2608
|
Posted: Wed Apr 10, 2024 2:21 pm Post subject: |
|
|
@Dominique_71, thank you for the details regarding JACK and for putting that information on the Wiki. I may give it a try as well in order to see a comparison between JACK and apulse.
@pa4wdh, that has been my experience as well. Without having an .asoundrc, I don't even get the ability to change sound output (let alone the microphone inputs). WebRTC just doesn't work with direct ALSA, and I think it is because Firefox looks ONLY for the device named 'default' for the microphone. So, if one's microphone is on another device, there's not really any way to make it work. _________________ “Truth, like infinity, is to be forever approached but never reached.” --Jean Ayres (1972)
---avatar cropped from =AimanStudio--- |
|
Back to top |
|
|
NathanZachary Moderator
Joined: 30 Jan 2007 Posts: 2608
|
Posted: Wed Apr 10, 2024 4:18 pm Post subject: |
|
|
Wow, so even using apulse, I still can't select my webcam microphone when in a video chat in Firefox. Though I really don't like using Chromium, my audio and video "just work" in it. _________________ “Truth, like infinity, is to be forever approached but never reached.” --Jean Ayres (1972)
---avatar cropped from =AimanStudio--- |
|
Back to top |
|
|
pa4wdh l33t
Joined: 16 Dec 2005 Posts: 881
|
Posted: Wed Apr 10, 2024 5:06 pm Post subject: |
|
|
IIRC Firefox has dropped alsa support. I can't find the relevant link to an authoritative source anymore, but the message was "We won't remove the support that's there, but if it breaks we won't fix it".
Does apulse work (except for the device selection)? Maybe you could configure a new device in asoudrc consisting of the correct input and output and use that with apulse? _________________ The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world
My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com |
|
Back to top |
|
|
NathanZachary Moderator
Joined: 30 Jan 2007 Posts: 2608
|
Posted: Wed Apr 10, 2024 5:56 pm Post subject: |
|
|
That's true that Firefox did drop "support" for ALSA quite some time ago. However, it's still available using the '--enable-audio-backends' option at compile-time. The Gentoo ebuild automatically enables ALSA if the 'pulseaudio' USE flag is not set and apulse is not installed:
https://gitweb.gentoo.org/repo/gentoo.git/tree/www-client/firefox/firefox-124.0.1.ebuild#n927
So, I decided to run some tests:
1. Emerge apulse WITH the 'sdk' USE flag and then re-emerge Firefox:
* In about:support under the 'Media' section, the 'Audio Backend' shows 'pulse-rust' --> indicating that the apulse headers and libraries are in place
* In about:support under the 'Media' section, the 'Input Devices' still only shows 'default_source_name' though, which isn't my USB webcam microphone
2. Emerge apulse WITHOUT the 'sdk' USE flag and then re-emerge Firefox:
* In about:support under the 'Media' section, the 'Audio Backend' shows 'alsa' (even when running `apulse firefox`)
These tests show me that apulse may not actually function as intended any longer, but that's not surprising since development hasn't been active for years and it has deviated from the full PulseAudio implementation a lot.
I found a thread on the PuppyLinux forum that might explain the problem:
https://forum.puppylinux.com/viewtopic.php?t=9169
It seems like Firefox only looks for the "default" input device and lazily passes the responsibility of determining that device to pavucontrol (part of PulseAudio). As such, I think that's why I can't select my microphone properly.
I'm not sure where this leaves me on options for getting rid of Chromium because I don't see great choices for getting my microphone to work in Firefox for WebRTC-based video chats (like Jitsi, Google Meet, or Zoom). _________________ “Truth, like infinity, is to be forever approached but never reached.” --Jean Ayres (1972)
---avatar cropped from =AimanStudio--- |
|
Back to top |
|
|
NathanZachary Moderator
Joined: 30 Jan 2007 Posts: 2608
|
|
Back to top |
|
|
Dominique_71 Veteran
Joined: 17 Aug 2005 Posts: 1886 Location: Switzerland (Romandie)
|
Posted: Fri Apr 12, 2024 7:15 pm Post subject: |
|
|
With the jack USE flag, I get
* In about:support under the 'Media' section, the 'Audio Backend' shows 'jack'.
* Output device: JACK playback
* Input device: JACK capture
Between jack and pulseaudio, I will always choose jack, that because with the setup I put into the wiki, You get all the advantages of pulseaudio - the ALSA applications are even auto-connecting into the JACK graph, a professional sound server (which pulseaudio will never be because it doesn't implement a constant latency, and when its latency increase, the only way to return to a lower value is to restart it), and a setup that doesn't change with time and is portable between different machines with very few minors changes into /etc/modules.conf/alsa.conf. _________________ "Confirm You are a robot." - the singularity |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|