Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(778)

Unified Diff: Source/core/platform/audio/chromium/AudioDestinationChromium.cpp

Issue 14628008: Require use of AudioBus::create() to avoid ref-counting issues (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Require use of Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/audio/chromium/AudioDestinationChromium.cpp
diff --git a/Source/core/platform/audio/chromium/AudioDestinationChromium.cpp b/Source/core/platform/audio/chromium/AudioDestinationChromium.cpp
index 8506a59e0d7942c8fb2f265a1b633a5fd6a51c0c..841c65613f816da296f6fac116c4d070a3ab83dd 100644
--- a/Source/core/platform/audio/chromium/AudioDestinationChromium.cpp
+++ b/Source/core/platform/audio/chromium/AudioDestinationChromium.cpp
@@ -53,8 +53,8 @@ PassOwnPtr<AudioDestination> AudioDestination::create(AudioIOCallback& callback,
AudioDestinationChromium::AudioDestinationChromium(AudioIOCallback& callback, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate)
: m_callback(callback)
, m_numberOfOutputChannels(numberOfOutputChannels)
- , m_inputBus(numberOfInputChannels, renderBufferSize)
- , m_renderBus(numberOfOutputChannels, renderBufferSize, false)
+ , m_inputBus(AudioBus::create(numberOfInputChannels, renderBufferSize))
+ , m_renderBus(AudioBus::create(numberOfOutputChannels, renderBufferSize, false))
, m_sampleRate(sampleRate)
, m_isPlaying(false)
{
@@ -83,8 +83,8 @@ AudioDestinationChromium::AudioDestinationChromium(AudioIOCallback& callback, co
// extra silence for the input. Otherwise, we can over-consume the input FIFO.
if (m_callbackBufferSize != renderBufferSize) {
// FIXME: handle multi-channel input and don't hard-code to stereo.
- AudioBus silence(2, renderBufferSize);
- m_inputFifo->push(&silence);
+ RefPtr<AudioBus> silence = AudioBus::create(2, renderBufferSize);
+ m_inputFifo->push(silence.get());
}
}
@@ -136,24 +136,24 @@ void AudioDestinationChromium::render(const WebKit::WebVector<float*>& sourceDat
// Buffer optional live input.
if (sourceData.size() >= 2) {
// FIXME: handle multi-channel input and don't hard-code to stereo.
- AudioBus wrapperBus(2, numberOfFrames, false);
- wrapperBus.setChannelMemory(0, sourceData[0], numberOfFrames);
- wrapperBus.setChannelMemory(1, sourceData[1], numberOfFrames);
- m_inputFifo->push(&wrapperBus);
+ RefPtr<AudioBus> wrapperBus = AudioBus::create(2, numberOfFrames, false);
+ wrapperBus->setChannelMemory(0, sourceData[0], numberOfFrames);
+ wrapperBus->setChannelMemory(1, sourceData[1], numberOfFrames);
+ m_inputFifo->push(wrapperBus.get());
}
for (unsigned i = 0; i < m_numberOfOutputChannels; ++i)
- m_renderBus.setChannelMemory(i, audioData[i], numberOfFrames);
+ m_renderBus->setChannelMemory(i, audioData[i], numberOfFrames);
- m_fifo->consume(&m_renderBus, numberOfFrames);
+ m_fifo->consume(m_renderBus.get(), numberOfFrames);
}
void AudioDestinationChromium::provideInput(AudioBus* bus, size_t framesToProcess)
{
AudioBus* sourceBus = 0;
if (m_inputFifo->framesInFifo() >= framesToProcess) {
- m_inputFifo->consume(&m_inputBus, framesToProcess);
- sourceBus = &m_inputBus;
+ m_inputFifo->consume(m_inputBus.get(), framesToProcess);
+ sourceBus = m_inputBus.get();
}
m_callback.render(sourceBus, bus, framesToProcess);
« no previous file with comments | « Source/core/platform/audio/chromium/AudioDestinationChromium.h ('k') | Source/core/platform/chromium/support/WebAudioBus.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698