Changeset 267505 in webkit
- Timestamp:
- Sep 23, 2020, 4:06:16 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
Modules/webaudio/BaseAudioContext.cpp (modified) (1 diff)
-
Modules/webaudio/MediaElementAudioSourceNode.cpp (modified) (4 diffs)
-
Modules/webaudio/MediaElementAudioSourceNode.h (modified) (2 diffs)
-
Modules/webaudio/OfflineAudioDestinationNode.cpp (modified) (2 diffs)
-
html/HTMLMediaElement.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r267504 r267505 1 2020-09-23 Chris Dumez <cdumez@apple.com> 2 3 Use less explicit ref() / deref() calls in WebAudio code 4 https://bugs.webkit.org/show_bug.cgi?id=216894 5 6 Reviewed by Darin Adler. 7 8 * Modules/webaudio/BaseAudioContext.cpp: 9 (WebCore::BaseAudioContext::clearPendingActivity): 10 (WebCore::BaseAudioContext::makePendingActivity): 11 * Modules/webaudio/MediaElementAudioSourceNode.cpp: 12 (WebCore::MediaElementAudioSourceNode::setFormat): 13 (WebCore::MediaElementAudioSourceNode::process): 14 * Modules/webaudio/MediaElementAudioSourceNode.h: 15 * Modules/webaudio/OfflineAudioDestinationNode.cpp: 16 (WebCore::OfflineAudioDestinationNode::startRendering): 17 * html/HTMLMediaElement.cpp: 18 (WebCore::HTMLMediaElement::mediaEngineWasUpdated): 19 (WebCore::HTMLMediaElement::createMediaPlayer): 20 1 21 2020-09-23 Chris Dumez <cdumez@apple.com> 2 22 -
trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp
r267147 r267505 1304 1304 void BaseAudioContext::clearPendingActivity() 1305 1305 { 1306 m_pendingActivity = nullptr; 1307 } 1308 1309 void BaseAudioContext::makePendingActivity() 1310 { 1306 1311 if (!m_pendingActivity) 1307 return; 1308 m_pendingActivity = nullptr; 1309 // FIXME: Remove this specific deref() and ref() call in makePendingActivity(). 1310 deref(); 1311 } 1312 1313 void BaseAudioContext::makePendingActivity() 1314 { 1315 if (m_pendingActivity) 1316 return; 1317 m_pendingActivity = ActiveDOMObject::makePendingActivity(*this); 1318 ref(); 1312 m_pendingActivity = ActiveDOMObject::makePendingActivity(*this); 1319 1313 } 1320 1314 -
trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp
r265375 r267505 86 86 void MediaElementAudioSourceNode::setFormat(size_t numberOfChannels, float sourceSampleRate) 87 87 { 88 auto protectedThis = makeRef(*this); 88 89 m_muted = wouldTaintOrigin(); 89 90 … … 101 102 102 103 // Synchronize with process(). 103 auto locker = holdLock( *this);104 auto locker = holdLock(m_processLock); 104 105 105 106 if (sourceSampleRate != sampleRate()) { … … 147 148 // If we fail to acquire the lock then the HTMLMediaElement must be in the middle of 148 149 // reconfiguring its playback engine, so we output silence in this case. 149 std::unique_lock<Lock> lock(m_process Mutex, std::try_to_lock);150 std::unique_lock<Lock> lock(m_processLock, std::try_to_lock); 150 151 if (!lock.owns_lock()) { 151 152 // We failed to acquire the lock. … … 178 179 } 179 180 180 void MediaElementAudioSourceNode::lock()181 {182 ref();183 m_processMutex.lock();184 }185 186 void MediaElementAudioSourceNode::unlock()187 {188 m_processMutex.unlock();189 deref();190 }191 192 181 } // namespace WebCore 193 182 -
trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.h
r266417 r267505 56 56 void setFormat(size_t numberOfChannels, float sampleRate) override; 57 57 58 void lock(); 59 void unlock(); 58 Lock& processLock() { return m_processLock; } 60 59 61 60 private: … … 72 71 73 72 Ref<HTMLMediaElement> m_mediaElement; 74 Lock m_process Mutex;73 Lock m_processLock; 75 74 76 75 unsigned m_sourceNumberOfChannels { 0 }; -
trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp
r267147 r267505 96 96 97 97 m_startedRendering = true; 98 ref(); 98 auto protectedThis = makeRef(*this); 99 99 100 // FIXME: Should we call lazyInitialize here? 100 101 // FIXME: We should probably limit the number of threads we create for offline audio. 101 m_renderThread = Thread::create("offline renderer", [this ]{102 m_renderThread = Thread::create("offline renderer", [this, protectedThis = WTFMove(protectedThis)]() mutable { 102 103 auto result = offlineRender(); 103 callOnMainThread([this, result, currentSampleFrame = m_currentSampleFrame ] {104 callOnMainThread([this, result, currentSampleFrame = m_currentSampleFrame, protectedThis = WTFMove(protectedThis)] { 104 105 m_startedRendering = false; 105 106 switch (result) { … … 114 115 break; 115 116 } 116 deref();117 117 }); 118 118 }, ThreadType::Audio); -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r267472 r267505 5035 5035 #if ENABLE(WEB_AUDIO) 5036 5036 if (m_audioSourceNode && audioSourceProvider()) { 5037 m_audioSourceNode->lock();5037 auto locker = holdLock(m_audioSourceNode->processLock()); 5038 5038 audioSourceProvider()->setClient(m_audioSourceNode); 5039 m_audioSourceNode->unlock();5040 5039 } 5041 5040 #endif … … 6584 6583 6585 6584 #if ENABLE(WEB_AUDIO) 6586 if (m_audioSourceNode)6587 m_audioSourceNode->lock();6585 auto protectedAudioSourceNode = makeRefPtr(m_audioSourceNode); 6586 Locker<Lock> audioSourceNodeLocker(m_audioSourceNode ? &m_audioSourceNode->processLock() : nullptr); 6588 6587 #endif 6589 6588 … … 6610 6609 if (audioSourceProvider()) 6611 6610 audioSourceProvider()->setClient(m_audioSourceNode); 6612 6613 m_audioSourceNode->unlock();6614 6611 } 6615 6612 #endif
Note:
See TracChangeset
for help on using the changeset viewer.