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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 , m_positionZ(positionZ) | 65 , m_positionZ(positionZ) |
66 , m_orientationX(orientationX) | 66 , m_orientationX(orientationX) |
67 , m_orientationY(orientationY) | 67 , m_orientationY(orientationY) |
68 , m_orientationZ(orientationZ) | 68 , m_orientationZ(orientationZ) |
69 { | 69 { |
70 addInput(); | 70 addInput(); |
71 addOutput(2); | 71 addOutput(2); |
72 | 72 |
73 // Node-specific default mixing rules. | 73 // Node-specific default mixing rules. |
74 m_channelCount = 2; | 74 m_channelCount = 2; |
75 m_channelCountMode = ClampedMax; | 75 setInternalChannelCountMode(ClampedMax); |
76 m_channelInterpretation = AudioBus::Speakers; | 76 setInternalChannelInterpretation(AudioBus::Speakers); |
77 | 77 |
78 // Explicitly set the default panning model here so that the histograms | 78 // Explicitly set the default panning model here so that the histograms |
79 // include the default value. | 79 // include the default value. |
80 setPanningModel("equalpower"); | 80 setPanningModel("equalpower"); |
81 | 81 |
82 initialize(); | 82 initialize(); |
83 } | 83 } |
84 | 84 |
85 PassRefPtr<PannerHandler> PannerHandler::create( | 85 PassRefPtr<PannerHandler> PannerHandler::create( |
86 AudioNode& node, float sampleRate, | 86 AudioNode& node, float sampleRate, |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 | 558 |
559 void PannerHandler::setChannelCount(unsigned long channelCount, ExceptionState&
exceptionState) | 559 void PannerHandler::setChannelCount(unsigned long channelCount, ExceptionState&
exceptionState) |
560 { | 560 { |
561 ASSERT(isMainThread()); | 561 ASSERT(isMainThread()); |
562 BaseAudioContext::AutoLocker locker(context()); | 562 BaseAudioContext::AutoLocker locker(context()); |
563 | 563 |
564 // A PannerNode only supports 1 or 2 channels | 564 // A PannerNode only supports 1 or 2 channels |
565 if (channelCount > 0 && channelCount <= 2) { | 565 if (channelCount > 0 && channelCount <= 2) { |
566 if (m_channelCount != channelCount) { | 566 if (m_channelCount != channelCount) { |
567 m_channelCount = channelCount; | 567 m_channelCount = channelCount; |
568 if (m_channelCountMode != Max) | 568 if (internalChannelCountMode() != Max) |
569 updateChannelsForInputs(); | 569 updateChannelsForInputs(); |
570 } | 570 } |
571 } else { | 571 } else { |
572 exceptionState.throwDOMException( | 572 exceptionState.throwDOMException( |
573 NotSupportedError, | 573 NotSupportedError, |
574 ExceptionMessages::indexOutsideRange<unsigned long>( | 574 ExceptionMessages::indexOutsideRange<unsigned long>( |
575 "channelCount", | 575 "channelCount", |
576 channelCount, | 576 channelCount, |
577 1, | 577 1, |
578 ExceptionMessages::InclusiveBound, | 578 ExceptionMessages::InclusiveBound, |
579 2, | 579 2, |
580 ExceptionMessages::InclusiveBound)); | 580 ExceptionMessages::InclusiveBound)); |
581 } | 581 } |
582 } | 582 } |
583 | 583 |
584 void PannerHandler::setChannelCountMode(const String& mode, ExceptionState& exce
ptionState) | 584 void PannerHandler::setChannelCountMode(const String& mode, ExceptionState& exce
ptionState) |
585 { | 585 { |
586 ASSERT(isMainThread()); | 586 ASSERT(isMainThread()); |
587 BaseAudioContext::AutoLocker locker(context()); | 587 BaseAudioContext::AutoLocker locker(context()); |
588 | 588 |
589 ChannelCountMode oldMode = m_channelCountMode; | |
590 | |
591 if (mode == "clamped-max") { | 589 if (mode == "clamped-max") { |
592 m_newChannelCountMode = ClampedMax; | 590 setInternalChannelCountMode(ClampedMax); |
593 } else if (mode == "explicit") { | 591 } else if (mode == "explicit") { |
594 m_newChannelCountMode = Explicit; | 592 setInternalChannelCountMode(Explicit); |
595 } else if (mode == "max") { | 593 } else if (mode == "max") { |
596 // This is not supported for a PannerNode, which can only handle 1 or 2
channels. | 594 // This is not supported for a PannerNode, which can only handle 1 or 2
channels. |
597 exceptionState.throwDOMException( | 595 exceptionState.throwDOMException( |
598 NotSupportedError, | 596 NotSupportedError, |
599 "Panner: 'max' is not allowed"); | 597 "Panner: 'max' is not allowed"); |
600 m_newChannelCountMode = oldMode; | |
601 } else { | |
602 // Do nothing for other invalid values. | |
603 m_newChannelCountMode = oldMode; | |
604 } | 598 } |
605 | |
606 if (m_newChannelCountMode != oldMode) | |
607 context()->deferredTaskHandler().addChangedChannelCountMode(this); | |
608 } | 599 } |
609 | 600 |
610 bool PannerHandler::hasSampleAccurateValues() const | 601 bool PannerHandler::hasSampleAccurateValues() const |
611 { | 602 { |
612 return m_positionX->hasSampleAccurateValues() | 603 return m_positionX->hasSampleAccurateValues() |
613 || m_positionY->hasSampleAccurateValues() | 604 || m_positionY->hasSampleAccurateValues() |
614 || m_positionZ->hasSampleAccurateValues() | 605 || m_positionZ->hasSampleAccurateValues() |
615 || m_orientationX->hasSampleAccurateValues() | 606 || m_orientationX->hasSampleAccurateValues() |
616 || m_orientationY->hasSampleAccurateValues() | 607 || m_orientationY->hasSampleAccurateValues() |
617 || m_orientationZ->hasSampleAccurateValues(); | 608 || m_orientationZ->hasSampleAccurateValues(); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 visitor->trace(m_positionZ); | 767 visitor->trace(m_positionZ); |
777 | 768 |
778 visitor->trace(m_orientationX); | 769 visitor->trace(m_orientationX); |
779 visitor->trace(m_orientationY); | 770 visitor->trace(m_orientationY); |
780 visitor->trace(m_orientationZ); | 771 visitor->trace(m_orientationZ); |
781 | 772 |
782 AudioNode::trace(visitor); | 773 AudioNode::trace(visitor); |
783 } | 774 } |
784 | 775 |
785 } // namespace blink | 776 } // namespace blink |
OLD | NEW |