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

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

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

Powered by Google App Engine
This is Rietveld 408576698