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

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

Issue 18548003: Rename ExceptionCode constants to use the names in the spec (2/3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 /* 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return m_outputs[i].get(); 124 return m_outputs[i].get();
125 return 0; 125 return 0;
126 } 126 }
127 127
128 void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i nputIndex, ExceptionCode& ec) 128 void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i nputIndex, ExceptionCode& ec)
129 { 129 {
130 ASSERT(isMainThread()); 130 ASSERT(isMainThread());
131 AudioContext::AutoLocker locker(context()); 131 AudioContext::AutoLocker locker(context());
132 132
133 if (!destination) { 133 if (!destination) {
134 ec = SYNTAX_ERR; 134 ec = SyntaxError;
135 return; 135 return;
136 } 136 }
137 137
138 // Sanity check input and output indices. 138 // Sanity check input and output indices.
139 if (outputIndex >= numberOfOutputs()) { 139 if (outputIndex >= numberOfOutputs()) {
140 ec = IndexSizeError; 140 ec = IndexSizeError;
141 return; 141 return;
142 } 142 }
143 143
144 if (destination && inputIndex >= destination->numberOfInputs()) { 144 if (destination && inputIndex >= destination->numberOfInputs()) {
145 ec = IndexSizeError; 145 ec = IndexSizeError;
146 return; 146 return;
147 } 147 }
148 148
149 if (context() != destination->context()) { 149 if (context() != destination->context()) {
150 ec = SYNTAX_ERR; 150 ec = SyntaxError;
151 return; 151 return;
152 } 152 }
153 153
154 AudioNodeInput* input = destination->input(inputIndex); 154 AudioNodeInput* input = destination->input(inputIndex);
155 AudioNodeOutput* output = this->output(outputIndex); 155 AudioNodeOutput* output = this->output(outputIndex);
156 input->connect(output); 156 input->connect(output);
157 157
158 // Let context know that a connection has been made. 158 // Let context know that a connection has been made.
159 context()->incrementConnectionCount(); 159 context()->incrementConnectionCount();
160 } 160 }
161 161
162 void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionCode& ec) 162 void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionCode& ec)
163 { 163 {
164 ASSERT(isMainThread()); 164 ASSERT(isMainThread());
165 AudioContext::AutoLocker locker(context()); 165 AudioContext::AutoLocker locker(context());
166 166
167 if (!param) { 167 if (!param) {
168 ec = SYNTAX_ERR; 168 ec = SyntaxError;
169 return; 169 return;
170 } 170 }
171 171
172 if (outputIndex >= numberOfOutputs()) { 172 if (outputIndex >= numberOfOutputs()) {
173 ec = IndexSizeError; 173 ec = IndexSizeError;
174 return; 174 return;
175 } 175 }
176 176
177 if (context() != param->context()) { 177 if (context() != param->context()) {
178 ec = SYNTAX_ERR; 178 ec = SyntaxError;
179 return; 179 return;
180 } 180 }
181 181
182 AudioNodeOutput* output = this->output(outputIndex); 182 AudioNodeOutput* output = this->output(outputIndex);
183 param->connect(output); 183 param->connect(output);
184 } 184 }
185 185
186 void AudioNode::disconnect(unsigned outputIndex, ExceptionCode& ec) 186 void AudioNode::disconnect(unsigned outputIndex, ExceptionCode& ec)
187 { 187 {
188 ASSERT(isMainThread()); 188 ASSERT(isMainThread());
(...skipping 18 matching lines...) Expand all
207 { 207 {
208 ASSERT(isMainThread()); 208 ASSERT(isMainThread());
209 AudioContext::AutoLocker locker(context()); 209 AudioContext::AutoLocker locker(context());
210 210
211 if (channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels()) { 211 if (channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels()) {
212 if (m_channelCount != channelCount) { 212 if (m_channelCount != channelCount) {
213 m_channelCount = channelCount; 213 m_channelCount = channelCount;
214 if (m_channelCountMode != Max) 214 if (m_channelCountMode != Max)
215 updateChannelsForInputs(); 215 updateChannelsForInputs();
216 } 216 }
217 } else 217 } else {
218 ec = INVALID_STATE_ERR; 218 ec = InvalidStateError;
219 }
219 } 220 }
220 221
221 String AudioNode::channelCountMode() 222 String AudioNode::channelCountMode()
222 { 223 {
223 switch (m_channelCountMode) { 224 switch (m_channelCountMode) {
224 case Max: 225 case Max:
225 return "max"; 226 return "max";
226 case ClampedMax: 227 case ClampedMax:
227 return "clamped-max"; 228 return "clamped-max";
228 case Explicit: 229 case Explicit:
(...skipping 10 matching lines...) Expand all
239 240
240 ChannelCountMode oldMode = m_channelCountMode; 241 ChannelCountMode oldMode = m_channelCountMode;
241 242
242 if (mode == "max") 243 if (mode == "max")
243 m_channelCountMode = Max; 244 m_channelCountMode = Max;
244 else if (mode == "clamped-max") 245 else if (mode == "clamped-max")
245 m_channelCountMode = ClampedMax; 246 m_channelCountMode = ClampedMax;
246 else if (mode == "explicit") 247 else if (mode == "explicit")
247 m_channelCountMode = Explicit; 248 m_channelCountMode = Explicit;
248 else 249 else
249 ec = INVALID_STATE_ERR; 250 ec = InvalidStateError;
250 251
251 if (m_channelCountMode != oldMode) 252 if (m_channelCountMode != oldMode)
252 updateChannelsForInputs(); 253 updateChannelsForInputs();
253 } 254 }
254 255
255 String AudioNode::channelInterpretation() 256 String AudioNode::channelInterpretation()
256 { 257 {
257 switch (m_channelInterpretation) { 258 switch (m_channelInterpretation) {
258 case AudioBus::Speakers: 259 case AudioBus::Speakers:
259 return "speakers"; 260 return "speakers";
260 case AudioBus::Discrete: 261 case AudioBus::Discrete:
261 return "discrete"; 262 return "discrete";
262 } 263 }
263 ASSERT_NOT_REACHED(); 264 ASSERT_NOT_REACHED();
264 return ""; 265 return "";
265 } 266 }
266 267
267 void AudioNode::setChannelInterpretation(const String& interpretation, Exception Code& ec) 268 void AudioNode::setChannelInterpretation(const String& interpretation, Exception Code& ec)
268 { 269 {
269 ASSERT(isMainThread()); 270 ASSERT(isMainThread());
270 AudioContext::AutoLocker locker(context()); 271 AudioContext::AutoLocker locker(context());
271 272
272 if (interpretation == "speakers") 273 if (interpretation == "speakers")
273 m_channelInterpretation = AudioBus::Speakers; 274 m_channelInterpretation = AudioBus::Speakers;
274 else if (interpretation == "discrete") 275 else if (interpretation == "discrete")
275 m_channelInterpretation = AudioBus::Discrete; 276 m_channelInterpretation = AudioBus::Discrete;
276 else 277 else
277 ec = INVALID_STATE_ERR; 278 ec = InvalidStateError;
278 } 279 }
279 280
280 void AudioNode::updateChannelsForInputs() 281 void AudioNode::updateChannelsForInputs()
281 { 282 {
282 for (unsigned i = 0; i < m_inputs.size(); ++i) 283 for (unsigned i = 0; i < m_inputs.size(); ++i)
283 input(i)->changedOutputs(); 284 input(i)->changedOutputs();
284 } 285 }
285 286
286 const AtomicString& AudioNode::interfaceName() const 287 const AtomicString& AudioNode::interfaceName() const
287 { 288 {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 fprintf(stderr, "%d: %d\n", i, s_nodeCount[i]); 528 fprintf(stderr, "%d: %d\n", i, s_nodeCount[i]);
528 529
529 fprintf(stderr, "===========================\n\n\n"); 530 fprintf(stderr, "===========================\n\n\n");
530 } 531 }
531 532
532 #endif // DEBUG_AUDIONODE_REFERENCES 533 #endif // DEBUG_AUDIONODE_REFERENCES
533 534
534 } // namespace WebCore 535 } // namespace WebCore
535 536
536 #endif // ENABLE(WEB_AUDIO) 537 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioContext.cpp ('k') | Source/modules/webaudio/DefaultAudioDestinationNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698