- Revision
- 274819
- Author
- [email protected]
- Date
- 2021-03-22 16:57:35 -0700 (Mon, 22 Mar 2021)
Log Message
AVAudioSessionCaptureDeviceManager should use crossThreadCopy
https://bugs.webkit.org/show_bug.cgi?id=223565
<rdar://75480589>
Reviewed by Youenn Fablet.
Tested manually, this can only be tested on device.
* platform/mediastream/CaptureDevice.h: Change access restriction for member
variables from `private:` to `protected:` so derived classes can access them
directly.
* platform/mediastream/ios/AVAudioSessionCaptureDevice.h:
* platform/mediastream/ios/AVAudioSessionCaptureDevice.mm:
(WebCore::AVAudioSessionCaptureDevice::AVAudioSessionCaptureDevice): New constructor.
(WebCore::AVAudioSessionCaptureDevice::isolatedCopy const): New.
* platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm:
(WebCore::AVAudioSessionCaptureDeviceManager::refreshAudioCaptureDevices): Use
`WTFMove(deviceList).isolatedCopy()` when moving from AVAudioSession queue
to main thread.
(WebCore::AVAudioSessionCaptureDeviceManager::getCaptureDevices): Ditto.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (274818 => 274819)
--- trunk/Source/WebCore/ChangeLog 2021-03-22 23:36:35 UTC (rev 274818)
+++ trunk/Source/WebCore/ChangeLog 2021-03-22 23:57:35 UTC (rev 274819)
@@ -1,3 +1,28 @@
+2021-03-22 Eric Carlson <[email protected]>
+
+ AVAudioSessionCaptureDeviceManager should use crossThreadCopy
+ https://bugs.webkit.org/show_bug.cgi?id=223565
+ <rdar://75480589>
+
+ Reviewed by Youenn Fablet.
+
+ Tested manually, this can only be tested on device.
+
+ * platform/mediastream/CaptureDevice.h: Change access restriction for member
+ variables from `private:` to `protected:` so derived classes can access them
+ directly.
+
+ * platform/mediastream/ios/AVAudioSessionCaptureDevice.h:
+ * platform/mediastream/ios/AVAudioSessionCaptureDevice.mm:
+ (WebCore::AVAudioSessionCaptureDevice::AVAudioSessionCaptureDevice): New constructor.
+ (WebCore::AVAudioSessionCaptureDevice::isolatedCopy const): New.
+
+ * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm:
+ (WebCore::AVAudioSessionCaptureDeviceManager::refreshAudioCaptureDevices): Use
+ `WTFMove(deviceList).isolatedCopy()` when moving from AVAudioSession queue
+ to main thread.
+ (WebCore::AVAudioSessionCaptureDeviceManager::getCaptureDevices): Ditto.
+
2021-03-22 Patrick Angle <[email protected]>
REGRESSION(r272433): Inspector should not instrument inside `WebCore::Node::setRenderer`
Modified: trunk/Source/WebCore/platform/mediastream/CaptureDevice.h (274818 => 274819)
--- trunk/Source/WebCore/platform/mediastream/CaptureDevice.h 2021-03-22 23:36:35 UTC (rev 274818)
+++ trunk/Source/WebCore/platform/mediastream/CaptureDevice.h 2021-03-22 23:57:35 UTC (rev 274819)
@@ -130,7 +130,7 @@
}
#endif
-private:
+protected:
String m_persistentId;
DeviceType m_type { DeviceType::Unknown };
String m_label;
Modified: trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDevice.h (274818 => 274819)
--- trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDevice.h 2021-03-22 23:36:35 UTC (rev 274818)
+++ trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDevice.h 2021-03-22 23:57:35 UTC (rev 274819)
@@ -39,8 +39,11 @@
static AVAudioSessionCaptureDevice create(AVAudioSessionPortDescription *deviceInput, AVAudioSessionPortDescription *defaultInput);
virtual ~AVAudioSessionCaptureDevice() = default;
+ AVAudioSessionCaptureDevice isolatedCopy() &&;
+
private:
AVAudioSessionCaptureDevice(AVAudioSessionPortDescription *deviceInput, AVAudioSessionPortDescription *defaultInput);
+ AVAudioSessionCaptureDevice(const String& persistentId, DeviceType, const String& label, const String& groupId, bool isEnabled, bool isDefault, bool isMock);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDevice.mm (274818 => 274819)
--- trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDevice.mm 2021-03-22 23:36:35 UTC (rev 274818)
+++ trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDevice.mm 2021-03-22 23:57:35 UTC (rev 274819)
@@ -44,6 +44,27 @@
setIsDefault(defaultInput && [defaultInput.UID isEqualToString:deviceInput.UID]);
}
+AVAudioSessionCaptureDevice::AVAudioSessionCaptureDevice(const String& persistentId, DeviceType type, const String& label, const String& groupId, bool isEnabled, bool isDefault, bool isMock)
+ : CaptureDevice(persistentId, type, label, groupId)
+{
+ setEnabled(isEnabled);
+ setIsDefault(isDefault);
+ setIsMockDevice(isMock);
}
+AVAudioSessionCaptureDevice AVAudioSessionCaptureDevice::isolatedCopy() &&
+{
+ return {
+ WTFMove(m_persistentId).isolatedCopy(),
+ m_type,
+ WTFMove(m_label).isolatedCopy(),
+ WTFMove(m_groupId).isolatedCopy(),
+ m_enabled,
+ m_default,
+ m_isMockDevice,
+ };
+}
+
+}
+
#endif // ENABLE(MEDIA_STREAM) && PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm (274818 => 274819)
--- trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm 2021-03-22 23:36:35 UTC (rev 274818)
+++ trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm 2021-03-22 23:57:35 UTC (rev 274819)
@@ -163,7 +163,7 @@
m_dispatchQueue->dispatchSync([&] {
newAudioDevices = retrieveAudioSessionCaptureDevices();
});
- setAudioCaptureDevices(WTFMove(newAudioDevices));
+ setAudioCaptureDevices(WTFMove(newAudioDevices).isolatedCopy());
}
void AVAudioSessionCaptureDeviceManager::getCaptureDevices(CompletionHandler<void(Vector<CaptureDevice>&&)>&& completion)
@@ -178,7 +178,7 @@
m_dispatchQueue->dispatch([this, completion = WTFMove(completion)] () mutable {
auto newAudioDevices = retrieveAudioSessionCaptureDevices();
- callOnWebThreadOrDispatchAsyncOnMainThread(makeBlockPtr([this, completion = WTFMove(completion), newAudioDevices = WTFMove(newAudioDevices)] () mutable {
+ callOnWebThreadOrDispatchAsyncOnMainThread(makeBlockPtr([this, completion = WTFMove(completion), newAudioDevices = WTFMove(newAudioDevices).isolatedCopy()] () mutable {
setAudioCaptureDevices(WTFMove(newAudioDevices));
completion(copyToVector(*m_devices));
}).get());