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 11 matching lines...) Expand all Loading... |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 */ | 23 */ |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #if ENABLE(WEB_AUDIO) | 26 #if ENABLE(WEB_AUDIO) |
27 #include "modules/webaudio/AudioNode.h" | 27 #include "modules/webaudio/AudioNode.h" |
28 | 28 |
29 #include "bindings/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
30 #include "core/dom/ExceptionCode.h" | 30 #include "core/dom/ExceptionCode.h" |
31 #include "core/inspector/InstanceCounters.h" | 31 #include "core/inspector/InstanceCounters.h" |
32 #include "modules/webaudio/AudioContext.h" | 32 #include "modules/webaudio/AbstractAudioContext.h" |
33 #include "modules/webaudio/AudioNodeInput.h" | 33 #include "modules/webaudio/AudioNodeInput.h" |
34 #include "modules/webaudio/AudioNodeOutput.h" | 34 #include "modules/webaudio/AudioNodeOutput.h" |
35 #include "modules/webaudio/AudioParam.h" | 35 #include "modules/webaudio/AudioParam.h" |
36 #include "wtf/Atomics.h" | 36 #include "wtf/Atomics.h" |
37 #include "wtf/MainThread.h" | 37 #include "wtf/MainThread.h" |
38 | 38 |
39 #if DEBUG_AUDIONODE_REFERENCES | 39 #if DEBUG_AUDIONODE_REFERENCES |
40 #include <stdio.h> | 40 #include <stdio.h> |
41 #endif | 41 #endif |
42 | 42 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 output->dispose(); | 106 output->dispose(); |
107 m_node = nullptr; | 107 m_node = nullptr; |
108 } | 108 } |
109 | 109 |
110 AudioNode* AudioHandler::node() const | 110 AudioNode* AudioHandler::node() const |
111 { | 111 { |
112 ASSERT(isMainThread()); | 112 ASSERT(isMainThread()); |
113 return m_node; | 113 return m_node; |
114 } | 114 } |
115 | 115 |
116 AudioContext* AudioHandler::context() const | 116 AbstractAudioContext* AudioHandler::context() const |
117 { | 117 { |
118 return m_context; | 118 return m_context; |
119 } | 119 } |
120 | 120 |
121 String AudioHandler::nodeTypeName() const | 121 String AudioHandler::nodeTypeName() const |
122 { | 122 { |
123 switch (m_nodeType) { | 123 switch (m_nodeType) { |
124 case NodeTypeDestination: | 124 case NodeTypeDestination: |
125 return "AudioDestinationNode"; | 125 return "AudioDestinationNode"; |
126 case NodeTypeOscillator: | 126 case NodeTypeOscillator: |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 | 205 |
206 unsigned long AudioHandler::channelCount() | 206 unsigned long AudioHandler::channelCount() |
207 { | 207 { |
208 return m_channelCount; | 208 return m_channelCount; |
209 } | 209 } |
210 | 210 |
211 void AudioHandler::setChannelCount(unsigned long channelCount, ExceptionState& e
xceptionState) | 211 void AudioHandler::setChannelCount(unsigned long channelCount, ExceptionState& e
xceptionState) |
212 { | 212 { |
213 ASSERT(isMainThread()); | 213 ASSERT(isMainThread()); |
214 AudioContext::AutoLocker locker(context()); | 214 AbstractAudioContext::AutoLocker locker(context()); |
215 | 215 |
216 if (channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels())
{ | 216 if (channelCount > 0 && channelCount <= AbstractAudioContext::maxNumberOfCha
nnels()) { |
217 if (m_channelCount != channelCount) { | 217 if (m_channelCount != channelCount) { |
218 m_channelCount = channelCount; | 218 m_channelCount = channelCount; |
219 if (m_channelCountMode != Max) | 219 if (m_channelCountMode != Max) |
220 updateChannelsForInputs(); | 220 updateChannelsForInputs(); |
221 } | 221 } |
222 } else { | 222 } else { |
223 exceptionState.throwDOMException( | 223 exceptionState.throwDOMException( |
224 NotSupportedError, | 224 NotSupportedError, |
225 ExceptionMessages::indexOutsideRange<unsigned long>( | 225 ExceptionMessages::indexOutsideRange<unsigned long>( |
226 "channel count", | 226 "channel count", |
227 channelCount, | 227 channelCount, |
228 1, | 228 1, |
229 ExceptionMessages::InclusiveBound, | 229 ExceptionMessages::InclusiveBound, |
230 AudioContext::maxNumberOfChannels(), | 230 AbstractAudioContext::maxNumberOfChannels(), |
231 ExceptionMessages::InclusiveBound)); | 231 ExceptionMessages::InclusiveBound)); |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 String AudioHandler::channelCountMode() | 235 String AudioHandler::channelCountMode() |
236 { | 236 { |
237 switch (m_channelCountMode) { | 237 switch (m_channelCountMode) { |
238 case Max: | 238 case Max: |
239 return "max"; | 239 return "max"; |
240 case ClampedMax: | 240 case ClampedMax: |
241 return "clamped-max"; | 241 return "clamped-max"; |
242 case Explicit: | 242 case Explicit: |
243 return "explicit"; | 243 return "explicit"; |
244 } | 244 } |
245 ASSERT_NOT_REACHED(); | 245 ASSERT_NOT_REACHED(); |
246 return ""; | 246 return ""; |
247 } | 247 } |
248 | 248 |
249 void AudioHandler::setChannelCountMode(const String& mode, ExceptionState& excep
tionState) | 249 void AudioHandler::setChannelCountMode(const String& mode, ExceptionState& excep
tionState) |
250 { | 250 { |
251 ASSERT(isMainThread()); | 251 ASSERT(isMainThread()); |
252 AudioContext::AutoLocker locker(context()); | 252 AbstractAudioContext::AutoLocker locker(context()); |
253 | 253 |
254 ChannelCountMode oldMode = m_channelCountMode; | 254 ChannelCountMode oldMode = m_channelCountMode; |
255 | 255 |
256 if (mode == "max") { | 256 if (mode == "max") { |
257 m_newChannelCountMode = Max; | 257 m_newChannelCountMode = Max; |
258 } else if (mode == "clamped-max") { | 258 } else if (mode == "clamped-max") { |
259 m_newChannelCountMode = ClampedMax; | 259 m_newChannelCountMode = ClampedMax; |
260 } else if (mode == "explicit") { | 260 } else if (mode == "explicit") { |
261 m_newChannelCountMode = Explicit; | 261 m_newChannelCountMode = Explicit; |
262 } else { | 262 } else { |
(...skipping 12 matching lines...) Expand all Loading... |
275 case AudioBus::Discrete: | 275 case AudioBus::Discrete: |
276 return "discrete"; | 276 return "discrete"; |
277 } | 277 } |
278 ASSERT_NOT_REACHED(); | 278 ASSERT_NOT_REACHED(); |
279 return ""; | 279 return ""; |
280 } | 280 } |
281 | 281 |
282 void AudioHandler::setChannelInterpretation(const String& interpretation, Except
ionState& exceptionState) | 282 void AudioHandler::setChannelInterpretation(const String& interpretation, Except
ionState& exceptionState) |
283 { | 283 { |
284 ASSERT(isMainThread()); | 284 ASSERT(isMainThread()); |
285 AudioContext::AutoLocker locker(context()); | 285 AbstractAudioContext::AutoLocker locker(context()); |
286 | 286 |
287 if (interpretation == "speakers") { | 287 if (interpretation == "speakers") { |
288 m_channelInterpretation = AudioBus::Speakers; | 288 m_channelInterpretation = AudioBus::Speakers; |
289 } else if (interpretation == "discrete") { | 289 } else if (interpretation == "discrete") { |
290 m_channelInterpretation = AudioBus::Discrete; | 290 m_channelInterpretation = AudioBus::Discrete; |
291 } else { | 291 } else { |
292 ASSERT_NOT_REACHED(); | 292 ASSERT_NOT_REACHED(); |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 void AudioHandler::unsilenceOutputs() | 383 void AudioHandler::unsilenceOutputs() |
384 { | 384 { |
385 for (auto& output : m_outputs) | 385 for (auto& output : m_outputs) |
386 output->bus()->clearSilentFlag(); | 386 output->bus()->clearSilentFlag(); |
387 } | 387 } |
388 | 388 |
389 void AudioHandler::enableOutputsIfNecessary() | 389 void AudioHandler::enableOutputsIfNecessary() |
390 { | 390 { |
391 if (m_isDisabled && m_connectionRefCount > 0) { | 391 if (m_isDisabled && m_connectionRefCount > 0) { |
392 ASSERT(isMainThread()); | 392 ASSERT(isMainThread()); |
393 AudioContext::AutoLocker locker(context()); | 393 AbstractAudioContext::AutoLocker locker(context()); |
394 | 394 |
395 m_isDisabled = false; | 395 m_isDisabled = false; |
396 for (auto& output : m_outputs) | 396 for (auto& output : m_outputs) |
397 output->enable(); | 397 output->enable(); |
398 } | 398 } |
399 } | 399 } |
400 | 400 |
401 void AudioHandler::disableOutputsIfNecessary() | 401 void AudioHandler::disableOutputsIfNecessary() |
402 { | 402 { |
403 // Disable outputs if appropriate. We do this if the number of connections i
s 0 or 1. The case | 403 // Disable outputs if appropriate. We do this if the number of connections i
s 0 or 1. The case |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 unsigned AudioHandler::numberOfOutputChannels() const | 506 unsigned AudioHandler::numberOfOutputChannels() const |
507 { | 507 { |
508 // This should only be called for ScriptProcessorNodes which are the only no
des where you can | 508 // This should only be called for ScriptProcessorNodes which are the only no
des where you can |
509 // have an output with 0 channels. All other nodes have have at least one o
utput channel, so | 509 // have an output with 0 channels. All other nodes have have at least one o
utput channel, so |
510 // there's no reason other nodes should ever call this function. | 510 // there's no reason other nodes should ever call this function. |
511 ASSERT_WITH_MESSAGE(1, "numberOfOutputChannels() not valid for node type %d"
, nodeType()); | 511 ASSERT_WITH_MESSAGE(1, "numberOfOutputChannels() not valid for node type %d"
, nodeType()); |
512 return 1; | 512 return 1; |
513 } | 513 } |
514 // ---------------------------------------------------------------- | 514 // ---------------------------------------------------------------- |
515 | 515 |
516 AudioNode::AudioNode(AudioContext& context) | 516 AudioNode::AudioNode(AbstractAudioContext& context) |
517 : m_context(context) | 517 : m_context(context) |
518 , m_handler(nullptr) | 518 , m_handler(nullptr) |
519 { | 519 { |
520 ThreadState::current()->registerPreFinalizer(this); | 520 ThreadState::current()->registerPreFinalizer(this); |
521 } | 521 } |
522 | 522 |
523 void AudioNode::dispose() | 523 void AudioNode::dispose() |
524 { | 524 { |
525 ASSERT(isMainThread()); | 525 ASSERT(isMainThread()); |
526 AudioContext::AutoLocker locker(context()); | 526 AbstractAudioContext::AutoLocker locker(context()); |
527 handler().dispose(); | 527 handler().dispose(); |
528 if (context()->contextState() == AudioContext::Running) | 528 if (context()->contextState() == AbstractAudioContext::Running) |
529 context()->deferredTaskHandler().addRenderingOrphanHandler(m_handler.rel
ease()); | 529 context()->deferredTaskHandler().addRenderingOrphanHandler(m_handler.rel
ease()); |
530 } | 530 } |
531 | 531 |
532 void AudioNode::setHandler(PassRefPtr<AudioHandler> handler) | 532 void AudioNode::setHandler(PassRefPtr<AudioHandler> handler) |
533 { | 533 { |
534 ASSERT(handler); | 534 ASSERT(handler); |
535 m_handler = handler; | 535 m_handler = handler; |
536 } | 536 } |
537 | 537 |
538 AudioHandler& AudioNode::handler() const | 538 AudioHandler& AudioNode::handler() const |
539 { | 539 { |
540 return *m_handler; | 540 return *m_handler; |
541 } | 541 } |
542 | 542 |
543 DEFINE_TRACE(AudioNode) | 543 DEFINE_TRACE(AudioNode) |
544 { | 544 { |
545 visitor->trace(m_context); | 545 visitor->trace(m_context); |
546 visitor->trace(m_connectedNodes); | 546 visitor->trace(m_connectedNodes); |
547 visitor->trace(m_connectedParams); | 547 visitor->trace(m_connectedParams); |
548 RefCountedGarbageCollectedEventTargetWithInlineData<AudioNode>::trace(visito
r); | 548 RefCountedGarbageCollectedEventTargetWithInlineData<AudioNode>::trace(visito
r); |
549 } | 549 } |
550 | 550 |
551 AudioContext* AudioNode::context() const | 551 AbstractAudioContext* AudioNode::context() const |
552 { | 552 { |
553 return m_context; | 553 return m_context; |
554 } | 554 } |
555 | 555 |
556 void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i
nputIndex, ExceptionState& exceptionState) | 556 void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i
nputIndex, ExceptionState& exceptionState) |
557 { | 557 { |
558 ASSERT(isMainThread()); | 558 ASSERT(isMainThread()); |
559 AudioContext::AutoLocker locker(context()); | 559 AbstractAudioContext::AutoLocker locker(context()); |
560 | 560 |
561 if (context()->isContextClosed()) { | 561 if (context()->isContextClosed()) { |
562 exceptionState.throwDOMException( | 562 exceptionState.throwDOMException( |
563 InvalidStateError, | 563 InvalidStateError, |
564 "Cannot connect after the context has been closed."); | 564 "Cannot connect after the context has been closed."); |
565 return; | 565 return; |
566 } | 566 } |
567 | 567 |
568 if (!destination) { | 568 if (!destination) { |
569 exceptionState.throwDOMException( | 569 exceptionState.throwDOMException( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 m_connectedNodes[outputIndex] = new HeapHashSet<Member<AudioNode>>(); | 609 m_connectedNodes[outputIndex] = new HeapHashSet<Member<AudioNode>>(); |
610 m_connectedNodes[outputIndex]->add(destination); | 610 m_connectedNodes[outputIndex]->add(destination); |
611 | 611 |
612 // Let context know that a connection has been made. | 612 // Let context know that a connection has been made. |
613 context()->incrementConnectionCount(); | 613 context()->incrementConnectionCount(); |
614 } | 614 } |
615 | 615 |
616 void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionState&
exceptionState) | 616 void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionState&
exceptionState) |
617 { | 617 { |
618 ASSERT(isMainThread()); | 618 ASSERT(isMainThread()); |
619 AudioContext::AutoLocker locker(context()); | 619 AbstractAudioContext::AutoLocker locker(context()); |
620 | 620 |
621 if (context()->isContextClosed()) { | 621 if (context()->isContextClosed()) { |
622 exceptionState.throwDOMException( | 622 exceptionState.throwDOMException( |
623 InvalidStateError, | 623 InvalidStateError, |
624 "Cannot connect after the context has been closed."); | 624 "Cannot connect after the context has been closed."); |
625 return; | 625 return; |
626 } | 626 } |
627 | 627 |
628 if (!param) { | 628 if (!param) { |
629 exceptionState.throwDOMException( | 629 exceptionState.throwDOMException( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 if (!output.isConnectedToAudioParam(param.handler())) | 676 if (!output.isConnectedToAudioParam(param.handler())) |
677 return false; | 677 return false; |
678 output.disconnectAudioParam(param.handler()); | 678 output.disconnectAudioParam(param.handler()); |
679 m_connectedParams[outputIndex]->remove(¶m); | 679 m_connectedParams[outputIndex]->remove(¶m); |
680 return true; | 680 return true; |
681 } | 681 } |
682 | 682 |
683 void AudioNode::disconnect() | 683 void AudioNode::disconnect() |
684 { | 684 { |
685 ASSERT(isMainThread()); | 685 ASSERT(isMainThread()); |
686 AudioContext::AutoLocker locker(context()); | 686 AbstractAudioContext::AutoLocker locker(context()); |
687 | 687 |
688 // Disconnect all outgoing connections. | 688 // Disconnect all outgoing connections. |
689 for (unsigned i = 0; i < numberOfOutputs(); ++i) | 689 for (unsigned i = 0; i < numberOfOutputs(); ++i) |
690 disconnectAllFromOutput(i); | 690 disconnectAllFromOutput(i); |
691 } | 691 } |
692 | 692 |
693 void AudioNode::disconnect(unsigned outputIndex, ExceptionState& exceptionState) | 693 void AudioNode::disconnect(unsigned outputIndex, ExceptionState& exceptionState) |
694 { | 694 { |
695 ASSERT(isMainThread()); | 695 ASSERT(isMainThread()); |
696 AudioContext::AutoLocker locker(context()); | 696 AbstractAudioContext::AutoLocker locker(context()); |
697 | 697 |
698 // Sanity check on the output index. | 698 // Sanity check on the output index. |
699 if (outputIndex >= numberOfOutputs()) { | 699 if (outputIndex >= numberOfOutputs()) { |
700 exceptionState.throwDOMException( | 700 exceptionState.throwDOMException( |
701 IndexSizeError, | 701 IndexSizeError, |
702 ExceptionMessages::indexOutsideRange( | 702 ExceptionMessages::indexOutsideRange( |
703 "output index", | 703 "output index", |
704 outputIndex, | 704 outputIndex, |
705 0u, | 705 0u, |
706 ExceptionMessages::InclusiveBound, | 706 ExceptionMessages::InclusiveBound, |
707 numberOfOutputs() - 1, | 707 numberOfOutputs() - 1, |
708 ExceptionMessages::InclusiveBound)); | 708 ExceptionMessages::InclusiveBound)); |
709 return; | 709 return; |
710 } | 710 } |
711 // Disconnect all outgoing connections from the given output. | 711 // Disconnect all outgoing connections from the given output. |
712 disconnectAllFromOutput(outputIndex); | 712 disconnectAllFromOutput(outputIndex); |
713 } | 713 } |
714 | 714 |
715 void AudioNode::disconnect(AudioNode* destination, ExceptionState& exceptionStat
e) | 715 void AudioNode::disconnect(AudioNode* destination, ExceptionState& exceptionStat
e) |
716 { | 716 { |
717 ASSERT(isMainThread()); | 717 ASSERT(isMainThread()); |
718 AudioContext::AutoLocker locker(context()); | 718 AbstractAudioContext::AutoLocker locker(context()); |
719 | 719 |
720 unsigned numberOfDisconnections = 0; | 720 unsigned numberOfDisconnections = 0; |
721 | 721 |
722 // FIXME: Can this be optimized? ChannelSplitter and ChannelMerger can have | 722 // FIXME: Can this be optimized? ChannelSplitter and ChannelMerger can have |
723 // 32 ports and that requires 1024 iterations to validate entire connections
. | 723 // 32 ports and that requires 1024 iterations to validate entire connections
. |
724 for (unsigned outputIndex = 0; outputIndex < numberOfOutputs(); ++outputInde
x) { | 724 for (unsigned outputIndex = 0; outputIndex < numberOfOutputs(); ++outputInde
x) { |
725 for (unsigned inputIndex = 0; inputIndex < destination->handler().number
OfInputs(); ++inputIndex) { | 725 for (unsigned inputIndex = 0; inputIndex < destination->handler().number
OfInputs(); ++inputIndex) { |
726 if (disconnectFromOutputIfConnected(outputIndex, *destination, input
Index)) | 726 if (disconnectFromOutputIfConnected(outputIndex, *destination, input
Index)) |
727 numberOfDisconnections++; | 727 numberOfDisconnections++; |
728 } | 728 } |
729 } | 729 } |
730 | 730 |
731 // If there is no connection to the destination, throw an exception. | 731 // If there is no connection to the destination, throw an exception. |
732 if (numberOfDisconnections == 0) { | 732 if (numberOfDisconnections == 0) { |
733 exceptionState.throwDOMException( | 733 exceptionState.throwDOMException( |
734 InvalidAccessError, | 734 InvalidAccessError, |
735 "the given destination is not connected."); | 735 "the given destination is not connected."); |
736 return; | 736 return; |
737 } | 737 } |
738 } | 738 } |
739 | 739 |
740 void AudioNode::disconnect(AudioNode* destination, unsigned outputIndex, Excepti
onState& exceptionState) | 740 void AudioNode::disconnect(AudioNode* destination, unsigned outputIndex, Excepti
onState& exceptionState) |
741 { | 741 { |
742 ASSERT(isMainThread()); | 742 ASSERT(isMainThread()); |
743 AudioContext::AutoLocker locker(context()); | 743 AbstractAudioContext::AutoLocker locker(context()); |
744 | 744 |
745 if (outputIndex >= numberOfOutputs()) { | 745 if (outputIndex >= numberOfOutputs()) { |
746 // The output index is out of range. Throw an exception. | 746 // The output index is out of range. Throw an exception. |
747 exceptionState.throwDOMException( | 747 exceptionState.throwDOMException( |
748 IndexSizeError, | 748 IndexSizeError, |
749 ExceptionMessages::indexOutsideRange( | 749 ExceptionMessages::indexOutsideRange( |
750 "output index", | 750 "output index", |
751 outputIndex, | 751 outputIndex, |
752 0u, | 752 0u, |
753 ExceptionMessages::InclusiveBound, | 753 ExceptionMessages::InclusiveBound, |
(...skipping 14 matching lines...) Expand all Loading... |
768 if (numberOfDisconnections == 0) { | 768 if (numberOfDisconnections == 0) { |
769 exceptionState.throwDOMException( | 769 exceptionState.throwDOMException( |
770 InvalidAccessError, | 770 InvalidAccessError, |
771 "output (" + String::number(outputIndex) + ") is not connected to th
e given destination."); | 771 "output (" + String::number(outputIndex) + ") is not connected to th
e given destination."); |
772 } | 772 } |
773 } | 773 } |
774 | 774 |
775 void AudioNode::disconnect(AudioNode* destination, unsigned outputIndex, unsigne
d inputIndex, ExceptionState& exceptionState) | 775 void AudioNode::disconnect(AudioNode* destination, unsigned outputIndex, unsigne
d inputIndex, ExceptionState& exceptionState) |
776 { | 776 { |
777 ASSERT(isMainThread()); | 777 ASSERT(isMainThread()); |
778 AudioContext::AutoLocker locker(context()); | 778 AbstractAudioContext::AutoLocker locker(context()); |
779 | 779 |
780 if (outputIndex >= numberOfOutputs()) { | 780 if (outputIndex >= numberOfOutputs()) { |
781 exceptionState.throwDOMException( | 781 exceptionState.throwDOMException( |
782 IndexSizeError, | 782 IndexSizeError, |
783 ExceptionMessages::indexOutsideRange( | 783 ExceptionMessages::indexOutsideRange( |
784 "output index", | 784 "output index", |
785 outputIndex, | 785 outputIndex, |
786 0u, | 786 0u, |
787 ExceptionMessages::InclusiveBound, | 787 ExceptionMessages::InclusiveBound, |
788 numberOfOutputs() - 1, | 788 numberOfOutputs() - 1, |
(...skipping 19 matching lines...) Expand all Loading... |
808 exceptionState.throwDOMException( | 808 exceptionState.throwDOMException( |
809 InvalidAccessError, | 809 InvalidAccessError, |
810 "output (" + String::number(outputIndex) + ") is not connected to th
e input (" + String::number(inputIndex) + ") of the destination."); | 810 "output (" + String::number(outputIndex) + ") is not connected to th
e input (" + String::number(inputIndex) + ") of the destination."); |
811 return; | 811 return; |
812 } | 812 } |
813 } | 813 } |
814 | 814 |
815 void AudioNode::disconnect(AudioParam* destinationParam, ExceptionState& excepti
onState) | 815 void AudioNode::disconnect(AudioParam* destinationParam, ExceptionState& excepti
onState) |
816 { | 816 { |
817 ASSERT(isMainThread()); | 817 ASSERT(isMainThread()); |
818 AudioContext::AutoLocker locker(context()); | 818 AbstractAudioContext::AutoLocker locker(context()); |
819 | 819 |
820 // The number of disconnection made. | 820 // The number of disconnection made. |
821 unsigned numberOfDisconnections = 0; | 821 unsigned numberOfDisconnections = 0; |
822 | 822 |
823 // Check if the node output is connected the destination AudioParam. | 823 // Check if the node output is connected the destination AudioParam. |
824 // Disconnect if connected and increase |numberOfDisconnectios| by 1. | 824 // Disconnect if connected and increase |numberOfDisconnectios| by 1. |
825 for (unsigned outputIndex = 0; outputIndex < handler().numberOfOutputs(); ++
outputIndex) { | 825 for (unsigned outputIndex = 0; outputIndex < handler().numberOfOutputs(); ++
outputIndex) { |
826 if (disconnectFromOutputIfConnected(outputIndex, *destinationParam)) | 826 if (disconnectFromOutputIfConnected(outputIndex, *destinationParam)) |
827 numberOfDisconnections++; | 827 numberOfDisconnections++; |
828 } | 828 } |
829 | 829 |
830 // Throw an exception when there is no valid connection to the destination. | 830 // Throw an exception when there is no valid connection to the destination. |
831 if (numberOfDisconnections == 0) { | 831 if (numberOfDisconnections == 0) { |
832 exceptionState.throwDOMException( | 832 exceptionState.throwDOMException( |
833 InvalidAccessError, | 833 InvalidAccessError, |
834 "the given AudioParam is not connected."); | 834 "the given AudioParam is not connected."); |
835 return; | 835 return; |
836 } | 836 } |
837 } | 837 } |
838 | 838 |
839 void AudioNode::disconnect(AudioParam* destinationParam, unsigned outputIndex, E
xceptionState& exceptionState) | 839 void AudioNode::disconnect(AudioParam* destinationParam, unsigned outputIndex, E
xceptionState& exceptionState) |
840 { | 840 { |
841 ASSERT(isMainThread()); | 841 ASSERT(isMainThread()); |
842 AudioContext::AutoLocker locker(context()); | 842 AbstractAudioContext::AutoLocker locker(context()); |
843 | 843 |
844 if (outputIndex >= handler().numberOfOutputs()) { | 844 if (outputIndex >= handler().numberOfOutputs()) { |
845 // The output index is out of range. Throw an exception. | 845 // The output index is out of range. Throw an exception. |
846 exceptionState.throwDOMException( | 846 exceptionState.throwDOMException( |
847 IndexSizeError, | 847 IndexSizeError, |
848 ExceptionMessages::indexOutsideRange( | 848 ExceptionMessages::indexOutsideRange( |
849 "output index", | 849 "output index", |
850 outputIndex, | 850 outputIndex, |
851 0u, | 851 0u, |
852 ExceptionMessages::InclusiveBound, | 852 ExceptionMessages::InclusiveBound, |
853 numberOfOutputs() - 1, | 853 numberOfOutputs() - 1, |
854 ExceptionMessages::InclusiveBound)); | 854 ExceptionMessages::InclusiveBound)); |
855 return; | 855 return; |
856 } | 856 } |
857 | 857 |
858 // If the output index is valid, proceed to disconnect. | 858 // If the output index is valid, proceed to disconnect. |
859 if (!disconnectFromOutputIfConnected(outputIndex, *destinationParam)) { | 859 if (!disconnectFromOutputIfConnected(outputIndex, *destinationParam)) { |
860 exceptionState.throwDOMException( | 860 exceptionState.throwDOMException( |
861 InvalidAccessError, | 861 InvalidAccessError, |
862 "specified destination AudioParam and node output (" + String::numbe
r(outputIndex) + ") are not connected."); | 862 "specified destination AudioParam and node output (" + String::numbe
r(outputIndex) + ") are not connected."); |
863 return; | 863 return; |
864 } | 864 } |
865 } | 865 } |
866 | 866 |
867 void AudioNode::disconnectWithoutException(unsigned outputIndex) | 867 void AudioNode::disconnectWithoutException(unsigned outputIndex) |
868 { | 868 { |
869 ASSERT(isMainThread()); | 869 ASSERT(isMainThread()); |
870 AudioContext::AutoLocker locker(context()); | 870 AbstractAudioContext::AutoLocker locker(context()); |
871 | 871 |
872 // Sanity check input and output indices. | 872 // Sanity check input and output indices. |
873 if (outputIndex >= handler().numberOfOutputs()) | 873 if (outputIndex >= handler().numberOfOutputs()) |
874 return; | 874 return; |
875 disconnectAllFromOutput(outputIndex); | 875 disconnectAllFromOutput(outputIndex); |
876 } | 876 } |
877 | 877 |
878 unsigned AudioNode::numberOfInputs() const | 878 unsigned AudioNode::numberOfInputs() const |
879 { | 879 { |
880 return handler().numberOfInputs(); | 880 return handler().numberOfInputs(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 { | 929 { |
930 m_connectedNodes.append(nullptr); | 930 m_connectedNodes.append(nullptr); |
931 ASSERT_UNUSED(numberOfOutputs, numberOfOutputs == m_connectedNodes.size()); | 931 ASSERT_UNUSED(numberOfOutputs, numberOfOutputs == m_connectedNodes.size()); |
932 m_connectedParams.append(nullptr); | 932 m_connectedParams.append(nullptr); |
933 ASSERT_UNUSED(numberOfOutputs, numberOfOutputs == m_connectedParams.size()); | 933 ASSERT_UNUSED(numberOfOutputs, numberOfOutputs == m_connectedParams.size()); |
934 } | 934 } |
935 | 935 |
936 } // namespace blink | 936 } // namespace blink |
937 | 937 |
938 #endif // ENABLE(WEB_AUDIO) | 938 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |