Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 if (context() != param->context()) { | 270 if (context() != param->context()) { |
| 271 exceptionState.throwDOMException( | 271 exceptionState.throwDOMException( |
| 272 SyntaxError, | 272 SyntaxError, |
| 273 "cannot connect to an AudioParam belonging to a different audio cont ext."); | 273 "cannot connect to an AudioParam belonging to a different audio cont ext."); |
| 274 return; | 274 return; |
| 275 } | 275 } |
| 276 | 276 |
| 277 param->connect(*output(outputIndex)); | 277 param->connect(*output(outputIndex)); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void AudioNode::disconnect() | |
| 281 { | |
| 282 ASSERT(isMainThread()); | |
| 283 AudioContext::AutoLocker locker(context()); | |
| 284 | |
| 285 // Disconnect all outgoing connections. | |
| 286 for (unsigned i = 0; i < numberOfOutputs(); ++i) | |
| 287 this->output(i)->disconnectAll(); | |
| 288 } | |
| 289 | |
| 280 void AudioNode::disconnect(unsigned outputIndex, ExceptionState& exceptionState) | 290 void AudioNode::disconnect(unsigned outputIndex, ExceptionState& exceptionState) |
| 281 { | 291 { |
| 282 ASSERT(isMainThread()); | 292 ASSERT(isMainThread()); |
| 283 AudioContext::AutoLocker locker(context()); | 293 AudioContext::AutoLocker locker(context()); |
| 284 | 294 |
| 285 // Sanity check input and output indices. | 295 // Sanity check on the output index. |
| 286 if (outputIndex >= numberOfOutputs()) { | 296 if (outputIndex >= numberOfOutputs()) { |
| 287 exceptionState.throwDOMException( | 297 exceptionState.throwDOMException( |
| 288 IndexSizeError, | 298 IndexSizeError, |
| 289 "output index (" + String::number(outputIndex) + ") exceeds number o f outputs (" + String::number(numberOfOutputs()) + ")."); | 299 "output index (" + String::number(outputIndex) + ") exceeds number o f outputs (" + String::number(numberOfOutputs()) + ")."); |
| 290 return; | 300 return; |
| 291 } | 301 } |
| 292 | 302 |
| 303 // Disconnect all outgoing connections from the given output. | |
| 304 AudioNodeOutput* output = this->output(outputIndex); | |
| 305 output->disconnectAll(); | |
| 306 } | |
| 307 | |
| 308 void AudioNode::disconnect(AudioNode* destination, ExceptionState& exceptionStat e) | |
| 309 { | |
| 310 ASSERT(isMainThread()); | |
| 311 AudioContext::AutoLocker locker(context()); | |
| 312 | |
| 313 bool isConnectedToDestination = false; | |
| 314 | |
| 315 // TO FIX: Can this be optimized? ChannelSplitter and ChannelMerger can have | |
|
Raymond Toy
2015/02/11 21:31:18
s/TO FIX/FIXME/ according to http://www.webkit.org
hongchan
2015/02/12 18:38:01
Done.
| |
| 316 // 32 ports and that requires 1024 iterations to validate entire connections . | |
| 317 for (unsigned i = 0; i < numberOfOutputs(); ++i) { | |
| 318 AudioNodeOutput* output = this->output(i); | |
| 319 for (unsigned j = 0; j < destination->numberOfInputs(); ++j) { | |
| 320 AudioNodeInput* input = destination->input(j); | |
| 321 if (output->isConnectedWithInput(*input)) { | |
| 322 output->disconnectInput(*input); | |
| 323 isConnectedToDestination = true; | |
| 324 } | |
| 325 } | |
| 326 } | |
| 327 | |
| 328 // If there is no connection to the destination, throw an exception. | |
| 329 if (!isConnectedToDestination) { | |
| 330 exceptionState.throwDOMException( | |
| 331 InvalidAccessError, | |
| 332 "the given destination is not connected."); | |
| 333 return; | |
| 334 } | |
| 335 } | |
| 336 | |
| 337 void AudioNode::disconnect(AudioNode* destination, unsigned outputIndex, Excepti onState& exceptionState) | |
| 338 { | |
| 339 ASSERT(isMainThread()); | |
| 340 AudioContext::AutoLocker locker(context()); | |
| 341 | |
| 342 // Sanity check on output index. | |
| 343 if (outputIndex >= numberOfOutputs()) { | |
| 344 exceptionState.throwDOMException( | |
| 345 IndexSizeError, | |
| 346 "output index (" + String::number(outputIndex) + ") exceeds number o f outputs (" + String::number(numberOfOutputs()) + ")."); | |
|
Raymond Toy
2015/02/11 21:31:18
Consider using IndexOutsideOfRange.
hongchan
2015/02/12 18:38:01
Acknowledged.
| |
| 347 return; | |
| 348 } | |
| 349 | |
| 350 bool isConnectedToDestination = false; | |
| 351 AudioNodeOutput* output = this->output(outputIndex); | |
| 352 | |
| 353 // Sanity check on destination inputs and disconnect when possible. | |
| 354 for (unsigned i = 0; i < destination->numberOfInputs(); ++i) { | |
| 355 AudioNodeInput* input = destination->input(i); | |
| 356 if (output->isConnectedWithInput(*input)) { | |
| 357 output->disconnectInput(*input); | |
| 358 isConnectedToDestination = true; | |
| 359 } | |
| 360 } | |
| 361 | |
| 362 // If there is no connection to the destination, throw an exception. | |
| 363 if (!isConnectedToDestination) { | |
| 364 exceptionState.throwDOMException( | |
| 365 InvalidAccessError, | |
| 366 "the given destination is not connected."); | |
|
Raymond Toy
2015/02/11 21:31:18
Give the output index with the message.
hongchan
2015/02/12 18:38:00
I will try to come up with the better error messag
| |
| 367 return; | |
| 368 } | |
| 369 } | |
| 370 | |
| 371 void AudioNode::disconnect(AudioNode* destination, unsigned outputIndex, unsigne d inputIndex, ExceptionState& exceptionState) | |
| 372 { | |
| 373 ASSERT(isMainThread()); | |
| 374 AudioContext::AutoLocker locker(context()); | |
| 375 | |
| 376 // Sanity check input and output indices. | |
| 377 if (outputIndex >= numberOfOutputs()) { | |
| 378 exceptionState.throwDOMException( | |
| 379 IndexSizeError, | |
| 380 "output index (" + String::number(outputIndex) + ") exceeds number o f outputs (" + String::number(numberOfOutputs()) + ")."); | |
|
Raymond Toy
2015/02/11 21:31:18
Consider using IndexOutsideOfRange, here and below
hongchan
2015/02/12 18:38:01
Done.
| |
| 381 return; | |
| 382 } | |
| 383 | |
| 384 if (inputIndex >= destination->numberOfInputs()) { | |
| 385 exceptionState.throwDOMException( | |
| 386 IndexSizeError, | |
| 387 "input index (" + String::number(inputIndex) + ") exceeds number of inputs of destination node (" + String::number(destination->numberOfInputs()) + ")."); | |
| 388 return; | |
| 389 } | |
| 390 | |
| 293 AudioNodeOutput* output = this->output(outputIndex); | 391 AudioNodeOutput* output = this->output(outputIndex); |
| 294 output->disconnectAll(); | 392 AudioNodeInput* input = destination->input(inputIndex); |
| 393 | |
| 394 // Sanity check on the connection between the output and the destination inp ut. | |
| 395 if (!output->isConnectedWithInput(*input)) { | |
| 396 exceptionState.throwDOMException( | |
| 397 InvalidAccessError, | |
| 398 "the given destination input (" + String::number(inputIndex) + ") an d node output (" + String::number(outputIndex) + ") are not connected."); | |
|
Raymond Toy
2015/02/11 21:31:18
I think it reads better to say output # is not con
hongchan
2015/02/12 18:38:01
Done.
| |
| 399 return; | |
| 400 } | |
| 401 | |
| 402 output->disconnectInput(*input); | |
| 403 } | |
| 404 | |
| 405 void AudioNode::disconnect(AudioParam* destinationParam, ExceptionState& excepti onState) | |
| 406 { | |
| 407 ASSERT(isMainThread()); | |
| 408 AudioContext::AutoLocker locker(context()); | |
| 409 | |
| 410 bool isConnectedToDestination = false; | |
| 411 | |
| 412 for (unsigned i = 0; i < numberOfOutputs(); ++i) { | |
| 413 AudioNodeOutput* output = this->output(i); | |
| 414 if (output->isConnectedWithAudioParam(*destinationParam)) { | |
| 415 output->disconnectAudioParam(*destinationParam); | |
| 416 isConnectedToDestination = true; | |
| 417 } | |
| 418 } | |
| 419 | |
| 420 // Throw an exception when there is no valid connection to the destination. | |
| 421 if (!isConnectedToDestination) { | |
| 422 exceptionState.throwDOMException( | |
| 423 InvalidAccessError, | |
| 424 "the given destination AudioParam and the node are not connected."); | |
| 425 return; | |
| 426 } | |
| 427 } | |
| 428 | |
| 429 void AudioNode::disconnect(AudioParam* destinationParam, unsigned outputIndex, E xceptionState& exceptionState) | |
| 430 { | |
| 431 ASSERT(isMainThread()); | |
| 432 AudioContext::AutoLocker locker(context()); | |
| 433 | |
| 434 // Sanity check input and output indices. | |
| 435 if (outputIndex >= numberOfOutputs()) { | |
| 436 exceptionState.throwDOMException( | |
| 437 IndexSizeError, | |
| 438 "output index (" + String::number(outputIndex) + ") exceeds number o f outputs (" + String::number(numberOfOutputs()) + ")."); | |
| 439 return; | |
| 440 } | |
| 441 | |
| 442 AudioNodeOutput* output = this->output(outputIndex); | |
| 443 | |
| 444 // Sanity check on the connection between the output and the destination. | |
| 445 if (!output->isConnectedWithAudioParam(*destinationParam)) { | |
| 446 exceptionState.throwDOMException( | |
| 447 InvalidAccessError, | |
| 448 "specified destination AudioParam and node output (" + String::numbe r(outputIndex) + ") are not connected."); | |
| 449 return; | |
| 450 } | |
| 451 | |
| 452 output->disconnectAudioParam(*destinationParam); | |
| 295 } | 453 } |
| 296 | 454 |
| 297 void AudioNode::disconnectWithoutException(unsigned outputIndex) | 455 void AudioNode::disconnectWithoutException(unsigned outputIndex) |
| 298 { | 456 { |
| 299 ASSERT(isMainThread()); | 457 ASSERT(isMainThread()); |
| 300 AudioContext::AutoLocker locker(context()); | 458 AudioContext::AutoLocker locker(context()); |
| 301 | 459 |
| 302 // Sanity check input and output indices. | 460 // Sanity check input and output indices. |
| 303 if (outputIndex < numberOfOutputs()) { | 461 if (outputIndex < numberOfOutputs()) { |
| 304 AudioNodeOutput* output = this->output(outputIndex); | 462 AudioNodeOutput* output = this->output(outputIndex); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 603 | 761 |
| 604 void AudioNode::updateChannelCountMode() | 762 void AudioNode::updateChannelCountMode() |
| 605 { | 763 { |
| 606 m_channelCountMode = m_newChannelCountMode; | 764 m_channelCountMode = m_newChannelCountMode; |
| 607 updateChannelsForInputs(); | 765 updateChannelsForInputs(); |
| 608 } | 766 } |
| 609 | 767 |
| 610 } // namespace blink | 768 } // namespace blink |
| 611 | 769 |
| 612 #endif // ENABLE(WEB_AUDIO) | 770 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |