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

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

Issue 386343004: WebAudio: Use references instead of pointers in AudioNodeInput and AudioNodeOutput. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/webaudio/AudioNodeOutput.h ('k') | Source/modules/webaudio/AudioParam.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 { 141 {
142 ASSERT(context()->isGraphOwner()); 142 ASSERT(context()->isGraphOwner());
143 return m_params.size(); 143 return m_params.size();
144 } 144 }
145 145
146 unsigned AudioNodeOutput::renderingFanOutCount() const 146 unsigned AudioNodeOutput::renderingFanOutCount() const
147 { 147 {
148 return m_renderingFanOutCount; 148 return m_renderingFanOutCount;
149 } 149 }
150 150
151 void AudioNodeOutput::addInput(AudioNodeInput* input) 151 void AudioNodeOutput::addInput(AudioNodeInput& input)
152 { 152 {
153 ASSERT(context()->isGraphOwner()); 153 ASSERT(context()->isGraphOwner());
154 154 m_inputs.add(&input, &input.node());
155 ASSERT(input); 155 input.node().makeConnection();
156 if (!input)
157 return;
158
159 m_inputs.add(input, input->node());
160 input->node()->makeConnection();
161 } 156 }
162 157
163 void AudioNodeOutput::removeInput(AudioNodeInput* input) 158 void AudioNodeOutput::removeInput(AudioNodeInput& input)
164 { 159 {
165 ASSERT(context()->isGraphOwner()); 160 ASSERT(context()->isGraphOwner());
166 161 input.node().breakConnection();
167 ASSERT(input); 162 m_inputs.remove(&input);
168 if (!input)
169 return;
170
171 input->node()->breakConnection();
172 m_inputs.remove(input);
173 } 163 }
174 164
175 void AudioNodeOutput::disconnectAllInputs() 165 void AudioNodeOutput::disconnectAllInputs()
176 { 166 {
177 ASSERT(context()->isGraphOwner()); 167 ASSERT(context()->isGraphOwner());
178 168
179 // AudioNodeInput::disconnect() changes m_inputs by calling removeInput(). 169 // AudioNodeInput::disconnect() changes m_inputs by calling removeInput().
180 while (!m_inputs.isEmpty()) 170 while (!m_inputs.isEmpty())
181 m_inputs.begin()->key->disconnect(this); 171 m_inputs.begin()->key->disconnect(*this);
182 } 172 }
183 173
184 void AudioNodeOutput::addParam(AudioParam* param) 174 void AudioNodeOutput::addParam(AudioParam& param)
185 { 175 {
186 ASSERT(context()->isGraphOwner()); 176 ASSERT(context()->isGraphOwner());
187 177 m_params.add(&param);
188 ASSERT(param);
189 if (!param)
190 return;
191
192 m_params.add(param);
193 } 178 }
194 179
195 void AudioNodeOutput::removeParam(AudioParam* param) 180 void AudioNodeOutput::removeParam(AudioParam& param)
196 { 181 {
197 ASSERT(context()->isGraphOwner()); 182 ASSERT(context()->isGraphOwner());
198 183 m_params.remove(&param);
199 ASSERT(param);
200 if (!param)
201 return;
202
203 m_params.remove(param);
204 } 184 }
205 185
206 void AudioNodeOutput::disconnectAllParams() 186 void AudioNodeOutput::disconnectAllParams()
207 { 187 {
208 ASSERT(context()->isGraphOwner()); 188 ASSERT(context()->isGraphOwner());
209 189
210 // AudioParam::disconnect() changes m_params by calling removeParam(). 190 // AudioParam::disconnect() changes m_params by calling removeParam().
211 while (!m_params.isEmpty()) { 191 while (!m_params.isEmpty()) {
212 AudioParam* param = m_params.begin()->get(); 192 AudioParam* param = m_params.begin()->get();
213 param->disconnect(this); 193 param->disconnect(this);
214 } 194 }
215 } 195 }
216 196
217 void AudioNodeOutput::disconnectAll() 197 void AudioNodeOutput::disconnectAll()
218 { 198 {
219 disconnectAllInputs(); 199 disconnectAllInputs();
220 disconnectAllParams(); 200 disconnectAllParams();
221 } 201 }
222 202
223 void AudioNodeOutput::disable() 203 void AudioNodeOutput::disable()
224 { 204 {
225 ASSERT(context()->isGraphOwner()); 205 ASSERT(context()->isGraphOwner());
226 206
227 if (m_isEnabled) { 207 if (m_isEnabled) {
228 for (InputsIterator i = m_inputs.begin(); i != m_inputs.end(); ++i) 208 for (InputsIterator i = m_inputs.begin(); i != m_inputs.end(); ++i)
229 i->key->disable(this); 209 i->key->disable(*this);
230 m_isEnabled = false; 210 m_isEnabled = false;
231 } 211 }
232 } 212 }
233 213
234 void AudioNodeOutput::enable() 214 void AudioNodeOutput::enable()
235 { 215 {
236 ASSERT(context()->isGraphOwner()); 216 ASSERT(context()->isGraphOwner());
237 217
238 if (!m_isEnabled) { 218 if (!m_isEnabled) {
239 for (InputsIterator i = m_inputs.begin(); i != m_inputs.end(); ++i) 219 for (InputsIterator i = m_inputs.begin(); i != m_inputs.end(); ++i)
240 i->key->enable(this); 220 i->key->enable(*this);
241 m_isEnabled = true; 221 m_isEnabled = true;
242 } 222 }
243 } 223 }
244 224
245 } // namespace WebCore 225 } // namespace WebCore
246 226
247 #endif // ENABLE(WEB_AUDIO) 227 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioNodeOutput.h ('k') | Source/modules/webaudio/AudioParam.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698