Skip to content

Commit a1aedbe

Browse files
committed
Microphone capture can be muted when capturing with and without echo cancellation and using applyConstraints to switch dynamically between the two
rdar://164086015 https://bugs.webkit.org/show_bug.cgi?id=302005 Reviewed by Eric Carlson. When a web page has two tracks, one with echo cancellation and one without echo cancellation on the same device, the web page is running two CoreAudioCaptureUnits. If it renders audio, the VPIO unit may also be rendering audio. If the VPIO unit is stopping to capture (both tracks go to no echo cancellation), it will continue running to render audio. It will then mute capture as it does not need to capture and to remove the OS microphone capture indicator. But, this prevents the other unit to actually capture. We update CoreAudioCaptureUnit::updateMutedState by making sure to set muted to true only if there is no other audio unit doing capture. We also update CoreAudioCaptureUnit::updateMutedState to only set kAUVoiceIOProperty_MuteOutput on the VPIO unit since it fails with non VPIO units. Manually tested. Canonical link: https://commits.webkit.org/302637@main
1 parent 4cd951e commit a1aedbe

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Source/WebCore/platform/mediastream/mac/CoreAudioCaptureUnit.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,13 @@ void CoreAudioCaptureUnit::updateMutedState(SyncUpdate syncUpdate)
754754
auto error = m_ioUnit->set(kAUVoiceIOProperty_MuteOutput, kAudioUnitScope_Global, outputBus, &muteUplinkOutput, sizeof(muteUplinkOutput));
755755
RELEASE_LOG_ERROR_IF(error, WebRTC, "CoreAudioCaptureUnit::updateMutedState(%p) unable to set kAUVoiceIOProperty_MuteOutput, error %d (%.4s)", this, (int)error, (char*)&error);
756756
}
757-
setMutedState(muteUplinkOutput);
757+
758+
auto isAnyUnitCapturing = [] {
759+
return std::ranges::any_of(allCoreAudioCaptureUnits(), [](auto& unit) {
760+
return unit.isProducingData();
761+
});
762+
};
763+
setMutedState(muteUplinkOutput && !isAnyUnitCapturing());
758764
}
759765

760766
void CoreAudioCaptureUnit::updateMutedStateTimerFired()

0 commit comments

Comments
 (0)