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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 #if !ENABLE(OILPAN) | 55 #if !ENABLE(OILPAN) |
56 , m_normalRefCount(1) // start out with normal refCount == 1 (like WTF::RefC
ounted class) | 56 , m_normalRefCount(1) // start out with normal refCount == 1 (like WTF::RefC
ounted class) |
57 #endif | 57 #endif |
58 , m_connectionRefCount(0) | 58 , m_connectionRefCount(0) |
59 #if !ENABLE(OILPAN) | |
60 , m_isMarkedForDeletion(false) | |
61 #endif | |
62 , m_isDisabled(false) | 59 , m_isDisabled(false) |
63 #if ENABLE(ASSERT) | 60 , m_isDisposeCalled(false) |
64 , m_didCallDispose(false) | |
65 #endif | |
66 , m_channelCount(2) | 61 , m_channelCount(2) |
67 , m_channelCountMode(Max) | 62 , m_channelCountMode(Max) |
68 , m_channelInterpretation(AudioBus::Speakers) | 63 , m_channelInterpretation(AudioBus::Speakers) |
69 { | 64 { |
70 ScriptWrappable::init(this); | 65 ScriptWrappable::init(this); |
71 #if ENABLE(OILPAN) | 66 #if ENABLE(OILPAN) |
72 m_context->registerLiveNode(*this); | 67 m_context->registerLiveNode(*this); |
73 #endif | 68 #endif |
74 #if DEBUG_AUDIONODE_REFERENCES | 69 #if DEBUG_AUDIONODE_REFERENCES |
75 if (!s_isNodeCountInitialized) { | 70 if (!s_isNodeCountInitialized) { |
76 s_isNodeCountInitialized = true; | 71 s_isNodeCountInitialized = true; |
77 atexit(AudioNode::printNodeCounts); | 72 atexit(AudioNode::printNodeCounts); |
78 } | 73 } |
79 #endif | 74 #endif |
80 ++s_instanceCount; | 75 ++s_instanceCount; |
81 } | 76 } |
82 | 77 |
83 AudioNode::~AudioNode() | 78 AudioNode::~AudioNode() |
84 { | 79 { |
85 ASSERT(m_didCallDispose); | 80 ASSERT(m_isDisposeCalled); |
86 --s_instanceCount; | 81 --s_instanceCount; |
87 #if DEBUG_AUDIONODE_REFERENCES | 82 #if DEBUG_AUDIONODE_REFERENCES |
88 --s_nodeCount[nodeType()]; | 83 --s_nodeCount[nodeType()]; |
89 #if ENABLE(OILPAN) | 84 #if ENABLE(OILPAN) |
90 fprintf(stderr, "%p: %d: AudioNode::~AudioNode() %d\n", this, nodeType(), m_
connectionRefCount); | 85 fprintf(stderr, "%p: %d: AudioNode::~AudioNode() %d\n", this, nodeType(), m_
connectionRefCount); |
91 #else | 86 #else |
92 fprintf(stderr, "%p: %d: AudioNode::~AudioNode() %d %d\n", this, nodeType(),
m_normalRefCount, m_connectionRefCount); | 87 fprintf(stderr, "%p: %d: AudioNode::~AudioNode() %d %d\n", this, nodeType(),
m_normalRefCount, m_connectionRefCount); |
93 #endif | 88 #endif |
94 #endif | 89 #endif |
95 } | 90 } |
96 | 91 |
97 void AudioNode::initialize() | 92 void AudioNode::initialize() |
98 { | 93 { |
99 m_isInitialized = true; | 94 m_isInitialized = true; |
100 } | 95 } |
101 | 96 |
102 void AudioNode::uninitialize() | 97 void AudioNode::uninitialize() |
103 { | 98 { |
104 m_isInitialized = false; | 99 m_isInitialized = false; |
105 } | 100 } |
106 | 101 |
107 void AudioNode::dispose() | 102 void AudioNode::dispose() |
108 { | 103 { |
109 ASSERT(isMainThread()); | 104 ASSERT(isMainThread()); |
110 ASSERT(context()->isGraphOwner()); | 105 ASSERT(context()->isGraphOwner()); |
111 | 106 |
| 107 // This flag prevents: |
| 108 // - the following disconnectAll() from re-registering this AudioNode into |
| 109 // the m_outputs. |
| 110 // - this AudioNode from getting marked as dirty after calling |
| 111 // unmarkDirtyNode. |
| 112 m_isDisposeCalled = true; |
| 113 |
112 context()->removeAutomaticPullNode(this); | 114 context()->removeAutomaticPullNode(this); |
113 for (unsigned i = 0; i < m_outputs.size(); ++i) | 115 for (unsigned i = 0; i < m_outputs.size(); ++i) |
114 output(i)->disconnectAll(); | 116 output(i)->disconnectAll(); |
115 context()->unmarkDirtyNode(*this); | 117 context()->unmarkDirtyNode(*this); |
116 #if ENABLE(ASSERT) | |
117 m_didCallDispose = true; | |
118 #endif | |
119 } | 118 } |
120 | 119 |
121 String AudioNode::nodeTypeName() const | 120 String AudioNode::nodeTypeName() const |
122 { | 121 { |
123 switch (m_nodeType) { | 122 switch (m_nodeType) { |
124 case NodeTypeDestination: | 123 case NodeTypeDestination: |
125 return "AudioDestinationNode"; | 124 return "AudioDestinationNode"; |
126 case NodeTypeOscillator: | 125 case NodeTypeOscillator: |
127 return "OscillatorNode"; | 126 return "OscillatorNode"; |
128 case NodeTypeAudioBufferSource: | 127 case NodeTypeAudioBufferSource: |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 { | 597 { |
599 ASSERT(context()->isGraphOwner()); | 598 ASSERT(context()->isGraphOwner()); |
600 | 599 |
601 ASSERT(m_normalRefCount > 0); | 600 ASSERT(m_normalRefCount > 0); |
602 atomicDecrement(&m_normalRefCount); | 601 atomicDecrement(&m_normalRefCount); |
603 | 602 |
604 #if DEBUG_AUDIONODE_REFERENCES | 603 #if DEBUG_AUDIONODE_REFERENCES |
605 fprintf(stderr, "%p: %d: AudioNode::deref() %d %d\n", this, nodeType(), m_no
rmalRefCount, m_connectionRefCount); | 604 fprintf(stderr, "%p: %d: AudioNode::deref() %d %d\n", this, nodeType(), m_no
rmalRefCount, m_connectionRefCount); |
606 #endif | 605 #endif |
607 | 606 |
608 if (!m_normalRefCount && !m_isMarkedForDeletion) { | 607 if (!m_normalRefCount) { |
609 // Mark for deletion at end of each render quantum or when context shuts | 608 // Mark for deletion at end of each render quantum or when context shuts |
610 // down. | 609 // down. |
611 context()->markForDeletion(this); | 610 context()->markForDeletion(this); |
612 m_isMarkedForDeletion = true; | |
613 } | 611 } |
614 } | 612 } |
615 #endif | 613 #endif |
616 | 614 |
617 #if DEBUG_AUDIONODE_REFERENCES | 615 #if DEBUG_AUDIONODE_REFERENCES |
618 | 616 |
619 bool AudioNode::s_isNodeCountInitialized = false; | 617 bool AudioNode::s_isNodeCountInitialized = false; |
620 int AudioNode::s_nodeCount[NodeTypeEnd]; | 618 int AudioNode::s_nodeCount[NodeTypeEnd]; |
621 | 619 |
622 void AudioNode::printNodeCounts() | 620 void AudioNode::printNodeCounts() |
(...skipping 15 matching lines...) Expand all Loading... |
638 { | 636 { |
639 visitor->trace(m_context); | 637 visitor->trace(m_context); |
640 visitor->trace(m_inputs); | 638 visitor->trace(m_inputs); |
641 visitor->trace(m_outputs); | 639 visitor->trace(m_outputs); |
642 EventTargetWithInlineData::trace(visitor); | 640 EventTargetWithInlineData::trace(visitor); |
643 } | 641 } |
644 | 642 |
645 } // namespace blink | 643 } // namespace blink |
646 | 644 |
647 #endif // ENABLE(WEB_AUDIO) | 645 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |