Chromium Code Reviews| Index: Source/modules/webaudio/AudioContext.cpp |
| diff --git a/Source/modules/webaudio/AudioContext.cpp b/Source/modules/webaudio/AudioContext.cpp |
| index 0561c3ee7f6b7e74a23b2ad40686052789f4b232..4d858aef494ce27140e0ba37afc4636d90dfca9f 100644 |
| --- a/Source/modules/webaudio/AudioContext.cpp |
| +++ b/Source/modules/webaudio/AudioContext.cpp |
| @@ -119,9 +119,9 @@ AudioContext::AudioContext(Document* document) |
| , m_graphOwnerThread(UndefinedThreadIdentifier) |
| , m_isOfflineContext(false) |
| { |
| - constructCommon(); |
| - |
| m_destinationNode = DefaultAudioDestinationNode::create(this); |
|
Raymond Toy
2014/05/27 17:49:45
Why are these two lines swapped?
KhNo
2014/05/28 14:39:51
It must be initialized after creating m_destinatio
|
| + |
| + constructCommon(); |
| } |
| // Constructor for offline (non-realtime) rendering. |
| @@ -138,12 +138,12 @@ AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t |
| , m_graphOwnerThread(UndefinedThreadIdentifier) |
| , m_isOfflineContext(true) |
| { |
| - constructCommon(); |
| - |
| // Create a new destination for offline rendering. |
| m_renderTarget = AudioBuffer::create(numberOfChannels, numberOfFrames, sampleRate); |
| if (m_renderTarget.get()) |
| m_destinationNode = OfflineAudioDestinationNode::create(this, m_renderTarget.get()); |
| + |
| + constructCommon(); |
|
Raymond Toy
2014/05/27 17:49:45
Why is this moved from the beginning to the end?
KhNo
2014/05/28 14:39:51
It must be initialized after creating m_destinatio
|
| } |
| void AudioContext::constructCommon() |
| @@ -153,6 +153,8 @@ void AudioContext::constructCommon() |
| FFTFrame::initialize(); |
| m_listener = AudioListener::create(); |
| + |
| + initialize(); |
| } |
| AudioContext::~AudioContext() |
| @@ -171,29 +173,18 @@ AudioContext::~AudioContext() |
| ASSERT(!m_renderingAutomaticPullNodes.size()); |
| } |
| -void AudioContext::lazyInitialize() |
| -{ |
| - if (!m_isInitialized) { |
| - // Don't allow the context to initialize a second time after it's already been explicitly uninitialized. |
| - ASSERT(!m_isAudioThreadFinished); |
| - if (!m_isAudioThreadFinished) { |
| - // Creation of a destination node should not start the audio HW. The |
| - // creation of any other AudioNode will initialize the audio HW and start processing |
| - if (m_destinationNode.get()) { |
| - m_destinationNode->initialize(); |
| - |
| - if (!isOfflineContext()) { |
| - // This starts the audio thread. The destination node's provideInput() method will now be called repeatedly to render audio. |
| - // Each time provideInput() is called, a portion of the audio stream is rendered. Let's call this time period a "render quantum". |
| - // NOTE: for now default AudioContext does not need an explicit startRendering() call from JavaScript. |
| - // We may want to consider requiring it for symmetry with OfflineAudioContext. |
| - m_destinationNode->startRendering(); |
|
Raymond Toy
2014/05/27 17:49:45
Don't we still need to call startRendering()?
KhNo
2014/05/28 14:39:51
This is my big mistake. Sorry about it. It must be
|
| - ++s_hardwareContextCount; |
| - } |
| - |
| - m_isInitialized = true; |
| - } |
| - } |
| +void AudioContext::initialize() |
| +{ |
| + // Don't allow the context to initialize a second time after it's already been explicitly uninitialized. |
| + if (isInitialized()) |
| + return; |
| + |
| + if (m_destinationNode) { |
| + if (!isOfflineContext()) |
| + ++s_hardwareContextCount; |
| + |
| + m_destinationNode->initialize(); |
| + m_isInitialized = true; |
| } |
| } |