Index: Source/modules/webaudio/AudioContext.cpp |
diff --git a/Source/modules/webaudio/AudioContext.cpp b/Source/modules/webaudio/AudioContext.cpp |
index ced806dde9a14e7f74b3ac1b9e838d79ed01f252..98cf903f1bbc0bd9630dc5295e5940a52ce3857f 100644 |
--- a/Source/modules/webaudio/AudioContext.cpp |
+++ b/Source/modules/webaudio/AudioContext.cpp |
@@ -187,7 +187,6 @@ void AudioContext::lazyInitialize() |
if (!m_isAudioThreadFinished) { |
if (m_destinationNode.get()) { |
m_destinationNode->initialize(); |
- |
Raymond Toy
2014/04/01 17:49:49
Don't gratuitously delete (or add) blank lines.
KhNo
2014/04/01 18:25:08
Done.
|
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". |
@@ -197,8 +196,8 @@ void AudioContext::lazyInitialize() |
++s_hardwareContextCount; |
} |
+ m_isInitialized = true; |
} |
- m_isInitialized = true; |
Raymond Toy
2014/04/01 17:49:49
Why is this moved up?
KhNo
2014/04/01 18:25:08
It should be inside if (m_destinationNode.get()) {
Raymond Toy
2014/04/01 20:20:30
Ah. So it's because the destination node is create
|
} |
} |
} |
@@ -346,7 +345,6 @@ void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassOwnPtr<AudioBuffe |
PassRefPtr<AudioBufferSourceNode> AudioContext::createBufferSource() |
{ |
ASSERT(isMainThread()); |
Raymond Toy
2014/04/01 17:49:49
Should the ASSERT be moved to lazyInitialize?
KhNo
2014/04/01 18:25:08
It couldn't. Those function can be called internal
Raymond Toy
2014/04/01 20:20:30
Ok. Same could be said for lazyInitialize. Now som
|
- lazyInitialize(); |
RefPtr<AudioBufferSourceNode> node = AudioBufferSourceNode::create(this, m_destinationNode->sampleRate()); |
// Because this is an AudioScheduledSourceNode, the context keeps a reference until it has finished playing. |
@@ -358,6 +356,7 @@ PassRefPtr<AudioBufferSourceNode> AudioContext::createBufferSource() |
PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(HTMLMediaElement* mediaElement, ExceptionState& exceptionState) |
{ |
+ ASSERT(isMainThread()); |
if (!mediaElement) { |
exceptionState.throwDOMException( |
InvalidStateError, |
@@ -365,9 +364,6 @@ PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H |
return nullptr; |
} |
- ASSERT(isMainThread()); |
Raymond Toy
2014/04/01 17:49:49
This ASSERT should probably not have been removed.
KhNo
2014/04/01 18:25:08
It doesn't removed, Just move to top of function s
|
- lazyInitialize(); |
- |
// First check if this media element already has a source node. |
if (mediaElement->audioSourceNode()) { |
exceptionState.throwDOMException( |
@@ -386,6 +382,7 @@ PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H |
PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(MediaStream* mediaStream, ExceptionState& exceptionState) |
{ |
+ ASSERT(isMainThread()); |
if (!mediaStream) { |
exceptionState.throwDOMException( |
InvalidStateError, |
@@ -393,9 +390,6 @@ PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(Med |
return nullptr; |
} |
- ASSERT(isMainThread()); |
Raymond Toy
2014/04/01 17:49:49
This ASSERT should not have been removed.
KhNo
2014/04/01 18:25:08
ditto
|
- lazyInitialize(); |
- |
MediaStreamTrackVector audioTracks = mediaStream->getAudioTracks(); |
if (audioTracks.isEmpty()) { |
exceptionState.throwDOMException( |
@@ -443,7 +437,6 @@ PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe |
PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t bufferSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionState& exceptionState) |
{ |
ASSERT(isMainThread()); |
- lazyInitialize(); |
RefPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(this, m_destinationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChannels); |
if (!node.get()) { |
@@ -479,49 +472,42 @@ PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe |
PassRefPtr<BiquadFilterNode> AudioContext::createBiquadFilter() |
{ |
ASSERT(isMainThread()); |
- lazyInitialize(); |
return BiquadFilterNode::create(this, m_destinationNode->sampleRate()); |
} |
PassRefPtr<WaveShaperNode> AudioContext::createWaveShaper() |
{ |
ASSERT(isMainThread()); |
- lazyInitialize(); |
return WaveShaperNode::create(this); |
} |
PassRefPtr<PannerNode> AudioContext::createPanner() |
{ |
ASSERT(isMainThread()); |
- lazyInitialize(); |
return PannerNode::create(this, m_destinationNode->sampleRate()); |
} |
PassRefPtr<ConvolverNode> AudioContext::createConvolver() |
{ |
ASSERT(isMainThread()); |
- lazyInitialize(); |
return ConvolverNode::create(this, m_destinationNode->sampleRate()); |
} |
PassRefPtr<DynamicsCompressorNode> AudioContext::createDynamicsCompressor() |
{ |
ASSERT(isMainThread()); |
- lazyInitialize(); |
return DynamicsCompressorNode::create(this, m_destinationNode->sampleRate()); |
} |
PassRefPtr<AnalyserNode> AudioContext::createAnalyser() |
{ |
ASSERT(isMainThread()); |
- lazyInitialize(); |
return AnalyserNode::create(this, m_destinationNode->sampleRate()); |
} |
PassRefPtr<GainNode> AudioContext::createGain() |
{ |
ASSERT(isMainThread()); |
- lazyInitialize(); |
return GainNode::create(this, m_destinationNode->sampleRate()); |
} |
@@ -534,7 +520,6 @@ PassRefPtr<DelayNode> AudioContext::createDelay(ExceptionState& exceptionState) |
PassRefPtr<DelayNode> AudioContext::createDelay(double maxDelayTime, ExceptionState& exceptionState) |
{ |
ASSERT(isMainThread()); |
- lazyInitialize(); |
RefPtr<DelayNode> node = DelayNode::create(this, m_destinationNode->sampleRate(), maxDelayTime, exceptionState); |
if (exceptionState.hadException()) |
return nullptr; |
@@ -550,8 +535,6 @@ PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(ExceptionSta |
PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numberOfOutputs, ExceptionState& exceptionState) |
{ |
ASSERT(isMainThread()); |
- lazyInitialize(); |
- |
RefPtr<ChannelSplitterNode> node = ChannelSplitterNode::create(this, m_destinationNode->sampleRate(), numberOfOutputs); |
if (!node.get()) { |
@@ -575,8 +558,6 @@ PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(ExceptionState& |
PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfInputs, ExceptionState& exceptionState) |
{ |
ASSERT(isMainThread()); |
- lazyInitialize(); |
- |
RefPtr<ChannelMergerNode> node = ChannelMergerNode::create(this, m_destinationNode->sampleRate(), numberOfInputs); |
if (!node.get()) { |
@@ -594,8 +575,6 @@ PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfI |
PassRefPtr<OscillatorNode> AudioContext::createOscillator() |
{ |
ASSERT(isMainThread()); |
- lazyInitialize(); |
- |
RefPtr<OscillatorNode> node = OscillatorNode::create(this, m_destinationNode->sampleRate()); |
// Because this is an AudioScheduledSourceNode, the context keeps a reference until it has finished playing. |
@@ -608,7 +587,6 @@ PassRefPtr<OscillatorNode> AudioContext::createOscillator() |
PassRefPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Array* real, Float32Array* imag, ExceptionState& exceptionState) |
{ |
ASSERT(isMainThread()); |
- |
Raymond Toy
2014/04/01 17:49:49
Don't gratuitously delete (or add) blank lines.
KhNo
2014/04/01 18:25:08
Done.
|
if (!real) { |
exceptionState.throwDOMException( |
SyntaxError, |
@@ -648,7 +626,6 @@ PassRefPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Array* real, Fl |
return nullptr; |
} |
- lazyInitialize(); |
return PeriodicWave::create(sampleRate(), real, imag); |
} |