Owners of MultiChannelResampler should make sure that the output bus given to it...
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jul 2019 17:31:17 +0000 (17:31 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jul 2019 17:31:17 +0000 (17:31 +0000)
commit2555d255a06dafd2d6fc75d9c9d82a29b5323e32
tree785276c9cc4a78fbde7db2f6839caf0814ba68ac
parent73ef94678684f7f40276e59c74d0f00f46144c2b
Owners of MultiChannelResampler should make sure that the output bus given to it has the same number of channels
https://bugs.webkit.org/show_bug.cgi?id=200248
<rdar://problem/53411051>

Reviewed by Eric Carlson.

Source/WebCore:

When a track's number of channels changes, MediaStreamAudioSourceNode is expected
to update its MultiChannelResampler and its output number of channels.
MultiChannelResampler expects to have the same number of channels as the output
but it is not always the case since the channel numbers are changed in different threads
and locks do not help there.

Instead, whenever detecting that the number of channels do not match, render silence
and wait for the next rendering where the number of channels should again match.

Add internals API to change the number of channels from 2 to 1 or 1 to 2
to allow testing that code path (iOS only as MacOS audio capture is in UIProcess).
Covered by updated test.

* Modules/webaudio/MediaElementAudioSourceNode.cpp:
(WebCore::MediaElementAudioSourceNode::process):
* Modules/webaudio/MediaStreamAudioSourceNode.cpp:
(WebCore::MediaStreamAudioSourceNode::process):
* platform/audio/MultiChannelResampler.cpp:
(WebCore::MultiChannelResampler::process):
* platform/mediastream/RealtimeMediaSource.h:
* platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
(WebCore::MockRealtimeAudioSourceMac::reconfigure):
* platform/mock/MockRealtimeAudioSource.cpp:
(WebCore::MockRealtimeAudioSource::setChannelCount):
* platform/mock/MockRealtimeAudioSource.h:
(isType):
* platform/mock/MockRealtimeVideoSource.h:
* testing/Internals.cpp:
(WebCore::Internals::setMockAudioTrackChannelNumber):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* fast/mediastream/getUserMedia-webaudio-expected.txt:
* fast/mediastream/getUserMedia-webaudio.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248046 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/getUserMedia-webaudio-expected.txt
LayoutTests/fast/mediastream/getUserMedia-webaudio.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp
Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp
Source/WebCore/platform/audio/MultiChannelResampler.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSource.h
Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm
Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp
Source/WebCore/platform/mock/MockRealtimeAudioSource.h
Source/WebCore/platform/mock/MockRealtimeVideoSource.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl