Changeset 278306 in webkit
- Timestamp:
- Jun 1, 2021, 7:56:04 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
Modules/webaudio/MediaElementAudioSourceNode.cpp (modified) (4 diffs)
-
Modules/webaudio/MediaElementAudioSourceNode.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r278305 r278306 1 2021-06-01 Chris Dumez <cdumez@apple.com> 2 3 Fix thread safety issues in MediaElementAudioSourceNode 4 https://bugs.webkit.org/show_bug.cgi?id=226475 5 6 Reviewed by Youenn Fablet. 7 8 Adopt thread safety analysis annotations in MediaElementAudioSourceNode and fix 9 bugs found by clang. In particular, the following issues were fixed: 10 - setFormat() was modifying m_muted / m_sourceNumberOfChannels / m_sourceSampleRate 11 on the main thread without locking, even though those data members are accessed 12 from the rendering thread. 13 - process() was accessing m_muted / m_sourceNumberOfChannels / m_sourceSampleRate 14 on the rendering thread *before* locking. 15 16 * Modules/webaudio/MediaElementAudioSourceNode.cpp: 17 (WebCore::MediaElementAudioSourceNode::setFormat): 18 (WebCore::MediaElementAudioSourceNode::process): 19 * Modules/webaudio/MediaElementAudioSourceNode.h: 20 1 21 2021-06-01 Antti Koivisto <antti@apple.com> 2 22 -
trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp
r277932 r278306 84 84 { 85 85 auto protectedThis = makeRef(*this); 86 87 // Synchronize with process(). 88 Locker locker { m_processLock }; 89 86 90 m_muted = wouldTaintOrigin(); 87 91 … … 97 101 m_sourceNumberOfChannels = numberOfChannels; 98 102 m_sourceSampleRate = sourceSampleRate; 99 100 // Synchronize with process().101 Locker locker { m_processLock };102 103 103 104 if (sourceSampleRate != sampleRate()) { … … 151 152 AudioBus* outputBus = output(0)->bus(); 152 153 153 if (m_muted || !m_sourceNumberOfChannels || !m_sourceSampleRate) {154 outputBus->zero();155 return;156 }157 158 154 // Use tryLock() to avoid contention in the real-time audio thread. 159 155 // If we fail to acquire the lock then the HTMLMediaElement must be in the middle of … … 166 162 167 163 Locker locker { AdoptLock, m_processLock }; 168 if (m_sourceNumberOfChannels != outputBus->numberOfChannels()) { 164 165 if (m_muted || !m_sourceNumberOfChannels || !m_sourceSampleRate || m_sourceNumberOfChannels != outputBus->numberOfChannels()) { 169 166 outputBus->zero(); 170 167 return; -
trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.h
r278077 r278306 73 73 Lock m_processLock; 74 74 75 unsigned m_sourceNumberOfChannels { 0 };76 double m_sourceSampleRate { 0 };77 bool m_muted { false };75 unsigned m_sourceNumberOfChannels WTF_GUARDED_BY_LOCK(m_processLock) { 0 }; 76 double m_sourceSampleRate WTF_GUARDED_BY_LOCK(m_processLock) { 0 }; 77 bool m_muted WTF_GUARDED_BY_LOCK(m_processLock) { false }; 78 78 79 std::unique_ptr<MultiChannelResampler> m_multiChannelResampler ;79 std::unique_ptr<MultiChannelResampler> m_multiChannelResampler WTF_GUARDED_BY_LOCK(m_processLock); 80 80 }; 81 81
Note:
See TracChangeset
for help on using the changeset viewer.