New issue
Advanced search Search tips

Issue 794501 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Getting audio input channels fails on Mac - always falls back on stereo

Project Member Reported by grunell@chromium.org, Dec 13 2017

Issue description

Chrome Version: M63, has likely been around for some time.
OS: Mac

What steps will reproduce the problem?
(1) Use a mono mic, for example Jabra 410.
(1) Open a page that does getUserMedia, for example https://webrtc.github.io/samples/src/content/getusermedia/audio/
(2) Open a new tab, go to chrome://webrtc-internals, expand "Create dump", select "Enable diagnostic audio recordings".
(3) Talk a little, close tabs.

What is the expected result?
The produced file *.source_input.1.wav or *.input.1.wav (number may vary) should be in mono.

What happens instead?
File is in stereo, with audio only in left channel.

One problem with this is that when the channels are mixed to mono in WebRTC's audio processing module, the resulting volume is lower.
 
These errors are spit out:

[7403:775:1213/115335.218643:ERROR:scoped_audio_unit.cc(43)] Failed to set current device for audio unit.: Error Domain=NSOSStatusErrorDomain Code=-10851 "(null)" (-10851)
[7403:775:1213/115335.218739:ERROR:audio_manager_mac.cc(634)] Failed to get the device channels, use stereo as default for device default
[7403:775:1213/115335.220171:ERROR:scoped_audio_unit.cc(43)] Failed to set current device for audio unit.: Error Domain=NSOSStatusErrorDomain Code=-10851 "(null)" (-10851)
[7403:775:1213/115335.220204:ERROR:audio_manager_mac.cc(634)] Failed to get the device channels, use stereo as default for device AppleHDAEngineInput:1F,3,0,1,0:1
[7403:775:1213/115335.221032:ERROR:scoped_audio_unit.cc(43)] Failed to set current device for audio unit.: Error Domain=NSOSStatusErrorDomain Code=-10851 "(null)" (-10851)
[7403:775:1213/115335.221069:ERROR:audio_manager_mac.cc(634)] Failed to get the device channels, use stereo as default for device AppleUSBAudioEngine:Unknown Manufacturer:Jabra SPEAK 410 USB:1C48F959BFE4x010900:2
[7403:775:1213/115335.224960:ERROR:scoped_audio_unit.cc(43)] Failed to set current device for audio unit.: Error Domain=NSOSStatusErrorDomain Code=-10851 "(null)" (-10851)
[7403:775:1213/115335.225004:ERROR:audio_manager_mac.cc(634)] Failed to get the device channels, use stereo as default for device default

I saw that IO is not enabled on input, which is required before setting the current device. I fixed that and instead the failures:

[10525:775:1213/132413.043872:ERROR:audio_manager_mac.cc(379)] Failed to get property info for AudioUnit channel layout.: Error Domain=NSOSStatusErrorDomain Code=-10879 "(null)" (-10879)
[10525:775:1213/132413.044172:ERROR:audio_manager_mac.cc(634)] Failed to get the device channels, use stereo as default for device default
[10525:775:1213/132413.045529:ERROR:audio_manager_mac.cc(379)] Failed to get property info for AudioUnit channel layout.: Error Domain=NSOSStatusErrorDomain Code=-10879 "(null)" (-10879)
[10525:775:1213/132413.045781:ERROR:audio_manager_mac.cc(634)] Failed to get the device channels, use stereo as default for device AppleHDAEngineInput:1F,3,0,1,0:1
[10525:775:1213/132413.047281:ERROR:audio_manager_mac.cc(379)] Failed to get property info for AudioUnit channel layout.: Error Domain=NSOSStatusErrorDomain Code=-10879 "(null)" (-10879)
[10525:775:1213/132413.047534:ERROR:audio_manager_mac.cc(634)] Failed to get the device channels, use stereo as default for device AppleUSBAudioEngine:Unknown Manufacturer:Jabra SPEAK 410 USB:1C48F959BFE4x010900:2
[10525:775:1213/132413.059119:ERROR:audio_manager_mac.cc(379)] Failed to get property info for AudioUnit channel layout.: Error Domain=NSOSStatusErrorDomain Code=-10879 "(null)" (-10879)
[10525:775:1213/132413.059387:ERROR:audio_manager_mac.cc(634)] Failed to get the device channels, use stereo as default for device default

The failure is kAudioUnitErr_InvalidProperty, which to the best of my knowledge means that the property isn't relevant for that element & scope on that AudioUnit. (Input element, output scope in this case.) As a verification, changing scope gives kAudioUnitErr_InvalidElement. It would make sense that channel layout isn't relevant for the input element.

Using GetDeviceTotalChannelCount() in AudioManagerMac, which we already call before getting the layout, for number of input channels should fix this. I wrote a CL for that: https://chromium-review.googlesource.com/c/chromium/src/+/823972
Status: Started (was: Assigned)
Dale: can you have a look since you wrote the change in how we get the number of channels? Would you say my conclusion in #1 is correct?
Project Member

Comment 3 by bugdroid1@chromium.org, Dec 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3ccfcbbac6f7055e92d9da39be10c656617468fb

commit 3ccfcbbac6f7055e92d9da39be10c656617468fb
Author: Henrik Grunell <grunell@chromium.org>
Date: Wed Dec 20 12:52:13 2017

Fix for getting number of audio input channels on Mac.

Don't get channel layout for input element since that's not supported on AUHAL[1], instead get the channel count from the stream layout.

Plus fixes in ScopedAudioUnit:
* Enable IO before setting current device which is a requirement.
* Use element 0 with global scope, which is the element to use with that scope. (This didn't cause a failure.)

[1] Follow-up on this to confirm: https://crbug.com/796163

Bug:  794501 
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I3879989e30449000dc9d75f756c69738ac54615a
Reviewed-on: https://chromium-review.googlesource.com/823972
Commit-Queue: Henrik Grunell <grunell@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525314}
[modify] https://crrev.com/3ccfcbbac6f7055e92d9da39be10c656617468fb/media/audio/mac/audio_auhal_mac.cc
[modify] https://crrev.com/3ccfcbbac6f7055e92d9da39be10c656617468fb/media/audio/mac/audio_manager_mac.cc
[modify] https://crrev.com/3ccfcbbac6f7055e92d9da39be10c656617468fb/media/audio/mac/scoped_audio_unit.cc

Status: Fixed (was: Started)

Comment 5 by ssonning@google.com, Dec 28 2017

Status: Verified (was: Fixed)

Sign in to add a comment