Changeset 106423 in webkit


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

Dynamic allocate AudioBus with required number of channels for AudioNodeInput
https://bugs.webkit.org/show_bug.cgi?id=76516

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::checkNumberOfChannelsForInput):

  • webaudio/AudioChannelMerger.cpp:

(WebCore::AudioChannelMerger::checkNumberOfChannelsForInput):

  • webaudio/AudioGainNode.cpp:

(WebCore::AudioGainNode::checkNumberOfChannelsForInput):

  • webaudio/AudioNode.cpp:

(WebCore::AudioNode::checkNumberOfChannelsForInput):

  • webaudio/AudioNode.h:
  • webaudio/AudioNodeInput.cpp:

(WebCore::AudioNodeInput::AudioNodeInput):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::internalSummingBus):

  • webaudio/AudioNodeInput.h:
Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r106422 r106423  
     12012-01-31  Raymond Liu  <raymond.liu@intel.com>
     2
     3        Dynamic allocate AudioBus with required number of channels for AudioNodeInput
     4        https://bugs.webkit.org/show_bug.cgi?id=76516
     5
     6        Reviewed by Kenneth Russell.
     7
     8        No new tests required.
     9
     10        * webaudio/AudioBasicProcessorNode.cpp:
     11        (WebCore::AudioBasicProcessorNode::checkNumberOfChannelsForInput):
     12        * webaudio/AudioChannelMerger.cpp:
     13        (WebCore::AudioChannelMerger::checkNumberOfChannelsForInput):
     14        * webaudio/AudioGainNode.cpp:
     15        (WebCore::AudioGainNode::checkNumberOfChannelsForInput):
     16        * webaudio/AudioNode.cpp:
     17        (WebCore::AudioNode::checkNumberOfChannelsForInput):
     18        * webaudio/AudioNode.h:
     19        * webaudio/AudioNodeInput.cpp:
     20        (WebCore::AudioNodeInput::AudioNodeInput):
     21        (WebCore::AudioNodeInput::updateInternalBus):
     22        (WebCore::AudioNodeInput::internalSummingBus):
     23        * webaudio/AudioNodeInput.h:
     24
    1252012-01-31  Alexey Proskuryakov  <ap@apple.com>
    226
  • trunk/Source/WebCore/webaudio/AudioBasicProcessorNode.cpp

    r106420 r106423  
    128128        initialize();
    129129    }
     130
     131    AudioNode::checkNumberOfChannelsForInput(input);
    130132}
    131133
  • trunk/Source/WebCore/webaudio/AudioChannelMerger.cpp

    r96745 r106423  
    9090// Any time a connection or disconnection happens on any of our inputs, we potentially need to change the
    9191// number of channels of our output.
    92 void AudioChannelMerger::checkNumberOfChannelsForInput(AudioNodeInput*)
     92void AudioChannelMerger::checkNumberOfChannelsForInput(AudioNodeInput* input)
    9393{
    9494    ASSERT(context()->isAudioThread() && context()->isGraphOwner());
     
    106106    ASSERT(output);
    107107    output->setNumberOfChannels(numberOfOutputChannels);
     108
     109    AudioNode::checkNumberOfChannelsForInput(input);
    108110}
    109111
  • trunk/Source/WebCore/webaudio/AudioGainNode.cpp

    r106420 r106423  
    111111        initialize();
    112112    }
     113
     114    AudioNode::checkNumberOfChannelsForInput(input);
    113115}
    114116
  • trunk/Source/WebCore/webaudio/AudioNode.cpp

    r103882 r106423  
    183183}
    184184
     185void AudioNode::checkNumberOfChannelsForInput(AudioNodeInput* input)
     186{
     187    ASSERT(context()->isAudioThread() && context()->isGraphOwner());
     188
     189    ASSERT(m_inputs.contains(input));
     190    if (!m_inputs.contains(input))
     191        return;
     192
     193    input->updateInternalBus();
     194}
     195
    185196void AudioNode::pullInputs(size_t framesToProcess)
    186197{
  • trunk/Source/WebCore/webaudio/AudioNode.h

    r103882 r106423  
    130130    // This potentially gives us enough information to perform a lazy initialization or, if necessary, a re-initialization.
    131131    // Called from main thread.
    132     virtual void checkNumberOfChannelsForInput(AudioNodeInput*) { }
     132    virtual void checkNumberOfChannelsForInput(AudioNodeInput*);
    133133
    134134#if DEBUG_AUDIONODE_REFERENCES
  • trunk/Source/WebCore/webaudio/AudioNodeInput.cpp

    r95901 r106423  
    4242    , m_renderingStateNeedUpdating(false)
    4343{
    44     m_monoSummingBus = adoptPtr(new AudioBus(1, AudioNode::ProcessingSizeInFrames));
    45     m_stereoSummingBus = adoptPtr(new AudioBus(2, AudioNode::ProcessingSizeInFrames));
     44    // Set to mono by default.
     45    m_internalSummingBus = adoptPtr(new AudioBus(1, AudioNode::ProcessingSizeInFrames));
    4646}
    4747
     
    160160}
    161161
     162void AudioNodeInput::updateInternalBus()
     163{
     164    ASSERT(context()->isAudioThread() && context()->isGraphOwner());
     165
     166    unsigned numberOfInputChannels = numberOfChannels();
     167
     168    if (numberOfInputChannels == m_internalSummingBus->numberOfChannels())
     169        return;
     170
     171    m_internalSummingBus = adoptPtr(new AudioBus(numberOfInputChannels, AudioNode::ProcessingSizeInFrames));
     172}
     173
    162174unsigned AudioNodeInput::numberOfChannels() const
    163175{
     
    202214    ASSERT(context()->isAudioThread());
    203215
    204     // We must pick a summing bus which is the right size to handle the largest connection.
    205     switch (numberOfRenderingChannels()) {
    206     case 1:
    207         return m_monoSummingBus.get();
    208     case 2:
    209         return m_stereoSummingBus.get();
    210     // FIXME: could implement more than just mono and stereo mixing in the future
    211     }
    212    
    213     ASSERT_NOT_REACHED();
    214     return 0;
     216    ASSERT(numberOfRenderingChannels() == m_internalSummingBus->numberOfChannels());
     217
     218    return m_internalSummingBus.get();
    215219}
    216220
  • trunk/Source/WebCore/webaudio/AudioNodeInput.h

    r95901 r106423  
    7373    void updateRenderingState();
    7474
     75    // updateInternalBus() updates m_internalSummingBus appropriately for the number of channels.
     76    // This must be called when we own the context's graph lock in the audio thread at the very start or end of the render quantum.
     77    void updateInternalBus();
     78
    7579    // Rendering code accesses its version of the current connections here.
    7680    unsigned numberOfRenderingConnections() const { return m_renderingOutputs.size(); }
     
    117121    void sumAllConnections(AudioBus* summingBus, size_t framesToProcess);
    118122
    119     OwnPtr<AudioBus> m_monoSummingBus;
    120     OwnPtr<AudioBus> m_stereoSummingBus;
     123    OwnPtr<AudioBus> m_internalSummingBus;
    121124};
    122125
Note: See TracChangeset for help on using the changeset viewer.