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 EventTarget { | 53 class AudioNode : public ScriptWrappable, public EventTargetWithInlineData { |
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 String channelInterpretation(); | 176 String channelInterpretation(); |
177 void setChannelInterpretation(const String&, ExceptionState&); | 177 void setChannelInterpretation(const String&, ExceptionState&); |
178 | 178 |
179 ChannelCountMode internalChannelCountMode() const { return m_channelCountMod
e; } | 179 ChannelCountMode internalChannelCountMode() const { return m_channelCountMod
e; } |
180 AudioBus::ChannelInterpretation internalChannelInterpretation() const { retu
rn m_channelInterpretation; } | 180 AudioBus::ChannelInterpretation internalChannelInterpretation() const { retu
rn m_channelInterpretation; } |
181 | 181 |
182 // EventTarget | 182 // EventTarget |
183 virtual const AtomicString& interfaceName() const OVERRIDE; | 183 virtual const AtomicString& interfaceName() const OVERRIDE; |
184 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; | 184 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; |
185 virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetD
ata; } | |
186 virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventT
argetData; } | |
187 | 185 |
188 protected: | 186 protected: |
189 // Inputs and outputs must be created before the AudioNode is initialized. | 187 // Inputs and outputs must be created before the AudioNode is initialized. |
190 void addInput(PassOwnPtr<AudioNodeInput>); | 188 void addInput(PassOwnPtr<AudioNodeInput>); |
191 void addOutput(PassOwnPtr<AudioNodeOutput>); | 189 void addOutput(PassOwnPtr<AudioNodeOutput>); |
192 | 190 |
193 // 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. |
194 // 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. |
195 // Called from context's audio thread. | 193 // Called from context's audio thread. |
196 virtual void pullInputs(size_t framesToProcess); | 194 virtual void pullInputs(size_t framesToProcess); |
197 | 195 |
198 // Force all inputs to take any channel interpretation changes into account. | 196 // Force all inputs to take any channel interpretation changes into account. |
199 void updateChannelsForInputs(); | 197 void updateChannelsForInputs(); |
200 | 198 |
201 private: | 199 private: |
202 volatile bool m_isInitialized; | 200 volatile bool m_isInitialized; |
203 NodeType m_nodeType; | 201 NodeType m_nodeType; |
204 RefPtr<AudioContext> m_context; | 202 RefPtr<AudioContext> m_context; |
205 float m_sampleRate; | 203 float m_sampleRate; |
206 Vector<OwnPtr<AudioNodeInput> > m_inputs; | 204 Vector<OwnPtr<AudioNodeInput> > m_inputs; |
207 Vector<OwnPtr<AudioNodeOutput> > m_outputs; | 205 Vector<OwnPtr<AudioNodeOutput> > m_outputs; |
208 | 206 |
209 EventTargetData m_eventTargetData; | |
210 | |
211 double m_lastProcessingTime; | 207 double m_lastProcessingTime; |
212 double m_lastNonSilentTime; | 208 double m_lastNonSilentTime; |
213 | 209 |
214 // Ref-counting | 210 // Ref-counting |
215 volatile int m_normalRefCount; | 211 volatile int m_normalRefCount; |
216 volatile int m_connectionRefCount; | 212 volatile int m_connectionRefCount; |
217 | 213 |
218 bool m_isMarkedForDeletion; | 214 bool m_isMarkedForDeletion; |
219 bool m_isDisabled; | 215 bool m_isDisabled; |
220 | 216 |
221 #if DEBUG_AUDIONODE_REFERENCES | 217 #if DEBUG_AUDIONODE_REFERENCES |
222 static bool s_isNodeCountInitialized; | 218 static bool s_isNodeCountInitialized; |
223 static int s_nodeCount[NodeTypeEnd]; | 219 static int s_nodeCount[NodeTypeEnd]; |
224 #endif | 220 #endif |
225 | 221 |
226 virtual void refEventTarget() OVERRIDE { ref(); } | 222 virtual void refEventTarget() OVERRIDE { ref(); } |
227 virtual void derefEventTarget() OVERRIDE { deref(); } | 223 virtual void derefEventTarget() OVERRIDE { deref(); } |
228 | 224 |
229 protected: | 225 protected: |
230 unsigned m_channelCount; | 226 unsigned m_channelCount; |
231 ChannelCountMode m_channelCountMode; | 227 ChannelCountMode m_channelCountMode; |
232 AudioBus::ChannelInterpretation m_channelInterpretation; | 228 AudioBus::ChannelInterpretation m_channelInterpretation; |
233 }; | 229 }; |
234 | 230 |
235 } // namespace WebCore | 231 } // namespace WebCore |
236 | 232 |
237 #endif // AudioNode_h | 233 #endif // AudioNode_h |
OLD | NEW |