Changeset 278285 in webkit
- Timestamp:
- May 31, 2021, 5:03:36 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
Modules/webaudio/OscillatorNode.cpp (modified) (3 diffs)
-
Modules/webaudio/OscillatorNode.h (modified) (3 diffs)
-
Modules/webaudio/OscillatorNode.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r278284 r278285 1 2021-05-31 Chris Dumez <cdumez@apple.com> 2 3 Fix thread safety issues in OscillatorNode 4 https://bugs.webkit.org/show_bug.cgi?id=226450 5 6 Reviewed by Darin Adler. 7 8 Adopt thread safety annotations in OscillatorNode and fix bugs found by clang. 9 In particular, propagatesSilence() was failing to grab the lock before accessing 10 m_periodicWave, which gets modified on the main thread. 11 12 * Modules/webaudio/OscillatorNode.cpp: 13 (WebCore::OscillatorNode::create): 14 (WebCore::OscillatorNode::setTypeForBindings): 15 (WebCore::OscillatorNode::propagatesSilence const): 16 * Modules/webaudio/OscillatorNode.h: 17 * Modules/webaudio/OscillatorNode.idl: 18 1 19 2021-05-31 Chris Dumez <cdumez@apple.com> 2 20 -
trunk/Source/WebCore/Modules/webaudio/OscillatorNode.cpp
r277932 r278285 73 73 oscillator->setPeriodicWave(*options.periodicWave); 74 74 else { 75 result = oscillator->setType (options.type);75 result = oscillator->setTypeForBindings(options.type); 76 76 if (result.hasException()) 77 77 return result.releaseException(); … … 98 98 } 99 99 100 ExceptionOr<void> OscillatorNode::setType (OscillatorType type)100 ExceptionOr<void> OscillatorNode::setTypeForBindings(OscillatorType type) 101 101 { 102 102 ALWAYS_LOG(LOGIDENTIFIER, type); 103 ASSERT(isMainThread()); 103 104 104 105 if (type == OscillatorType::Custom) { … … 439 440 bool OscillatorNode::propagatesSilence() const 440 441 { 441 return !isPlayingOrScheduled() || hasFinished() || !m_periodicWave.get(); 442 ASSERT(context().isAudioThread()); 443 if (!isPlayingOrScheduled() || hasFinished()) 444 return true; 445 if (!m_processLock.tryLock()) 446 return false; // Assume we have a periodic wave if we are unable to grab the lock. 447 Locker locker { AdoptLock, m_processLock }; 448 return !m_periodicWave.get(); 442 449 } 443 450 -
trunk/Source/WebCore/Modules/webaudio/OscillatorNode.h
r277530 r278285 45 45 const char* activeDOMObjectName() const final { return "OscillatorNode"; } 46 46 47 OscillatorType type () const {return m_type; }48 ExceptionOr<void> setType (OscillatorType);47 OscillatorType typeForBindings() const { ASSERT(isMainThread()); return m_type; } 48 ExceptionOr<void> setTypeForBindings(OscillatorType); 49 49 50 50 AudioParam* frequency() { return m_frequency.get(); } … … 63 63 64 64 // Returns true if there are sample-accurate timeline parameter changes. 65 bool calculateSampleAccuratePhaseIncrements(size_t framesToProcess) ;65 bool calculateSampleAccuratePhaseIncrements(size_t framesToProcess) WTF_REQUIRES_LOCK(m_processLock); 66 66 67 double processARate(int, float* destP, double virtualReadIndex, float* phaseIncrements) ;68 double processKRate(int, float* destP, double virtualReadIndex) ;67 double processARate(int, float* destP, double virtualReadIndex, float* phaseIncrements) WTF_REQUIRES_LOCK(m_processLock); 68 double processKRate(int, float* destP, double virtualReadIndex) WTF_REQUIRES_LOCK(m_processLock); 69 69 70 70 bool propagatesSilence() const final; 71 71 72 72 // One of the waveform types defined in the enum. 73 OscillatorType m_type; 73 OscillatorType m_type; // Only used on the main thread. 74 74 75 75 // Frequency value in Hertz. … … 92 92 AudioFloatArray m_detuneValues; 93 93 94 RefPtr<PeriodicWave> m_periodicWave ;94 RefPtr<PeriodicWave> m_periodicWave WTF_GUARDED_BY_LOCK(m_processLock); 95 95 }; 96 96 -
trunk/Source/WebCore/Modules/webaudio/OscillatorNode.idl
r277530 r278285 32 32 [EnabledBySetting=WebAudio] constructor (BaseAudioContext context, optional OscillatorOptions options); 33 33 34 attribute OscillatorType type;34 [ImplementedAs=typeForBindings] attribute OscillatorType type; 35 35 36 36 readonly attribute AudioParam frequency; // in Hertz
Note:
See TracChangeset
for help on using the changeset viewer.