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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 class AudioNodeOutput; | 43 class AudioNodeOutput; |
44 class AudioParam; | 44 class AudioParam; |
45 class ExceptionState; | 45 class ExceptionState; |
46 | 46 |
47 // An AudioNode is the basic building block for handling audio within an AudioCo ntext. | 47 // An AudioNode is the basic building block for handling audio within an AudioCo ntext. |
48 // It may be an audio source, an intermediate processing module, or an audio des tination. | 48 // It may be an audio source, an intermediate processing module, or an audio des tination. |
49 // Each AudioNode can have inputs and/or outputs. An AudioSourceNode has no inpu ts and a single output. | 49 // Each AudioNode can have inputs and/or outputs. An AudioSourceNode has no inpu ts and a single output. |
50 // An AudioDestinationNode has one input and no outputs and represents the final destination to the audio hardware. | 50 // An AudioDestinationNode has one input and no outputs and represents the final destination to the audio hardware. |
51 // Most processing nodes such as filters will have one input and one output, alt hough multiple inputs and outputs are possible. | 51 // Most processing nodes such as filters will have one input and one output, alt hough multiple inputs and outputs are possible. |
52 | 52 |
53 class AudioNode : public ScriptWrappable, public EventTargetWithInlineData { | 53 class AudioNode : public GarbageCollectedFinalized<AudioNode>, public ScriptWrap pable, public EventTargetWithInlineData { |
Mads Ager (chromium)
2014/03/20 08:30:00
We don't want to move this into the oilpan heap wh
keishi
2014/03/27 07:39:37
Done.
| |
54 public: | 54 public: |
55 enum { ProcessingSizeInFrames = 128 }; | 55 enum { ProcessingSizeInFrames = 128 }; |
56 | 56 |
57 AudioNode(AudioContext*, float sampleRate); | 57 AudioNode(AudioContext*, float sampleRate); |
58 virtual ~AudioNode(); | 58 virtual ~AudioNode(); |
59 | 59 |
60 AudioContext* context() { return m_context.get(); } | 60 AudioContext* context() { return m_context.get(); } |
61 const AudioContext* context() const { return m_context.get(); } | 61 const AudioContext* context() const { return m_context.get(); } |
62 | 62 |
63 enum NodeType { | 63 enum NodeType { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 String channelInterpretation(); | 172 String channelInterpretation(); |
173 void setChannelInterpretation(const String&, ExceptionState&); | 173 void setChannelInterpretation(const String&, ExceptionState&); |
174 | 174 |
175 ChannelCountMode internalChannelCountMode() const { return m_channelCountMod e; } | 175 ChannelCountMode internalChannelCountMode() const { return m_channelCountMod e; } |
176 AudioBus::ChannelInterpretation internalChannelInterpretation() const { retu rn m_channelInterpretation; } | 176 AudioBus::ChannelInterpretation internalChannelInterpretation() const { retu rn m_channelInterpretation; } |
177 | 177 |
178 // EventTarget | 178 // EventTarget |
179 virtual const AtomicString& interfaceName() const OVERRIDE FINAL; | 179 virtual const AtomicString& interfaceName() const OVERRIDE FINAL; |
180 virtual ExecutionContext* executionContext() const OVERRIDE FINAL; | 180 virtual ExecutionContext* executionContext() const OVERRIDE FINAL; |
181 | 181 |
182 virtual void trace(Visitor*); | |
183 | |
184 void clearKeepAlive(); | |
185 | |
182 protected: | 186 protected: |
183 // Inputs and outputs must be created before the AudioNode is initialized. | 187 // Inputs and outputs must be created before the AudioNode is initialized. |
184 void addInput(PassOwnPtr<AudioNodeInput>); | 188 void addInput(PassOwnPtr<AudioNodeInput>); |
185 void addOutput(PassOwnPtr<AudioNodeOutput>); | 189 void addOutput(PassOwnPtr<AudioNodeOutput>); |
186 | 190 |
187 // Called by processIfNecessary() to cause all parts of the rendering graph connected to us to process. | 191 // Called by processIfNecessary() to cause all parts of the rendering graph connected to us to process. |
188 // Each rendering quantum, the audio data for each of the AudioNode's inputs will be available after this method is called. | 192 // Each rendering quantum, the audio data for each of the AudioNode's inputs will be available after this method is called. |
189 // Called from context's audio thread. | 193 // Called from context's audio thread. |
190 virtual void pullInputs(size_t framesToProcess); | 194 virtual void pullInputs(size_t framesToProcess); |
191 | 195 |
192 // Force all inputs to take any channel interpretation changes into account. | 196 // Force all inputs to take any channel interpretation changes into account. |
193 void updateChannelsForInputs(); | 197 void updateChannelsForInputs(); |
194 | 198 |
195 private: | 199 private: |
196 volatile bool m_isInitialized; | 200 volatile bool m_isInitialized; |
197 NodeType m_nodeType; | 201 NodeType m_nodeType; |
198 RefPtr<AudioContext> m_context; | 202 RefPtrWillBeMember<AudioContext> m_context; |
199 float m_sampleRate; | 203 float m_sampleRate; |
200 Vector<OwnPtr<AudioNodeInput> > m_inputs; | 204 Vector<OwnPtr<AudioNodeInput> > m_inputs; |
201 Vector<OwnPtr<AudioNodeOutput> > m_outputs; | 205 Vector<OwnPtr<AudioNodeOutput> > m_outputs; |
202 | 206 |
207 // AudioNodes are still reference counted but they are in the | |
208 // oilpan heap because the ScriptProcessorNode is an EventTarget. | |
209 // This self-persistent keeps the object from being deleted | |
210 // until the reference count reaches zero. | |
211 // | |
212 // It is safe to drop the self-persistent when the ref count | |
213 // of a ScriptProcessorNode reaches zero. At that point, the | |
214 // ScriptProcessor node is removed from the AudioContext and | |
215 // it cannot be reattached. Therefore, the reference count | |
216 // will not go above zero again. | |
217 OwnPtr<Persistent<AudioNode> > m_keepAlive; | |
Mads Ager (chromium)
2014/03/20 08:30:00
This should be guarded with #if ENABLE(OILPAN)
| |
218 | |
203 double m_lastProcessingTime; | 219 double m_lastProcessingTime; |
204 double m_lastNonSilentTime; | 220 double m_lastNonSilentTime; |
205 | 221 |
206 // Ref-counting | 222 // Ref-counting |
207 volatile int m_normalRefCount; | 223 volatile int m_normalRefCount; |
208 volatile int m_connectionRefCount; | 224 volatile int m_connectionRefCount; |
209 | 225 |
210 bool m_isMarkedForDeletion; | 226 bool m_isMarkedForDeletion; |
211 bool m_isDisabled; | 227 bool m_isDisabled; |
212 | 228 |
213 #if DEBUG_AUDIONODE_REFERENCES | 229 #if DEBUG_AUDIONODE_REFERENCES |
214 static bool s_isNodeCountInitialized; | 230 static bool s_isNodeCountInitialized; |
215 static int s_nodeCount[NodeTypeEnd]; | 231 static int s_nodeCount[NodeTypeEnd]; |
216 #endif | 232 #endif |
217 | 233 |
218 virtual void refEventTarget() OVERRIDE FINAL { ref(); } | 234 virtual void refEventTarget() OVERRIDE FINAL { ref(); } |
219 virtual void derefEventTarget() OVERRIDE FINAL { deref(); } | 235 virtual void derefEventTarget() OVERRIDE FINAL { deref(); } |
220 | 236 |
221 protected: | 237 protected: |
222 unsigned m_channelCount; | 238 unsigned m_channelCount; |
223 ChannelCountMode m_channelCountMode; | 239 ChannelCountMode m_channelCountMode; |
224 AudioBus::ChannelInterpretation m_channelInterpretation; | 240 AudioBus::ChannelInterpretation m_channelInterpretation; |
225 }; | 241 }; |
226 | 242 |
227 } // namespace WebCore | 243 } // namespace WebCore |
228 | 244 |
229 #endif // AudioNode_h | 245 #endif // AudioNode_h |
OLD | NEW |