Index: third_party/WebKit/Source/modules/webaudio/DeferredTaskHandler.cpp |
diff --git a/third_party/WebKit/Source/modules/webaudio/DeferredTaskHandler.cpp b/third_party/WebKit/Source/modules/webaudio/DeferredTaskHandler.cpp |
index cba5a99247ab2929a07aae6107dbb4a70cfee023..5ff4b2f204a06f5ebab4d50b16c1ede6e7f364a2 100644 |
--- a/third_party/WebKit/Source/modules/webaudio/DeferredTaskHandler.cpp |
+++ b/third_party/WebKit/Source/modules/webaudio/DeferredTaskHandler.cpp |
@@ -28,6 +28,7 @@ |
#include "modules/webaudio/AudioNode.h" |
#include "modules/webaudio/AudioNodeOutput.h" |
+#include "modules/webaudio/OfflineAudioContext.h" |
#include "platform/ThreadSafeFunctional.h" |
#include "public/platform/Platform.h" |
#include "wtf/MainThread.h" |
@@ -60,6 +61,17 @@ void DeferredTaskHandler::unlock() |
m_contextGraphMutex.unlock(); |
} |
+void DeferredTaskHandler::offlineLock() |
+{ |
+ // It is safe to lock the graph from the audio thread for offline rendering, |
+ // but let us have RELEASE_ASSERT here to make sure to explicitly crash |
+ // rather than accidentally blocking the audio thread. |
Raymond Toy
2015/10/22 18:49:47
This comment kind of doesn't make sense. You say
hongchan
2015/10/22 20:17:04
Done.
|
+ RELEASE_ASSERT_WITH_MESSAGE(isAudioThread(), |
+ "DeferredTaskHandler::offlineLock() should be called within the audio thread."); |
+ |
+ m_contextGraphMutex.lock(); |
+} |
+ |
#if ENABLE(ASSERT) |
bool DeferredTaskHandler::isGraphOwner() |
{ |
@@ -226,12 +238,19 @@ void DeferredTaskHandler::contextWillBeDestroyed() |
// Some handlers might live because of their cross thread tasks. |
} |
+ |
DeferredTaskHandler::AutoLocker::AutoLocker(AbstractAudioContext* context) |
: m_handler(context->deferredTaskHandler()) |
{ |
m_handler.lock(); |
} |
+DeferredTaskHandler::OfflineGraphAutoLocker::OfflineGraphAutoLocker(OfflineAudioContext* context) |
+ : m_handler(context->deferredTaskHandler()) |
+{ |
+ m_handler.offlineLock(); |
+} |
+ |
void DeferredTaskHandler::addRenderingOrphanHandler(PassRefPtr<AudioHandler> handler) |
{ |
ASSERT(handler); |