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

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

Issue 2014343002: Defer changes to channelInterpretation to pre/post rendering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 void removeAutomaticPullNode(AudioHandler*); 72 void removeAutomaticPullNode(AudioHandler*);
73 // Called right before handlePostRenderTasks() to handle nodes which need to 73 // Called right before handlePostRenderTasks() to handle nodes which need to
74 // be pulled even when they are not connected to anything. 74 // be pulled even when they are not connected to anything.
75 void processAutomaticPullNodes(size_t framesToProcess); 75 void processAutomaticPullNodes(size_t framesToProcess);
76 76
77 // Keep track of AudioNode's that have their channel count mode changed. We 77 // Keep track of AudioNode's that have their channel count mode changed. We
78 // process the changes in the post rendering phase. 78 // process the changes in the post rendering phase.
79 void addChangedChannelCountMode(AudioHandler*); 79 void addChangedChannelCountMode(AudioHandler*);
80 void removeChangedChannelCountMode(AudioHandler*); 80 void removeChangedChannelCountMode(AudioHandler*);
81 81
82 // Keep track of AudioNode's that have their channel interpretation
83 // changed. We process the changes in the post rendering phase.
84 void addChangedChannelInterpretation(AudioHandler*);
85 void removeChangedChannelInterpretation(AudioHandler*);
86
82 // Only accessed when the graph lock is held. 87 // Only accessed when the graph lock is held.
83 void markSummingJunctionDirty(AudioSummingJunction*); 88 void markSummingJunctionDirty(AudioSummingJunction*);
84 // Only accessed when the graph lock is held. Must be called on the main thr ead. 89 // Only accessed when the graph lock is held. Must be called on the main thr ead.
85 void removeMarkedSummingJunction(AudioSummingJunction*); 90 void removeMarkedSummingJunction(AudioSummingJunction*);
86 91
87 void markAudioNodeOutputDirty(AudioNodeOutput*); 92 void markAudioNodeOutputDirty(AudioNodeOutput*);
88 void removeMarkedAudioNodeOutput(AudioNodeOutput*); 93 void removeMarkedAudioNodeOutput(AudioNodeOutput*);
89 94
90 // In AudioNode::breakConnection() and deref(), a tryLock() is used for 95 // In AudioNode::breakConnection() and deref(), a tryLock() is used for
91 // calling actual processing, but if it fails keep track here. 96 // calling actual processing, but if it fails keep track here.
(...skipping 18 matching lines...) Expand all
110 bool isAudioThread() const { return currentThread() == acquireLoad(&m_audioT hread); } 115 bool isAudioThread() const { return currentThread() == acquireLoad(&m_audioT hread); }
111 116
112 void lock(); 117 void lock();
113 bool tryLock(); 118 bool tryLock();
114 void unlock(); 119 void unlock();
115 120
116 // This locks the audio render thread for OfflineAudioContext rendering. 121 // This locks the audio render thread for OfflineAudioContext rendering.
117 // MUST NOT be used in the real-time audio context. 122 // MUST NOT be used in the real-time audio context.
118 void offlineLock(); 123 void offlineLock();
119 124
120 #if ENABLE(ASSERT)
Nico 2016/05/27 13:09:33 You removed this here but not in the cc file. So n
121 // Returns true if this thread owns the context's lock. 125 // Returns true if this thread owns the context's lock.
122 bool isGraphOwner(); 126 bool isGraphOwner();
123 #endif
124 127
125 class MODULES_EXPORT AutoLocker { 128 class MODULES_EXPORT AutoLocker {
126 STACK_ALLOCATED(); 129 STACK_ALLOCATED();
127 public: 130 public:
128 explicit AutoLocker(DeferredTaskHandler& handler) 131 explicit AutoLocker(DeferredTaskHandler& handler)
129 : m_handler(handler) 132 : m_handler(handler)
130 { 133 {
131 m_handler.lock(); 134 m_handler.lock();
132 } 135 }
133 explicit AutoLocker(AbstractAudioContext*); 136 explicit AutoLocker(AbstractAudioContext*);
(...skipping 16 matching lines...) Expand all
150 ~OfflineGraphAutoLocker() { m_handler.unlock(); } 153 ~OfflineGraphAutoLocker() { m_handler.unlock(); }
151 154
152 private: 155 private:
153 DeferredTaskHandler& m_handler; 156 DeferredTaskHandler& m_handler;
154 }; 157 };
155 158
156 private: 159 private:
157 DeferredTaskHandler(); 160 DeferredTaskHandler();
158 void updateAutomaticPullNodes(); 161 void updateAutomaticPullNodes();
159 void updateChangedChannelCountMode(); 162 void updateChangedChannelCountMode();
163 void updateChangedChannelInterpretation();
160 void handleDirtyAudioSummingJunctions(); 164 void handleDirtyAudioSummingJunctions();
161 void handleDirtyAudioNodeOutputs(); 165 void handleDirtyAudioNodeOutputs();
162 void deleteHandlersOnMainThread(); 166 void deleteHandlersOnMainThread();
163 167
164 // For the sake of thread safety, we maintain a seperate Vector of automatic 168 // For the sake of thread safety, we maintain a seperate Vector of automatic
165 // pull nodes for rendering in m_renderingAutomaticPullNodes. It will be 169 // pull nodes for rendering in m_renderingAutomaticPullNodes. It will be
166 // copied from m_automaticPullNodes by updateAutomaticPullNodes() at the 170 // copied from m_automaticPullNodes by updateAutomaticPullNodes() at the
167 // very start or end of the rendering quantum. 171 // very start or end of the rendering quantum.
168 HashSet<AudioHandler*> m_automaticPullNodes; 172 HashSet<AudioHandler*> m_automaticPullNodes;
169 Vector<AudioHandler*> m_renderingAutomaticPullNodes; 173 Vector<AudioHandler*> m_renderingAutomaticPullNodes;
170 // m_automaticPullNodesNeedUpdating keeps track if m_automaticPullNodes is m odified. 174 // m_automaticPullNodesNeedUpdating keeps track if m_automaticPullNodes is m odified.
171 bool m_automaticPullNodesNeedUpdating; 175 bool m_automaticPullNodesNeedUpdating;
172 176
173 // Collection of nodes where the channel count mode has changed. We want the 177 // Collection of nodes where the channel count mode has changed. We want the
174 // channel count mode to change in the pre- or post-rendering phase so as 178 // channel count mode to change in the pre- or post-rendering phase so as
175 // not to disturb the running audio thread. 179 // not to disturb the running audio thread.
176 HashSet<AudioHandler*> m_deferredCountModeChange; 180 HashSet<AudioHandler*> m_deferredCountModeChange;
177 181
182 HashSet<AudioHandler*> m_deferredChannelInterpretationChange;
183
178 // These two HashSet must be accessed only when the graph lock is held. 184 // These two HashSet must be accessed only when the graph lock is held.
179 // These raw pointers are safe because their destructors unregister them. 185 // These raw pointers are safe because their destructors unregister them.
180 HashSet<AudioSummingJunction*> m_dirtySummingJunctions; 186 HashSet<AudioSummingJunction*> m_dirtySummingJunctions;
181 HashSet<AudioNodeOutput*> m_dirtyAudioNodeOutputs; 187 HashSet<AudioNodeOutput*> m_dirtyAudioNodeOutputs;
182 188
183 // Only accessed in the audio thread. 189 // Only accessed in the audio thread.
184 Vector<AudioHandler*> m_deferredBreakConnectionList; 190 Vector<AudioHandler*> m_deferredBreakConnectionList;
185 191
186 Vector<RefPtr<AudioHandler>> m_renderingOrphanHandlers; 192 Vector<RefPtr<AudioHandler>> m_renderingOrphanHandlers;
187 Vector<RefPtr<AudioHandler>> m_deletableOrphanHandlers; 193 Vector<RefPtr<AudioHandler>> m_deletableOrphanHandlers;
188 194
189 // Graph locking. 195 // Graph locking.
190 RecursiveMutex m_contextGraphMutex; 196 RecursiveMutex m_contextGraphMutex;
191 volatile ThreadIdentifier m_audioThread; 197 volatile ThreadIdentifier m_audioThread;
192 }; 198 };
193 199
194 } // namespace blink 200 } // namespace blink
195 201
196 #endif // DeferredTaskHandler_h 202 #endif // DeferredTaskHandler_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698