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

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

Issue 1214463003: Split "Online" and "Offline" AudioContext processing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Bring to ToT Created 5 years, 5 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #if ENABLE(WEB_AUDIO) 6 #if ENABLE(WEB_AUDIO)
7 #include "modules/webaudio/StereoPannerNode.h" 7 #include "modules/webaudio/StereoPannerNode.h"
8 8
9 #include "bindings/core/v8/ExceptionMessages.h" 9 #include "bindings/core/v8/ExceptionMessages.h"
10 #include "bindings/core/v8/ExceptionState.h" 10 #include "bindings/core/v8/ExceptionState.h"
11 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
12 #include "core/dom/ExecutionContext.h" 12 #include "core/dom/ExecutionContext.h"
13 #include "modules/webaudio/AudioContext.h" 13 #include "modules/webaudio/AbstractAudioContext.h"
14 #include "modules/webaudio/AudioNodeInput.h" 14 #include "modules/webaudio/AudioNodeInput.h"
15 #include "modules/webaudio/AudioNodeOutput.h" 15 #include "modules/webaudio/AudioNodeOutput.h"
16 #include "platform/audio/StereoPanner.h" 16 #include "platform/audio/StereoPanner.h"
17 #include "wtf/MathExtras.h" 17 #include "wtf/MathExtras.h"
18 18
19 namespace blink { 19 namespace blink {
20 20
21 StereoPannerHandler::StereoPannerHandler(AudioNode& node, float sampleRate, Audi oParamHandler& pan) 21 StereoPannerHandler::StereoPannerHandler(AudioNode& node, float sampleRate, Audi oParamHandler& pan)
22 : AudioHandler(NodeTypeStereoPanner, node, sampleRate) 22 : AudioHandler(NodeTypeStereoPanner, node, sampleRate)
23 , m_pan(pan) 23 , m_pan(pan)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return; 79 return;
80 80
81 m_stereoPanner = Spatializer::create(Spatializer::PanningModelEqualPower, sa mpleRate()); 81 m_stereoPanner = Spatializer::create(Spatializer::PanningModelEqualPower, sa mpleRate());
82 82
83 AudioHandler::initialize(); 83 AudioHandler::initialize();
84 } 84 }
85 85
86 void StereoPannerHandler::setChannelCount(unsigned long channelCount, ExceptionS tate& exceptionState) 86 void StereoPannerHandler::setChannelCount(unsigned long channelCount, ExceptionS tate& exceptionState)
87 { 87 {
88 ASSERT(isMainThread()); 88 ASSERT(isMainThread());
89 AudioContext::AutoLocker locker(context()); 89 AbstractAudioContext::AutoLocker locker(context());
90 90
91 // A PannerNode only supports 1 or 2 channels 91 // A PannerNode only supports 1 or 2 channels
92 if (channelCount > 0 && channelCount <= 2) { 92 if (channelCount > 0 && channelCount <= 2) {
93 if (m_channelCount != channelCount) { 93 if (m_channelCount != channelCount) {
94 m_channelCount = channelCount; 94 m_channelCount = channelCount;
95 if (m_channelCountMode != Max) 95 if (m_channelCountMode != Max)
96 updateChannelsForInputs(); 96 updateChannelsForInputs();
97 } 97 }
98 } else { 98 } else {
99 exceptionState.throwDOMException( 99 exceptionState.throwDOMException(
100 NotSupportedError, 100 NotSupportedError,
101 ExceptionMessages::indexOutsideRange<unsigned long>( 101 ExceptionMessages::indexOutsideRange<unsigned long>(
102 "channelCount", 102 "channelCount",
103 channelCount, 103 channelCount,
104 1, 104 1,
105 ExceptionMessages::InclusiveBound, 105 ExceptionMessages::InclusiveBound,
106 2, 106 2,
107 ExceptionMessages::InclusiveBound)); 107 ExceptionMessages::InclusiveBound));
108 } 108 }
109 } 109 }
110 110
111 void StereoPannerHandler::setChannelCountMode(const String& mode, ExceptionState & exceptionState) 111 void StereoPannerHandler::setChannelCountMode(const String& mode, ExceptionState & exceptionState)
112 { 112 {
113 ASSERT(isMainThread()); 113 ASSERT(isMainThread());
114 AudioContext::AutoLocker locker(context()); 114 AbstractAudioContext::AutoLocker locker(context());
115 115
116 ChannelCountMode oldMode = m_channelCountMode; 116 ChannelCountMode oldMode = m_channelCountMode;
117 117
118 if (mode == "clamped-max") { 118 if (mode == "clamped-max") {
119 m_newChannelCountMode = ClampedMax; 119 m_newChannelCountMode = ClampedMax;
120 } else if (mode == "explicit") { 120 } else if (mode == "explicit") {
121 m_newChannelCountMode = Explicit; 121 m_newChannelCountMode = Explicit;
122 } else if (mode == "max") { 122 } else if (mode == "max") {
123 // This is not supported for a StereoPannerNode, which can only handle 123 // This is not supported for a StereoPannerNode, which can only handle
124 // 1 or 2 channels. 124 // 1 or 2 channels.
125 exceptionState.throwDOMException( 125 exceptionState.throwDOMException(
126 NotSupportedError, 126 NotSupportedError,
127 "StereoPanner: 'max' is not allowed"); 127 "StereoPanner: 'max' is not allowed");
128 m_newChannelCountMode = oldMode; 128 m_newChannelCountMode = oldMode;
129 } else { 129 } else {
130 // Do nothing for other invalid values. 130 // Do nothing for other invalid values.
131 m_newChannelCountMode = oldMode; 131 m_newChannelCountMode = oldMode;
132 } 132 }
133 133
134 if (m_newChannelCountMode != oldMode) 134 if (m_newChannelCountMode != oldMode)
135 context()->deferredTaskHandler().addChangedChannelCountMode(this); 135 context()->deferredTaskHandler().addChangedChannelCountMode(this);
136 } 136 }
137 137
138 // ---------------------------------------------------------------- 138 // ----------------------------------------------------------------
139 139
140 StereoPannerNode::StereoPannerNode(AudioContext& context, float sampleRate) 140 StereoPannerNode::StereoPannerNode(AbstractAudioContext& context, float sampleRa te)
141 : AudioNode(context) 141 : AudioNode(context)
142 , m_pan(AudioParam::create(context, 0)) 142 , m_pan(AudioParam::create(context, 0))
143 { 143 {
144 setHandler(StereoPannerHandler::create(*this, sampleRate, m_pan->handler())) ; 144 setHandler(StereoPannerHandler::create(*this, sampleRate, m_pan->handler())) ;
145 } 145 }
146 146
147 StereoPannerNode* StereoPannerNode::create(AudioContext& context, float sampleRa te) 147 StereoPannerNode* StereoPannerNode::create(AbstractAudioContext& context, float sampleRate)
148 { 148 {
149 return new StereoPannerNode(context, sampleRate); 149 return new StereoPannerNode(context, sampleRate);
150 } 150 }
151 151
152 DEFINE_TRACE(StereoPannerNode) 152 DEFINE_TRACE(StereoPannerNode)
153 { 153 {
154 visitor->trace(m_pan); 154 visitor->trace(m_pan);
155 AudioNode::trace(visitor); 155 AudioNode::trace(visitor);
156 } 156 }
157 157
158 AudioParam* StereoPannerNode::pan() const 158 AudioParam* StereoPannerNode::pan() const
159 { 159 {
160 return m_pan; 160 return m_pan;
161 } 161 }
162 162
163 } // namespace blink 163 } // namespace blink
164 164
165 #endif // ENABLE(WEB_AUDIO) 165 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/StereoPannerNode.h ('k') | Source/modules/webaudio/StereoPannerNodeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698