Changeset 94780 in webkit


Ignore:
Timestamp:
Sep 8, 2011 12:22:59 PM (13 years ago)
Author:
crogers@google.com
Message:

Check AudioContext createChannelMerger() for thread safety
https://bugs.webkit.org/show_bug.cgi?id=67247

Reviewed by Kenneth Russell.

Source/WebCore:

Test: webaudio/audiochannelmerger-stereo.html

  • webaudio/AudioChannelMerger.cpp:

(WebCore::AudioChannelMerger::process):
(WebCore::AudioChannelMerger::checkNumberOfChannelsForInput):

  • webaudio/AudioChannelMerger.h:

LayoutTests:

  • webaudio/audiochannelmerger-stereo-expected.txt: Added.
  • webaudio/audiochannelmerger-stereo.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r94779 r94780  
     12011-09-08  Chris Rogers  <crogers@google.com>
     2
     3        Check AudioContext createChannelMerger() for thread safety
     4        https://bugs.webkit.org/show_bug.cgi?id=67247
     5
     6        Reviewed by Kenneth Russell.
     7
     8        * webaudio/audiochannelmerger-stereo-expected.txt: Added.
     9        * webaudio/audiochannelmerger-stereo.html: Added.
     10
    1112011-09-08  Fady Samuel  <fsamuel@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r94778 r94780  
     12011-09-08  Chris Rogers  <crogers@google.com>
     2
     3        Check AudioContext createChannelMerger() for thread safety
     4        https://bugs.webkit.org/show_bug.cgi?id=67247
     5
     6        Reviewed by Kenneth Russell.
     7
     8        Test: webaudio/audiochannelmerger-stereo.html
     9
     10        * webaudio/AudioChannelMerger.cpp:
     11        (WebCore::AudioChannelMerger::process):
     12        (WebCore::AudioChannelMerger::checkNumberOfChannelsForInput):
     13        * webaudio/AudioChannelMerger.h:
     14
    1152011-09-08  Ned Holbrook  <nholbrook@apple.com>
    216
  • trunk/Source/WebCore/webaudio/AudioChannelMerger.cpp

    r68732 r94780  
    3333#include "AudioChannelMerger.h"
    3434
     35#include "AudioContext.h"
    3536#include "AudioNodeInput.h"
    3637#include "AudioNodeOutput.h"
     
    6263    ASSERT_UNUSED(framesToProcess, framesToProcess == output->bus()->length());   
    6364   
    64     // Count how many channels we have all together from all of the inputs.
    65     unsigned numberOfOutputChannels = 0;
    66     for (unsigned i = 0; i < numberOfInputs(); ++i) {
    67         AudioNodeInput* input = this->input(i);
    68         if (input->isConnected())
    69             numberOfOutputChannels += input->bus()->numberOfChannels();
    70     }
    71 
    72     // Set the correct number of channels on the output
    73     output->setNumberOfChannels(numberOfOutputChannels);
    74    
    75     // Now merge the channels back into one output.
     65    // Merge all the channels from all the inputs into one output.
    7666    unsigned outputChannelIndex = 0;
    7767    for (unsigned i = 0; i < numberOfInputs(); ++i) {
     
    9181    }
    9282   
    93     ASSERT(outputChannelIndex == numberOfOutputChannels);
     83    ASSERT(outputChannelIndex == output->numberOfChannels());
    9484}
    9585
     
    9888}
    9989
     90// Any time a connection or disconnection happens on any of our inputs, we potentially need to change the
     91// number of channels of our output.
     92void AudioChannelMerger::checkNumberOfChannelsForInput(AudioNodeInput* input)
     93{
     94    ASSERT(context()->isAudioThread() && context()->isGraphOwner());
     95
     96    // Count how many channels we have all together from all of the inputs.
     97    unsigned numberOfOutputChannels = 0;
     98    for (unsigned i = 0; i < numberOfInputs(); ++i) {
     99        AudioNodeInput* input = this->input(i);
     100        if (input->isConnected())
     101            numberOfOutputChannels += input->bus()->numberOfChannels();
     102    }
     103
     104    // Set the correct number of channels on the output
     105    AudioNodeOutput* output = this->output(0);
     106    ASSERT(output);
     107    output->setNumberOfChannels(numberOfOutputChannels);
     108}
     109
    100110} // namespace WebCore
    101111
  • trunk/Source/WebCore/webaudio/AudioChannelMerger.h

    r68732 r94780  
    4848    virtual void reset();
    4949
     50    // Called in the audio thread (pre-rendering task) when the number of channels for an input may have changed.
     51    virtual void checkNumberOfChannelsForInput(AudioNodeInput*);
     52
    5053private:
    5154    AudioChannelMerger(AudioContext*, double sampleRate);
Note: See TracChangeset for help on using the changeset viewer.