Title: [288620] trunk/Source/WebCore
- Revision
- 288620
- Author
- [email protected]
- Date
- 2022-01-26 08:42:09 -0800 (Wed, 26 Jan 2022)
Log Message
[MacOS] Set kAudioOutputUnitProperty_CurrentDevice on CoreAudioSharedUnit outputBus
https://bugs.webkit.org/show_bug.cgi?id=235632
<rdar://87771490>
Reviewed by Eric Carlson.
When VPIO is used for rendering audio, it is not always updating the audio route when system default speaker is updated.
While it is doing so when capturing using the built-in microphone, it is not doing so with BT microphones.
To make it reliable, we are now setting kAudioOutputUnitProperty_CurrentDevice on the output bus to the default output device.
Whenever we detect a change of default output device, we reconfigure the audio unit to select the new default output device.
Manually tested.
* platform/mediastream/mac/BaseAudioSharedUnit.cpp:
(WebCore::BaseAudioSharedUnit::devicesChanged):
* platform/mediastream/mac/BaseAudioSharedUnit.h:
(WebCore::BaseAudioSharedUnit::setOutputDeviceID):
(WebCore::BaseAudioSharedUnit::validateOutputDevice):
* platform/mediastream/mac/CoreAudioCaptureSource.cpp:
(WebCore::CoreAudioSharedUnit::setupAudioUnit):
(WebCore::CoreAudioSharedUnit::validateOutputDevice):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (288619 => 288620)
--- trunk/Source/WebCore/ChangeLog 2022-01-26 15:54:23 UTC (rev 288619)
+++ trunk/Source/WebCore/ChangeLog 2022-01-26 16:42:09 UTC (rev 288620)
@@ -1,3 +1,28 @@
+2022-01-26 Youenn Fablet <[email protected]>
+
+ [MacOS] Set kAudioOutputUnitProperty_CurrentDevice on CoreAudioSharedUnit outputBus
+ https://bugs.webkit.org/show_bug.cgi?id=235632
+ <rdar://87771490>
+
+ Reviewed by Eric Carlson.
+
+ When VPIO is used for rendering audio, it is not always updating the audio route when system default speaker is updated.
+ While it is doing so when capturing using the built-in microphone, it is not doing so with BT microphones.
+
+ To make it reliable, we are now setting kAudioOutputUnitProperty_CurrentDevice on the output bus to the default output device.
+ Whenever we detect a change of default output device, we reconfigure the audio unit to select the new default output device.
+
+ Manually tested.
+
+ * platform/mediastream/mac/BaseAudioSharedUnit.cpp:
+ (WebCore::BaseAudioSharedUnit::devicesChanged):
+ * platform/mediastream/mac/BaseAudioSharedUnit.h:
+ (WebCore::BaseAudioSharedUnit::setOutputDeviceID):
+ (WebCore::BaseAudioSharedUnit::validateOutputDevice):
+ * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+ (WebCore::CoreAudioSharedUnit::setupAudioUnit):
+ (WebCore::CoreAudioSharedUnit::validateOutputDevice):
+
2022-01-26 Tyler Wilcock <[email protected]>
AX: Do less work under m_changeLogLock in AXIsolatedTree::clear and AXIsolatedTree::setFocusedNodeID
Modified: trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp (288619 => 288620)
--- trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp 2022-01-26 15:54:23 UTC (rev 288619)
+++ trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp 2022-01-26 16:42:09 UTC (rev 288620)
@@ -149,8 +149,10 @@
return;
auto persistentID = this->persistentID();
- if (WTF::anyOf(devices, [&persistentID] (auto& device) { return persistentID == device.persistentId(); }))
+ if (WTF::anyOf(devices, [&persistentID] (auto& device) { return persistentID == device.persistentId(); })) {
+ validateOutputDevice(m_outputDeviceID);
return;
+ }
RELEASE_LOG_ERROR(WebRTC, "BaseAudioSharedUnit::devicesChanged - failing capture, capturing device is missing");
captureFailed();
Modified: trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h (288619 => 288620)
--- trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h 2022-01-26 15:54:23 UTC (rev 288619)
+++ trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h 2022-01-26 16:42:09 UTC (rev 288620)
@@ -105,7 +105,10 @@
protected:
void setIsProducingMicrophoneSamples(bool);
bool isProducingMicrophoneSamples() const { return m_isProducingMicrophoneSamples; }
+ void setOutputDeviceID(uint32_t deviceID) { m_outputDeviceID = deviceID; }
+
virtual void isProducingMicrophoneSamplesChanged() { }
+ virtual void validateOutputDevice(uint32_t /* currentOutputDeviceID */) { }
private:
OSStatus startUnit();
@@ -119,6 +122,7 @@
int32_t m_producingCount { 0 };
+ uint32_t m_outputDeviceID { 0 };
std::optional<std::pair<String, uint32_t>> m_capturingDevice;
HashSet<CoreAudioCaptureSource*> m_clients;
Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp (288619 => 288620)
--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp 2022-01-26 15:54:23 UTC (rev 288619)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp 2022-01-26 16:42:09 UTC (rev 288620)
@@ -100,6 +100,7 @@
void stopInternal() final;
bool isProducingData() const final { return m_ioUnitStarted; }
void isProducingMicrophoneSamplesChanged() final;
+ void validateOutputDevice(uint32_t deviceID) final;
OSStatus configureSpeakerProc();
OSStatus configureMicrophoneProc();
@@ -247,6 +248,14 @@
RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::setupAudioUnit(%p) unable to set vpio unit capture device ID %d, error %d (%.4s)", this, (int)deviceID, (int)err, (char*)&err);
return err;
}
+
+ uint32_t defaultOutputDeviceID;
+ err = defaultOutputDevice(&defaultOutputDeviceID);
+ if (!err) {
+ err = PAL::AudioUnitSetProperty(m_ioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, outputBus, &defaultOutputDeviceID, sizeof(defaultOutputDeviceID));
+ RELEASE_LOG_ERROR_IF(err, WebRTC, "CoreAudioSharedUnit::setupAudioUnit(%p) unable to set vpio unit output device ID %d, error %d (%.4s)", this, (int)defaultOutputDeviceID, (int)err, (char*)&err);
+ }
+ setOutputDeviceID(!err ? defaultOutputDeviceID : 0);
#endif
err = configureMicrophoneProc();
@@ -535,6 +544,22 @@
m_verifyCapturingTimer.startRepeating(verifyCaptureInterval());
}
+void CoreAudioSharedUnit::validateOutputDevice(uint32_t currentOutputDeviceID)
+{
+#if PLATFORM(MAC)
+ uint32_t currentDefaultOutputDeviceID = 0;
+ if (auto err = defaultOutputDevice(¤tDefaultOutputDeviceID))
+ return;
+
+ if (!currentDefaultOutputDeviceID || currentOutputDeviceID == currentDefaultOutputDeviceID)
+ return;
+
+ reconfigure();
+#else
+ UNUSED_PARAM(currentOutputDeviceID);
+#endif
+}
+
void CoreAudioSharedUnit::verifyIsCapturing()
{
if (m_microphoneProcsCalledLastTime != m_microphoneProcsCalled) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes