Changeset 149817 in webkit


Ignore:
Timestamp:
May 9, 2013 9:13:05 AM (11 years ago)
Author:
crogers@google.com
Message:

Require use of AudioBus::create() to avoid ref-counting issues
https://bugs.webkit.org/show_bug.cgi?id=115836

Reviewed by Andreas Kling.

There were a couple of places still embedding raw AudioBus objects as
member variables or local variables causing ref-counting problems
now that AudioBus is ref-counted. Make AudioBus constructor private
to enforce use of AudioBus::create().

Adapted from Blink patch:
https://chromiumcodereview.appspot.com/14628008/

  • Modules/webaudio/AudioDestinationNode.h:

(WebCore::AudioDestinationNode::LocalAudioInputProvider::LocalAudioInputProvider):
(WebCore::AudioDestinationNode::LocalAudioInputProvider::set):
(WebCore::AudioDestinationNode::LocalAudioInputProvider::provideInput):
(LocalAudioInputProvider):

  • Modules/webaudio/AudioNodeInput.cpp:

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

  • Modules/webaudio/AudioNodeOutput.cpp:

(WebCore::AudioNodeOutput::AudioNodeOutput):
(WebCore::AudioNodeOutput::updateInternalBus):

  • Modules/webaudio/AudioParam.cpp:

(WebCore::AudioParam::calculateFinalValues):

  • Modules/webaudio/ConvolverNode.cpp:

(WebCore::ConvolverNode::setBuffer):

  • Modules/webaudio/MediaStreamAudioDestinationNode.cpp:

(WebCore::MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode):
(WebCore::MediaStreamAudioDestinationNode::process):

  • Modules/webaudio/MediaStreamAudioDestinationNode.h:
  • Modules/webaudio/OfflineAudioDestinationNode.cpp:

(WebCore::OfflineAudioDestinationNode::OfflineAudioDestinationNode):

  • Modules/webaudio/ScriptProcessorNode.cpp:

(WebCore::ScriptProcessorNode::ScriptProcessorNode):
(WebCore::ScriptProcessorNode::process):

  • Modules/webaudio/ScriptProcessorNode.h:

(ScriptProcessorNode):

  • platform/audio/AudioBus.cpp:

(WebCore::AudioBus::create):
(WebCore):
(WebCore::AudioBus::AudioBus):
(WebCore::AudioBus::createBufferFromRange):
(WebCore::AudioBus::createBySampleRateConverting):
(WebCore::AudioBus::createByMixingToMono):

  • platform/audio/AudioBus.h:

(AudioBus):

  • platform/audio/AudioFIFO.cpp:

(WebCore::AudioFIFO::AudioFIFO):
(WebCore::AudioFIFO::consume):
(WebCore::AudioFIFO::push):

  • platform/audio/AudioFIFO.h:

(AudioFIFO):

  • platform/audio/AudioPullFIFO.cpp:

(WebCore::AudioPullFIFO::AudioPullFIFO):
(WebCore::AudioPullFIFO::fillBuffer):

  • platform/audio/AudioPullFIFO.h:

(AudioPullFIFO):

  • platform/audio/AudioResampler.cpp:

(WebCore::AudioResampler::AudioResampler):
(WebCore::AudioResampler::configureChannels):

  • platform/audio/MultiChannelResampler.cpp:
  • platform/audio/Reverb.cpp:

(WebCore::Reverb::initialize):

  • platform/audio/SincResampler.cpp:

(WebCore::SincResampler::consumeSource):
(WebCore):

  • platform/audio/gstreamer/AudioDestinationGStreamer.cpp:

(WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):

  • platform/audio/gstreamer/AudioDestinationGStreamer.h:

(AudioDestinationGStreamer):

  • platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:

(WebCore::AudioFileReader::createBus):

  • platform/audio/ios/AudioDestinationIOS.cpp:

(WebCore::AudioDestinationIOS::AudioDestinationIOS):
(WebCore::AudioDestinationIOS::render):

  • platform/audio/ios/AudioDestinationIOS.h:

(AudioDestinationIOS):

  • platform/audio/mac/AudioDestinationMac.cpp:

(WebCore::AudioDestinationMac::AudioDestinationMac):
(WebCore::AudioDestinationMac::render):

  • platform/audio/mac/AudioDestinationMac.h:

(AudioDestinationMac):

  • platform/audio/mac/AudioFileReaderMac.cpp:

(WebCore::AudioFileReader::createBus):

Location:
trunk/Source/WebCore
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r149814 r149817  
     12013-05-09  Chris Rogers  <crogers@google.com>
     2
     3        Require use of AudioBus::create() to avoid ref-counting issues
     4        https://bugs.webkit.org/show_bug.cgi?id=115836
     5
     6        Reviewed by Andreas Kling.
     7
     8        There were a couple of places still embedding raw AudioBus objects as
     9        member variables or local variables causing ref-counting problems
     10        now that AudioBus is ref-counted.  Make AudioBus constructor private
     11        to enforce use of AudioBus::create().
     12
     13        Adapted from Blink patch:
     14        https://chromiumcodereview.appspot.com/14628008/
     15
     16        * Modules/webaudio/AudioDestinationNode.h:
     17        (WebCore::AudioDestinationNode::LocalAudioInputProvider::LocalAudioInputProvider):
     18        (WebCore::AudioDestinationNode::LocalAudioInputProvider::set):
     19        (WebCore::AudioDestinationNode::LocalAudioInputProvider::provideInput):
     20        (LocalAudioInputProvider):
     21        * Modules/webaudio/AudioNodeInput.cpp:
     22        (WebCore::AudioNodeInput::AudioNodeInput):
     23        (WebCore::AudioNodeInput::updateInternalBus):
     24        * Modules/webaudio/AudioNodeOutput.cpp:
     25        (WebCore::AudioNodeOutput::AudioNodeOutput):
     26        (WebCore::AudioNodeOutput::updateInternalBus):
     27        * Modules/webaudio/AudioParam.cpp:
     28        (WebCore::AudioParam::calculateFinalValues):
     29        * Modules/webaudio/ConvolverNode.cpp:
     30        (WebCore::ConvolverNode::setBuffer):
     31        * Modules/webaudio/MediaStreamAudioDestinationNode.cpp:
     32        (WebCore::MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode):
     33        (WebCore::MediaStreamAudioDestinationNode::process):
     34        * Modules/webaudio/MediaStreamAudioDestinationNode.h:
     35        * Modules/webaudio/OfflineAudioDestinationNode.cpp:
     36        (WebCore::OfflineAudioDestinationNode::OfflineAudioDestinationNode):
     37        * Modules/webaudio/ScriptProcessorNode.cpp:
     38        (WebCore::ScriptProcessorNode::ScriptProcessorNode):
     39        (WebCore::ScriptProcessorNode::process):
     40        * Modules/webaudio/ScriptProcessorNode.h:
     41        (ScriptProcessorNode):
     42        * platform/audio/AudioBus.cpp:
     43        (WebCore::AudioBus::create):
     44        (WebCore):
     45        (WebCore::AudioBus::AudioBus):
     46        (WebCore::AudioBus::createBufferFromRange):
     47        (WebCore::AudioBus::createBySampleRateConverting):
     48        (WebCore::AudioBus::createByMixingToMono):
     49        * platform/audio/AudioBus.h:
     50        (AudioBus):
     51        * platform/audio/AudioFIFO.cpp:
     52        (WebCore::AudioFIFO::AudioFIFO):
     53        (WebCore::AudioFIFO::consume):
     54        (WebCore::AudioFIFO::push):
     55        * platform/audio/AudioFIFO.h:
     56        (AudioFIFO):
     57        * platform/audio/AudioPullFIFO.cpp:
     58        (WebCore::AudioPullFIFO::AudioPullFIFO):
     59        (WebCore::AudioPullFIFO::fillBuffer):
     60        * platform/audio/AudioPullFIFO.h:
     61        (AudioPullFIFO):
     62        * platform/audio/AudioResampler.cpp:
     63        (WebCore::AudioResampler::AudioResampler):
     64        (WebCore::AudioResampler::configureChannels):
     65        * platform/audio/MultiChannelResampler.cpp:
     66        * platform/audio/Reverb.cpp:
     67        (WebCore::Reverb::initialize):
     68        * platform/audio/SincResampler.cpp:
     69        (WebCore::SincResampler::consumeSource):
     70        (WebCore):
     71        * platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
     72        (WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):
     73        * platform/audio/gstreamer/AudioDestinationGStreamer.h:
     74        (AudioDestinationGStreamer):
     75        * platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:
     76        (WebCore::AudioFileReader::createBus):
     77        * platform/audio/ios/AudioDestinationIOS.cpp:
     78        (WebCore::AudioDestinationIOS::AudioDestinationIOS):
     79        (WebCore::AudioDestinationIOS::render):
     80        * platform/audio/ios/AudioDestinationIOS.h:
     81        (AudioDestinationIOS):
     82        * platform/audio/mac/AudioDestinationMac.cpp:
     83        (WebCore::AudioDestinationMac::AudioDestinationMac):
     84        (WebCore::AudioDestinationMac::render):
     85        * platform/audio/mac/AudioDestinationMac.h:
     86        (AudioDestinationMac):
     87        * platform/audio/mac/AudioFileReaderMac.cpp:
     88        (WebCore::AudioFileReader::createBus):
     89
    1902013-05-09  Alberto Garcia  <agarcia@igalia.com>
    291
  • trunk/Source/WebCore/Modules/webaudio/AudioDestinationNode.h

    r144720 r149817  
    6868    public:
    6969        LocalAudioInputProvider()
    70             : m_sourceBus(2, AudioNode::ProcessingSizeInFrames) // FIXME: handle non-stereo local input.
     70            : m_sourceBus(AudioBus::create(2, AudioNode::ProcessingSizeInFrames)) // FIXME: handle non-stereo local input.
    7171        {
    7272        }
     
    7575        {
    7676            if (bus)
    77                 m_sourceBus.copyFrom(*bus);
     77                m_sourceBus->copyFrom(*bus);
    7878        }
    7979
     
    8181        virtual void provideInput(AudioBus* destinationBus, size_t numberOfFrames)
    8282        {
    83             bool isGood = destinationBus && destinationBus->length() == numberOfFrames && m_sourceBus.length() == numberOfFrames;
     83            bool isGood = destinationBus && destinationBus->length() == numberOfFrames && m_sourceBus->length() == numberOfFrames;
    8484            ASSERT(isGood);
    8585            if (isGood)
    86                 destinationBus->copyFrom(m_sourceBus);
     86                destinationBus->copyFrom(*m_sourceBus);
    8787        }
    8888
    8989    private:
    90         AudioBus m_sourceBus;
     90        RefPtr<AudioBus> m_sourceBus;
    9191    };
    9292
  • trunk/Source/WebCore/Modules/webaudio/AudioNodeInput.cpp

    r149778 r149817  
    4343{
    4444    // Set to mono by default.
    45     m_internalSummingBus = adoptRef(new AudioBus(1, AudioNode::ProcessingSizeInFrames));
     45    m_internalSummingBus = AudioBus::create(1, AudioNode::ProcessingSizeInFrames);
    4646}
    4747
     
    145145        return;
    146146
    147     m_internalSummingBus = adoptRef(new AudioBus(numberOfInputChannels, AudioNode::ProcessingSizeInFrames));
     147    m_internalSummingBus = AudioBus::create(numberOfInputChannels, AudioNode::ProcessingSizeInFrames);
    148148}
    149149
  • trunk/Source/WebCore/Modules/webaudio/AudioNodeOutput.cpp

    r149778 r149817  
    4848    ASSERT(numberOfChannels <= AudioContext::maxNumberOfChannels());
    4949
    50     m_internalBus = adoptRef(new AudioBus(numberOfChannels, AudioNode::ProcessingSizeInFrames));
     50    m_internalBus = AudioBus::create(numberOfChannels, AudioNode::ProcessingSizeInFrames);
    5151}
    5252
     
    7272        return;
    7373
    74     m_internalBus = adoptRef(new AudioBus(numberOfChannels(), AudioNode::ProcessingSizeInFrames));
     74    m_internalBus = AudioBus::create(numberOfChannels(), AudioNode::ProcessingSizeInFrames);
    7575}
    7676
  • trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp

    r142810 r149817  
    137137    // Now sum all of the audio-rate connections together (unity-gain summing junction).
    138138    // Note that connections would normally be mono, but we mix down to mono if necessary.
    139     AudioBus summingBus(1, numberOfValues, false);
    140     summingBus.setChannelMemory(0, values, numberOfValues);
     139    RefPtr<AudioBus> summingBus = AudioBus::create(1, numberOfValues, false);
     140    summingBus->setChannelMemory(0, values, numberOfValues);
    141141
    142142    for (unsigned i = 0; i < numberOfRenderingConnections(); ++i) {
     
    148148
    149149        // Sum, with unity-gain.
    150         summingBus.sumFrom(*connectionBus);
     150        summingBus->sumFrom(*connectionBus);
    151151    }
    152152}
  • trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp

    r144235 r149817  
    133133    // Wrap the AudioBuffer by an AudioBus. It's an efficient pointer set and not a memcpy().
    134134    // This memory is simply used in the Reverb constructor and no reference to it is kept for later use in that class.
    135     AudioBus bufferBus(numberOfChannels, bufferLength, false);
     135    RefPtr<AudioBus> bufferBus = AudioBus::create(numberOfChannels, bufferLength, false);
    136136    for (unsigned i = 0; i < numberOfChannels; ++i)
    137         bufferBus.setChannelMemory(i, buffer->getChannelData(i)->data(), bufferLength);
     137        bufferBus->setChannelMemory(i, buffer->getChannelData(i)->data(), bufferLength);
    138138
    139     bufferBus.setSampleRate(buffer->sampleRate());
     139    bufferBus->setSampleRate(buffer->sampleRate());
    140140
    141141    // Create the reverb with the given impulse response.
    142142    bool useBackgroundThreads = !context()->isOfflineContext();
    143     OwnPtr<Reverb> reverb = adoptPtr(new Reverb(&bufferBus, AudioNode::ProcessingSizeInFrames, MaxFFTSize, 2, useBackgroundThreads, m_normalize));
     143    OwnPtr<Reverb> reverb = adoptPtr(new Reverb(bufferBus.get(), AudioNode::ProcessingSizeInFrames, MaxFFTSize, 2, useBackgroundThreads, m_normalize));
    144144
    145145    {
  • trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.cpp

    r149175 r149817  
    4646MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode(AudioContext* context, size_t numberOfChannels)
    4747    : AudioBasicInspectorNode(context, context->sampleRate(), numberOfChannels)
    48     , m_mixBus(numberOfChannels, ProcessingSizeInFrames)
     48    , m_mixBus(AudioBus::create(numberOfChannels, ProcessingSizeInFrames))
    4949{
    5050    setNodeType(NodeTypeMediaStreamAudioDestination);
     
    7474void MediaStreamAudioDestinationNode::process(size_t numberOfFrames)
    7575{
    76     m_mixBus.copyFrom(*input(0)->bus());
    77     m_source->consumeAudio(&m_mixBus, numberOfFrames);
     76    m_mixBus->copyFrom(*input(0)->bus());
     77    m_source->consumeAudio(m_mixBus.get(), numberOfFrames);
    7878}
    7979
  • trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.h

    r135985 r149817  
    6363    RefPtr<MediaStream> m_stream;
    6464    RefPtr<MediaStreamSource> m_source;
    65     AudioBus m_mixBus;
     65    RefPtr<AudioBus> m_mixBus;
    6666};
    6767
  • trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp

    r149778 r149817  
    4747    , m_startedRendering(false)
    4848{
    49     m_renderBus = adoptRef(new AudioBus(renderTarget->numberOfChannels(), renderQuantumSize));
     49    m_renderBus = AudioBus::create(renderTarget->numberOfChannels(), renderQuantumSize);
    5050}
    5151
  • trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp

    r135156 r149817  
    8080    , m_numberOfInputChannels(numberOfInputChannels)
    8181    , m_numberOfOutputChannels(numberOfOutputChannels)
    82     , m_internalInputBus(numberOfInputChannels, AudioNode::ProcessingSizeInFrames, false)
     82    , m_internalInputBus(AudioBus::create(numberOfInputChannels, AudioNode::ProcessingSizeInFrames, false))
    8383{
    8484    // Regardless of the allowed buffer sizes, we still need to process at the granularity of the AudioNode.
     
    155155
    156156    // Check the consistency of input and output buffers.
    157     unsigned numberOfInputChannels = m_internalInputBus.numberOfChannels();
     157    unsigned numberOfInputChannels = m_internalInputBus->numberOfChannels();
    158158    bool buffersAreGood = outputBuffer && bufferSize() == outputBuffer->length() && m_bufferReadWriteIndex + framesToProcess <= bufferSize();
    159159
    160160    // If the number of input channels is zero, it's ok to have inputBuffer = 0.
    161     if (m_internalInputBus.numberOfChannels())
     161    if (m_internalInputBus->numberOfChannels())
    162162        buffersAreGood = buffersAreGood && inputBuffer && bufferSize() == inputBuffer->length();
    163163
     
    180180
    181181    for (unsigned i = 0; i < numberOfInputChannels; i++)
    182         m_internalInputBus.setChannelMemory(i, inputBuffer->getChannelData(i)->data() + m_bufferReadWriteIndex, framesToProcess);
     182        m_internalInputBus->setChannelMemory(i, inputBuffer->getChannelData(i)->data() + m_bufferReadWriteIndex, framesToProcess);
    183183
    184184    if (numberOfInputChannels)
    185         m_internalInputBus.copyFrom(*inputBus);
     185        m_internalInputBus->copyFrom(*inputBus);
    186186
    187187    // Copy from the output buffer to the output.
  • trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.h

    r131486 r149817  
    107107    unsigned m_numberOfOutputChannels;
    108108
    109     AudioBus m_internalInputBus;
     109    RefPtr<AudioBus> m_internalInputBus;
    110110};
    111111
  • trunk/Source/WebCore/platform/audio/AudioBus.cpp

    r149778 r149817  
    4949const unsigned MaxBusChannels = 32;
    5050
     51PassRefPtr<AudioBus> AudioBus::create(unsigned numberOfChannels, size_t length, bool allocate)
     52{
     53    ASSERT(numberOfChannels <= MaxBusChannels);
     54    if (numberOfChannels > MaxBusChannels)
     55        return 0;
     56
     57    return adoptRef(new AudioBus(numberOfChannels, length, allocate));
     58}
     59
    5160AudioBus::AudioBus(unsigned numberOfChannels, size_t length, bool allocate)
    5261    : m_length(length)
     
    5564    , m_sampleRate(0)
    5665{
    57     ASSERT(numberOfChannels <= MaxBusChannels);
    58     if (numberOfChannels > MaxBusChannels)
    59         return;
    60 
    6166    m_channels.reserveInitialCapacity(numberOfChannels);
    6267
     
    178183    size_t rangeLength = endFrame - startFrame;
    179184
    180     RefPtr<AudioBus> audioBus = adoptRef(new AudioBus(numberOfChannels, rangeLength));
     185    RefPtr<AudioBus> audioBus = create(numberOfChannels, rangeLength);
    181186    audioBus->setSampleRate(sourceBuffer->sampleRate());
    182187
     
    544549
    545550    if (sourceBus->isSilent()) {
    546         RefPtr<AudioBus> silentBus = adoptRef(new AudioBus(numberOfSourceChannels, sourceBus->length() / sampleRateRatio));
     551        RefPtr<AudioBus> silentBus = create(numberOfSourceChannels, sourceBus->length() / sampleRateRatio);
    547552        silentBus->setSampleRate(newSampleRate);
    548553        return silentBus;
     
    566571    // Create destination bus with same number of channels.
    567572    unsigned numberOfDestinationChannels = resamplerSourceBus->numberOfChannels();
    568     RefPtr<AudioBus> destinationBus(adoptRef(new AudioBus(numberOfDestinationChannels, destinationLength)));
     573    RefPtr<AudioBus> destinationBus = create(numberOfDestinationChannels, destinationLength);
    569574
    570575    // Sample-rate convert each channel.
     
    585590{
    586591    if (sourceBus->isSilent())
    587         return adoptRef(new AudioBus(1, sourceBus->length()));
     592        return create(1, sourceBus->length());
    588593
    589594    switch (sourceBus->numberOfChannels()) {
     
    594599        {
    595600            unsigned n = sourceBus->length();
    596             RefPtr<AudioBus> destinationBus(adoptRef(new AudioBus(1, n)));
     601            RefPtr<AudioBus> destinationBus = create(1, n);
    597602
    598603            const float* sourceL = sourceBus->channel(0)->data();
  • trunk/Source/WebCore/platform/audio/AudioBus.h

    r149778 r149817  
    6767    // Normal usage is to pass true here, in which case the AudioChannels will memory-manage their own storage.
    6868    // If allocate is false then setChannelMemory() has to be called later on for each channel before the AudioBus is useable...
    69     AudioBus(unsigned numberOfChannels, size_t length, bool allocate = true);
     69    static PassRefPtr<AudioBus> create(unsigned numberOfChannels, size_t length, bool allocate = true);
    7070
    7171    // Tells the given channel to use an externally allocated buffer.
     
    150150    AudioBus() { };
    151151
     152    AudioBus(unsigned numberOfChannels, size_t length, bool allocate);
     153
    152154    void speakersCopyFrom(const AudioBus&);
    153155    void discreteCopyFrom(const AudioBus&);
  • trunk/Source/WebCore/platform/audio/AudioFIFO.cpp

    r141816 r149817  
    3636
    3737AudioFIFO::AudioFIFO(unsigned numberOfChannels, size_t fifoLength)
    38     : m_fifoAudioBus(numberOfChannels, fifoLength)
     38    : m_fifoAudioBus(AudioBus::create(numberOfChannels, fifoLength))
    3939    , m_fifoLength(fifoLength)
    4040    , m_framesInFifo(0)
     
    5757    findWrapLengths(m_readIndex, framesToConsume, part1Length, part2Length);
    5858
    59     size_t numberOfChannels = m_fifoAudioBus.numberOfChannels();
     59    size_t numberOfChannels = m_fifoAudioBus->numberOfChannels();
    6060
    6161    for (size_t channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex) {
    6262        float* destinationData = destination->channel(channelIndex)->mutableData();
    63         const float* sourceData = m_fifoAudioBus.channel(channelIndex)->data();
     63        const float* sourceData = m_fifoAudioBus->channel(channelIndex)->data();
    6464
    6565        bool isCopyGood = ((m_readIndex < m_fifoLength)
     
    9494    findWrapLengths(m_writeIndex, sourceLength, part1Length, part2Length);
    9595
    96     size_t numberOfChannels = m_fifoAudioBus.numberOfChannels();
     96    size_t numberOfChannels = m_fifoAudioBus->numberOfChannels();
    9797
    9898    for (size_t channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex) {
    99         float* destination = m_fifoAudioBus.channel(channelIndex)->mutableData();
     99        float* destination = m_fifoAudioBus->channel(channelIndex)->mutableData();
    100100        const float* source = sourceBus->channel(channelIndex)->data();
    101101
  • trunk/Source/WebCore/platform/audio/AudioFIFO.h

    r121810 r149817  
    5656   
    5757    // The FIFO itself. In reality, the FIFO is a circular buffer.
    58     AudioBus m_fifoAudioBus;
     58    RefPtr<AudioBus> m_fifoAudioBus;
    5959
    6060    // The total available space in the FIFO.
  • trunk/Source/WebCore/platform/audio/AudioPullFIFO.cpp

    r121810 r149817  
    3939    , m_fifo(numberOfChannels, fifoLength)
    4040    , m_providerSize(providerSize)
    41     , m_tempBus(numberOfChannels, providerSize)
     41    , m_tempBus(AudioBus::create(numberOfChannels, providerSize))
    4242{
    4343}
     
    6363
    6464    while (framesProvided < numberOfFrames) {
    65         m_provider.provideInput(&m_tempBus, m_providerSize);
     65        m_provider.provideInput(m_tempBus.get(), m_providerSize);
    6666
    67         m_fifo.push(&m_tempBus);
     67        m_fifo.push(m_tempBus.get());
    6868
    6969        framesProvided += m_providerSize;
  • trunk/Source/WebCore/platform/audio/AudioPullFIFO.h

    r121810 r149817  
    6767
    6868    // Temporary workspace to hold the data from the provider.
    69     AudioBus m_tempBus;
     69    RefPtr<AudioBus> m_tempBus;
    7070};
    7171
  • trunk/Source/WebCore/platform/audio/AudioResampler.cpp

    r149778 r149817  
    4343{
    4444    m_kernels.append(adoptPtr(new AudioResamplerKernel(this)));
    45     m_sourceBus = adoptRef(new AudioBus(1, 0, false));
     45    m_sourceBus = AudioBus::create(1, 0, false);
    4646}
    4747
     
    5252        m_kernels.append(adoptPtr(new AudioResamplerKernel(this)));
    5353
    54     m_sourceBus = adoptRef(new AudioBus(numberOfChannels, 0, false));
     54    m_sourceBus = AudioBus::create(numberOfChannels, 0, false);
    5555}
    5656
     
    6969
    7070    // Reconfigure our source bus to the new channel size.
    71     m_sourceBus = adoptRef(new AudioBus(numberOfChannels, 0, false));
     71    m_sourceBus = AudioBus::create(numberOfChannels, 0, false);
    7272}
    7373
  • trunk/Source/WebCore/platform/audio/MultiChannelResampler.cpp

    r149778 r149817  
    6565        if (!m_currentChannel) {
    6666            m_framesToProcess = framesToProcess;
    67             m_multiChannelBus = adoptRef(new AudioBus(m_numberOfChannels, framesToProcess));
     67            m_multiChannelBus = AudioBus::create(m_numberOfChannels, framesToProcess);
    6868            m_multiChannelProvider->provideInput(m_multiChannelBus.get(), framesToProcess);
    6969        }
  • trunk/Source/WebCore/platform/audio/Reverb.cpp

    r149778 r149817  
    133133    // It can be bad to allocate memory in a real-time thread.
    134134    if (numResponseChannels == 4)
    135         m_tempBuffer = adoptRef(new AudioBus(2, MaxFrameSize));
     135        m_tempBuffer = AudioBus::create(2, MaxFrameSize);
    136136}
    137137
  • trunk/Source/WebCore/platform/audio/SincResampler.cpp

    r105431 r149817  
    135135   
    136136    // Wrap the provided buffer by an AudioBus for use by the source provider.
    137     AudioBus bus(1, numberOfSourceFrames, false);
     137    RefPtr<AudioBus> bus = AudioBus::create(1, numberOfSourceFrames, false);
    138138
    139139    // FIXME: Find a way to make the following const-correct:
    140     bus.setChannelMemory(0, buffer, numberOfSourceFrames);
    141    
    142     m_sourceProvider->provideInput(&bus, numberOfSourceFrames);
     140    bus->setChannelMemory(0, buffer, numberOfSourceFrames);
     141   
     142    m_sourceProvider->provideInput(bus.get(), numberOfSourceFrames);
    143143}
    144144
  • trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp

    r145808 r149817  
    8080AudioDestinationGStreamer::AudioDestinationGStreamer(AudioIOCallback& callback, float sampleRate)
    8181    : m_callback(callback)
    82     , m_renderBus(2, framesToPull, false)
     82    , m_renderBus(AudioBus::create(2, framesToPull, false))
    8383    , m_sampleRate(sampleRate)
    8484    , m_isPlaying(false)
     
    9292    GstElement* webkitAudioSrc = reinterpret_cast<GstElement*>(g_object_new(WEBKIT_TYPE_WEB_AUDIO_SRC,
    9393                                                                            "rate", sampleRate,
    94                                                                             "bus", &m_renderBus,
     94                                                                            "bus", m_renderBus.get(),
    9595                                                                            "provider", &m_callback,
    9696                                                                            "frames", framesToPull, NULL));
  • trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.h

    r138786 r149817  
    2222#include "AudioBus.h"
    2323#include "AudioDestination.h"
     24#include <wtf/RefPtr.h>
    2425
    2526typedef struct _GstElement GstElement;
     
    4647private:
    4748    AudioIOCallback& m_callback;
    48     AudioBus m_renderBus;
     49    RefPtr<AudioBus> m_renderBus;
    4950
    5051    float m_sampleRate;
  • trunk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp

    r149778 r149817  
    468468
    469469    unsigned channels = mixToMono ? 1 : 2;
    470     RefPtr<AudioBus> audioBus = adoptRef(new AudioBus(channels, m_channelSize, true));
     470    RefPtr<AudioBus> audioBus = AudioBus::create(channels, m_channelSize, true);
    471471    audioBus->setSampleRate(m_sampleRate);
    472472
  • trunk/Source/WebCore/platform/audio/ios/AudioDestinationIOS.cpp

    r147494 r149817  
    102102    : m_outputUnit(0)
    103103    , m_callback(callback)
    104     , m_renderBus(2, kRenderBufferSize, false)
     104    , m_renderBus(AudioBus::create(2, kRenderBufferSize, false))
    105105    , m_sampleRate(sampleRate)
    106106    , m_isPlaying(false)
     
    236236            UInt32 byteOffset = frameOffset * bytesPerFrame;
    237237            float* memory = (float*)((char*)buffers[i].mData + byteOffset);
    238             m_renderBus.setChannelMemory(i, memory, remainingFrames);
     238            m_renderBus->setChannelMemory(i, memory, remainingFrames);
    239239        }
    240         m_callback.render(0, &m_renderBus, remainingFrames);
     240        m_callback.render(0, m_renderBus.get(), remainingFrames);
    241241    }
    242242
  • trunk/Source/WebCore/platform/audio/ios/AudioDestinationIOS.h

    r147561 r149817  
    3535#include "AudioSessionListener.h"
    3636#include <AudioUnit/AudioUnit.h>
     37#include <wtf/RefPtr.h>
    3738
    3839namespace WebCore {
     
    6667    AudioUnit m_outputUnit;
    6768    AudioIOCallback& m_callback;
    68     AudioBus m_renderBus;
     69    RefPtr<AudioBus> m_renderBus;
    6970
    7071    double m_sampleRate;
  • trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.cpp

    r144720 r149817  
    9595    : m_outputUnit(0)
    9696    , m_callback(callback)
    97     , m_renderBus(2, kBufferSize, false)
     97    , m_renderBus(AudioBus::create(2, kBufferSize, false))
    9898    , m_sampleRate(sampleRate)
    9999    , m_isPlaying(false)
     
    176176{
    177177    AudioBuffer* buffers = ioData->mBuffers;
    178     m_renderBus.setChannelMemory(0, (float*)buffers[0].mData, numberOfFrames);
    179     m_renderBus.setChannelMemory(1, (float*)buffers[1].mData, numberOfFrames);
     178    m_renderBus->setChannelMemory(0, (float*)buffers[0].mData, numberOfFrames);
     179    m_renderBus->setChannelMemory(1, (float*)buffers[1].mData, numberOfFrames);
    180180
    181181    // FIXME: Add support for local/live audio input.
    182     m_callback.render(0, &m_renderBus, numberOfFrames);
     182    m_callback.render(0, m_renderBus.get(), numberOfFrames);
    183183
    184184    // Clamp values at 0db (i.e., [-1.0, 1.0])
    185     for (unsigned i = 0; i < m_renderBus.numberOfChannels(); ++i) {
    186         AudioChannel* channel = m_renderBus.channel(i);
     185    for (unsigned i = 0; i < m_renderBus->numberOfChannels(); ++i) {
     186        AudioChannel* channel = m_renderBus->channel(i);
    187187        VectorMath::vclip(channel->data(), 1, &kLowThreshold, &kHighThreshold, channel->mutableData(), 1, numberOfFrames);
    188188    }
  • trunk/Source/WebCore/platform/audio/mac/AudioDestinationMac.h

    r124264 r149817  
    3333#include "AudioDestination.h"
    3434#include <AudioUnit/AudioUnit.h>
     35#include <wtf/RefPtr.h>
    3536
    3637namespace WebCore {
     
    5960    AudioUnit m_outputUnit;
    6061    AudioIOCallback& m_callback;
    61     AudioBus m_renderBus;
     62    RefPtr<AudioBus> m_renderBus;
    6263
    6364    float m_sampleRate;
  • trunk/Source/WebCore/platform/audio/mac/AudioFileReaderMac.cpp

    r149778 r149817  
    179179
    180180    // Create AudioBus where we'll put the PCM audio data
    181     RefPtr<AudioBus> audioBus = adoptRef(new AudioBus(busChannelCount, numberOfFrames));
     181    RefPtr<AudioBus> audioBus = AudioBus::create(busChannelCount, numberOfFrames);
    182182    audioBus->setSampleRate(narrowPrecisionToFloat(m_clientDataFormat.mSampleRate)); // save for later
    183183
Note: See TracChangeset for help on using the changeset viewer.