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

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

Issue 2959663002: Repost offline rendering task if GC prevents. (Closed)
Patch Set: do want to try-lock 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 unsigned number_of_channels; 176 unsigned number_of_channels;
177 Vector<float*> destinations; 177 Vector<float*> destinations;
178 { 178 {
179 // Main thread GCs cannot happen while we're reading out channel 179 // Main thread GCs cannot happen while we're reading out channel
180 // data. Detect that condition by trying to take the cross-thread 180 // data. Detect that condition by trying to take the cross-thread
181 // persistent lock which is held while a GC runs. If the lock is 181 // persistent lock which is held while a GC runs. If the lock is
182 // already held, simply delay rendering until the next quantum. 182 // already held, simply delay rendering until the next quantum.
183 CrossThreadPersistentRegion::LockScope gc_lock( 183 CrossThreadPersistentRegion::LockScope gc_lock(
184 ProcessHeap::GetCrossThreadPersistentRegion(), true); 184 ProcessHeap::GetCrossThreadPersistentRegion(), true);
185 if (!gc_lock.HasLock()) 185 if (!gc_lock.HasLock()) {
186 // To ensure that the rendering step eventually happens, repost.
187 render_thread_->GetWebTaskRunner()->PostTask(
188 BLINK_FROM_HERE,
189 Bind(&OfflineAudioDestinationHandler::DoOfflineRendering,
190 WrapPassRefPtr(this)));
186 return; 191 return;
192 }
187 193
188 number_of_channels = render_target_->numberOfChannels(); 194 number_of_channels = render_target_->numberOfChannels();
189 destinations.ReserveInitialCapacity(number_of_channels); 195 destinations.ReserveInitialCapacity(number_of_channels);
190 for (unsigned i = 0; i < number_of_channels; ++i) 196 for (unsigned i = 0; i < number_of_channels; ++i)
191 destinations.push_back(render_target_->getChannelData(i).View()->Data()); 197 destinations.push_back(render_target_->getChannelData(i).View()->Data());
192 } 198 }
193 199
194 // Reset the suspend flag. 200 // Reset the suspend flag.
195 should_suspend_ = false; 201 should_suspend_ = false;
196 202
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 SetHandler(OfflineAudioDestinationHandler::Create(*this, render_target)); 364 SetHandler(OfflineAudioDestinationHandler::Create(*this, render_target));
359 } 365 }
360 366
361 OfflineAudioDestinationNode* OfflineAudioDestinationNode::Create( 367 OfflineAudioDestinationNode* OfflineAudioDestinationNode::Create(
362 BaseAudioContext* context, 368 BaseAudioContext* context,
363 AudioBuffer* render_target) { 369 AudioBuffer* render_target) {
364 return new OfflineAudioDestinationNode(*context, render_target); 370 return new OfflineAudioDestinationNode(*context, render_target);
365 } 371 }
366 372
367 } // namespace blink 373 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698