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()); |
106 | |
107 // This flag prevents: | |
108 // - the following disconnectAll() from re-registering this AudioNode into t he m_outputs. | |
tkent
2014/08/14 23:25:01
I recommend to wrap code comments in 80 columns.
haraken
2014/08/15 01:27:18
Done.
| |
109 // - this AudioNode from getting marked as dirty after calling unmarkDirtyNo de. | |
110 m_isDisposeCalled = true; | |
111 | |
111 #if ENABLE(OILPAN) | 112 #if ENABLE(OILPAN) |
haraken
2014/08/12 14:29:51
Note: This CL depends on https://codereview.chromi
| |
112 context()->removeAutomaticPullNode(this); | 113 context()->removeAutomaticPullNode(this); |
113 for (unsigned i = 0; i < m_outputs.size(); ++i) | 114 for (unsigned i = 0; i < m_outputs.size(); ++i) |
114 output(i)->disconnectAll(); | 115 output(i)->disconnectAll(); |
115 #endif | 116 #endif |
116 context()->unmarkDirtyNode(*this); | 117 context()->unmarkDirtyNode(*this); |
117 #if ENABLE(ASSERT) | |
118 m_didCallDispose = true; | |
119 #endif | |
120 } | 118 } |
121 | 119 |
122 String AudioNode::nodeTypeName() const | 120 String AudioNode::nodeTypeName() const |
123 { | 121 { |
124 switch (m_nodeType) { | 122 switch (m_nodeType) { |
125 case NodeTypeDestination: | 123 case NodeTypeDestination: |
126 return "AudioDestinationNode"; | 124 return "AudioDestinationNode"; |
127 case NodeTypeOscillator: | 125 case NodeTypeOscillator: |
128 return "OscillatorNode"; | 126 return "OscillatorNode"; |
129 case NodeTypeAudioBufferSource: | 127 case NodeTypeAudioBufferSource: |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 { | 601 { |
604 ASSERT(context()->isGraphOwner()); | 602 ASSERT(context()->isGraphOwner()); |
605 | 603 |
606 ASSERT(m_normalRefCount > 0); | 604 ASSERT(m_normalRefCount > 0); |
607 atomicDecrement(&m_normalRefCount); | 605 atomicDecrement(&m_normalRefCount); |
608 | 606 |
609 #if DEBUG_AUDIONODE_REFERENCES | 607 #if DEBUG_AUDIONODE_REFERENCES |
610 fprintf(stderr, "%p: %d: AudioNode::deref() %d %d\n", this, nodeType(), m_no rmalRefCount, m_connectionRefCount); | 608 fprintf(stderr, "%p: %d: AudioNode::deref() %d %d\n", this, nodeType(), m_no rmalRefCount, m_connectionRefCount); |
611 #endif | 609 #endif |
612 | 610 |
613 if (!m_normalRefCount && !m_isMarkedForDeletion) { | 611 if (!m_normalRefCount) { |
614 // All references are gone - we need to go away. | 612 // All references are gone - we need to go away. |
615 for (unsigned i = 0; i < m_outputs.size(); ++i) | 613 for (unsigned i = 0; i < m_outputs.size(); ++i) |
616 output(i)->disconnectAll(); // This will deref() nodes we're connect ed to. | 614 output(i)->disconnectAll(); // This will deref() nodes we're connect ed to. |
617 | 615 |
618 // Mark for deletion at end of each render quantum or when context shuts | 616 // Mark for deletion at end of each render quantum or when context shuts |
619 // down. | 617 // down. |
620 context()->markForDeletion(this); | 618 context()->markForDeletion(this); |
621 m_isMarkedForDeletion = true; | |
622 } | 619 } |
623 } | 620 } |
624 #endif | 621 #endif |
625 | 622 |
626 #if DEBUG_AUDIONODE_REFERENCES | 623 #if DEBUG_AUDIONODE_REFERENCES |
627 | 624 |
628 bool AudioNode::s_isNodeCountInitialized = false; | 625 bool AudioNode::s_isNodeCountInitialized = false; |
629 int AudioNode::s_nodeCount[NodeTypeEnd]; | 626 int AudioNode::s_nodeCount[NodeTypeEnd]; |
630 | 627 |
631 void AudioNode::printNodeCounts() | 628 void AudioNode::printNodeCounts() |
(...skipping 15 matching lines...) Expand all Loading... | |
647 { | 644 { |
648 visitor->trace(m_context); | 645 visitor->trace(m_context); |
649 visitor->trace(m_inputs); | 646 visitor->trace(m_inputs); |
650 visitor->trace(m_outputs); | 647 visitor->trace(m_outputs); |
651 EventTargetWithInlineData::trace(visitor); | 648 EventTargetWithInlineData::trace(visitor); |
652 } | 649 } |
653 | 650 |
654 } // namespace blink | 651 } // namespace blink |
655 | 652 |
656 #endif // ENABLE(WEB_AUDIO) | 653 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |