Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 #include "core/events/EventListener.h" | 29 #include "core/events/EventListener.h" |
| 30 #include "modules/EventTargetModules.h" | 30 #include "modules/EventTargetModules.h" |
| 31 #include "modules/webaudio/AsyncAudioDecoder.h" | 31 #include "modules/webaudio/AsyncAudioDecoder.h" |
| 32 #include "modules/webaudio/AudioDestinationNode.h" | 32 #include "modules/webaudio/AudioDestinationNode.h" |
| 33 #include "platform/audio/AudioBus.h" | 33 #include "platform/audio/AudioBus.h" |
| 34 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
| 35 #include "wtf/HashSet.h" | 35 #include "wtf/HashSet.h" |
| 36 #include "wtf/MainThread.h" | 36 #include "wtf/MainThread.h" |
| 37 #include "wtf/OwnPtr.h" | 37 #include "wtf/OwnPtr.h" |
| 38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefCounted.h" | |
| 40 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 41 #include "wtf/ThreadSafeRefCounted.h" | 40 #include "wtf/ThreadSafeRefCounted.h" |
| 42 #include "wtf/Threading.h" | 41 #include "wtf/Threading.h" |
| 43 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
| 44 #include "wtf/text/AtomicStringHash.h" | 43 #include "wtf/text/AtomicStringHash.h" |
| 45 | 44 |
| 46 namespace blink { | 45 namespace blink { |
| 47 | 46 |
| 48 class AnalyserNode; | 47 class AnalyserNode; |
| 49 class AudioBuffer; | 48 class AudioBuffer; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 66 class MediaStreamAudioSourceNode; | 65 class MediaStreamAudioSourceNode; |
| 67 class OscillatorNode; | 66 class OscillatorNode; |
| 68 class PannerNode; | 67 class PannerNode; |
| 69 class PeriodicWave; | 68 class PeriodicWave; |
| 70 class ScriptProcessorNode; | 69 class ScriptProcessorNode; |
| 71 class WaveShaperNode; | 70 class WaveShaperNode; |
| 72 | 71 |
| 73 // AudioContext is the cornerstone of the web audio API and all AudioNodes are c reated from it. | 72 // AudioContext is the cornerstone of the web audio API and all AudioNodes are c reated from it. |
| 74 // For thread safety between the audio thread and the main thread, it has a rend ering graph locking mechanism. | 73 // For thread safety between the audio thread and the main thread, it has a rend ering graph locking mechanism. |
| 75 | 74 |
| 76 class AudioContext : public ThreadSafeRefCountedWillBeThreadSafeRefCountedGarbag eCollected<AudioContext>, public ActiveDOMObject, public EventTargetWithInlineDa ta { | 75 class AudioContext : public ThreadSafeRefCountedGarbageCollected<AudioContext>, public ActiveDOMObject, public EventTargetWithInlineData { |
|
tkent
2014/08/15 07:39:00
should be ThreadSafeRefCountedGarbageCollectedWill
haraken
2014/08/15 08:08:00
Sounds reasonable. However, this change also needs
| |
| 77 DEFINE_EVENT_TARGET_REFCOUNTING(ThreadSafeRefCountedWillBeThreadSafeRefCount edGarbageCollected<AudioContext>); | 76 DEFINE_EVENT_TARGET_REFCOUNTING(ThreadSafeRefCountedGarbageCollected<AudioCo ntext>); |
| 78 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AudioContext); | 77 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AudioContext); |
| 79 public: | 78 public: |
| 80 // Create an AudioContext for rendering to the audio hardware. | 79 // Create an AudioContext for rendering to the audio hardware. |
| 81 static PassRefPtrWillBeRawPtr<AudioContext> create(Document&, ExceptionState &); | 80 static AudioContext* create(Document&, ExceptionState&); |
| 82 | 81 |
| 83 virtual ~AudioContext(); | 82 virtual ~AudioContext(); |
| 84 | 83 |
| 85 virtual void trace(Visitor*) OVERRIDE; | 84 virtual void trace(Visitor*) OVERRIDE; |
| 86 | 85 |
| 87 bool isInitialized() const { return m_isInitialized; } | 86 bool isInitialized() const { return m_isInitialized; } |
| 88 bool isOfflineContext() { return m_isOfflineContext; } | 87 bool isOfflineContext() { return m_isOfflineContext; } |
| 89 | 88 |
| 90 // Document notification | 89 // Document notification |
| 91 virtual void stop() OVERRIDE FINAL; | 90 virtual void stop() OVERRIDE FINAL; |
| 92 virtual bool hasPendingActivity() const OVERRIDE; | 91 virtual bool hasPendingActivity() const OVERRIDE; |
| 93 | 92 |
| 94 AudioDestinationNode* destination() { return m_destinationNode.get(); } | 93 AudioDestinationNode* destination() { return m_destinationNode.get(); } |
| 95 size_t currentSampleFrame() const { return m_destinationNode->currentSampleF rame(); } | 94 size_t currentSampleFrame() const { return m_destinationNode->currentSampleF rame(); } |
| 96 double currentTime() const { return m_destinationNode->currentTime(); } | 95 double currentTime() const { return m_destinationNode->currentTime(); } |
| 97 float sampleRate() const { return m_destinationNode->sampleRate(); } | 96 float sampleRate() const { return m_destinationNode->sampleRate(); } |
| 98 | 97 |
| 99 PassRefPtrWillBeRawPtr<AudioBuffer> createBuffer(unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState&); | 98 AudioBuffer* createBuffer(unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState&); |
| 100 | 99 |
| 101 // Asynchronous audio file data decoding. | 100 // Asynchronous audio file data decoding. |
| 102 void decodeAudioData(ArrayBuffer*, PassOwnPtr<AudioBufferCallback>, PassOwnP tr<AudioBufferCallback>, ExceptionState&); | 101 void decodeAudioData(ArrayBuffer*, PassOwnPtr<AudioBufferCallback>, PassOwnP tr<AudioBufferCallback>, ExceptionState&); |
| 103 | 102 |
| 104 AudioListener* listener() { return m_listener.get(); } | 103 AudioListener* listener() { return m_listener.get(); } |
| 105 | 104 |
| 106 // The AudioNode create methods are called on the main thread (from JavaScri pt). | 105 // The AudioNode create methods are called on the main thread (from JavaScri pt). |
| 107 PassRefPtrWillBeRawPtr<AudioBufferSourceNode> createBufferSource(); | 106 AudioBufferSourceNode* createBufferSource(); |
| 108 PassRefPtrWillBeRawPtr<MediaElementAudioSourceNode> createMediaElementSource (HTMLMediaElement*, ExceptionState&); | 107 MediaElementAudioSourceNode* createMediaElementSource(HTMLMediaElement*, Exc eptionState&); |
| 109 PassRefPtrWillBeRawPtr<MediaStreamAudioSourceNode> createMediaStreamSource(M ediaStream*, ExceptionState&); | 108 MediaStreamAudioSourceNode* createMediaStreamSource(MediaStream*, ExceptionS tate&); |
| 110 PassRefPtrWillBeRawPtr<MediaStreamAudioDestinationNode> createMediaStreamDes tination(); | 109 MediaStreamAudioDestinationNode* createMediaStreamDestination(); |
| 111 PassRefPtrWillBeRawPtr<GainNode> createGain(); | 110 GainNode* createGain(); |
| 112 PassRefPtrWillBeRawPtr<BiquadFilterNode> createBiquadFilter(); | 111 BiquadFilterNode* createBiquadFilter(); |
| 113 PassRefPtrWillBeRawPtr<WaveShaperNode> createWaveShaper(); | 112 WaveShaperNode* createWaveShaper(); |
| 114 PassRefPtrWillBeRawPtr<DelayNode> createDelay(ExceptionState&); | 113 DelayNode* createDelay(ExceptionState&); |
| 115 PassRefPtrWillBeRawPtr<DelayNode> createDelay(double maxDelayTime, Exception State&); | 114 DelayNode* createDelay(double maxDelayTime, ExceptionState&); |
| 116 PassRefPtrWillBeRawPtr<PannerNode> createPanner(); | 115 PannerNode* createPanner(); |
| 117 PassRefPtrWillBeRawPtr<ConvolverNode> createConvolver(); | 116 ConvolverNode* createConvolver(); |
| 118 PassRefPtrWillBeRawPtr<DynamicsCompressorNode> createDynamicsCompressor(); | 117 DynamicsCompressorNode* createDynamicsCompressor(); |
| 119 PassRefPtrWillBeRawPtr<AnalyserNode> createAnalyser(); | 118 AnalyserNode* createAnalyser(); |
| 120 PassRefPtrWillBeRawPtr<ScriptProcessorNode> createScriptProcessor(ExceptionS tate&); | 119 ScriptProcessorNode* createScriptProcessor(ExceptionState&); |
| 121 PassRefPtrWillBeRawPtr<ScriptProcessorNode> createScriptProcessor(size_t buf ferSize, ExceptionState&); | 120 ScriptProcessorNode* createScriptProcessor(size_t bufferSize, ExceptionState &); |
| 122 PassRefPtrWillBeRawPtr<ScriptProcessorNode> createScriptProcessor(size_t buf ferSize, size_t numberOfInputChannels, ExceptionState&); | 121 ScriptProcessorNode* createScriptProcessor(size_t bufferSize, size_t numberO fInputChannels, ExceptionState&); |
| 123 PassRefPtrWillBeRawPtr<ScriptProcessorNode> createScriptProcessor(size_t buf ferSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionS tate&); | 122 ScriptProcessorNode* createScriptProcessor(size_t bufferSize, size_t numberO fInputChannels, size_t numberOfOutputChannels, ExceptionState&); |
| 124 PassRefPtrWillBeRawPtr<ChannelSplitterNode> createChannelSplitter(ExceptionS tate&); | 123 ChannelSplitterNode* createChannelSplitter(ExceptionState&); |
| 125 PassRefPtrWillBeRawPtr<ChannelSplitterNode> createChannelSplitter(size_t num berOfOutputs, ExceptionState&); | 124 ChannelSplitterNode* createChannelSplitter(size_t numberOfOutputs, Exception State&); |
| 126 PassRefPtrWillBeRawPtr<ChannelMergerNode> createChannelMerger(ExceptionState &); | 125 ChannelMergerNode* createChannelMerger(ExceptionState&); |
| 127 PassRefPtrWillBeRawPtr<ChannelMergerNode> createChannelMerger(size_t numberO fInputs, ExceptionState&); | 126 ChannelMergerNode* createChannelMerger(size_t numberOfInputs, ExceptionState &); |
| 128 PassRefPtrWillBeRawPtr<OscillatorNode> createOscillator(); | 127 OscillatorNode* createOscillator(); |
| 129 PassRefPtrWillBeRawPtr<PeriodicWave> createPeriodicWave(Float32Array* real, Float32Array* imag, ExceptionState&); | 128 PeriodicWave* createPeriodicWave(Float32Array* real, Float32Array* imag, Exc eptionState&); |
| 130 | 129 |
| 131 // When a source node has no more processing to do (has finished playing), t hen it tells the context to dereference it. | 130 // When a source node has no more processing to do (has finished playing), t hen it tells the context to dereference it. |
| 132 void notifyNodeFinishedProcessing(AudioNode*); | 131 void notifyNodeFinishedProcessing(AudioNode*); |
| 133 | 132 |
| 134 // Called at the start of each render quantum. | 133 // Called at the start of each render quantum. |
| 135 void handlePreRenderTasks(); | 134 void handlePreRenderTasks(); |
| 136 | 135 |
| 137 // Called at the end of each render quantum. | 136 // Called at the end of each render quantum. |
| 138 void handlePostRenderTasks(); | 137 void handlePostRenderTasks(); |
| 139 | 138 |
| 140 // Called periodically at the end of each render quantum to dereference fini shed source nodes. | 139 // Called periodically at the end of each render quantum to dereference fini shed source nodes. |
| 141 void derefFinishedSourceNodes(); | 140 void derefFinishedSourceNodes(); |
| 142 | 141 |
| 143 #if ENABLE(OILPAN) | |
| 144 void registerLiveAudioSummingJunction(AudioSummingJunction&); | 142 void registerLiveAudioSummingJunction(AudioSummingJunction&); |
| 145 void registerLiveNode(AudioNode&); | 143 void registerLiveNode(AudioNode&); |
| 146 #else | |
| 147 // We schedule deletion of all marked nodes at the end of each realtime rend er quantum. | |
| 148 void markForDeletion(AudioNode*); | |
| 149 void deleteMarkedNodes(); | |
| 150 #endif | |
| 151 | 144 |
| 152 // AudioContext can pull node(s) at the end of each render quantum even when they are not connected to any downstream nodes. | 145 // AudioContext can pull node(s) at the end of each render quantum even when they are not connected to any downstream nodes. |
| 153 // These two methods are called by the nodes who want to add/remove themselv es into/from the automatic pull lists. | 146 // These two methods are called by the nodes who want to add/remove themselv es into/from the automatic pull lists. |
| 154 void addAutomaticPullNode(AudioNode*); | 147 void addAutomaticPullNode(AudioNode*); |
| 155 void removeAutomaticPullNode(AudioNode*); | 148 void removeAutomaticPullNode(AudioNode*); |
| 156 | 149 |
| 157 // Called right before handlePostRenderTasks() to handle nodes which need to be pulled even when they are not connected to anything. | 150 // Called right before handlePostRenderTasks() to handle nodes which need to be pulled even when they are not connected to anything. |
| 158 void processAutomaticPullNodes(size_t framesToProcess); | 151 void processAutomaticPullNodes(size_t framesToProcess); |
| 159 | 152 |
| 160 // Keeps track of the number of connections made. | 153 // Keeps track of the number of connections made. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 ASSERT(context); | 191 ASSERT(context); |
| 199 context->lock(m_mustReleaseLock); | 192 context->lock(m_mustReleaseLock); |
| 200 } | 193 } |
| 201 | 194 |
| 202 ~AutoLocker() | 195 ~AutoLocker() |
| 203 { | 196 { |
| 204 if (m_mustReleaseLock) | 197 if (m_mustReleaseLock) |
| 205 m_context->unlock(); | 198 m_context->unlock(); |
| 206 } | 199 } |
| 207 private: | 200 private: |
| 208 RawPtrWillBeMember<AudioContext> m_context; | 201 Member<AudioContext> m_context; |
| 209 bool m_mustReleaseLock; | 202 bool m_mustReleaseLock; |
| 210 }; | 203 }; |
| 211 | 204 |
| 212 // In AudioNode::breakConnection() and deref(), a tryLock() is used for | 205 // In AudioNode::breakConnection() and deref(), a tryLock() is used for |
| 213 // calling actual processing, but if it fails keep track here. | 206 // calling actual processing, but if it fails keep track here. |
| 214 void addDeferredBreakConnection(AudioNode&); | 207 void addDeferredBreakConnection(AudioNode&); |
| 215 #if !ENABLE(OILPAN) | 208 #if !ENABLE(OILPAN) |
| 216 void addDeferredFinishDeref(AudioNode*); | 209 void addDeferredFinishDeref(AudioNode*); |
| 217 #endif | 210 #endif |
| 218 | 211 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 247 private: | 240 private: |
| 248 void initialize(); | 241 void initialize(); |
| 249 void uninitialize(); | 242 void uninitialize(); |
| 250 | 243 |
| 251 // ExecutionContext calls stop twice. | 244 // ExecutionContext calls stop twice. |
| 252 // We'd like to schedule only one stop action for them. | 245 // We'd like to schedule only one stop action for them. |
| 253 bool m_isStopScheduled; | 246 bool m_isStopScheduled; |
| 254 bool m_isCleared; | 247 bool m_isCleared; |
| 255 void clear(); | 248 void clear(); |
| 256 | 249 |
| 257 #if !ENABLE(OILPAN) | |
| 258 void scheduleNodeDeletion(); | |
| 259 static void deleteMarkedNodesDispatch(void* userData); | |
| 260 #endif | |
| 261 | |
| 262 // Set to true when the destination node has been initialized and is ready t o process data. | 250 // Set to true when the destination node has been initialized and is ready t o process data. |
| 263 bool m_isInitialized; | 251 bool m_isInitialized; |
| 264 | 252 |
| 265 // The context itself keeps a reference to all source nodes. The source nod es, then reference all nodes they're connected to. | 253 // The context itself keeps a reference to all source nodes. The source nod es, then reference all nodes they're connected to. |
| 266 // In turn, these nodes reference all nodes they're connected to. All nodes are ultimately connected to the AudioDestinationNode. | 254 // In turn, these nodes reference all nodes they're connected to. All nodes are ultimately connected to the AudioDestinationNode. |
| 267 // When the context dereferences a source node, it will be deactivated from the rendering graph along with all other nodes it is | 255 // When the context dereferences a source node, it will be deactivated from the rendering graph along with all other nodes it is |
| 268 // uniquely connected to. See the AudioNode::ref() and AudioNode::deref() m ethods for more details. | 256 // uniquely connected to. See the AudioNode::ref() and AudioNode::deref() m ethods for more details. |
| 269 void refNode(AudioNode*); | 257 void refNode(AudioNode*); |
| 270 void derefNode(AudioNode*); | 258 void derefNode(AudioNode*); |
| 271 | 259 |
| 272 // When the context goes away, there might still be some sources which haven 't finished playing. | 260 // When the context goes away, there might still be some sources which haven 't finished playing. |
| 273 // Make sure to dereference them here. | 261 // Make sure to dereference them here. |
| 274 void derefUnfinishedSourceNodes(); | 262 void derefUnfinishedSourceNodes(); |
| 275 | 263 |
| 276 RefPtrWillBeMember<AudioDestinationNode> m_destinationNode; | 264 Member<AudioDestinationNode> m_destinationNode; |
| 277 RefPtrWillBeMember<AudioListener> m_listener; | 265 Member<AudioListener> m_listener; |
| 278 | 266 |
| 279 // Only accessed in the audio thread. | 267 // Only accessed in the audio thread. |
| 280 // Oilpan: Since items are added to the vector by the audio thread (not regi stered to Oilpan), | 268 // Oilpan: Since items are added to the vector by the audio thread (not regi stered to Oilpan), |
| 281 // we cannot use a HeapVector. | 269 // we cannot use a HeapVector. |
| 270 GC_PLUGIN_IGNORE("") | |
| 282 Vector<AudioNode*> m_finishedNodes; | 271 Vector<AudioNode*> m_finishedNodes; |
| 283 | 272 |
| 284 // List of source nodes. This is either accessed when the graph lock is | 273 // List of source nodes. This is either accessed when the graph lock is |
| 285 // held, or on the main thread when the audio thread has finished. | 274 // held, or on the main thread when the audio thread has finished. |
| 286 // This RefPtr is connection reference. We must call AudioNode:: | 275 // This RefPtr is connection reference. We must call AudioNode:: |
|
tkent
2014/08/15 07:39:00
Remove this paragraph.
haraken
2014/08/15 08:08:00
Done.
| |
| 287 // makeConnection() after ref(), and call AudioNode::breakConnection() | 276 // makeConnection() after ref(), and call AudioNode::breakConnection() |
| 288 // before deref(). | 277 // before deref(). |
| 289 // Oilpan: This Vector holds connection references. We must call | 278 // Oilpan: This Vector holds connection references. We must call |
| 290 // AudioNode::makeConnection when we add an AudioNode to this, and must call | 279 // AudioNode::makeConnection when we add an AudioNode to this, and must call |
| 291 // AudioNode::breakConnection() when we remove an AudioNode from this. | 280 // AudioNode::breakConnection() when we remove an AudioNode from this. |
| 292 WillBeHeapVector<RefPtrWillBeMember<AudioNode> > m_referencedNodes; | 281 HeapVector<Member<AudioNode> > m_referencedNodes; |
| 293 | 282 |
| 294 #if ENABLE(OILPAN) | |
| 295 class AudioNodeDisposer { | 283 class AudioNodeDisposer { |
| 296 public: | 284 public: |
| 297 explicit AudioNodeDisposer(AudioNode& node) : m_node(node) { } | 285 explicit AudioNodeDisposer(AudioNode& node) : m_node(node) { } |
| 298 ~AudioNodeDisposer(); | 286 ~AudioNodeDisposer(); |
| 299 | 287 |
| 300 private: | 288 private: |
| 301 AudioNode& m_node; | 289 AudioNode& m_node; |
| 302 }; | 290 }; |
| 303 HeapHashMap<WeakMember<AudioNode>, OwnPtr<AudioNodeDisposer> > m_liveNodes; | 291 HeapHashMap<WeakMember<AudioNode>, OwnPtr<AudioNodeDisposer> > m_liveNodes; |
| 304 | 292 |
| 305 class AudioSummingJunctionDisposer { | 293 class AudioSummingJunctionDisposer { |
| 306 public: | 294 public: |
| 307 explicit AudioSummingJunctionDisposer(AudioSummingJunction& junction) : m_junction(junction) { } | 295 explicit AudioSummingJunctionDisposer(AudioSummingJunction& junction) : m_junction(junction) { } |
| 308 ~AudioSummingJunctionDisposer(); | 296 ~AudioSummingJunctionDisposer(); |
| 309 | 297 |
| 310 private: | 298 private: |
| 311 AudioSummingJunction& m_junction; | 299 AudioSummingJunction& m_junction; |
| 312 }; | 300 }; |
| 313 // The purpose of m_liveAudioSummingJunctions is to remove a dying | 301 // The purpose of m_liveAudioSummingJunctions is to remove a dying |
| 314 // AudioSummingJunction from m_dirtySummingJunctions. However we put all of | 302 // AudioSummingJunction from m_dirtySummingJunctions. However we put all of |
| 315 // AudioSummingJunction objects to m_liveAudioSummingJunctions to avoid | 303 // AudioSummingJunction objects to m_liveAudioSummingJunctions to avoid |
| 316 // concurrent access to m_liveAudioSummingJunctions. | 304 // concurrent access to m_liveAudioSummingJunctions. |
| 317 HeapHashMap<WeakMember<AudioSummingJunction>, OwnPtr<AudioSummingJunctionDis poser> > m_liveAudioSummingJunctions; | 305 HeapHashMap<WeakMember<AudioSummingJunction>, OwnPtr<AudioSummingJunctionDis poser> > m_liveAudioSummingJunctions; |
| 318 #else | |
| 319 // Accumulate nodes which need to be deleted here. | |
| 320 // This is copied to m_nodesToDelete at the end of a render cycle in handleP ostRenderTasks(), where we're assured of a stable graph | |
| 321 // state which will have no references to any of the nodes in m_nodesToDelet e once the context lock is released | |
| 322 // (when handlePostRenderTasks() has completed). | |
| 323 // Oilpan: Since items are added to the vector by the audio thread (not regi stered to Oilpan), | |
| 324 // we cannot use a HeapVector. | |
| 325 Vector<AudioNode*> m_nodesMarkedForDeletion; | |
| 326 | |
| 327 // They will be scheduled for deletion (on the main thread) at the end of a render cycle (in realtime thread). | |
| 328 // Oilpan: Since items are added to the vector by the audio thread (not regi stered to Oilpan), | |
| 329 // we cannot use a HeapVector. | |
| 330 Vector<AudioNode*> m_nodesToDelete; | |
| 331 bool m_isDeletionScheduled; | |
| 332 #endif | |
| 333 | 306 |
| 334 // These two HashSet must be accessed only when the graph lock is held. | 307 // These two HashSet must be accessed only when the graph lock is held. |
| 335 // Oilpan: These HashSet should be HeapHashSet<WeakMember<AudioNodeOutput>> | 308 // Oilpan: These HashSet should be HeapHashSet<WeakMember<AudioNodeOutput>> |
| 336 // ideally. But it's difficult to lock them correctly during GC. | 309 // ideally. But it's difficult to lock them correctly during GC. |
| 337 // Oilpan: Since items are added to these hash sets by the audio thread (not registered to Oilpan), | 310 // Oilpan: Since items are added to these hash sets by the audio thread (not registered to Oilpan), |
| 338 // we cannot use HeapHashSets. | 311 // we cannot use HeapHashSets. |
| 312 GC_PLUGIN_IGNORE("") | |
| 339 HashSet<AudioSummingJunction*> m_dirtySummingJunctions; | 313 HashSet<AudioSummingJunction*> m_dirtySummingJunctions; |
| 314 GC_PLUGIN_IGNORE("") | |
| 340 HashSet<AudioNodeOutput*> m_dirtyAudioNodeOutputs; | 315 HashSet<AudioNodeOutput*> m_dirtyAudioNodeOutputs; |
| 341 void handleDirtyAudioSummingJunctions(); | 316 void handleDirtyAudioSummingJunctions(); |
| 342 void handleDirtyAudioNodeOutputs(); | 317 void handleDirtyAudioNodeOutputs(); |
| 343 | 318 |
| 344 // For the sake of thread safety, we maintain a seperate Vector of automatic pull nodes for rendering in m_renderingAutomaticPullNodes. | 319 // For the sake of thread safety, we maintain a seperate Vector of automatic pull nodes for rendering in m_renderingAutomaticPullNodes. |
| 345 // It will be copied from m_automaticPullNodes by updateAutomaticPullNodes() at the very start or end of the rendering quantum. | 320 // It will be copied from m_automaticPullNodes by updateAutomaticPullNodes() at the very start or end of the rendering quantum. |
| 346 // Oilpan: Since items are added to the vector/hash set by the audio thread (not registered to Oilpan), | 321 // Oilpan: Since items are added to the vector/hash set by the audio thread (not registered to Oilpan), |
| 347 // we cannot use a HeapVector/HeapHashSet. | 322 // we cannot use a HeapVector/HeapHashSet. |
| 323 GC_PLUGIN_IGNORE("") | |
| 348 HashSet<AudioNode*> m_automaticPullNodes; | 324 HashSet<AudioNode*> m_automaticPullNodes; |
| 325 GC_PLUGIN_IGNORE("") | |
| 349 Vector<AudioNode*> m_renderingAutomaticPullNodes; | 326 Vector<AudioNode*> m_renderingAutomaticPullNodes; |
| 350 // m_automaticPullNodesNeedUpdating keeps track if m_automaticPullNodes is m odified. | 327 // m_automaticPullNodesNeedUpdating keeps track if m_automaticPullNodes is m odified. |
| 351 bool m_automaticPullNodesNeedUpdating; | 328 bool m_automaticPullNodesNeedUpdating; |
| 352 void updateAutomaticPullNodes(); | 329 void updateAutomaticPullNodes(); |
| 353 | 330 |
| 354 unsigned m_connectionCount; | 331 unsigned m_connectionCount; |
| 355 | 332 |
| 356 // Graph locking. | 333 // Graph locking. |
| 357 Mutex m_contextGraphMutex; | 334 Mutex m_contextGraphMutex; |
| 358 volatile ThreadIdentifier m_audioThread; | 335 volatile ThreadIdentifier m_audioThread; |
| 359 volatile ThreadIdentifier m_graphOwnerThread; // if the lock is held then th is is the thread which owns it, otherwise == UndefinedThreadIdentifier | 336 volatile ThreadIdentifier m_graphOwnerThread; // if the lock is held then th is is the thread which owns it, otherwise == UndefinedThreadIdentifier |
| 360 | 337 |
| 361 // Only accessed in the audio thread. | 338 // Only accessed in the audio thread. |
| 362 // Oilpan: Since items are added to these vectors by the audio thread (not r egistered to Oilpan), | 339 // Oilpan: Since items are added to these vectors by the audio thread (not r egistered to Oilpan), |
| 363 // we cannot use HeapVectors. | 340 // we cannot use HeapVectors. |
| 341 GC_PLUGIN_IGNORE("") | |
| 364 Vector<AudioNode*> m_deferredBreakConnectionList; | 342 Vector<AudioNode*> m_deferredBreakConnectionList; |
| 343 GC_PLUGIN_IGNORE("") | |
| 365 Vector<AudioNode*> m_deferredFinishDerefList; | 344 Vector<AudioNode*> m_deferredFinishDerefList; |
| 366 | 345 |
| 367 RefPtrWillBeMember<AudioBuffer> m_renderTarget; | 346 Member<AudioBuffer> m_renderTarget; |
| 368 | 347 |
| 369 bool m_isOfflineContext; | 348 bool m_isOfflineContext; |
| 370 | 349 |
| 371 AsyncAudioDecoder m_audioDecoder; | 350 AsyncAudioDecoder m_audioDecoder; |
| 372 | 351 |
| 373 // This is considering 32 is large enough for multiple channels audio. | 352 // This is considering 32 is large enough for multiple channels audio. |
| 374 // It is somewhat arbitrary and could be increased if necessary. | 353 // It is somewhat arbitrary and could be increased if necessary. |
| 375 enum { MaxNumberOfChannels = 32 }; | 354 enum { MaxNumberOfChannels = 32 }; |
| 376 }; | 355 }; |
| 377 | 356 |
| 378 } // namespace blink | 357 } // namespace blink |
| 379 | 358 |
| 380 #endif // AudioContext_h | 359 #endif // AudioContext_h |
| OLD | NEW |