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

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

Issue 1214463003: Split "Online" and "Offline" AudioContext processing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Bring to ToT Created 5 years, 5 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
« no previous file with comments | « Source/modules/webaudio/AudioDestinationNode.cpp ('k') | Source/modules/webaudio/AudioNode.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 20 matching lines...) Expand all
31 #include "wtf/Forward.h" 31 #include "wtf/Forward.h"
32 #include "wtf/OwnPtr.h" 32 #include "wtf/OwnPtr.h"
33 #include "wtf/PassOwnPtr.h" 33 #include "wtf/PassOwnPtr.h"
34 #include "wtf/RefPtr.h" 34 #include "wtf/RefPtr.h"
35 #include "wtf/Vector.h" 35 #include "wtf/Vector.h"
36 36
37 #define DEBUG_AUDIONODE_REFERENCES 0 37 #define DEBUG_AUDIONODE_REFERENCES 0
38 38
39 namespace blink { 39 namespace blink {
40 40
41 class AudioContext; 41 class AbstractAudioContext;
42 class AudioNode; 42 class AudioNode;
43 class AudioNodeInput; 43 class AudioNodeInput;
44 class AudioNodeOutput; 44 class AudioNodeOutput;
45 class AudioParam; 45 class AudioParam;
46 class ExceptionState; 46 class ExceptionState;
47 47
48 // An AudioNode is the basic building block for handling audio within an AudioCo ntext. 48 // An AudioNode is the basic building block for handling audio within an Abstrac tAudioContext.
49 // It may be an audio source, an intermediate processing module, or an audio des tination. 49 // It may be an audio source, an intermediate processing module, or an audio des tination.
50 // Each AudioNode can have inputs and/or outputs. An AudioSourceNode has no inpu ts and a single output. 50 // Each AudioNode can have inputs and/or outputs. An AudioSourceNode has no inpu ts and a single output.
51 // An AudioDestinationNode has one input and no outputs and represents the final destination to the audio hardware. 51 // An AudioDestinationNode has one input and no outputs and represents the final destination to the audio hardware.
52 // Most processing nodes such as filters will have one input and one output, alt hough multiple inputs and outputs are possible. 52 // Most processing nodes such as filters will have one input and one output, alt hough multiple inputs and outputs are possible.
53 53
54 // Each of AudioNode objects owns its dedicated AudioHandler object. AudioNode 54 // Each of AudioNode objects owns its dedicated AudioHandler object. AudioNode
55 // is responsible to provide IDL-accessible interface and its lifetime is 55 // is responsible to provide IDL-accessible interface and its lifetime is
56 // managed by Oilpan GC. AudioHandler is responsible for anything else. We must 56 // managed by Oilpan GC. AudioHandler is responsible for anything else. We must
57 // not touch AudioNode objects in an audio rendering thread. 57 // not touch AudioNode objects in an audio rendering thread.
58 58
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // dispose() is called when the owner AudioNode is about to be 96 // dispose() is called when the owner AudioNode is about to be
97 // destructed. This must be called in the main thread, and while the graph 97 // destructed. This must be called in the main thread, and while the graph
98 // lock is held. 98 // lock is held.
99 // Do not release resources used by an audio rendering thread in dispose(). 99 // Do not release resources used by an audio rendering thread in dispose().
100 virtual void dispose(); 100 virtual void dispose();
101 101
102 // node() returns a valid object until dispose() is called. This returns 102 // node() returns a valid object until dispose() is called. This returns
103 // nullptr after dispose(). We must not call node() in an audio rendering 103 // nullptr after dispose(). We must not call node() in an audio rendering
104 // thread. 104 // thread.
105 AudioNode* node() const; 105 AudioNode* node() const;
106 // context() returns a valid object until the AudioContext dies, and returns 106 // context() returns a valid object until the AbstractAudioContext dies, and returns
107 // nullptr otherwise. This always returns a valid object in an audio 107 // nullptr otherwise. This always returns a valid object in an audio
108 // rendering thread, and inside dispose(). We must not call context() in 108 // rendering thread, and inside dispose(). We must not call context() in
109 // the destructor. 109 // the destructor.
110 AudioContext* context() const; 110 AbstractAudioContext* context() const;
111 void clearContext() { m_context = nullptr; } 111 void clearContext() { m_context = nullptr; }
112 112
113 enum ChannelCountMode { 113 enum ChannelCountMode {
114 Max, 114 Max,
115 ClampedMax, 115 ClampedMax,
116 Explicit 116 Explicit
117 }; 117 };
118 118
119 NodeType nodeType() const { return m_nodeType; } 119 NodeType nodeType() const { return m_nodeType; }
120 String nodeTypeName() const; 120 String nodeTypeName() const;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 volatile bool m_isInitialized; 235 volatile bool m_isInitialized;
236 NodeType m_nodeType; 236 NodeType m_nodeType;
237 237
238 // The owner AudioNode. This raw pointer is safe because dispose() is 238 // The owner AudioNode. This raw pointer is safe because dispose() is
239 // called before the AudioNode death, and it clears m_node. Do not access 239 // called before the AudioNode death, and it clears m_node. Do not access
240 // m_node directly, use node() instead. 240 // m_node directly, use node() instead.
241 GC_PLUGIN_IGNORE("http://crbug.com/404527") 241 GC_PLUGIN_IGNORE("http://crbug.com/404527")
242 AudioNode* m_node; 242 AudioNode* m_node;
243 243
244 // This raw pointer is safe because this is cleared for all of live 244 // This raw pointer is safe because this is cleared for all of live
245 // AudioHandlers when the AudioContext dies. Do not access m_context 245 // AudioHandlers when the AbstractAudioContext dies. Do not access m_contex t
246 // directly, use context() instead. 246 // directly, use context() instead.
247 GC_PLUGIN_IGNORE("http://crbug.com/404527") 247 GC_PLUGIN_IGNORE("http://crbug.com/404527")
248 AudioContext* m_context; 248 AbstractAudioContext* m_context;
249 249
250 float m_sampleRate; 250 float m_sampleRate;
251 Vector<OwnPtr<AudioNodeInput>> m_inputs; 251 Vector<OwnPtr<AudioNodeInput>> m_inputs;
252 Vector<OwnPtr<AudioNodeOutput>> m_outputs; 252 Vector<OwnPtr<AudioNodeOutput>> m_outputs;
253 253
254 double m_lastProcessingTime; 254 double m_lastProcessingTime;
255 double m_lastNonSilentTime; 255 double m_lastNonSilentTime;
256 256
257 volatile int m_connectionRefCount; 257 volatile int m_connectionRefCount;
258 258
(...skipping 23 matching lines...) Expand all
282 282
283 virtual void connect(AudioNode*, unsigned outputIndex, unsigned inputIndex, ExceptionState&); 283 virtual void connect(AudioNode*, unsigned outputIndex, unsigned inputIndex, ExceptionState&);
284 void connect(AudioParam*, unsigned outputIndex, ExceptionState&); 284 void connect(AudioParam*, unsigned outputIndex, ExceptionState&);
285 void disconnect(); 285 void disconnect();
286 virtual void disconnect(unsigned outputIndex, ExceptionState&); 286 virtual void disconnect(unsigned outputIndex, ExceptionState&);
287 void disconnect(AudioNode*, ExceptionState&); 287 void disconnect(AudioNode*, ExceptionState&);
288 void disconnect(AudioNode*, unsigned outputIndex, ExceptionState&); 288 void disconnect(AudioNode*, unsigned outputIndex, ExceptionState&);
289 void disconnect(AudioNode*, unsigned outputIndex, unsigned inputIndex, Excep tionState&); 289 void disconnect(AudioNode*, unsigned outputIndex, unsigned inputIndex, Excep tionState&);
290 void disconnect(AudioParam*, ExceptionState&); 290 void disconnect(AudioParam*, ExceptionState&);
291 void disconnect(AudioParam*, unsigned outputIndex, ExceptionState&); 291 void disconnect(AudioParam*, unsigned outputIndex, ExceptionState&);
292 AudioContext* context() const; 292 AbstractAudioContext* context() const;
293 unsigned numberOfInputs() const; 293 unsigned numberOfInputs() const;
294 unsigned numberOfOutputs() const; 294 unsigned numberOfOutputs() const;
295 unsigned long channelCount() const; 295 unsigned long channelCount() const;
296 void setChannelCount(unsigned long, ExceptionState&); 296 void setChannelCount(unsigned long, ExceptionState&);
297 String channelCountMode() const; 297 String channelCountMode() const;
298 void setChannelCountMode(const String&, ExceptionState&); 298 void setChannelCountMode(const String&, ExceptionState&);
299 String channelInterpretation() const; 299 String channelInterpretation() const;
300 void setChannelInterpretation(const String&, ExceptionState&); 300 void setChannelInterpretation(const String&, ExceptionState&);
301 301
302 // EventTarget 302 // EventTarget
303 const AtomicString& interfaceName() const final; 303 const AtomicString& interfaceName() const final;
304 ExecutionContext* executionContext() const final; 304 ExecutionContext* executionContext() const final;
305 305
306 // Called inside AudioHandler constructors. 306 // Called inside AudioHandler constructors.
307 void didAddOutput(unsigned numberOfOutputs); 307 void didAddOutput(unsigned numberOfOutputs);
308 // Like disconnect, but no exception is thrown if the outputIndex is invalid . Just do nothing 308 // Like disconnect, but no exception is thrown if the outputIndex is invalid . Just do nothing
309 // in that case. 309 // in that case.
310 void disconnectWithoutException(unsigned outputIndex); 310 void disconnectWithoutException(unsigned outputIndex);
311 311
312 protected: 312 protected:
313 explicit AudioNode(AudioContext&); 313 explicit AudioNode(AbstractAudioContext&);
314 // This should be called in a constructor. 314 // This should be called in a constructor.
315 void setHandler(PassRefPtr<AudioHandler>); 315 void setHandler(PassRefPtr<AudioHandler>);
316 316
317 private: 317 private:
318 void dispose(); 318 void dispose();
319 void disconnectAllFromOutput(unsigned outputIndex); 319 void disconnectAllFromOutput(unsigned outputIndex);
320 // Returns true if the specified AudioNodeInput was connected. 320 // Returns true if the specified AudioNodeInput was connected.
321 bool disconnectFromOutputIfConnected(unsigned outputIndex, AudioNode& destin ation, unsigned inputIndexOfDestination); 321 bool disconnectFromOutputIfConnected(unsigned outputIndex, AudioNode& destin ation, unsigned inputIndexOfDestination);
322 // Returns true if the specified AudioParam was connected. 322 // Returns true if the specified AudioParam was connected.
323 bool disconnectFromOutputIfConnected(unsigned outputIndex, AudioParam&); 323 bool disconnectFromOutputIfConnected(unsigned outputIndex, AudioParam&);
324 324
325 Member<AudioContext> m_context; 325 Member<AbstractAudioContext> m_context;
326 RefPtr<AudioHandler> m_handler; 326 RefPtr<AudioHandler> m_handler;
327 // Represents audio node graph with Oilpan references. N-th HeapHashSet 327 // Represents audio node graph with Oilpan references. N-th HeapHashSet
328 // represents a set of AudioNode objects connected to this AudioNode's N-th 328 // represents a set of AudioNode objects connected to this AudioNode's N-th
329 // output. 329 // output.
330 HeapVector<Member<HeapHashSet<Member<AudioNode>>>> m_connectedNodes; 330 HeapVector<Member<HeapHashSet<Member<AudioNode>>>> m_connectedNodes;
331 // Represents audio node graph with Oilpan references. N-th HeapHashSet 331 // Represents audio node graph with Oilpan references. N-th HeapHashSet
332 // represents a set of AudioParam objects connected to this AudioNode's N-th 332 // represents a set of AudioParam objects connected to this AudioNode's N-th
333 // output. 333 // output.
334 HeapVector<Member<HeapHashSet<Member<AudioParam>>>> m_connectedParams; 334 HeapVector<Member<HeapHashSet<Member<AudioParam>>>> m_connectedParams;
335 }; 335 };
336 336
337 } // namespace blink 337 } // namespace blink
338 338
339 #endif // AudioNode_h 339 #endif // AudioNode_h
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioDestinationNode.cpp ('k') | Source/modules/webaudio/AudioNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698