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

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

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 years, 1 month 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
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 return 0; 163 return 0;
164 } 164 }
165 165
166 AudioNodeOutput* AudioNode::output(unsigned i) 166 AudioNodeOutput* AudioNode::output(unsigned i)
167 { 167 {
168 if (i < m_outputs.size()) 168 if (i < m_outputs.size())
169 return m_outputs[i].get(); 169 return m_outputs[i].get();
170 return 0; 170 return 0;
171 } 171 }
172 172
173 void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i nputIndex, ExceptionState& es) 173 void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i nputIndex, ExceptionState& exceptionState)
174 { 174 {
175 ASSERT(isMainThread()); 175 ASSERT(isMainThread());
176 AudioContext::AutoLocker locker(context()); 176 AudioContext::AutoLocker locker(context());
177 177
178 if (!destination) { 178 if (!destination) {
179 es.throwDOMException( 179 exceptionState.throwDOMException(
180 SyntaxError, 180 SyntaxError,
181 ExceptionMessages::failedToExecute( 181 ExceptionMessages::failedToExecute(
182 "connect", 182 "connect",
183 "AudioNode", 183 "AudioNode",
184 "invalid destination node.")); 184 "invalid destination node."));
185 return; 185 return;
186 } 186 }
187 187
188 // Sanity check input and output indices. 188 // Sanity check input and output indices.
189 if (outputIndex >= numberOfOutputs()) { 189 if (outputIndex >= numberOfOutputs()) {
190 es.throwDOMException( 190 exceptionState.throwDOMException(
191 IndexSizeError, 191 IndexSizeError,
192 ExceptionMessages::failedToExecute( 192 ExceptionMessages::failedToExecute(
193 "connect", 193 "connect",
194 "AudioNode", 194 "AudioNode",
195 "output index (" + String::number(outputIndex) + ") exceeds numb er of outputs (" + String::number(numberOfOutputs()) + ").")); 195 "output index (" + String::number(outputIndex) + ") exceeds numb er of outputs (" + String::number(numberOfOutputs()) + ")."));
196 return; 196 return;
197 } 197 }
198 198
199 if (destination && inputIndex >= destination->numberOfInputs()) { 199 if (destination && inputIndex >= destination->numberOfInputs()) {
200 es.throwDOMException( 200 exceptionState.throwDOMException(
201 IndexSizeError, 201 IndexSizeError,
202 ExceptionMessages::failedToExecute( 202 ExceptionMessages::failedToExecute(
203 "connect", 203 "connect",
204 "AudioNode", 204 "AudioNode",
205 "input index (" + String::number(inputIndex) + ") exceeds number of inputs (" + String::number(destination->numberOfInputs()) + ").")); 205 "input index (" + String::number(inputIndex) + ") exceeds number of inputs (" + String::number(destination->numberOfInputs()) + ")."));
206 return; 206 return;
207 } 207 }
208 208
209 if (context() != destination->context()) { 209 if (context() != destination->context()) {
210 es.throwDOMException( 210 exceptionState.throwDOMException(
211 SyntaxError, 211 SyntaxError,
212 ExceptionMessages::failedToExecute( 212 ExceptionMessages::failedToExecute(
213 "connect", 213 "connect",
214 "AudioNode", 214 "AudioNode",
215 "cannot connect to a destination belonging to a different audio context.")); 215 "cannot connect to a destination belonging to a different audio context."));
216 return; 216 return;
217 } 217 }
218 218
219 AudioNodeInput* input = destination->input(inputIndex); 219 AudioNodeInput* input = destination->input(inputIndex);
220 AudioNodeOutput* output = this->output(outputIndex); 220 AudioNodeOutput* output = this->output(outputIndex);
221 input->connect(output); 221 input->connect(output);
222 222
223 // Let context know that a connection has been made. 223 // Let context know that a connection has been made.
224 context()->incrementConnectionCount(); 224 context()->incrementConnectionCount();
225 } 225 }
226 226
227 void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionState& es) 227 void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionState& exceptionState)
228 { 228 {
229 ASSERT(isMainThread()); 229 ASSERT(isMainThread());
230 AudioContext::AutoLocker locker(context()); 230 AudioContext::AutoLocker locker(context());
231 231
232 if (!param) { 232 if (!param) {
233 es.throwDOMException( 233 exceptionState.throwDOMException(
234 SyntaxError, 234 SyntaxError,
235 ExceptionMessages::failedToExecute( 235 ExceptionMessages::failedToExecute(
236 "connect", 236 "connect",
237 "AudioNode", 237 "AudioNode",
238 "invalid AudioParam.")); 238 "invalid AudioParam."));
239 return; 239 return;
240 } 240 }
241 241
242 if (outputIndex >= numberOfOutputs()) { 242 if (outputIndex >= numberOfOutputs()) {
243 es.throwDOMException( 243 exceptionState.throwDOMException(
244 IndexSizeError, 244 IndexSizeError,
245 ExceptionMessages::failedToExecute( 245 ExceptionMessages::failedToExecute(
246 "connect", 246 "connect",
247 "AudioNode", 247 "AudioNode",
248 "output index (" + String::number(outputIndex) + ") exceeds numb er of outputs (" + String::number(numberOfOutputs()) + ").")); 248 "output index (" + String::number(outputIndex) + ") exceeds numb er of outputs (" + String::number(numberOfOutputs()) + ")."));
249 return; 249 return;
250 } 250 }
251 251
252 if (context() != param->context()) { 252 if (context() != param->context()) {
253 es.throwDOMException( 253 exceptionState.throwDOMException(
254 SyntaxError, 254 SyntaxError,
255 ExceptionMessages::failedToExecute( 255 ExceptionMessages::failedToExecute(
256 "connect", 256 "connect",
257 "AudioNode", 257 "AudioNode",
258 "cannot connect to an AudioParam belonging to a different audio context.")); 258 "cannot connect to an AudioParam belonging to a different audio context."));
259 return; 259 return;
260 } 260 }
261 261
262 AudioNodeOutput* output = this->output(outputIndex); 262 AudioNodeOutput* output = this->output(outputIndex);
263 param->connect(output); 263 param->connect(output);
264 } 264 }
265 265
266 void AudioNode::disconnect(unsigned outputIndex, ExceptionState& es) 266 void AudioNode::disconnect(unsigned outputIndex, ExceptionState& exceptionState)
267 { 267 {
268 ASSERT(isMainThread()); 268 ASSERT(isMainThread());
269 AudioContext::AutoLocker locker(context()); 269 AudioContext::AutoLocker locker(context());
270 270
271 // Sanity check input and output indices. 271 // Sanity check input and output indices.
272 if (outputIndex >= numberOfOutputs()) { 272 if (outputIndex >= numberOfOutputs()) {
273 es.throwDOMException( 273 exceptionState.throwDOMException(
274 IndexSizeError, 274 IndexSizeError,
275 ExceptionMessages::failedToExecute( 275 ExceptionMessages::failedToExecute(
276 "disconnect", 276 "disconnect",
277 "AudioNode", 277 "AudioNode",
278 "output index (" + String::number(outputIndex) + ") exceeds numb er of outputs (" + String::number(numberOfOutputs()) + ").")); 278 "output index (" + String::number(outputIndex) + ") exceeds numb er of outputs (" + String::number(numberOfOutputs()) + ")."));
279 return; 279 return;
280 } 280 }
281 281
282 AudioNodeOutput* output = this->output(outputIndex); 282 AudioNodeOutput* output = this->output(outputIndex);
283 output->disconnectAll(); 283 output->disconnectAll();
284 } 284 }
285 285
286 unsigned long AudioNode::channelCount() 286 unsigned long AudioNode::channelCount()
287 { 287 {
288 return m_channelCount; 288 return m_channelCount;
289 } 289 }
290 290
291 void AudioNode::setChannelCount(unsigned long channelCount, ExceptionState& es) 291 void AudioNode::setChannelCount(unsigned long channelCount, ExceptionState& exce ptionState)
292 { 292 {
293 ASSERT(isMainThread()); 293 ASSERT(isMainThread());
294 AudioContext::AutoLocker locker(context()); 294 AudioContext::AutoLocker locker(context());
295 295
296 if (channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels()) { 296 if (channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels()) {
297 if (m_channelCount != channelCount) { 297 if (m_channelCount != channelCount) {
298 m_channelCount = channelCount; 298 m_channelCount = channelCount;
299 if (m_channelCountMode != Max) 299 if (m_channelCountMode != Max)
300 updateChannelsForInputs(); 300 updateChannelsForInputs();
301 } 301 }
302 } else { 302 } else {
303 es.throwDOMException( 303 exceptionState.throwDOMException(
304 NotSupportedError, 304 NotSupportedError,
305 ExceptionMessages::failedToSet( 305 ExceptionMessages::failedToSet(
306 "channelCount", 306 "channelCount",
307 "AudioNode", 307 "AudioNode",
308 "channel count (" + String::number(channelCount) 308 "channel count (" + String::number(channelCount)
309 + ") must be between 1 and " 309 + ") must be between 1 and "
310 + String::number(AudioContext::maxNumberOfChannels()) + ".")); 310 + String::number(AudioContext::maxNumberOfChannels()) + "."));
311 } 311 }
312 } 312 }
313 313
314 String AudioNode::channelCountMode() 314 String AudioNode::channelCountMode()
315 { 315 {
316 switch (m_channelCountMode) { 316 switch (m_channelCountMode) {
317 case Max: 317 case Max:
318 return "max"; 318 return "max";
319 case ClampedMax: 319 case ClampedMax:
320 return "clamped-max"; 320 return "clamped-max";
321 case Explicit: 321 case Explicit:
322 return "explicit"; 322 return "explicit";
323 } 323 }
324 ASSERT_NOT_REACHED(); 324 ASSERT_NOT_REACHED();
325 return ""; 325 return "";
326 } 326 }
327 327
328 void AudioNode::setChannelCountMode(const String& mode, ExceptionState& es) 328 void AudioNode::setChannelCountMode(const String& mode, ExceptionState& exceptio nState)
329 { 329 {
330 ASSERT(isMainThread()); 330 ASSERT(isMainThread());
331 AudioContext::AutoLocker locker(context()); 331 AudioContext::AutoLocker locker(context());
332 332
333 ChannelCountMode oldMode = m_channelCountMode; 333 ChannelCountMode oldMode = m_channelCountMode;
334 334
335 if (mode == "max") { 335 if (mode == "max") {
336 m_channelCountMode = Max; 336 m_channelCountMode = Max;
337 } else if (mode == "clamped-max") { 337 } else if (mode == "clamped-max") {
338 m_channelCountMode = ClampedMax; 338 m_channelCountMode = ClampedMax;
339 } else if (mode == "explicit") { 339 } else if (mode == "explicit") {
340 m_channelCountMode = Explicit; 340 m_channelCountMode = Explicit;
341 } else { 341 } else {
342 es.throwDOMException( 342 exceptionState.throwDOMException(
343 InvalidStateError, 343 InvalidStateError,
344 ExceptionMessages::failedToSet( 344 ExceptionMessages::failedToSet(
345 "channelCountMode", 345 "channelCountMode",
346 "AudioNode", 346 "AudioNode",
347 "invalid mode '" + mode + "'; must be 'max', 'clamped-max', or ' explicit'.")); 347 "invalid mode '" + mode + "'; must be 'max', 'clamped-max', or ' explicit'."));
348 } 348 }
349 349
350 if (m_channelCountMode != oldMode) 350 if (m_channelCountMode != oldMode)
351 updateChannelsForInputs(); 351 updateChannelsForInputs();
352 } 352 }
353 353
354 String AudioNode::channelInterpretation() 354 String AudioNode::channelInterpretation()
355 { 355 {
356 switch (m_channelInterpretation) { 356 switch (m_channelInterpretation) {
357 case AudioBus::Speakers: 357 case AudioBus::Speakers:
358 return "speakers"; 358 return "speakers";
359 case AudioBus::Discrete: 359 case AudioBus::Discrete:
360 return "discrete"; 360 return "discrete";
361 } 361 }
362 ASSERT_NOT_REACHED(); 362 ASSERT_NOT_REACHED();
363 return ""; 363 return "";
364 } 364 }
365 365
366 void AudioNode::setChannelInterpretation(const String& interpretation, Exception State& es) 366 void AudioNode::setChannelInterpretation(const String& interpretation, Exception State& exceptionState)
367 { 367 {
368 ASSERT(isMainThread()); 368 ASSERT(isMainThread());
369 AudioContext::AutoLocker locker(context()); 369 AudioContext::AutoLocker locker(context());
370 370
371 if (interpretation == "speakers") { 371 if (interpretation == "speakers") {
372 m_channelInterpretation = AudioBus::Speakers; 372 m_channelInterpretation = AudioBus::Speakers;
373 } else if (interpretation == "discrete") { 373 } else if (interpretation == "discrete") {
374 m_channelInterpretation = AudioBus::Discrete; 374 m_channelInterpretation = AudioBus::Discrete;
375 } else { 375 } else {
376 es.throwDOMException( 376 exceptionState.throwDOMException(
377 InvalidStateError, 377 InvalidStateError,
378 ExceptionMessages::failedToSet( 378 ExceptionMessages::failedToSet(
379 "channelInterpretation", 379 "channelInterpretation",
380 "AudioNode", 380 "AudioNode",
381 "invalid interpretation '" + interpretation + "'; must be 'speak ers' or 'discrete'.")); 381 "invalid interpretation '" + interpretation + "'; must be 'speak ers' or 'discrete'."));
382 } 382 }
383 } 383 }
384 384
385 void AudioNode::updateChannelsForInputs() 385 void AudioNode::updateChannelsForInputs()
386 { 386 {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 fprintf(stderr, "%d: %d\n", i, s_nodeCount[i]); 624 fprintf(stderr, "%d: %d\n", i, s_nodeCount[i]);
625 625
626 fprintf(stderr, "===========================\n\n\n"); 626 fprintf(stderr, "===========================\n\n\n");
627 } 627 }
628 628
629 #endif // DEBUG_AUDIONODE_REFERENCES 629 #endif // DEBUG_AUDIONODE_REFERENCES
630 630
631 } // namespace WebCore 631 } // namespace WebCore
632 632
633 #endif // ENABLE(WEB_AUDIO) 633 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioContext.cpp ('k') | Source/modules/webaudio/AudioScheduledSourceNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698