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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioNodeOutput.cpp

Issue 2159403002: Replace ASSERT with DCHECK in WebAudio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return wrapUnique(new AudioNodeOutput(handler, numberOfChannels)); 53 return wrapUnique(new AudioNodeOutput(handler, numberOfChannels));
54 } 54 }
55 55
56 void AudioNodeOutput::dispose() 56 void AudioNodeOutput::dispose()
57 { 57 {
58 #if ENABLE_ASSERT 58 #if ENABLE_ASSERT
59 m_didCallDispose = true; 59 m_didCallDispose = true;
60 #endif 60 #endif
61 deferredTaskHandler().removeMarkedAudioNodeOutput(this); 61 deferredTaskHandler().removeMarkedAudioNodeOutput(this);
62 disconnectAll(); 62 disconnectAll();
63 ASSERT(m_inputs.isEmpty()); 63 DCHECK(m_inputs.isEmpty());
64 ASSERT(m_params.isEmpty()); 64 DCHECK(m_params.isEmpty());
65 } 65 }
66 66
67 void AudioNodeOutput::setNumberOfChannels(unsigned numberOfChannels) 67 void AudioNodeOutput::setNumberOfChannels(unsigned numberOfChannels)
68 { 68 {
69 DCHECK_LE(numberOfChannels, BaseAudioContext::maxNumberOfChannels()); 69 DCHECK_LE(numberOfChannels, BaseAudioContext::maxNumberOfChannels());
70 ASSERT(deferredTaskHandler().isGraphOwner()); 70 ASSERT(deferredTaskHandler().isGraphOwner());
71 71
72 m_desiredNumberOfChannels = numberOfChannels; 72 m_desiredNumberOfChannels = numberOfChannels;
73 73
74 if (deferredTaskHandler().isAudioThread()) { 74 if (deferredTaskHandler().isAudioThread()) {
75 // If we're in the audio thread then we can take care of it right away ( we should be at the very start or end of a rendering quantum). 75 // If we're in the audio thread then we can take care of it right away ( we should be at the very start or end of a rendering quantum).
76 updateNumberOfChannels(); 76 updateNumberOfChannels();
77 } else { 77 } else {
78 ASSERT(!m_didCallDispose); 78 DCHECK(!m_didCallDispose);
79 // Let the context take care of it in the audio thread in the pre and po st render tasks. 79 // Let the context take care of it in the audio thread in the pre and po st render tasks.
80 deferredTaskHandler().markAudioNodeOutputDirty(this); 80 deferredTaskHandler().markAudioNodeOutputDirty(this);
81 } 81 }
82 } 82 }
83 83
84 void AudioNodeOutput::updateInternalBus() 84 void AudioNodeOutput::updateInternalBus()
85 { 85 {
86 if (numberOfChannels() == m_internalBus->numberOfChannels()) 86 if (numberOfChannels() == m_internalBus->numberOfChannels())
87 return; 87 return;
88 88
89 m_internalBus = AudioBus::create(numberOfChannels(), AudioHandler::Processin gSizeInFrames); 89 m_internalBus = AudioBus::create(numberOfChannels(), AudioHandler::Processin gSizeInFrames);
90 } 90 }
91 91
92 void AudioNodeOutput::updateRenderingState() 92 void AudioNodeOutput::updateRenderingState()
93 { 93 {
94 updateNumberOfChannels(); 94 updateNumberOfChannels();
95 m_renderingFanOutCount = fanOutCount(); 95 m_renderingFanOutCount = fanOutCount();
96 m_renderingParamFanOutCount = paramFanOutCount(); 96 m_renderingParamFanOutCount = paramFanOutCount();
97 } 97 }
98 98
99 void AudioNodeOutput::updateNumberOfChannels() 99 void AudioNodeOutput::updateNumberOfChannels()
100 { 100 {
101 ASSERT(deferredTaskHandler().isAudioThread()); 101 DCHECK(deferredTaskHandler().isAudioThread());
102 ASSERT(deferredTaskHandler().isGraphOwner()); 102 ASSERT(deferredTaskHandler().isGraphOwner());
103 103
104 if (m_numberOfChannels != m_desiredNumberOfChannels) { 104 if (m_numberOfChannels != m_desiredNumberOfChannels) {
105 m_numberOfChannels = m_desiredNumberOfChannels; 105 m_numberOfChannels = m_desiredNumberOfChannels;
106 updateInternalBus(); 106 updateInternalBus();
107 propagateChannelCount(); 107 propagateChannelCount();
108 } 108 }
109 } 109 }
110 110
111 void AudioNodeOutput::propagateChannelCount() 111 void AudioNodeOutput::propagateChannelCount()
112 { 112 {
113 ASSERT(deferredTaskHandler().isAudioThread()); 113 DCHECK(deferredTaskHandler().isAudioThread());
114 ASSERT(deferredTaskHandler().isGraphOwner()); 114 ASSERT(deferredTaskHandler().isGraphOwner());
115 115
116 if (isChannelCountKnown()) { 116 if (isChannelCountKnown()) {
117 // Announce to any nodes we're connected to that we changed our channel count for its input. 117 // Announce to any nodes we're connected to that we changed our channel count for its input.
118 for (AudioNodeInput* i : m_inputs) 118 for (AudioNodeInput* i : m_inputs)
119 i->handler().checkNumberOfChannelsForInput(i); 119 i->handler().checkNumberOfChannelsForInput(i);
120 } 120 }
121 } 121 }
122 122
123 AudioBus* AudioNodeOutput::pull(AudioBus* inPlaceBus, size_t framesToProcess) 123 AudioBus* AudioNodeOutput::pull(AudioBus* inPlaceBus, size_t framesToProcess)
124 { 124 {
125 ASSERT(deferredTaskHandler().isAudioThread()); 125 DCHECK(deferredTaskHandler().isAudioThread());
126 ASSERT(m_renderingFanOutCount > 0 || m_renderingParamFanOutCount > 0); 126 DCHECK(m_renderingFanOutCount > 0 || m_renderingParamFanOutCount > 0);
127 127
128 // Causes our AudioNode to process if it hasn't already for this render quan tum. 128 // Causes our AudioNode to process if it hasn't already for this render quan tum.
129 // We try to do in-place processing (using inPlaceBus) if at all possible, 129 // We try to do in-place processing (using inPlaceBus) if at all possible,
130 // but we can't process in-place if we're connected to more than one input ( fan-out > 1). 130 // but we can't process in-place if we're connected to more than one input ( fan-out > 1).
131 // In this case pull() is called multiple times per rendering quantum, and t he processIfNecessary() call below will 131 // In this case pull() is called multiple times per rendering quantum, and t he processIfNecessary() call below will
132 // cause our node to process() only the first time, caching the output in m_ internalOutputBus for subsequent calls. 132 // cause our node to process() only the first time, caching the output in m_ internalOutputBus for subsequent calls.
133 133
134 m_isInPlace = inPlaceBus && inPlaceBus->numberOfChannels() == numberOfChanne ls() && (m_renderingFanOutCount + m_renderingParamFanOutCount) == 1; 134 m_isInPlace = inPlaceBus && inPlaceBus->numberOfChannels() == numberOfChanne ls() && (m_renderingFanOutCount + m_renderingParamFanOutCount) == 1;
135 135
136 m_inPlaceBus = m_isInPlace ? inPlaceBus : 0; 136 m_inPlaceBus = m_isInPlace ? inPlaceBus : 0;
137 137
138 handler().processIfNecessary(framesToProcess); 138 handler().processIfNecessary(framesToProcess);
139 return bus(); 139 return bus();
140 } 140 }
141 141
142 AudioBus* AudioNodeOutput::bus() const 142 AudioBus* AudioNodeOutput::bus() const
143 { 143 {
144 ASSERT(deferredTaskHandler().isAudioThread()); 144 DCHECK(deferredTaskHandler().isAudioThread());
145 return m_isInPlace ? m_inPlaceBus.get() : m_internalBus.get(); 145 return m_isInPlace ? m_inPlaceBus.get() : m_internalBus.get();
146 } 146 }
147 147
148 unsigned AudioNodeOutput::fanOutCount() 148 unsigned AudioNodeOutput::fanOutCount()
149 { 149 {
150 ASSERT(deferredTaskHandler().isGraphOwner()); 150 ASSERT(deferredTaskHandler().isGraphOwner());
151 return m_inputs.size(); 151 return m_inputs.size();
152 } 152 }
153 153
154 unsigned AudioNodeOutput::paramFanOutCount() 154 unsigned AudioNodeOutput::paramFanOutCount()
(...skipping 26 matching lines...) Expand all
181 ASSERT(deferredTaskHandler().isGraphOwner()); 181 ASSERT(deferredTaskHandler().isGraphOwner());
182 182
183 // AudioNodeInput::disconnect() changes m_inputs by calling removeInput(). 183 // AudioNodeInput::disconnect() changes m_inputs by calling removeInput().
184 while (!m_inputs.isEmpty()) 184 while (!m_inputs.isEmpty())
185 (*m_inputs.begin())->disconnect(*this); 185 (*m_inputs.begin())->disconnect(*this);
186 } 186 }
187 187
188 void AudioNodeOutput::disconnectInput(AudioNodeInput& input) 188 void AudioNodeOutput::disconnectInput(AudioNodeInput& input)
189 { 189 {
190 ASSERT(deferredTaskHandler().isGraphOwner()); 190 ASSERT(deferredTaskHandler().isGraphOwner());
191 ASSERT(isConnectedToInput(input)); 191 DCHECK(isConnectedToInput(input));
192 input.disconnect(*this); 192 input.disconnect(*this);
193 } 193 }
194 194
195 void AudioNodeOutput::disconnectAudioParam(AudioParamHandler& param) 195 void AudioNodeOutput::disconnectAudioParam(AudioParamHandler& param)
196 { 196 {
197 ASSERT(deferredTaskHandler().isGraphOwner()); 197 ASSERT(deferredTaskHandler().isGraphOwner());
198 ASSERT(isConnectedToAudioParam(param)); 198 DCHECK(isConnectedToAudioParam(param));
199 param.disconnect(*this); 199 param.disconnect(*this);
200 } 200 }
201 201
202 void AudioNodeOutput::addParam(AudioParamHandler& param) 202 void AudioNodeOutput::addParam(AudioParamHandler& param)
203 { 203 {
204 ASSERT(deferredTaskHandler().isGraphOwner()); 204 ASSERT(deferredTaskHandler().isGraphOwner());
205 m_params.add(&param); 205 m_params.add(&param);
206 } 206 }
207 207
208 void AudioNodeOutput::removeParam(AudioParamHandler& param) 208 void AudioNodeOutput::removeParam(AudioParamHandler& param)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 if (!m_isEnabled) { 256 if (!m_isEnabled) {
257 m_isEnabled = true; 257 m_isEnabled = true;
258 for (AudioNodeInput* i : m_inputs) 258 for (AudioNodeInput* i : m_inputs)
259 i->enable(*this); 259 i->enable(*this);
260 } 260 }
261 } 261 }
262 262
263 } // namespace blink 263 } // namespace blink
264 264
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698