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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class AudioNodeOutput; | 42 class AudioNodeOutput; |
43 class AudioParam; | 43 class AudioParam; |
44 class ExceptionState; | 44 class ExceptionState; |
45 | 45 |
46 // An AudioNode is the basic building block for handling audio within an AudioCo
ntext. | 46 // An AudioNode is the basic building block for handling audio within an AudioCo
ntext. |
47 // It may be an audio source, an intermediate processing module, or an audio des
tination. | 47 // It may be an audio source, an intermediate processing module, or an audio des
tination. |
48 // Each AudioNode can have inputs and/or outputs. An AudioSourceNode has no inpu
ts and a single output. | 48 // Each AudioNode can have inputs and/or outputs. An AudioSourceNode has no inpu
ts and a single output. |
49 // An AudioDestinationNode has one input and no outputs and represents the final
destination to the audio hardware. | 49 // An AudioDestinationNode has one input and no outputs and represents the final
destination to the audio hardware. |
50 // Most processing nodes such as filters will have one input and one output, alt
hough multiple inputs and outputs are possible. | 50 // Most processing nodes such as filters will have one input and one output, alt
hough multiple inputs and outputs are possible. |
51 | 51 |
52 // AudioNode has its own ref-counting mechanism that use RefTypes so we cannot u
se RefCountedGarbageCollected. | 52 class AudioNode : public RefCountedGarbageCollectedWillBeGarbageCollectedFinaliz
ed<AudioNode>, public EventTargetWithInlineData { |
53 class AudioNode : public NoBaseWillBeGarbageCollectedFinalized<AudioNode>, publi
c EventTargetWithInlineData { | 53 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<A
udioNode>); |
54 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AudioNode); | 54 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AudioNode); |
55 public: | 55 public: |
56 enum { ProcessingSizeInFrames = 128 }; | 56 enum { ProcessingSizeInFrames = 128 }; |
57 | 57 |
58 AudioNode(AudioContext*, float sampleRate); | 58 AudioNode(AudioContext*, float sampleRate); |
59 virtual ~AudioNode(); | 59 virtual ~AudioNode(); |
60 // dispose() is called just before the destructor. This must be called in | 60 // dispose() is called just before the destructor. This must be called in |
61 // the main thread, and while the graph lock is held. | 61 // the main thread, and while the graph lock is held. |
62 virtual void dispose(); | 62 virtual void dispose(); |
63 static unsigned instanceCount() { return s_instanceCount; } | 63 static unsigned instanceCount() { return s_instanceCount; } |
(...skipping 26 matching lines...) Expand all Loading... |
90 enum ChannelCountMode { | 90 enum ChannelCountMode { |
91 Max, | 91 Max, |
92 ClampedMax, | 92 ClampedMax, |
93 Explicit | 93 Explicit |
94 }; | 94 }; |
95 | 95 |
96 NodeType nodeType() const { return m_nodeType; } | 96 NodeType nodeType() const { return m_nodeType; } |
97 String nodeTypeName() const; | 97 String nodeTypeName() const; |
98 void setNodeType(NodeType); | 98 void setNodeType(NodeType); |
99 | 99 |
100 #if !ENABLE(OILPAN) | |
101 // Can be called from main thread or context's audio thread. | |
102 void ref(); | |
103 void deref(); | |
104 #endif | |
105 | |
106 // This object has been connected to another object. This might have | 100 // This object has been connected to another object. This might have |
107 // existing connections from others. | 101 // existing connections from others. |
108 // This function must be called after acquiring a connection reference. | 102 // This function must be called after acquiring a connection reference. |
109 void makeConnection(); | 103 void makeConnection(); |
110 // This object will be disconnected from another object. This might have | 104 // This object will be disconnected from another object. This might have |
111 // remaining connections from others. | 105 // remaining connections from others. |
112 // This function must be called before releasing a connection reference. | 106 // This function must be called before releasing a connection reference. |
113 void breakConnection(); | 107 void breakConnection(); |
114 | 108 |
115 // Can be called from main thread or context's audio thread. It must be cal
led while the context's graph lock is held. | 109 // Can be called from main thread or context's audio thread. It must be cal
led while the context's graph lock is held. |
116 #if !ENABLE(OILPAN) | |
117 void finishDeref(); | |
118 #endif | |
119 void breakConnectionWithLock(); | 110 void breakConnectionWithLock(); |
120 | 111 |
121 // The AudioNodeInput(s) (if any) will already have their input data availab
le when process() is called. | 112 // The AudioNodeInput(s) (if any) will already have their input data availab
le when process() is called. |
122 // Subclasses will take this input data and put the results in the AudioBus(
s) of its AudioNodeOutput(s) (if any). | 113 // Subclasses will take this input data and put the results in the AudioBus(
s) of its AudioNodeOutput(s) (if any). |
123 // Called from context's audio thread. | 114 // Called from context's audio thread. |
124 virtual void process(size_t framesToProcess) = 0; | 115 virtual void process(size_t framesToProcess) = 0; |
125 | 116 |
126 // No significant resources should be allocated until initialize() is called
. | 117 // No significant resources should be allocated until initialize() is called
. |
127 // Processing may not occur until a node is initialized. | 118 // Processing may not occur until a node is initialized. |
128 virtual void initialize(); | 119 virtual void initialize(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 182 |
192 // EventTarget | 183 // EventTarget |
193 virtual const AtomicString& interfaceName() const OVERRIDE FINAL; | 184 virtual const AtomicString& interfaceName() const OVERRIDE FINAL; |
194 virtual ExecutionContext* executionContext() const OVERRIDE FINAL; | 185 virtual ExecutionContext* executionContext() const OVERRIDE FINAL; |
195 | 186 |
196 virtual void trace(Visitor*) OVERRIDE; | 187 virtual void trace(Visitor*) OVERRIDE; |
197 | 188 |
198 protected: | 189 protected: |
199 // Inputs and outputs must be created before the AudioNode is initialized. | 190 // Inputs and outputs must be created before the AudioNode is initialized. |
200 void addInput(); | 191 void addInput(); |
201 void addOutput(PassOwnPtrWillBeRawPtr<AudioNodeOutput>); | 192 void addOutput(AudioNodeOutput*); |
202 | 193 |
203 // Called by processIfNecessary() to cause all parts of the rendering graph
connected to us to process. | 194 // Called by processIfNecessary() to cause all parts of the rendering graph
connected to us to process. |
204 // Each rendering quantum, the audio data for each of the AudioNode's inputs
will be available after this method is called. | 195 // Each rendering quantum, the audio data for each of the AudioNode's inputs
will be available after this method is called. |
205 // Called from context's audio thread. | 196 // Called from context's audio thread. |
206 virtual void pullInputs(size_t framesToProcess); | 197 virtual void pullInputs(size_t framesToProcess); |
207 | 198 |
208 // Force all inputs to take any channel interpretation changes into account. | 199 // Force all inputs to take any channel interpretation changes into account. |
209 void updateChannelsForInputs(); | 200 void updateChannelsForInputs(); |
210 | 201 |
211 private: | 202 private: |
212 volatile bool m_isInitialized; | 203 volatile bool m_isInitialized; |
213 NodeType m_nodeType; | 204 NodeType m_nodeType; |
214 RefPtrWillBeMember<AudioContext> m_context; | 205 Member<AudioContext> m_context; |
215 float m_sampleRate; | 206 float m_sampleRate; |
216 WillBeHeapVector<OwnPtrWillBeMember<AudioNodeInput> > m_inputs; | 207 HeapVector<Member<AudioNodeInput> > m_inputs; |
217 WillBeHeapVector<OwnPtrWillBeMember<AudioNodeOutput> > m_outputs; | 208 HeapVector<Member<AudioNodeOutput> > m_outputs; |
218 | 209 |
219 double m_lastProcessingTime; | 210 double m_lastProcessingTime; |
220 double m_lastNonSilentTime; | 211 double m_lastNonSilentTime; |
221 | 212 |
222 #if !ENABLE(OILPAN) | |
223 // Ref-counting | |
224 volatile int m_normalRefCount; | |
225 #endif | |
226 volatile int m_connectionRefCount; | 213 volatile int m_connectionRefCount; |
227 | 214 |
228 bool m_isDisabled; | 215 bool m_isDisabled; |
229 bool m_isDisposeCalled; | 216 bool m_isDisposeCalled; |
230 | 217 |
231 #if DEBUG_AUDIONODE_REFERENCES | 218 #if DEBUG_AUDIONODE_REFERENCES |
232 static bool s_isNodeCountInitialized; | 219 static bool s_isNodeCountInitialized; |
233 static int s_nodeCount[NodeTypeEnd]; | 220 static int s_nodeCount[NodeTypeEnd]; |
234 #endif | 221 #endif |
235 static unsigned s_instanceCount; | 222 static unsigned s_instanceCount; |
236 | 223 |
237 #if !ENABLE(OILPAN) | |
238 virtual void refEventTarget() OVERRIDE FINAL { ref(); } | |
239 virtual void derefEventTarget() OVERRIDE FINAL { deref(); } | |
240 #endif | |
241 | |
242 protected: | 224 protected: |
243 unsigned m_channelCount; | 225 unsigned m_channelCount; |
244 ChannelCountMode m_channelCountMode; | 226 ChannelCountMode m_channelCountMode; |
245 AudioBus::ChannelInterpretation m_channelInterpretation; | 227 AudioBus::ChannelInterpretation m_channelInterpretation; |
246 }; | 228 }; |
247 | 229 |
248 } // namespace blink | 230 } // namespace blink |
249 | 231 |
250 #endif // AudioNode_h | 232 #endif // AudioNode_h |
OLD | NEW |