| 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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 } | 602 } |
| 603 | 603 |
| 604 if (!destination) { | 604 if (!destination) { |
| 605 exceptionState.throwDOMException(SyntaxError, "invalid destination node."); | 605 exceptionState.throwDOMException(SyntaxError, "invalid destination node."); |
| 606 return nullptr; | 606 return nullptr; |
| 607 } | 607 } |
| 608 | 608 |
| 609 // Sanity check input and output indices. | 609 // Sanity check input and output indices. |
| 610 if (outputIndex >= numberOfOutputs()) { | 610 if (outputIndex >= numberOfOutputs()) { |
| 611 exceptionState.throwDOMException( | 611 exceptionState.throwDOMException( |
| 612 IndexSizeError, "output index (" + String::number(outputIndex) + | 612 IndexSizeError, |
| 613 ") exceeds number of outputs (" + | 613 "output index (" + String::number(outputIndex) + |
| 614 String::number(numberOfOutputs()) + ")."); | 614 ") exceeds number of outputs (" + |
| 615 String::number(numberOfOutputs()) + ")."); |
| 615 return nullptr; | 616 return nullptr; |
| 616 } | 617 } |
| 617 | 618 |
| 618 if (destination && inputIndex >= destination->numberOfInputs()) { | 619 if (destination && inputIndex >= destination->numberOfInputs()) { |
| 619 exceptionState.throwDOMException( | 620 exceptionState.throwDOMException( |
| 620 IndexSizeError, "input index (" + String::number(inputIndex) + | 621 IndexSizeError, |
| 621 ") exceeds number of inputs (" + | 622 "input index (" + String::number(inputIndex) + |
| 622 String::number(destination->numberOfInputs()) + | 623 ") exceeds number of inputs (" + |
| 623 ")."); | 624 String::number(destination->numberOfInputs()) + ")."); |
| 624 return nullptr; | 625 return nullptr; |
| 625 } | 626 } |
| 626 | 627 |
| 627 if (context() != destination->context()) { | 628 if (context() != destination->context()) { |
| 628 exceptionState.throwDOMException(InvalidAccessError, | 629 exceptionState.throwDOMException(InvalidAccessError, |
| 629 "cannot connect to a destination " | 630 "cannot connect to a destination " |
| 630 "belonging to a different audio context."); | 631 "belonging to a different audio context."); |
| 631 return nullptr; | 632 return nullptr; |
| 632 } | 633 } |
| 633 | 634 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 return; | 669 return; |
| 669 } | 670 } |
| 670 | 671 |
| 671 if (!param) { | 672 if (!param) { |
| 672 exceptionState.throwDOMException(SyntaxError, "invalid AudioParam."); | 673 exceptionState.throwDOMException(SyntaxError, "invalid AudioParam."); |
| 673 return; | 674 return; |
| 674 } | 675 } |
| 675 | 676 |
| 676 if (outputIndex >= numberOfOutputs()) { | 677 if (outputIndex >= numberOfOutputs()) { |
| 677 exceptionState.throwDOMException( | 678 exceptionState.throwDOMException( |
| 678 IndexSizeError, "output index (" + String::number(outputIndex) + | 679 IndexSizeError, |
| 679 ") exceeds number of outputs (" + | 680 "output index (" + String::number(outputIndex) + |
| 680 String::number(numberOfOutputs()) + ")."); | 681 ") exceeds number of outputs (" + |
| 682 String::number(numberOfOutputs()) + ")."); |
| 681 return; | 683 return; |
| 682 } | 684 } |
| 683 | 685 |
| 684 if (context() != param->context()) { | 686 if (context() != param->context()) { |
| 685 exceptionState.throwDOMException(SyntaxError, | 687 exceptionState.throwDOMException(SyntaxError, |
| 686 "cannot connect to an AudioParam " | 688 "cannot connect to an AudioParam " |
| 687 "belonging to a different audio context."); | 689 "belonging to a different audio context."); |
| 688 return; | 690 return; |
| 689 } | 691 } |
| 690 | 692 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 // Sanity check on destination inputs and disconnect when possible. | 800 // Sanity check on destination inputs and disconnect when possible. |
| 799 for (unsigned inputIndex = 0; inputIndex < destination->numberOfInputs(); | 801 for (unsigned inputIndex = 0; inputIndex < destination->numberOfInputs(); |
| 800 ++inputIndex) { | 802 ++inputIndex) { |
| 801 if (disconnectFromOutputIfConnected(outputIndex, *destination, inputIndex)) | 803 if (disconnectFromOutputIfConnected(outputIndex, *destination, inputIndex)) |
| 802 numberOfDisconnections++; | 804 numberOfDisconnections++; |
| 803 } | 805 } |
| 804 | 806 |
| 805 // If there is no connection to the destination, throw an exception. | 807 // If there is no connection to the destination, throw an exception. |
| 806 if (numberOfDisconnections == 0) { | 808 if (numberOfDisconnections == 0) { |
| 807 exceptionState.throwDOMException( | 809 exceptionState.throwDOMException( |
| 808 InvalidAccessError, "output (" + String::number(outputIndex) + | 810 InvalidAccessError, |
| 809 ") is not connected to the given destination."); | 811 "output (" + String::number(outputIndex) + |
| 812 ") is not connected to the given destination."); |
| 810 } | 813 } |
| 811 } | 814 } |
| 812 | 815 |
| 813 void AudioNode::disconnect(AudioNode* destination, | 816 void AudioNode::disconnect(AudioNode* destination, |
| 814 unsigned outputIndex, | 817 unsigned outputIndex, |
| 815 unsigned inputIndex, | 818 unsigned inputIndex, |
| 816 ExceptionState& exceptionState) { | 819 ExceptionState& exceptionState) { |
| 817 DCHECK(isMainThread()); | 820 DCHECK(isMainThread()); |
| 818 BaseAudioContext::AutoLocker locker(context()); | 821 BaseAudioContext::AutoLocker locker(context()); |
| 819 | 822 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 } | 954 } |
| 952 | 955 |
| 953 void AudioNode::didAddOutput(unsigned numberOfOutputs) { | 956 void AudioNode::didAddOutput(unsigned numberOfOutputs) { |
| 954 m_connectedNodes.push_back(nullptr); | 957 m_connectedNodes.push_back(nullptr); |
| 955 DCHECK_EQ(numberOfOutputs, m_connectedNodes.size()); | 958 DCHECK_EQ(numberOfOutputs, m_connectedNodes.size()); |
| 956 m_connectedParams.push_back(nullptr); | 959 m_connectedParams.push_back(nullptr); |
| 957 DCHECK_EQ(numberOfOutputs, m_connectedParams.size()); | 960 DCHECK_EQ(numberOfOutputs, m_connectedParams.size()); |
| 958 } | 961 } |
| 959 | 962 |
| 960 } // namespace blink | 963 } // namespace blink |
| OLD | NEW |