Changeset 106420 in webkit
- Timestamp:
- Jan 31, 2012 7:04:48 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r106418 r106420 1 2012-01-31 Raymond Liu <raymond.liu@intel.com> 2 3 Clean up m_processLock logic in AudioBasicProcessorNode and AudioGainNode 4 https://bugs.webkit.org/show_bug.cgi?id=76772 5 6 Reviewed by Kenneth Russell. 7 8 No new tests required. 9 10 * webaudio/AudioBasicProcessorNode.cpp: 11 (WebCore::AudioBasicProcessorNode::process): 12 (WebCore::AudioBasicProcessorNode::checkNumberOfChannelsForInput): 13 * webaudio/AudioBasicProcessorNode.h: 14 * webaudio/AudioGainNode.cpp: 15 (WebCore::AudioGainNode::process): 16 (WebCore::AudioGainNode::checkNumberOfChannelsForInput): 17 * webaudio/AudioGainNode.h: 18 (AudioGainNode): 19 1 20 2012-01-31 Adam Klein <adamk@chromium.org> 2 21 -
trunk/Source/WebCore/webaudio/AudioBasicProcessorNode.cpp
r106332 r106420 72 72 AudioBus* destinationBus = output(0)->bus(); 73 73 74 // The realtime thread can't block on this lock, so we call tryLock() instead. 75 if (m_processLock.tryLock()) { 76 if (!isInitialized() || !processor()) 77 destinationBus->zero(); 78 else { 79 AudioBus* sourceBus = input(0)->bus(); 74 if (!isInitialized() || !processor()) 75 destinationBus->zero(); 76 else { 77 AudioBus* sourceBus = input(0)->bus(); 80 78 81 // FIXME: if we take "tail time" into account, then we can avoid calling processor()->process() once the tail dies down. 82 if (!input(0)->isConnected()) 83 sourceBus->zero(); 84 85 processor()->process(sourceBus, destinationBus, framesToProcess); 86 } 79 // FIXME: if we take "tail time" into account, then we can avoid calling processor()->process() once the tail dies down. 80 if (!input(0)->isConnected()) 81 sourceBus->zero(); 87 82 88 m_processLock.unlock(); 89 } else { 90 // Too bad - the tryLock() failed. We must be in the middle of re-connecting and were already outputting silence anyway... 91 destinationBus->zero(); 83 processor()->process(sourceBus, destinationBus, framesToProcess); 92 84 } 93 85 } … … 125 117 if (isInitialized() && numberOfChannels != output(0)->numberOfChannels()) { 126 118 // We're already initialized but the channel count has changed. 127 // We need to be careful since we may be actively processing right now, so synchronize with process().128 MutexLocker locker(m_processLock);129 119 uninitialize(); 130 120 } -
trunk/Source/WebCore/webaudio/AudioBasicProcessorNode.h
r96745 r106420 58 58 AudioProcessor* processor() { return m_processor.get(); } 59 59 OwnPtr<AudioProcessor> m_processor; 60 61 private:62 // This synchronizes live channel count changes which require an uninitialization / re-initialization.63 mutable Mutex m_processLock;64 60 }; 65 61 -
trunk/Source/WebCore/webaudio/AudioGainNode.cpp
r96745 r106420 60 60 ASSERT(outputBus); 61 61 62 // The realtime thread can't block on this lock, so we call tryLock() instead. 63 if (m_processLock.tryLock()) { 64 if (!isInitialized() || !input(0)->isConnected()) 65 outputBus->zero(); 66 else { 67 AudioBus* inputBus = input(0)->bus(); 62 if (!isInitialized() || !input(0)->isConnected()) 63 outputBus->zero(); 64 else { 65 AudioBus* inputBus = input(0)->bus(); 68 66 69 if (gain()->hasTimelineValues()) { 70 // Apply sample-accurate gain scaling for precise envelopes, grain windows, etc. 71 ASSERT(framesToProcess <= m_sampleAccurateGainValues.size()); 72 if (framesToProcess <= m_sampleAccurateGainValues.size()) { 73 float* gainValues = m_sampleAccurateGainValues.data(); 74 gain()->calculateSampleAccurateValues(gainValues, framesToProcess); 75 outputBus->copyWithSampleAccurateGainValuesFrom(*inputBus, gainValues, framesToProcess); 76 } 77 } else { 78 // Apply the gain with de-zippering into the output bus. 79 outputBus->copyWithGainFrom(*inputBus, &m_lastGain, gain()->value()); 67 if (gain()->hasTimelineValues()) { 68 // Apply sample-accurate gain scaling for precise envelopes, grain windows, etc. 69 ASSERT(framesToProcess <= m_sampleAccurateGainValues.size()); 70 if (framesToProcess <= m_sampleAccurateGainValues.size()) { 71 float* gainValues = m_sampleAccurateGainValues.data(); 72 gain()->calculateSampleAccurateValues(gainValues, framesToProcess); 73 outputBus->copyWithSampleAccurateGainValuesFrom(*inputBus, gainValues, framesToProcess); 80 74 } 75 } else { 76 // Apply the gain with de-zippering into the output bus. 77 outputBus->copyWithGainFrom(*inputBus, &m_lastGain, gain()->value()); 81 78 } 82 83 m_processLock.unlock();84 } else {85 // Too bad - the tryLock() failed. We must be in the middle of re-connecting and were already outputting silence anyway...86 outputBus->zero();87 79 } 88 80 } … … 101 93 void AudioGainNode::checkNumberOfChannelsForInput(AudioNodeInput* input) 102 94 { 95 ASSERT(context()->isAudioThread() && context()->isGraphOwner()); 96 103 97 ASSERT(input && input == this->input(0)); 104 98 if (input != this->input(0)) … … 109 103 if (isInitialized() && numberOfChannels != output(0)->numberOfChannels()) { 110 104 // We're already initialized but the channel count has changed. 111 // We need to be careful since we may be actively processing right now, so synchronize with process().112 MutexLocker locker(m_processLock);113 105 uninitialize(); 114 106 } -
trunk/Source/WebCore/webaudio/AudioGainNode.h
r104993 r106420 62 62 63 63 AudioFloatArray m_sampleAccurateGainValues; 64 65 // This synchronizes live channel count changes which require an uninitialization / re-initialization.66 // FIXME: this can go away when we implement optimization for mixing with gain directly in summing junction of AudioNodeInput.67 mutable Mutex m_processLock;68 64 }; 69 65
Note: See TracChangeset
for help on using the changeset viewer.