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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 AudioNode::AudioNode(AudioContext* context, float sampleRate) | 48 AudioNode::AudioNode(AudioContext* context, float sampleRate) |
49 : m_isInitialized(false) | 49 : m_isInitialized(false) |
50 , m_nodeType(NodeTypeUnknown) | 50 , m_nodeType(NodeTypeUnknown) |
51 , m_context(context) | 51 , m_context(context) |
52 , m_sampleRate(sampleRate) | 52 , m_sampleRate(sampleRate) |
53 , m_lastProcessingTime(-1) | 53 , m_lastProcessingTime(-1) |
54 , m_lastNonSilentTime(-1) | 54 , m_lastNonSilentTime(-1) |
55 , m_connectionRefCount(0) | 55 , m_connectionRefCount(0) |
56 , m_isDisabled(false) | 56 , m_isDisabled(false) |
| 57 , m_newChannelCountMode(Max) |
57 , m_channelCount(2) | 58 , m_channelCount(2) |
58 , m_channelCountMode(Max) | 59 , m_channelCountMode(Max) |
59 , m_channelInterpretation(AudioBus::Speakers) | 60 , m_channelInterpretation(AudioBus::Speakers) |
60 { | 61 { |
61 ScriptWrappable::init(this); | 62 ScriptWrappable::init(this); |
62 m_context->registerLiveNode(*this); | 63 m_context->registerLiveNode(*this); |
63 #if DEBUG_AUDIONODE_REFERENCES | 64 #if DEBUG_AUDIONODE_REFERENCES |
64 if (!s_isNodeCountInitialized) { | 65 if (!s_isNodeCountInitialized) { |
65 s_isNodeCountInitialized = true; | 66 s_isNodeCountInitialized = true; |
66 atexit(AudioNode::printNodeCounts); | 67 atexit(AudioNode::printNodeCounts); |
(...skipping 19 matching lines...) Expand all Loading... |
86 void AudioNode::uninitialize() | 87 void AudioNode::uninitialize() |
87 { | 88 { |
88 m_isInitialized = false; | 89 m_isInitialized = false; |
89 } | 90 } |
90 | 91 |
91 void AudioNode::dispose() | 92 void AudioNode::dispose() |
92 { | 93 { |
93 ASSERT(isMainThread()); | 94 ASSERT(isMainThread()); |
94 ASSERT(context()->isGraphOwner()); | 95 ASSERT(context()->isGraphOwner()); |
95 | 96 |
| 97 context()->removeChangedChannelCountMode(this); |
96 context()->removeAutomaticPullNode(this); | 98 context()->removeAutomaticPullNode(this); |
97 context()->disposeOutputs(*this); | 99 context()->disposeOutputs(*this); |
98 for (unsigned i = 0; i < m_outputs.size(); ++i) | 100 for (unsigned i = 0; i < m_outputs.size(); ++i) |
99 output(i)->disconnectAll(); | 101 output(i)->disconnectAll(); |
100 } | 102 } |
101 | 103 |
102 String AudioNode::nodeTypeName() const | 104 String AudioNode::nodeTypeName() const |
103 { | 105 { |
104 switch (m_nodeType) { | 106 switch (m_nodeType) { |
105 case NodeTypeDestination: | 107 case NodeTypeDestination: |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 304 } |
303 | 305 |
304 void AudioNode::setChannelCountMode(const String& mode, ExceptionState& exceptio
nState) | 306 void AudioNode::setChannelCountMode(const String& mode, ExceptionState& exceptio
nState) |
305 { | 307 { |
306 ASSERT(isMainThread()); | 308 ASSERT(isMainThread()); |
307 AudioContext::AutoLocker locker(context()); | 309 AudioContext::AutoLocker locker(context()); |
308 | 310 |
309 ChannelCountMode oldMode = m_channelCountMode; | 311 ChannelCountMode oldMode = m_channelCountMode; |
310 | 312 |
311 if (mode == "max") { | 313 if (mode == "max") { |
312 m_channelCountMode = Max; | 314 m_newChannelCountMode = Max; |
313 } else if (mode == "clamped-max") { | 315 } else if (mode == "clamped-max") { |
314 m_channelCountMode = ClampedMax; | 316 m_newChannelCountMode = ClampedMax; |
315 } else if (mode == "explicit") { | 317 } else if (mode == "explicit") { |
316 m_channelCountMode = Explicit; | 318 m_newChannelCountMode = Explicit; |
317 } else { | 319 } else { |
318 ASSERT_NOT_REACHED(); | 320 ASSERT_NOT_REACHED(); |
319 } | 321 } |
320 | 322 |
321 if (m_channelCountMode != oldMode) | 323 if (m_newChannelCountMode != oldMode) |
322 updateChannelsForInputs(); | 324 context()->addChangedChannelCountMode(this); |
323 } | 325 } |
324 | 326 |
325 String AudioNode::channelInterpretation() | 327 String AudioNode::channelInterpretation() |
326 { | 328 { |
327 switch (m_channelInterpretation) { | 329 switch (m_channelInterpretation) { |
328 case AudioBus::Speakers: | 330 case AudioBus::Speakers: |
329 return "speakers"; | 331 return "speakers"; |
330 case AudioBus::Discrete: | 332 case AudioBus::Discrete: |
331 return "discrete"; | 333 return "discrete"; |
332 } | 334 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 #endif // DEBUG_AUDIONODE_REFERENCES | 546 #endif // DEBUG_AUDIONODE_REFERENCES |
545 | 547 |
546 void AudioNode::trace(Visitor* visitor) | 548 void AudioNode::trace(Visitor* visitor) |
547 { | 549 { |
548 visitor->trace(m_context); | 550 visitor->trace(m_context); |
549 visitor->trace(m_inputs); | 551 visitor->trace(m_inputs); |
550 visitor->trace(m_outputs); | 552 visitor->trace(m_outputs); |
551 EventTargetWithInlineData::trace(visitor); | 553 EventTargetWithInlineData::trace(visitor); |
552 } | 554 } |
553 | 555 |
| 556 void AudioNode::updateChannelCountMode() |
| 557 { |
| 558 m_channelCountMode = m_newChannelCountMode; |
| 559 updateChannelsForInputs(); |
| 560 } |
| 561 |
554 } // namespace blink | 562 } // namespace blink |
555 | 563 |
556 #endif // ENABLE(WEB_AUDIO) | 564 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |