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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/StereoPannerNode.cpp

Issue 2282483002: Return the correct channelCountMode and channelInterpretation (Closed)
Patch Set: Define setters for the mode and interpretation Created 4 years, 3 months 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
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/webaudio/StereoPannerNode.h" 5 #include "modules/webaudio/StereoPannerNode.h"
6 #include "bindings/core/v8/ExceptionMessages.h" 6 #include "bindings/core/v8/ExceptionMessages.h"
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/dom/ExceptionCode.h" 8 #include "core/dom/ExceptionCode.h"
9 #include "core/dom/ExecutionContext.h" 9 #include "core/dom/ExecutionContext.h"
10 #include "modules/webaudio/AudioNodeInput.h" 10 #include "modules/webaudio/AudioNodeInput.h"
11 #include "modules/webaudio/AudioNodeOutput.h" 11 #include "modules/webaudio/AudioNodeOutput.h"
12 #include "modules/webaudio/BaseAudioContext.h" 12 #include "modules/webaudio/BaseAudioContext.h"
13 #include "platform/audio/StereoPanner.h" 13 #include "platform/audio/StereoPanner.h"
14 #include "wtf/MathExtras.h" 14 #include "wtf/MathExtras.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 StereoPannerHandler::StereoPannerHandler(AudioNode& node, float sampleRate, Audi oParamHandler& pan) 18 StereoPannerHandler::StereoPannerHandler(AudioNode& node, float sampleRate, Audi oParamHandler& pan)
19 : AudioHandler(NodeTypeStereoPanner, node, sampleRate) 19 : AudioHandler(NodeTypeStereoPanner, node, sampleRate)
20 , m_pan(pan) 20 , m_pan(pan)
21 , m_sampleAccuratePanValues(ProcessingSizeInFrames) 21 , m_sampleAccuratePanValues(ProcessingSizeInFrames)
22 { 22 {
23 addInput(); 23 addInput();
24 addOutput(2); 24 addOutput(2);
25 25
26 // The node-specific default mixing rules declare that StereoPannerNode 26 // The node-specific default mixing rules declare that StereoPannerNode
27 // can handle mono to stereo and stereo to stereo conversion. 27 // can handle mono to stereo and stereo to stereo conversion.
28 m_channelCount = 2; 28 m_channelCount = 2;
29 m_channelCountMode = ClampedMax; 29 setInternalChannelCountMode(ClampedMax);
30 m_channelInterpretation = AudioBus::Speakers; 30 setInternalChannelInterpretation(AudioBus::Speakers);
31 31
32 initialize(); 32 initialize();
33 } 33 }
34 34
35 PassRefPtr<StereoPannerHandler> StereoPannerHandler::create(AudioNode& node, flo at sampleRate, AudioParamHandler& pan) 35 PassRefPtr<StereoPannerHandler> StereoPannerHandler::create(AudioNode& node, flo at sampleRate, AudioParamHandler& pan)
36 { 36 {
37 return adoptRef(new StereoPannerHandler(node, sampleRate, pan)); 37 return adoptRef(new StereoPannerHandler(node, sampleRate, pan));
38 } 38 }
39 39
40 StereoPannerHandler::~StereoPannerHandler() 40 StereoPannerHandler::~StereoPannerHandler()
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 void StereoPannerHandler::setChannelCount(unsigned long channelCount, ExceptionS tate& exceptionState) 83 void StereoPannerHandler::setChannelCount(unsigned long channelCount, ExceptionS tate& exceptionState)
84 { 84 {
85 DCHECK(isMainThread()); 85 DCHECK(isMainThread());
86 BaseAudioContext::AutoLocker locker(context()); 86 BaseAudioContext::AutoLocker locker(context());
87 87
88 // A PannerNode only supports 1 or 2 channels 88 // A PannerNode only supports 1 or 2 channels
89 if (channelCount > 0 && channelCount <= 2) { 89 if (channelCount > 0 && channelCount <= 2) {
90 if (m_channelCount != channelCount) { 90 if (m_channelCount != channelCount) {
91 m_channelCount = channelCount; 91 m_channelCount = channelCount;
92 if (m_channelCountMode != Max) 92 if (internalChannelCountMode() != Max)
93 updateChannelsForInputs(); 93 updateChannelsForInputs();
94 } 94 }
95 } else { 95 } else {
96 exceptionState.throwDOMException( 96 exceptionState.throwDOMException(
97 NotSupportedError, 97 NotSupportedError,
98 ExceptionMessages::indexOutsideRange<unsigned long>( 98 ExceptionMessages::indexOutsideRange<unsigned long>(
99 "channelCount", 99 "channelCount",
100 channelCount, 100 channelCount,
101 1, 101 1,
102 ExceptionMessages::InclusiveBound, 102 ExceptionMessages::InclusiveBound,
103 2, 103 2,
104 ExceptionMessages::InclusiveBound)); 104 ExceptionMessages::InclusiveBound));
105 } 105 }
106 } 106 }
107 107
108 void StereoPannerHandler::setChannelCountMode(const String& mode, ExceptionState & exceptionState) 108 void StereoPannerHandler::setChannelCountMode(const String& mode, ExceptionState & exceptionState)
109 { 109 {
110 DCHECK(isMainThread()); 110 DCHECK(isMainThread());
111 BaseAudioContext::AutoLocker locker(context()); 111 BaseAudioContext::AutoLocker locker(context());
112 112
113 ChannelCountMode oldMode = m_channelCountMode; 113 ChannelCountMode oldMode = internalChannelCountMode();
114 114
115 if (mode == "clamped-max") { 115 if (mode == "clamped-max") {
116 m_newChannelCountMode = ClampedMax; 116 m_newChannelCountMode = ClampedMax;
117 } else if (mode == "explicit") { 117 } else if (mode == "explicit") {
118 m_newChannelCountMode = Explicit; 118 m_newChannelCountMode = Explicit;
119 } else if (mode == "max") { 119 } else if (mode == "max") {
120 // This is not supported for a StereoPannerNode, which can only handle 120 // This is not supported for a StereoPannerNode, which can only handle
121 // 1 or 2 channels. 121 // 1 or 2 channels.
122 exceptionState.throwDOMException( 122 exceptionState.throwDOMException(
123 NotSupportedError, 123 NotSupportedError,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 AudioNode::trace(visitor); 159 AudioNode::trace(visitor);
160 } 160 }
161 161
162 AudioParam* StereoPannerNode::pan() const 162 AudioParam* StereoPannerNode::pan() const
163 { 163 {
164 return m_pan; 164 return m_pan;
165 } 165 }
166 166
167 } // namespace blink 167 } // namespace blink
168 168
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698