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

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

Issue 2638413004: Don't run removeFinishedSourceNodes with the context lock. (Closed)
Patch Set: Created 3 years, 11 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) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, 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 18 matching lines...) Expand all
29 #include "bindings/core/v8/ScriptState.h" 29 #include "bindings/core/v8/ScriptState.h"
30 #include "core/dom/DOMException.h" 30 #include "core/dom/DOMException.h"
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
33 #include "core/dom/ExecutionContext.h" 33 #include "core/dom/ExecutionContext.h"
34 #include "modules/webaudio/AudioListener.h" 34 #include "modules/webaudio/AudioListener.h"
35 #include "modules/webaudio/DeferredTaskHandler.h" 35 #include "modules/webaudio/DeferredTaskHandler.h"
36 #include "modules/webaudio/OfflineAudioCompletionEvent.h" 36 #include "modules/webaudio/OfflineAudioCompletionEvent.h"
37 #include "modules/webaudio/OfflineAudioDestinationNode.h" 37 #include "modules/webaudio/OfflineAudioDestinationNode.h"
38 38
39 #include "platform/CrossThreadFunctional.h"
39 #include "platform/Histogram.h" 40 #include "platform/Histogram.h"
40 #include "platform/audio/AudioUtilities.h" 41 #include "platform/audio/AudioUtilities.h"
42 #include "public/platform/Platform.h"
41 43
42 namespace blink { 44 namespace blink {
43 45
44 OfflineAudioContext* OfflineAudioContext::create( 46 OfflineAudioContext* OfflineAudioContext::create(
45 ExecutionContext* context, 47 ExecutionContext* context,
46 unsigned numberOfChannels, 48 unsigned numberOfChannels,
47 unsigned numberOfFrames, 49 unsigned numberOfFrames,
48 float sampleRate, 50 float sampleRate,
49 ExceptionState& exceptionState) { 51 ExceptionState& exceptionState) {
50 // FIXME: add support for workers. 52 // FIXME: add support for workers.
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 handleStoppableSourceNodes(); 369 handleStoppableSourceNodes();
368 370
369 return shouldSuspend(); 371 return shouldSuspend();
370 } 372 }
371 373
372 void OfflineAudioContext::handlePostOfflineRenderTasks() { 374 void OfflineAudioContext::handlePostOfflineRenderTasks() {
373 DCHECK(isAudioThread()); 375 DCHECK(isAudioThread());
374 376
375 // OfflineGraphAutoLocker here locks the audio graph for the same reason 377 // OfflineGraphAutoLocker here locks the audio graph for the same reason
376 // above in |handlePreOfflineRenderTasks|. 378 // above in |handlePreOfflineRenderTasks|.
377 OfflineGraphAutoLocker locker(this); 379 bool didRemove = false;
380 {
381 OfflineGraphAutoLocker locker(this);
378 382
379 deferredTaskHandler().breakConnections(); 383 deferredTaskHandler().breakConnections();
380 releaseFinishedSourceNodes(); 384 didRemove = releaseFinishedSourceNodes();
381 deferredTaskHandler().handleDeferredTasks(); 385 deferredTaskHandler().handleDeferredTasks();
382 deferredTaskHandler().requestToDeleteHandlersOnMainThread(); 386 deferredTaskHandler().requestToDeleteHandlersOnMainThread();
387 }
388 if (didRemove) {
389 Platform::current()->mainThread()->getWebTaskRunner()->postTask(
390 BLINK_FROM_HERE,
391 crossThreadBind(&BaseAudioContext::removeFinishedSourceNodes,
392 wrapCrossThreadPersistent(this)));
393 }
383 } 394 }
384 395
385 OfflineAudioDestinationHandler& OfflineAudioContext::destinationHandler() { 396 OfflineAudioDestinationHandler& OfflineAudioContext::destinationHandler() {
386 return static_cast<OfflineAudioDestinationHandler&>( 397 return static_cast<OfflineAudioDestinationHandler&>(
387 destination()->audioDestinationHandler()); 398 destination()->audioDestinationHandler());
388 } 399 }
389 400
390 void OfflineAudioContext::resolveSuspendOnMainThread(size_t frame) { 401 void OfflineAudioContext::resolveSuspendOnMainThread(size_t frame) {
391 DCHECK(isMainThread()); 402 DCHECK(isMainThread());
392 403
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 445
435 // Note that the GraphLock is required before this check. Since this needs 446 // Note that the GraphLock is required before this check. Since this needs
436 // to run on the audio thread, OfflineGraphAutoLocker must be used. 447 // to run on the audio thread, OfflineGraphAutoLocker must be used.
437 if (m_scheduledSuspends.contains(currentSampleFrame())) 448 if (m_scheduledSuspends.contains(currentSampleFrame()))
438 return true; 449 return true;
439 450
440 return false; 451 return false;
441 } 452 }
442 453
443 } // namespace blink 454 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698