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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioNode.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
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 : m_isInitialized(false) 42 : m_isInitialized(false)
43 , m_nodeType(NodeTypeUnknown) 43 , m_nodeType(NodeTypeUnknown)
44 , m_node(&node) 44 , m_node(&node)
45 , m_context(node.context()) 45 , m_context(node.context())
46 , m_sampleRate(sampleRate) 46 , m_sampleRate(sampleRate)
47 , m_lastProcessingTime(-1) 47 , m_lastProcessingTime(-1)
48 , m_lastNonSilentTime(-1) 48 , m_lastNonSilentTime(-1)
49 , m_connectionRefCount(0) 49 , m_connectionRefCount(0)
50 , m_isDisabled(false) 50 , m_isDisabled(false)
51 , m_channelCount(2) 51 , m_channelCount(2)
52 , m_channelCountMode(Max)
53 , m_channelInterpretation(AudioBus::Speakers)
54 , m_newChannelCountMode(Max)
55 { 52 {
56 setNodeType(nodeType); 53 setNodeType(nodeType);
54 setInternalChannelCountMode(Max);
55 setInternalChannelInterpretation(AudioBus::Speakers);
57 56
58 #if DEBUG_AUDIONODE_REFERENCES 57 #if DEBUG_AUDIONODE_REFERENCES
59 if (!s_isNodeCountInitialized) { 58 if (!s_isNodeCountInitialized) {
60 s_isNodeCountInitialized = true; 59 s_isNodeCountInitialized = true;
61 atexit(AudioHandler::printNodeCounts); 60 atexit(AudioHandler::printNodeCounts);
62 } 61 }
63 #endif 62 #endif
64 InstanceCounters::incrementCounter(InstanceCounters::AudioHandlerCounter); 63 InstanceCounters::incrementCounter(InstanceCounters::AudioHandlerCounter);
65 } 64 }
66 65
67 AudioHandler::~AudioHandler() 66 AudioHandler::~AudioHandler()
68 { 67 {
69 DCHECK(isMainThread()); 68 DCHECK(isMainThread());
70 // dispose() should be called. 69 // dispose() should be called.
71 DCHECK(!node()); 70 DCHECK(!node());
72 InstanceCounters::decrementCounter(InstanceCounters::AudioHandlerCounter); 71 InstanceCounters::decrementCounter(InstanceCounters::AudioHandlerCounter);
73 #if DEBUG_AUDIONODE_REFERENCES 72 #if DEBUG_AUDIONODE_REFERENCES
74 --s_nodeCount[getNodeType()]; 73 --s_nodeCount[getNodeType()];
75 fprintf(stderr, "[%16p]: %16p: %2d: AudioHandler::~AudioHandler() %d [%d]\n" , 74 fprintf(stderr, "[%16p]: %16p: %2d: AudioHandler::~AudioHandler() %d [%d]\n" ,
76 context(), this, getNodeType(), m_connectionRefCount, s_nodeCount[getNod eType()]); 75 context(), this, getNodeType(), m_connectionRefCount, s_nodeCount[getNod eType()]);
77 #endif 76 #endif
78 } 77 }
79 78
80 void AudioHandler::initialize() 79 void AudioHandler::initialize()
81 { 80 {
81 DCHECK_EQ(m_newChannelCountMode, m_channelCountMode);
82 DCHECK_EQ(m_newChannelInterpretation, m_channelInterpretation);
83
82 m_isInitialized = true; 84 m_isInitialized = true;
83 } 85 }
84 86
85 void AudioHandler::uninitialize() 87 void AudioHandler::uninitialize()
86 { 88 {
87 m_isInitialized = false; 89 m_isInitialized = false;
88 } 90 }
89 91
90 void AudioHandler::clearInternalStateWhenDisabled() 92 void AudioHandler::clearInternalStateWhenDisabled()
91 { 93 {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 AudioNodeOutput& AudioHandler::output(unsigned i) 201 AudioNodeOutput& AudioHandler::output(unsigned i)
200 { 202 {
201 return *m_outputs[i]; 203 return *m_outputs[i];
202 } 204 }
203 205
204 unsigned long AudioHandler::channelCount() 206 unsigned long AudioHandler::channelCount()
205 { 207 {
206 return m_channelCount; 208 return m_channelCount;
207 } 209 }
208 210
211 void AudioHandler::setInternalChannelCountMode(ChannelCountMode mode)
212 {
213 m_channelCountMode = mode;
214 m_newChannelCountMode = mode;
215 }
216
217 void AudioHandler::setInternalChannelInterpretation(AudioBus::ChannelInterpretat ion interpretation)
218 {
219 m_channelInterpretation = interpretation;
220 m_newChannelInterpretation = interpretation;
221 }
222
209 void AudioHandler::setChannelCount(unsigned long channelCount, ExceptionState& e xceptionState) 223 void AudioHandler::setChannelCount(unsigned long channelCount, ExceptionState& e xceptionState)
210 { 224 {
211 DCHECK(isMainThread()); 225 DCHECK(isMainThread());
212 BaseAudioContext::AutoLocker locker(context()); 226 BaseAudioContext::AutoLocker locker(context());
213 227
214 if (channelCount > 0 && channelCount <= BaseAudioContext::maxNumberOfChannel s()) { 228 if (channelCount > 0 && channelCount <= BaseAudioContext::maxNumberOfChannel s()) {
215 if (m_channelCount != channelCount) { 229 if (m_channelCount != channelCount) {
216 m_channelCount = channelCount; 230 m_channelCount = channelCount;
217 if (m_channelCountMode != Max) 231 if (m_channelCountMode != Max)
218 updateChannelsForInputs(); 232 updateChannelsForInputs();
219 } 233 }
220 } else { 234 } else {
221 exceptionState.throwDOMException( 235 exceptionState.throwDOMException(
222 NotSupportedError, 236 NotSupportedError,
223 ExceptionMessages::indexOutsideRange<unsigned long>( 237 ExceptionMessages::indexOutsideRange<unsigned long>(
224 "channel count", 238 "channel count",
225 channelCount, 239 channelCount,
226 1, 240 1,
227 ExceptionMessages::InclusiveBound, 241 ExceptionMessages::InclusiveBound,
228 BaseAudioContext::maxNumberOfChannels(), 242 BaseAudioContext::maxNumberOfChannels(),
229 ExceptionMessages::InclusiveBound)); 243 ExceptionMessages::InclusiveBound));
230 } 244 }
231 } 245 }
232 246
233 String AudioHandler::channelCountMode() 247 String AudioHandler::channelCountMode()
234 { 248 {
235 switch (m_channelCountMode) { 249 // Because we delay the actual setting of the mode to the pre or post
250 // rendering phase, we want to return the value that was set, not the actual
251 // current mode.
252 switch (m_newChannelCountMode) {
236 case Max: 253 case Max:
237 return "max"; 254 return "max";
238 case ClampedMax: 255 case ClampedMax:
239 return "clamped-max"; 256 return "clamped-max";
240 case Explicit: 257 case Explicit:
241 return "explicit"; 258 return "explicit";
242 } 259 }
243 ASSERT_NOT_REACHED(); 260 ASSERT_NOT_REACHED();
244 return ""; 261 return "";
245 } 262 }
(...skipping 14 matching lines...) Expand all
260 } else { 277 } else {
261 ASSERT_NOT_REACHED(); 278 ASSERT_NOT_REACHED();
262 } 279 }
263 280
264 if (m_newChannelCountMode != oldMode) 281 if (m_newChannelCountMode != oldMode)
265 context()->deferredTaskHandler().addChangedChannelCountMode(this); 282 context()->deferredTaskHandler().addChangedChannelCountMode(this);
266 } 283 }
267 284
268 String AudioHandler::channelInterpretation() 285 String AudioHandler::channelInterpretation()
269 { 286 {
270 switch (m_channelInterpretation) { 287 // Because we delay the actual setting of the interpreation to the pre or
288 // post rendering phase, we want to return the value that was set, not the
289 // actual current interpretation.
290 switch (m_newChannelInterpretation) {
271 case AudioBus::Speakers: 291 case AudioBus::Speakers:
272 return "speakers"; 292 return "speakers";
273 case AudioBus::Discrete: 293 case AudioBus::Discrete:
274 return "discrete"; 294 return "discrete";
275 } 295 }
276 ASSERT_NOT_REACHED(); 296 ASSERT_NOT_REACHED();
277 return ""; 297 return "";
278 } 298 }
279 299
280 void AudioHandler::setChannelInterpretation(const String& interpretation, Except ionState& exceptionState) 300 void AudioHandler::setChannelInterpretation(const String& interpretation, Except ionState& exceptionState)
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 void AudioNode::didAddOutput(unsigned numberOfOutputs) 974 void AudioNode::didAddOutput(unsigned numberOfOutputs)
955 { 975 {
956 m_connectedNodes.append(nullptr); 976 m_connectedNodes.append(nullptr);
957 DCHECK_EQ(numberOfOutputs, m_connectedNodes.size()); 977 DCHECK_EQ(numberOfOutputs, m_connectedNodes.size());
958 m_connectedParams.append(nullptr); 978 m_connectedParams.append(nullptr);
959 DCHECK_EQ(numberOfOutputs, m_connectedParams.size()); 979 DCHECK_EQ(numberOfOutputs, m_connectedParams.size());
960 } 980 }
961 981
962 } // namespace blink 982 } // namespace blink
963 983
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698