Chromium Code Reviews| Index: third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.cpp |
| diff --git a/third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.cpp b/third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.cpp |
| index f3e0445bb6aed1a29c4558caddbc90a4e868b1d9..736e5f6a48781a54510725ba7b73cc568fedcc20 100644 |
| --- a/third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.cpp |
| +++ b/third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.cpp |
| @@ -151,11 +151,11 @@ AbstractAudioContext::~AbstractAudioContext() |
| { |
| deferredTaskHandler().contextWillBeDestroyed(); |
| // AudioNodes keep a reference to their context, so there should be no way to be in the destructor if there are still AudioNodes around. |
| - ASSERT(!isDestinationInitialized()); |
| - ASSERT(!m_activeSourceNodes.size()); |
| - ASSERT(!m_finishedSourceHandlers.size()); |
| - ASSERT(!m_isResolvingResumePromises); |
| - ASSERT(!m_resumeResolvers.size()); |
| + DCHECK(!isDestinationInitialized()); |
| + DCHECK(!m_activeSourceNodes.size()); |
| + DCHECK(!m_finishedSourceHandlers.size()); |
| + DCHECK(!m_isResolvingResumePromises); |
| + DCHECK(!m_resumeResolvers.size()); |
| } |
| void AbstractAudioContext::initialize() |
| @@ -184,7 +184,7 @@ void AbstractAudioContext::clear() |
| void AbstractAudioContext::uninitialize() |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| if (!isDestinationInitialized()) |
| return; |
| @@ -200,7 +200,7 @@ void AbstractAudioContext::uninitialize() |
| rejectPendingResolvers(); |
| didClose(); |
| - ASSERT(m_listener); |
| + DCHECK(m_listener); |
| m_listener->waitForHRTFDatabaseLoaderThreadCompletion(); |
| clear(); |
| @@ -221,7 +221,7 @@ AudioDestinationNode* AbstractAudioContext::destination() const |
| { |
| // Cannot be called from the audio thread because this method touches objects managed by Oilpan, |
| // and the audio thread is not managed by Oilpan. |
| - ASSERT(!isAudioThread()); |
| + DCHECK(!isAudioThread()); |
| return m_destinationNode; |
| } |
| @@ -280,15 +280,15 @@ AudioBuffer* AbstractAudioContext::createBuffer(unsigned numberOfChannels, size_ |
| ScriptPromise AbstractAudioContext::decodeAudioData(ScriptState* scriptState, DOMArrayBuffer* audioData, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback, ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| - ASSERT(audioData); |
| + DCHECK(isMainThread()); |
| + DCHECK(audioData); |
| ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| ScriptPromise promise = resolver->promise(); |
| float rate = isContextClosed() ? closedContextSampleRate() : sampleRate(); |
| - ASSERT(rate > 0); |
| + DCHECK_GT(rate, 0); |
| m_decodeAudioResolvers.add(resolver); |
| m_audioDecoder.decodeAsync(audioData, rate, successCallback, errorCallback, resolver, this); |
| @@ -298,7 +298,7 @@ ScriptPromise AbstractAudioContext::decodeAudioData(ScriptState* scriptState, DO |
| void AbstractAudioContext::handleDecodeAudioData(AudioBuffer* audioBuffer, ScriptPromiseResolver* resolver, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| if (audioBuffer) { |
| // Resolve promise successfully and run the success callback |
| @@ -314,13 +314,13 @@ void AbstractAudioContext::handleDecodeAudioData(AudioBuffer* audioBuffer, Scrip |
| } |
| // We've resolved the promise. Remove it now. |
| - ASSERT(m_decodeAudioResolvers.contains(resolver)); |
| + DCHECK(m_decodeAudioResolvers.contains(resolver)); |
| m_decodeAudioResolvers.remove(resolver); |
| } |
| AudioBufferSourceNode* AbstractAudioContext::createBufferSource(ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| AudioBufferSourceNode* node = AudioBufferSourceNode::create(*this, exceptionState); |
| @@ -332,14 +332,14 @@ AudioBufferSourceNode* AbstractAudioContext::createBufferSource(ExceptionState& |
| MediaElementAudioSourceNode* AbstractAudioContext::createMediaElementSource(HTMLMediaElement* mediaElement, ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return MediaElementAudioSourceNode::create(*this, *mediaElement, exceptionState); |
| } |
| MediaStreamAudioSourceNode* AbstractAudioContext::createMediaStreamSource(MediaStream* mediaStream, ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return MediaStreamAudioSourceNode::create(*this, *mediaStream, exceptionState); |
| } |
| @@ -375,7 +375,7 @@ ScriptProcessorNode* AbstractAudioContext::createScriptProcessor(size_t bufferSi |
| ScriptProcessorNode* AbstractAudioContext::createScriptProcessor(size_t bufferSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return ScriptProcessorNode::create( |
| *this, |
| @@ -387,56 +387,56 @@ ScriptProcessorNode* AbstractAudioContext::createScriptProcessor(size_t bufferSi |
| StereoPannerNode* AbstractAudioContext::createStereoPanner(ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return StereoPannerNode::create(*this, exceptionState); |
| } |
| BiquadFilterNode* AbstractAudioContext::createBiquadFilter(ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return BiquadFilterNode::create(*this, exceptionState); |
| } |
| WaveShaperNode* AbstractAudioContext::createWaveShaper(ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return WaveShaperNode::create(*this, exceptionState); |
| } |
| PannerNode* AbstractAudioContext::createPanner(ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return PannerNode::create(*this, exceptionState); |
| } |
| ConvolverNode* AbstractAudioContext::createConvolver(ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return ConvolverNode::create(*this, exceptionState); |
| } |
| DynamicsCompressorNode* AbstractAudioContext::createDynamicsCompressor(ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return DynamicsCompressorNode::create(*this, exceptionState); |
| } |
| AnalyserNode* AbstractAudioContext::createAnalyser(ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return AnalyserNode::create(*this, exceptionState); |
| } |
| GainNode* AbstractAudioContext::createGain(ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return GainNode::create(*this, exceptionState); |
| } |
| @@ -450,7 +450,7 @@ DelayNode* AbstractAudioContext::createDelay(ExceptionState& exceptionState) |
| DelayNode* AbstractAudioContext::createDelay(double maxDelayTime, ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return DelayNode::create(*this, maxDelayTime, exceptionState); |
| } |
| @@ -464,7 +464,7 @@ ChannelSplitterNode* AbstractAudioContext::createChannelSplitter(ExceptionState& |
| ChannelSplitterNode* AbstractAudioContext::createChannelSplitter(size_t numberOfOutputs, ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return ChannelSplitterNode::create(*this, numberOfOutputs, exceptionState); |
| } |
| @@ -478,14 +478,14 @@ ChannelMergerNode* AbstractAudioContext::createChannelMerger(ExceptionState& exc |
| ChannelMergerNode* AbstractAudioContext::createChannelMerger(size_t numberOfInputs, ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return ChannelMergerNode::create(*this, numberOfInputs, exceptionState); |
| } |
| OscillatorNode* AbstractAudioContext::createOscillator(ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return OscillatorNode::create(*this, exceptionState); |
| } |
| @@ -499,7 +499,7 @@ PeriodicWave* AbstractAudioContext::createPeriodicWave(DOMFloat32Array* real, DO |
| PeriodicWave* AbstractAudioContext::createPeriodicWave(DOMFloat32Array* real, DOMFloat32Array* imag, const PeriodicWaveConstraints& options, ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| bool disable = options.hasDisableNormalization() ? options.disableNormalization() : false; |
| @@ -508,7 +508,7 @@ PeriodicWave* AbstractAudioContext::createPeriodicWave(DOMFloat32Array* real, DO |
| IIRFilterNode* AbstractAudioContext::createIIRFilter(Vector<double> feedforwardCoef, Vector<double> feedbackCoef, ExceptionState& exceptionState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| return IIRFilterNode::create(*this, feedforwardCoef, feedbackCoef, exceptionState); |
| } |
| @@ -578,19 +578,19 @@ String AbstractAudioContext::state() const |
| void AbstractAudioContext::setContextState(AudioContextState newState) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| // Validate the transitions. The valid transitions are Suspended->Running, Running->Suspended, |
| // and anything->Closed. |
| switch (newState) { |
| case Suspended: |
| - ASSERT(m_contextState == Running); |
| + DCHECK(m_contextState == Running); |
|
hongchan
2016/07/20 16:11:19
Perhaps use DCHECK_EQ?
HyungwookLee
2016/07/22 03:30:33
Done.
|
| break; |
| case Running: |
| - ASSERT(m_contextState == Suspended); |
| + DCHECK(m_contextState == Suspended); |
|
hongchan
2016/07/20 16:11:19
ditto.
HyungwookLee
2016/07/22 03:30:33
Done.
|
| break; |
| case Closed: |
| - ASSERT(m_contextState != Closed); |
| + DCHECK(m_contextState != Closed); |
|
hongchan
2016/07/20 16:11:19
DCHECK_NE here?
HyungwookLee
2016/07/22 03:30:33
Done.
|
| break; |
| } |
| @@ -613,13 +613,13 @@ void AbstractAudioContext::notifyStateChange() |
| void AbstractAudioContext::notifySourceNodeFinishedProcessing(AudioHandler* handler) |
| { |
| - ASSERT(isAudioThread()); |
| + DCHECK(isAudioThread()); |
| m_finishedSourceHandlers.append(handler); |
| } |
| void AbstractAudioContext::removeFinishedSourceNodes() |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| AutoLocker locker(this); |
| // Quadratic worst case, but sizes of both vectors are considered |
| // manageable, especially |m_finishedSourceNodes| is likely to be short. |
| @@ -634,7 +634,7 @@ void AbstractAudioContext::removeFinishedSourceNodes() |
| void AbstractAudioContext::releaseFinishedSourceNodes() |
| { |
| ASSERT(isGraphOwner()); |
| - ASSERT(isAudioThread()); |
| + DCHECK(isAudioThread()); |
| bool didRemove = false; |
| for (AudioHandler* handler : m_finishedSourceHandlers) { |
| for (AudioNode* node : m_activeSourceNodes) { |
| @@ -656,7 +656,7 @@ void AbstractAudioContext::releaseFinishedSourceNodes() |
| void AbstractAudioContext::notifySourceNodeStartedProcessing(AudioNode* node) |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| AutoLocker locker(this); |
| m_activeSourceNodes.append(node); |
| @@ -665,7 +665,7 @@ void AbstractAudioContext::notifySourceNodeStartedProcessing(AudioNode* node) |
| void AbstractAudioContext::releaseActiveSourceNodes() |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| for (auto& sourceNode : m_activeSourceNodes) |
| sourceNode->handler().breakConnection(); |
| @@ -693,7 +693,7 @@ void AbstractAudioContext::handleStoppableSourceNodes() |
| void AbstractAudioContext::handlePreRenderTasks() |
| { |
| - ASSERT(isAudioThread()); |
| + DCHECK(isAudioThread()); |
| // At the beginning of every render quantum, try to update the internal rendering graph state (from main thread changes). |
| // It's OK if the tryLock() fails, we'll just take slightly longer to pick up the changes. |
| @@ -714,7 +714,7 @@ void AbstractAudioContext::handlePreRenderTasks() |
| void AbstractAudioContext::handlePostRenderTasks() |
| { |
| - ASSERT(isAudioThread()); |
| + DCHECK(isAudioThread()); |
| // Must use a tryLock() here too. Don't worry, the lock will very rarely be contended and this method is called frequently. |
| // The worst that can happen is that there will be some nodes which will take slightly longer than usual to be deleted or removed |
| @@ -735,7 +735,7 @@ void AbstractAudioContext::handlePostRenderTasks() |
| void AbstractAudioContext::resolvePromisesForResumeOnMainThread() |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| AutoLocker locker(this); |
| for (auto& resolver : m_resumeResolvers) { |
| @@ -754,7 +754,7 @@ void AbstractAudioContext::resolvePromisesForResumeOnMainThread() |
| void AbstractAudioContext::resolvePromisesForResume() |
| { |
| // This runs inside the AbstractAudioContext's lock when handling pre-render tasks. |
| - ASSERT(isAudioThread()); |
| + DCHECK(isAudioThread()); |
| ASSERT(isGraphOwner()); |
| // Resolve any pending promises created by resume(). Only do this if we haven't already started |
| @@ -776,7 +776,7 @@ void AbstractAudioContext::rejectPendingDecodeAudioDataResolvers() |
| void AbstractAudioContext::rejectPendingResolvers() |
| { |
| - ASSERT(isMainThread()); |
| + DCHECK(isMainThread()); |
| // Audio context is closing down so reject any resume promises that are still pending. |
| @@ -802,8 +802,8 @@ ExecutionContext* AbstractAudioContext::getExecutionContext() const |
| void AbstractAudioContext::startRendering() |
| { |
| // This is called for both online and offline contexts. |
| - ASSERT(isMainThread()); |
| - ASSERT(m_destinationNode); |
| + DCHECK(isMainThread()); |
| + DCHECK(m_destinationNode); |
| recordUserGestureState(); |