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

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

Issue 2389253002: reflow comments in modules/{webaudio,vr} (Closed)
Patch Set: . Created 4 years, 2 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 29 matching lines...) Expand all
40 namespace blink { 40 namespace blink {
41 41
42 class BaseAudioContext; 42 class BaseAudioContext;
43 class OfflineAudioContext; 43 class OfflineAudioContext;
44 class AudioHandler; 44 class AudioHandler;
45 class AudioNodeOutput; 45 class AudioNodeOutput;
46 class AudioSummingJunction; 46 class AudioSummingJunction;
47 47
48 // DeferredTaskHandler manages the major part of pre- and post- rendering tasks, 48 // DeferredTaskHandler manages the major part of pre- and post- rendering tasks,
49 // and provides a lock mechanism against the audio rendering graph. A 49 // and provides a lock mechanism against the audio rendering graph. A
50 // DeferredTaskHandler object is created when an BaseAudioContext object is crea ted. 50 // DeferredTaskHandler object is created when an BaseAudioContext object is
51 // created.
51 // 52 //
52 // DeferredTaskHandler outlives the BaseAudioContext only if all of the followin g 53 // DeferredTaskHandler outlives the BaseAudioContext only if all of the
53 // conditions match: 54 // following conditions match:
54 // - An audio rendering thread is running, 55 // - An audio rendering thread is running,
55 // - It is requested to stop, 56 // - It is requested to stop,
56 // - The audio rendering thread calls requestToDeleteHandlersOnMainThread(), 57 // - The audio rendering thread calls requestToDeleteHandlersOnMainThread(),
57 // - It posts a task of deleteHandlersOnMainThread(), and 58 // - It posts a task of deleteHandlersOnMainThread(), and
58 // - GC happens and it collects the BaseAudioContext before the task execution. 59 // - GC happens and it collects the BaseAudioContext before the task execution.
59 // 60 //
60 class MODULES_EXPORT DeferredTaskHandler final 61 class MODULES_EXPORT DeferredTaskHandler final
61 : public ThreadSafeRefCounted<DeferredTaskHandler> { 62 : public ThreadSafeRefCounted<DeferredTaskHandler> {
62 public: 63 public:
63 static PassRefPtr<DeferredTaskHandler> create(); 64 static PassRefPtr<DeferredTaskHandler> create();
64 ~DeferredTaskHandler(); 65 ~DeferredTaskHandler();
65 66
66 void handleDeferredTasks(); 67 void handleDeferredTasks();
67 void contextWillBeDestroyed(); 68 void contextWillBeDestroyed();
68 69
69 // BaseAudioContext can pull node(s) at the end of each render quantum even wh en 70 // BaseAudioContext can pull node(s) at the end of each render quantum even
70 // they are not connected to any downstream nodes. These two methods are 71 // when they are not connected to any downstream nodes. These two methods are
71 // called by the nodes who want to add/remove themselves into/from the 72 // called by the nodes who want to add/remove themselves into/from the
72 // automatic pull lists. 73 // automatic pull lists.
73 void addAutomaticPullNode(AudioHandler*); 74 void addAutomaticPullNode(AudioHandler*);
74 void removeAutomaticPullNode(AudioHandler*); 75 void removeAutomaticPullNode(AudioHandler*);
75 // Called right before handlePostRenderTasks() to handle nodes which need to 76 // Called right before handlePostRenderTasks() to handle nodes which need to
76 // be pulled even when they are not connected to anything. 77 // be pulled even when they are not connected to anything.
77 void processAutomaticPullNodes(size_t framesToProcess); 78 void processAutomaticPullNodes(size_t framesToProcess);
78 79
79 // Keep track of AudioNode's that have their channel count mode changed. We 80 // Keep track of AudioNode's that have their channel count mode changed. We
80 // process the changes in the post rendering phase. 81 // process the changes in the post rendering phase.
81 void addChangedChannelCountMode(AudioHandler*); 82 void addChangedChannelCountMode(AudioHandler*);
82 void removeChangedChannelCountMode(AudioHandler*); 83 void removeChangedChannelCountMode(AudioHandler*);
83 84
84 // Keep track of AudioNode's that have their channel interpretation 85 // Keep track of AudioNode's that have their channel interpretation
85 // changed. We process the changes in the post rendering phase. 86 // changed. We process the changes in the post rendering phase.
86 void addChangedChannelInterpretation(AudioHandler*); 87 void addChangedChannelInterpretation(AudioHandler*);
87 void removeChangedChannelInterpretation(AudioHandler*); 88 void removeChangedChannelInterpretation(AudioHandler*);
88 89
89 // Only accessed when the graph lock is held. 90 // Only accessed when the graph lock is held.
90 void markSummingJunctionDirty(AudioSummingJunction*); 91 void markSummingJunctionDirty(AudioSummingJunction*);
91 // Only accessed when the graph lock is held. Must be called on the main threa d. 92 // Only accessed when the graph lock is held. Must be called on the main
93 // thread.
92 void removeMarkedSummingJunction(AudioSummingJunction*); 94 void removeMarkedSummingJunction(AudioSummingJunction*);
93 95
94 void markAudioNodeOutputDirty(AudioNodeOutput*); 96 void markAudioNodeOutputDirty(AudioNodeOutput*);
95 void removeMarkedAudioNodeOutput(AudioNodeOutput*); 97 void removeMarkedAudioNodeOutput(AudioNodeOutput*);
96 98
97 // In AudioNode::breakConnection() and deref(), a tryLock() is used for 99 // In AudioNode::breakConnection() and deref(), a tryLock() is used for
98 // calling actual processing, but if it fails keep track here. 100 // calling actual processing, but if it fails keep track here.
99 void addDeferredBreakConnection(AudioHandler&); 101 void addDeferredBreakConnection(AudioHandler&);
100 void breakConnections(); 102 void breakConnections();
101 103
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 void handleDirtyAudioSummingJunctions(); 172 void handleDirtyAudioSummingJunctions();
171 void handleDirtyAudioNodeOutputs(); 173 void handleDirtyAudioNodeOutputs();
172 void deleteHandlersOnMainThread(); 174 void deleteHandlersOnMainThread();
173 175
174 // For the sake of thread safety, we maintain a seperate Vector of automatic 176 // For the sake of thread safety, we maintain a seperate Vector of automatic
175 // pull nodes for rendering in m_renderingAutomaticPullNodes. It will be 177 // pull nodes for rendering in m_renderingAutomaticPullNodes. It will be
176 // copied from m_automaticPullNodes by updateAutomaticPullNodes() at the 178 // copied from m_automaticPullNodes by updateAutomaticPullNodes() at the
177 // very start or end of the rendering quantum. 179 // very start or end of the rendering quantum.
178 HashSet<AudioHandler*> m_automaticPullNodes; 180 HashSet<AudioHandler*> m_automaticPullNodes;
179 Vector<AudioHandler*> m_renderingAutomaticPullNodes; 181 Vector<AudioHandler*> m_renderingAutomaticPullNodes;
180 // m_automaticPullNodesNeedUpdating keeps track if m_automaticPullNodes is mod ified. 182 // m_automaticPullNodesNeedUpdating keeps track if m_automaticPullNodes is
183 // modified.
181 bool m_automaticPullNodesNeedUpdating; 184 bool m_automaticPullNodesNeedUpdating;
182 185
183 // Collection of nodes where the channel count mode has changed. We want the 186 // Collection of nodes where the channel count mode has changed. We want the
184 // channel count mode to change in the pre- or post-rendering phase so as 187 // channel count mode to change in the pre- or post-rendering phase so as
185 // not to disturb the running audio thread. 188 // not to disturb the running audio thread.
186 HashSet<AudioHandler*> m_deferredCountModeChange; 189 HashSet<AudioHandler*> m_deferredCountModeChange;
187 190
188 HashSet<AudioHandler*> m_deferredChannelInterpretationChange; 191 HashSet<AudioHandler*> m_deferredChannelInterpretationChange;
189 192
190 // These two HashSet must be accessed only when the graph lock is held. 193 // These two HashSet must be accessed only when the graph lock is held.
191 // These raw pointers are safe because their destructors unregister them. 194 // These raw pointers are safe because their destructors unregister them.
192 HashSet<AudioSummingJunction*> m_dirtySummingJunctions; 195 HashSet<AudioSummingJunction*> m_dirtySummingJunctions;
193 HashSet<AudioNodeOutput*> m_dirtyAudioNodeOutputs; 196 HashSet<AudioNodeOutput*> m_dirtyAudioNodeOutputs;
194 197
195 // Only accessed in the audio thread. 198 // Only accessed in the audio thread.
196 Vector<AudioHandler*> m_deferredBreakConnectionList; 199 Vector<AudioHandler*> m_deferredBreakConnectionList;
197 200
198 Vector<RefPtr<AudioHandler>> m_renderingOrphanHandlers; 201 Vector<RefPtr<AudioHandler>> m_renderingOrphanHandlers;
199 Vector<RefPtr<AudioHandler>> m_deletableOrphanHandlers; 202 Vector<RefPtr<AudioHandler>> m_deletableOrphanHandlers;
200 203
201 // Graph locking. 204 // Graph locking.
202 RecursiveMutex m_contextGraphMutex; 205 RecursiveMutex m_contextGraphMutex;
203 volatile ThreadIdentifier m_audioThread; 206 volatile ThreadIdentifier m_audioThread;
204 }; 207 };
205 208
206 } // namespace blink 209 } // namespace blink
207 210
208 #endif // DeferredTaskHandler_h 211 #endif // DeferredTaskHandler_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698