Changeset 106420 in webkit


Ignore:
Timestamp:
Jan 31, 2012 7:04:48 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Clean up m_processLock logic in AudioBasicProcessorNode and AudioGainNode
https://bugs.webkit.org/show_bug.cgi?id=76772

Patch by Raymond Liu <raymond.liu@intel.com> on 2012-01-31
Reviewed by Kenneth Russell.

No new tests required.

  • webaudio/AudioBasicProcessorNode.cpp:

(WebCore::AudioBasicProcessorNode::process):
(WebCore::AudioBasicProcessorNode::checkNumberOfChannelsForInput):

  • webaudio/AudioBasicProcessorNode.h:
  • webaudio/AudioGainNode.cpp:

(WebCore::AudioGainNode::process):
(WebCore::AudioGainNode::checkNumberOfChannelsForInput):

  • webaudio/AudioGainNode.h:

(AudioGainNode):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r106418 r106420  
     12012-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
    1202012-01-31  Adam Klein  <adamk@chromium.org>
    221
  • trunk/Source/WebCore/webaudio/AudioBasicProcessorNode.cpp

    r106332 r106420  
    7272    AudioBus* destinationBus = output(0)->bus();
    7373   
    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();
    8078
    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();
    8782
    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); 
    9284    }
    9385}
     
    125117    if (isInitialized() && numberOfChannels != output(0)->numberOfChannels()) {
    126118        // 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);
    129119        uninitialize();
    130120    }
  • trunk/Source/WebCore/webaudio/AudioBasicProcessorNode.h

    r96745 r106420  
    5858    AudioProcessor* processor() { return m_processor.get(); }
    5959    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;
    6460};
    6561
  • trunk/Source/WebCore/webaudio/AudioGainNode.cpp

    r96745 r106420  
    6060    ASSERT(outputBus);
    6161
    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();
    6866
    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);
    8074            }
     75        } else {
     76            // Apply the gain with de-zippering into the output bus.
     77            outputBus->copyWithGainFrom(*inputBus, &m_lastGain, gain()->value());
    8178        }
    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();
    8779    }
    8880}
     
    10193void AudioGainNode::checkNumberOfChannelsForInput(AudioNodeInput* input)
    10294{
     95    ASSERT(context()->isAudioThread() && context()->isGraphOwner());
     96
    10397    ASSERT(input && input == this->input(0));
    10498    if (input != this->input(0))
     
    109103    if (isInitialized() && numberOfChannels != output(0)->numberOfChannels()) {
    110104        // 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);
    113105        uninitialize();
    114106    }
  • trunk/Source/WebCore/webaudio/AudioGainNode.h

    r104993 r106420  
    6262
    6363    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;
    6864};
    6965
Note: See TracChangeset for help on using the changeset viewer.