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

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

Issue 438293003: Enable Oilpan by default for webaudio/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 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 // AudioNode has its own ref-counting mechanism that use RefTypes so we cannot u se RefCountedGarbageCollected.
53 class AudioNode : public NoBaseWillBeGarbageCollectedFinalized<AudioNode>, publi c EventTargetWithInlineData { 53 class AudioNode : public GarbageCollectedFinalized<AudioNode>, public EventTarge tWithInlineData {
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
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.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 185
192 // EventTarget 186 // EventTarget
193 virtual const AtomicString& interfaceName() const OVERRIDE FINAL; 187 virtual const AtomicString& interfaceName() const OVERRIDE FINAL;
194 virtual ExecutionContext* executionContext() const OVERRIDE FINAL; 188 virtual ExecutionContext* executionContext() const OVERRIDE FINAL;
195 189
196 virtual void trace(Visitor*) OVERRIDE; 190 virtual void trace(Visitor*) OVERRIDE;
197 191
198 protected: 192 protected:
199 // Inputs and outputs must be created before the AudioNode is initialized. 193 // Inputs and outputs must be created before the AudioNode is initialized.
200 void addInput(); 194 void addInput();
201 void addOutput(PassOwnPtrWillBeRawPtr<AudioNodeOutput>); 195 void addOutput(AudioNodeOutput*);
202 196
203 // Called by processIfNecessary() to cause all parts of the rendering graph connected to us to process. 197 // 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. 198 // 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. 199 // Called from context's audio thread.
206 virtual void pullInputs(size_t framesToProcess); 200 virtual void pullInputs(size_t framesToProcess);
207 201
208 // Force all inputs to take any channel interpretation changes into account. 202 // Force all inputs to take any channel interpretation changes into account.
209 void updateChannelsForInputs(); 203 void updateChannelsForInputs();
210 204
211 private: 205 private:
212 volatile bool m_isInitialized; 206 volatile bool m_isInitialized;
213 NodeType m_nodeType; 207 NodeType m_nodeType;
214 RefPtrWillBeMember<AudioContext> m_context; 208 Member<AudioContext> m_context;
215 float m_sampleRate; 209 float m_sampleRate;
216 WillBeHeapVector<OwnPtrWillBeMember<AudioNodeInput> > m_inputs; 210 HeapVector<Member<AudioNodeInput> > m_inputs;
217 WillBeHeapVector<OwnPtrWillBeMember<AudioNodeOutput> > m_outputs; 211 HeapVector<Member<AudioNodeOutput> > m_outputs;
218 212
219 double m_lastProcessingTime; 213 double m_lastProcessingTime;
220 double m_lastNonSilentTime; 214 double m_lastNonSilentTime;
221 215
222 #if !ENABLE(OILPAN) 216 #if !ENABLE(OILPAN)
223 // Ref-counting 217 // Ref-counting
224 volatile int m_normalRefCount; 218 volatile int m_normalRefCount;
219
220 // AudioNodes are in the oilpan heap but they are still reference counted at
221 // the same time. This is because we are not allowed to stop the audio
222 // thread and thus the audio thread cannot allocate objects in the oilpan
223 // heap.
224 // The m_keepAlive handle is used to keep a persistent reference to this
225 // AudioNode while someone has a reference to this AudioNode through a
226 // RefPtr.
227 GC_PLUGIN_IGNORE("")
228 Persistent<AudioNode> m_keepAlive;
225 #endif 229 #endif
226 volatile int m_connectionRefCount; 230 volatile int m_connectionRefCount;
227 231
228 bool m_isDisabled; 232 bool m_isDisabled;
229 bool m_isDisposeCalled; 233 bool m_isDisposeCalled;
230 234
231 #if DEBUG_AUDIONODE_REFERENCES 235 #if DEBUG_AUDIONODE_REFERENCES
232 static bool s_isNodeCountInitialized; 236 static bool s_isNodeCountInitialized;
233 static int s_nodeCount[NodeTypeEnd]; 237 static int s_nodeCount[NodeTypeEnd];
234 #endif 238 #endif
235 static unsigned s_instanceCount; 239 static unsigned s_instanceCount;
236 240
237 #if !ENABLE(OILPAN) 241 #if !ENABLE(OILPAN)
242 // Can be called from main thread or context's audio thread.
243 void ref();
244 void deref();
245
238 virtual void refEventTarget() OVERRIDE FINAL { ref(); } 246 virtual void refEventTarget() OVERRIDE FINAL { ref(); }
239 virtual void derefEventTarget() OVERRIDE FINAL { deref(); } 247 virtual void derefEventTarget() OVERRIDE FINAL { deref(); }
240 #endif 248 #endif
241 249
242 protected: 250 protected:
243 unsigned m_channelCount; 251 unsigned m_channelCount;
244 ChannelCountMode m_channelCountMode; 252 ChannelCountMode m_channelCountMode;
245 AudioBus::ChannelInterpretation m_channelInterpretation; 253 AudioBus::ChannelInterpretation m_channelInterpretation;
246 }; 254 };
247 255
248 } // namespace blink 256 } // namespace blink
249 257
250 #endif // AudioNode_h 258 #endif // AudioNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698