Changeset 249002 in webkit
- Timestamp:
- Aug 22, 2019, 4:05:50 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
platform/mediastream/CaptureDeviceManager.cpp (modified) (1 diff)
-
platform/mediastream/CaptureDeviceManager.h (modified) (1 diff)
-
platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp (modified) (3 diffs)
-
platform/mediastream/mac/CoreAudioCaptureDeviceManager.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r249000 r249002 1 2019-08-22 Youenn Fablet <youenn@apple.com> 2 3 CaptureDeviceManager does not need to be CanMakeWeakPtr 4 https://bugs.webkit.org/show_bug.cgi?id=200936 5 6 Reviewed by Alex Christensen. 7 8 CaptureDeviceManager does not need to create a weak pointer in deviceChanged 9 since it directly calls RealtimeMediaSourceCenter singleton. 10 11 CoreAudioCaptureDeviceManager does not need to create a weak pointer since its only 12 instance is NeverDestroyed. 13 No change of behavior. 14 15 * platform/mediastream/CaptureDeviceManager.cpp: 16 (WebCore::CaptureDeviceManager::deviceChanged): 17 * platform/mediastream/CaptureDeviceManager.h: 18 * platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp: 19 (WebCore::createAudioObjectPropertyListenerBlock): 20 (WebCore::CoreAudioCaptureDeviceManager::coreAudioCaptureDevices): 21 (WebCore::CoreAudioCaptureDeviceManager::refreshAudioCaptureDevices): 22 * platform/mediastream/mac/CoreAudioCaptureDeviceManager.h: 23 1 24 2019-08-22 Chris Dumez <cdumez@apple.com> 2 25 -
trunk/Source/WebCore/platform/mediastream/CaptureDeviceManager.cpp
r235115 r249002 53 53 void CaptureDeviceManager::deviceChanged() 54 54 { 55 callOnMainThread([weakThis = makeWeakPtr(*this)] { 56 if (!weakThis) 57 return; 58 59 RealtimeMediaSourceCenter::singleton().captureDevicesChanged(); 60 }); 55 if (!isMainThread()) { 56 callOnMainThread([] { 57 RealtimeMediaSourceCenter::singleton().captureDevicesChanged(); 58 }); 59 return; 60 } 61 RealtimeMediaSourceCenter::singleton().captureDevicesChanged(); 61 62 } 62 63 -
trunk/Source/WebCore/platform/mediastream/CaptureDeviceManager.h
r239427 r249002 30 30 #include "CaptureDevice.h" 31 31 #include "RealtimeMediaSource.h" 32 #include <wtf/WeakPtr.h>33 32 34 33 namespace WebCore { 35 34 36 class WEBCORE_EXPORT CaptureDeviceManager : public CanMakeWeakPtr<CaptureDeviceManager>{35 class WEBCORE_EXPORT CaptureDeviceManager { 37 36 public: 38 37 virtual const Vector<CaptureDevice>& captureDevices() = 0; -
trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp
r246215 r249002 120 120 if (!initialized) { 121 121 initialized = true; 122 refreshAudioCaptureDevices(DoNotNotify); 123 124 auto weakThis = makeWeakPtr(*this); 125 m_listenerBlock = Block_copy(^(UInt32 count, const AudioObjectPropertyAddress properties[]) { 126 if (!weakThis) 127 return; 128 122 refreshAudioCaptureDevices(NotifyIfDevicesHaveChanged::DoNotNotify); 123 124 auto listener = ^(UInt32 count, const AudioObjectPropertyAddress properties[]) { 129 125 for (UInt32 i = 0; i < count; ++i) { 130 126 const AudioObjectPropertyAddress& property = properties[i]; … … 133 129 continue; 134 130 135 weakThis->refreshAudioCaptureDevices(Notify);131 CoreAudioCaptureDeviceManager::singleton().refreshAudioCaptureDevices(NotifyIfDevicesHaveChanged::Notify); 136 132 return; 137 133 } 138 } );134 }; 139 135 140 136 AudioObjectPropertyAddress address = { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; 141 auto err = AudioObjectAddPropertyListenerBlock(kAudioObjectSystemObject, &address, dispatch_get_main_queue(), m_listenerBlock);137 auto err = AudioObjectAddPropertyListenerBlock(kAudioObjectSystemObject, &address, dispatch_get_main_queue(), listener); 142 138 if (err) 143 139 LOG_ERROR("CoreAudioCaptureDeviceManager::devices(%p) AudioObjectAddPropertyListener for kAudioHardwarePropertyDevices returned error %d (%.4s)", this, (int)err, (char*)&err); 144 140 145 141 address = { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; 146 err = AudioObjectAddPropertyListenerBlock(kAudioObjectSystemObject, &address, dispatch_get_main_queue(), m_listenerBlock);142 err = AudioObjectAddPropertyListenerBlock(kAudioObjectSystemObject, &address, dispatch_get_main_queue(), listener); 147 143 if (err) 148 144 LOG_ERROR("CoreAudioCaptureDeviceManager::devices(%p) AudioObjectAddPropertyListener for kAudioHardwarePropertyDefaultInputDevice returned error %d (%.4s)", this, (int)err, (char*)&err); … … 221 217 } 222 218 223 if (notify == Notify ) {219 if (notify == NotifyIfDevicesHaveChanged::Notify) { 224 220 deviceChanged(); 225 221 CoreAudioCaptureSourceFactory::singleton().devicesChanged(m_devices); -
trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.h
r239531 r249002 55 55 Vector<CoreAudioCaptureDevice>& coreAudioCaptureDevices(); 56 56 57 enum NotifyIfDevicesHaveChanged { Notify, DoNotNotify };57 enum class NotifyIfDevicesHaveChanged { Notify, DoNotNotify }; 58 58 void refreshAudioCaptureDevices(NotifyIfDevicesHaveChanged); 59 59 60 60 Vector<CaptureDevice> m_devices; 61 61 Vector<CoreAudioCaptureDevice> m_coreAudioCaptureDevices; 62 63 AudioObjectPropertyListenerBlock m_listenerBlock;64 62 }; 65 63
Note:
See TracChangeset
for help on using the changeset viewer.