Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: Source/modules/webaudio/AudioNode.h

Issue 205173002: Move webaudio to oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: WIP Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 NoBaseWillBeGarbageCollectedFinalized<AudioNode>, publi c ScriptWrappable, public EventTargetWithInlineData {
haraken 2014/03/27 11:44:05 Shouldn't this be NoBaseWillBeRefCountedGarbageCol
keishi 2014/04/03 06:53:19 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
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 #if ENABLE(OILPAN)
185 void clearKeepAlive();
186 #endif
187
182 protected: 188 protected:
183 // Inputs and outputs must be created before the AudioNode is initialized. 189 // Inputs and outputs must be created before the AudioNode is initialized.
184 void addInput(PassOwnPtr<AudioNodeInput>); 190 void addInput(PassOwnPtr<AudioNodeInput>);
185 void addOutput(PassOwnPtr<AudioNodeOutput>); 191 void addOutput(PassOwnPtr<AudioNodeOutput>);
186 192
187 // Called by processIfNecessary() to cause all parts of the rendering graph connected to us to process. 193 // 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. 194 // 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. 195 // Called from context's audio thread.
190 virtual void pullInputs(size_t framesToProcess); 196 virtual void pullInputs(size_t framesToProcess);
191 197
192 // Force all inputs to take any channel interpretation changes into account. 198 // Force all inputs to take any channel interpretation changes into account.
193 void updateChannelsForInputs(); 199 void updateChannelsForInputs();
194 200
195 private: 201 private:
196 volatile bool m_isInitialized; 202 volatile bool m_isInitialized;
197 NodeType m_nodeType; 203 NodeType m_nodeType;
198 RefPtr<AudioContext> m_context; 204 RefPtrWillBeMember<AudioContext> m_context;
199 float m_sampleRate; 205 float m_sampleRate;
200 Vector<OwnPtr<AudioNodeInput> > m_inputs; 206 Vector<OwnPtr<AudioNodeInput> > m_inputs;
201 Vector<OwnPtr<AudioNodeOutput> > m_outputs; 207 Vector<OwnPtr<AudioNodeOutput> > m_outputs;
202 208
209 #if ENABLE(OILPAN)
210 // AudioNodes are still reference counted but they are in the
211 // oilpan heap because the ScriptProcessorNode is an EventTarget.
212 // This self-persistent keeps the object from being deleted
213 // until the reference count reaches zero.
haraken 2014/03/27 11:44:05 If this statement is true, shouldn't we add an Own
keishi 2014/04/03 06:53:19 Done.
214 //
215 // It is safe to drop the self-persistent when the ref count
216 // of a ScriptProcessorNode reaches zero. At that point, the
217 // ScriptProcessor node is removed from the AudioContext and
218 // it cannot be reattached. Therefore, the reference count
219 // will not go above zero again.
haraken 2014/03/27 11:44:05 Can we add an ASSERT about the fact?
keishi 2014/04/08 02:33:40 Done. Added an ASSERT to AudioNode::ref
220 OwnPtr<Persistent<AudioNode> > m_keepAlive;
221 #endif
222
203 double m_lastProcessingTime; 223 double m_lastProcessingTime;
204 double m_lastNonSilentTime; 224 double m_lastNonSilentTime;
205 225
206 // Ref-counting 226 // Ref-counting
207 volatile int m_normalRefCount; 227 volatile int m_normalRefCount;
208 volatile int m_connectionRefCount; 228 volatile int m_connectionRefCount;
209 229
210 bool m_isMarkedForDeletion; 230 bool m_isMarkedForDeletion;
211 bool m_isDisabled; 231 bool m_isDisabled;
212 232
213 #if DEBUG_AUDIONODE_REFERENCES 233 #if DEBUG_AUDIONODE_REFERENCES
214 static bool s_isNodeCountInitialized; 234 static bool s_isNodeCountInitialized;
215 static int s_nodeCount[NodeTypeEnd]; 235 static int s_nodeCount[NodeTypeEnd];
216 #endif 236 #endif
217 237
218 virtual void refEventTarget() OVERRIDE FINAL { ref(); } 238 virtual void refEventTarget() OVERRIDE FINAL { ref(); }
219 virtual void derefEventTarget() OVERRIDE FINAL { deref(); } 239 virtual void derefEventTarget() OVERRIDE FINAL { deref(); }
220 240
221 protected: 241 protected:
222 unsigned m_channelCount; 242 unsigned m_channelCount;
223 ChannelCountMode m_channelCountMode; 243 ChannelCountMode m_channelCountMode;
224 AudioBus::ChannelInterpretation m_channelInterpretation; 244 AudioBus::ChannelInterpretation m_channelInterpretation;
225 }; 245 };
226 246
227 } // namespace WebCore 247 } // namespace WebCore
228 248
229 #endif // AudioNode_h 249 #endif // AudioNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698