Bug 246669 - www/firefox: Unable to use microphone with ALSA backend
Summary: www/firefox: Unable to use microphone with ALSA backend
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-gecko (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-22 21:52 UTC by Sean Farley
Modified: 2022-06-22 07:58 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (gecko)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sean Farley freebsd_committer freebsd_triage 2020-05-22 21:52:28 UTC
I am attempting to get the microphone on my webcam to work using ALSA in
Firefox 76.  It used to work although I do not know when it stopped.  If
I use ALSA with ffmpeg, the microphone does work, so I suspect it should
be something simple that I am missing in Firefox.  I am using a new
profile, so no addons should be interfering.

My asound.conf makes use of the ASYM PCM plugin to combine the input and
output from different devices.  In my case, speakers for output and
microphone from USB webcam.

I have also tried Chromium, but I am uncertain if it is using OSS or
ALSA for the microphone.

The simplest test I found, out of the many I tried, is
https://webrtc.github.io/samples/src/content/getusermedia/volume/
Firefox does not register any volume, yet Chromium does.

Another test is https://browserleaks.com/webrtc.  It shows "Open Sound
System" for one of the audio on Chromium, which may mean it is
seeing/using ALSA.  One odd behavior is that Chromium keeps the audio
and video devices open while Firefox stops them after several seconds.

/usr/local/etc/asound.conf
--------------------------

#
# FreeBSD/OSS
#

# Create slave of the sound card/speakers.
pcm_slave.oss4 {
	pcm.type oss
	pcm.device /dev/dsp4
	pcm.hint.description "Open Sound System"
}

# Create slave of the webcam microphone.
pcm_slave.oss7 {
	pcm.type oss
	pcm.device /dev/dsp7
	pcm.hint.description "Open Sound System"
}

# Mix webcam for input and speakers for output.
pcm.!sysdefault {
	type asym
	capture.pcm {
		type plug
		slave oss7
	}
	playback.pcm {
		type plug
		slave oss4
	}
	hint {
		description "Open Sound System"
	}
}
pcm.!default pcm.sysdefault

# There is no asym for ctl.  It would be nice to tie the controllers together
# into a single device like the PCM ASYM plugin does.
ctl.oss {
	type oss
	# device /dev/mixer7
	hint {
		description "Open Sound System"
	}
}
ctl.!sysdefault ctl.oss
ctl.!default ctl.sysdefault

--------------------------


Notes:
- Running firefox-76.0_2,1 built locally within poudriere.
- Firefox is using ALSA according to about:support.  However, it only
  shows an input device of "default" but no output device.  Firefox is
  able to output audio, so this is odd.
- Firefox is playing audio just fine.
- Firefox detects both the video (two blank lines) and microphone when a
  WebRTC session starts.  It calls the microphone "default".
- No other backend other than ALSA is installed on the system nor was
  Firefox compiled with one.
- ffmpeg is able to use the microphone with this command:
      ffmpeg -f alsa -i default test.wav
- The webcam mixer mic device is at 100.
- Muting the microphone in a WebRTC session in Jitsi Meet
  (https://meet.jit.si/) or AppRTC (https://appr.tc/) causes the tab to
  crash rather often with a signal 11.  Sometimes it freezes for a
  moment then crashes but mostly crashes instantly.
- FreeBSD 12.1-STABLE r360638.

Any suggestions?  I may have to try sndio or virtual_oss someday, but I
figure this should still work with Firefox.  Any logs to gather?  I have
messed around with MOZ_LOG, NSPR_LOG_MODULES, WEBRTC_TRACE_FILE and some
other environment variables, but there is a bit of black magic there.  :)