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

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

Issue 2839063003: Implement tail processing for AudioNodes (Closed)
Patch Set: Make declaration order consistent Created 3 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 // In AudioNode::breakConnection() and deref(), a tryLock() is used for 99 // In AudioNode::breakConnection() and deref(), a tryLock() is used for
100 // calling actual processing, but if it fails keep track here. 100 // calling actual processing, but if it fails keep track here.
101 void AddDeferredBreakConnection(AudioHandler&); 101 void AddDeferredBreakConnection(AudioHandler&);
102 void BreakConnections(); 102 void BreakConnections();
103 103
104 void AddRenderingOrphanHandler(PassRefPtr<AudioHandler>); 104 void AddRenderingOrphanHandler(PassRefPtr<AudioHandler>);
105 void RequestToDeleteHandlersOnMainThread(); 105 void RequestToDeleteHandlersOnMainThread();
106 void ClearHandlersToBeDeleted(); 106 void ClearHandlersToBeDeleted();
107 107
108 // If |node| requires tail processing, add it to the list of tail
109 // nodes so the tail is processed.
110 void AddTailProcessingNode(PassRefPtr<AudioHandler> node);
111
112 // Remove |node| from the list of tail nodes (because the tail
113 // processing is complete).
114 void RemoveTailProcessingNode(PassRefPtr<AudioHandler> node);
115
108 // 116 //
109 // Thread Safety and Graph Locking: 117 // Thread Safety and Graph Locking:
110 // 118 //
111 void SetAudioThreadToCurrentThread(); 119 void SetAudioThreadToCurrentThread();
112 ThreadIdentifier AudioThread() const { return AcquireLoad(&audio_thread_); } 120 ThreadIdentifier AudioThread() const { return AcquireLoad(&audio_thread_); }
113 121
114 // TODO(hongchan): Use no-barrier load here. (crbug.com/247328) 122 // TODO(hongchan): Use no-barrier load here. (crbug.com/247328)
115 // 123 //
116 // It is okay to use a relaxed (no-barrier) load here. Because the data 124 // It is okay to use a relaxed (no-barrier) load here. Because the data
117 // referenced by m_audioThread is not actually being used, thus we do not 125 // referenced by m_audioThread is not actually being used, thus we do not
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 172
165 private: 173 private:
166 DeferredTaskHandler(); 174 DeferredTaskHandler();
167 void UpdateAutomaticPullNodes(); 175 void UpdateAutomaticPullNodes();
168 void UpdateChangedChannelCountMode(); 176 void UpdateChangedChannelCountMode();
169 void UpdateChangedChannelInterpretation(); 177 void UpdateChangedChannelInterpretation();
170 void HandleDirtyAudioSummingJunctions(); 178 void HandleDirtyAudioSummingJunctions();
171 void HandleDirtyAudioNodeOutputs(); 179 void HandleDirtyAudioNodeOutputs();
172 void DeleteHandlersOnMainThread(); 180 void DeleteHandlersOnMainThread();
173 181
182 // Check tail processing nodes and remove any node if the tail has
183 // been processed.
184 void UpdateTailProcessingNodes();
185
174 // For the sake of thread safety, we maintain a seperate Vector of automatic 186 // For the sake of thread safety, we maintain a seperate Vector of automatic
175 // pull nodes for rendering in m_renderingAutomaticPullNodes. It will be 187 // pull nodes for rendering in m_renderingAutomaticPullNodes. It will be
176 // copied from m_automaticPullNodes by updateAutomaticPullNodes() at the 188 // copied from m_automaticPullNodes by updateAutomaticPullNodes() at the
177 // very start or end of the rendering quantum. 189 // very start or end of the rendering quantum.
178 HashSet<AudioHandler*> automatic_pull_nodes_; 190 HashSet<AudioHandler*> automatic_pull_nodes_;
179 Vector<AudioHandler*> rendering_automatic_pull_nodes_; 191 Vector<AudioHandler*> rendering_automatic_pull_nodes_;
180 // m_automaticPullNodesNeedUpdating keeps track if m_automaticPullNodes is 192 // m_automaticPullNodesNeedUpdating keeps track if m_automaticPullNodes is
181 // modified. 193 // modified.
182 bool automatic_pull_nodes_need_updating_; 194 bool automatic_pull_nodes_need_updating_;
183 195
184 // Collection of nodes where the channel count mode has changed. We want the 196 // Collection of nodes where the channel count mode has changed. We want the
185 // channel count mode to change in the pre- or post-rendering phase so as 197 // channel count mode to change in the pre- or post-rendering phase so as
186 // not to disturb the running audio thread. 198 // not to disturb the running audio thread.
187 HashSet<AudioHandler*> deferred_count_mode_change_; 199 HashSet<AudioHandler*> deferred_count_mode_change_;
188 200
189 HashSet<AudioHandler*> deferred_channel_interpretation_change_; 201 HashSet<AudioHandler*> deferred_channel_interpretation_change_;
190 202
191 // These two HashSet must be accessed only when the graph lock is held. 203 // These two HashSet must be accessed only when the graph lock is held.
192 // These raw pointers are safe because their destructors unregister them. 204 // These raw pointers are safe because their destructors unregister them.
193 HashSet<AudioSummingJunction*> dirty_summing_junctions_; 205 HashSet<AudioSummingJunction*> dirty_summing_junctions_;
194 HashSet<AudioNodeOutput*> dirty_audio_node_outputs_; 206 HashSet<AudioNodeOutput*> dirty_audio_node_outputs_;
195 207
196 // Only accessed in the audio thread. 208 // Only accessed in the audio thread.
197 Vector<AudioHandler*> deferred_break_connection_list_; 209 Vector<AudioHandler*> deferred_break_connection_list_;
198 210
199 Vector<RefPtr<AudioHandler>> rendering_orphan_handlers_; 211 Vector<RefPtr<AudioHandler>> rendering_orphan_handlers_;
200 Vector<RefPtr<AudioHandler>> deletable_orphan_handlers_; 212 Vector<RefPtr<AudioHandler>> deletable_orphan_handlers_;
201 213
214 // Nodes that are processing its tail.
215 Vector<RefPtr<AudioHandler>> tail_processing_nodes_;
216
202 // Graph locking. 217 // Graph locking.
203 RecursiveMutex context_graph_mutex_; 218 RecursiveMutex context_graph_mutex_;
204 volatile ThreadIdentifier audio_thread_; 219 volatile ThreadIdentifier audio_thread_;
205 }; 220 };
206 221
207 } // namespace blink 222 } // namespace blink
208 223
209 #endif // DeferredTaskHandler_h 224 #endif // DeferredTaskHandler_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698