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

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

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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 } 163 }
164 164
165 void DeferredTaskHandler::ProcessAutomaticPullNodes(size_t frames_to_process) { 165 void DeferredTaskHandler::ProcessAutomaticPullNodes(size_t frames_to_process) {
166 DCHECK(IsAudioThread()); 166 DCHECK(IsAudioThread());
167 167
168 for (unsigned i = 0; i < rendering_automatic_pull_nodes_.size(); ++i) 168 for (unsigned i = 0; i < rendering_automatic_pull_nodes_.size(); ++i)
169 rendering_automatic_pull_nodes_[i]->ProcessIfNecessary(frames_to_process); 169 rendering_automatic_pull_nodes_[i]->ProcessIfNecessary(frames_to_process);
170 } 170 }
171 171
172 void DeferredTaskHandler::AddTailProcessingNode(PassRefPtr<AudioHandler> node) {
173 DCHECK(IsGraphOwner());
174
175 if (!tail_processing_nodes_.Contains(node)) {
176 #if DEBUG_AUDIONODE_REFERENCES > 1
177 node->AddTailProcessingDebug();
178 #endif
179 tail_processing_nodes_.push_back(std::move(node));
180 }
181 }
182
183 void DeferredTaskHandler::RemoveTailProcessingNode(
184 PassRefPtr<AudioHandler> node) {
185 DCHECK(IsGraphOwner());
186
187 size_t index = tail_processing_nodes_.Find(node);
188 if (index != kNotFound) {
189 #if DEBUG_AUDIONODE_REFERENCES > 1
190 node->RemoveTailProcessingDebug();
191 #endif
192 node->ReallyDisableOutputs();
193 tail_processing_nodes_.erase(index);
194 }
195 }
196
197 void DeferredTaskHandler::UpdateTailProcessingNodes() {
198 DCHECK(IsAudioThread());
199
200 for (unsigned k = tail_processing_nodes_.size(); k > 0; --k) {
201 RefPtr<AudioHandler> node = tail_processing_nodes_[k - 1];
202 if (node->PropagatesSilence()) {
203 #if DEBUG_AUDIONODE_REFERENCES
204 fprintf(stderr, "[%16p]: %16p: %2d: updateTail @%.15g\n", node->Context(),
205 node.Get(), node->GetNodeType(), node->Context()->currentTime());
206 #endif
207 RemoveTailProcessingNode(node);
208 }
209 }
210 }
211
172 void DeferredTaskHandler::AddChangedChannelCountMode(AudioHandler* node) { 212 void DeferredTaskHandler::AddChangedChannelCountMode(AudioHandler* node) {
173 DCHECK(IsGraphOwner()); 213 DCHECK(IsGraphOwner());
174 DCHECK(IsMainThread()); 214 DCHECK(IsMainThread());
175 deferred_count_mode_change_.insert(node); 215 deferred_count_mode_change_.insert(node);
176 } 216 }
177 217
178 void DeferredTaskHandler::RemoveChangedChannelCountMode(AudioHandler* node) { 218 void DeferredTaskHandler::RemoveChangedChannelCountMode(AudioHandler* node) {
179 DCHECK(IsGraphOwner()); 219 DCHECK(IsGraphOwner());
180 220
181 deferred_count_mode_change_.erase(node); 221 deferred_count_mode_change_.erase(node);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 rendering_automatic_pull_nodes_.resize(automatic_pull_nodes_.size()); 263 rendering_automatic_pull_nodes_.resize(automatic_pull_nodes_.size());
224 DCHECK(!rendering_automatic_pull_nodes_.size()); 264 DCHECK(!rendering_automatic_pull_nodes_.size());
225 } 265 }
226 266
227 void DeferredTaskHandler::HandleDeferredTasks() { 267 void DeferredTaskHandler::HandleDeferredTasks() {
228 UpdateChangedChannelCountMode(); 268 UpdateChangedChannelCountMode();
229 UpdateChangedChannelInterpretation(); 269 UpdateChangedChannelInterpretation();
230 HandleDirtyAudioSummingJunctions(); 270 HandleDirtyAudioSummingJunctions();
231 HandleDirtyAudioNodeOutputs(); 271 HandleDirtyAudioNodeOutputs();
232 UpdateAutomaticPullNodes(); 272 UpdateAutomaticPullNodes();
273 UpdateTailProcessingNodes();
233 } 274 }
234 275
235 void DeferredTaskHandler::ContextWillBeDestroyed() { 276 void DeferredTaskHandler::ContextWillBeDestroyed() {
236 for (auto& handler : rendering_orphan_handlers_) 277 for (auto& handler : rendering_orphan_handlers_)
237 handler->ClearContext(); 278 handler->ClearContext();
238 for (auto& handler : deletable_orphan_handlers_) 279 for (auto& handler : deletable_orphan_handlers_)
239 handler->ClearContext(); 280 handler->ClearContext();
240 ClearHandlersToBeDeleted(); 281 ClearHandlersToBeDeleted();
241 // Some handlers might live because of their cross thread tasks. 282 // Some handlers might live because of their cross thread tasks.
242 } 283 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 deletable_orphan_handlers_.clear(); 326 deletable_orphan_handlers_.clear();
286 } 327 }
287 328
288 void DeferredTaskHandler::SetAudioThreadToCurrentThread() { 329 void DeferredTaskHandler::SetAudioThreadToCurrentThread() {
289 DCHECK(!IsMainThread()); 330 DCHECK(!IsMainThread());
290 ThreadIdentifier thread = CurrentThread(); 331 ThreadIdentifier thread = CurrentThread();
291 ReleaseStore(&audio_thread_, thread); 332 ReleaseStore(&audio_thread_, thread);
292 } 333 }
293 334
294 } // namespace blink 335 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698