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

Unified Diff: third_party/WebKit/Source/modules/webaudio/DeferredTaskHandler.h

Issue 1405413004: Implement suspend() and resume() for OfflineAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating UseCounter.h after L-G-T-M Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webaudio/DeferredTaskHandler.h
diff --git a/third_party/WebKit/Source/modules/webaudio/DeferredTaskHandler.h b/third_party/WebKit/Source/modules/webaudio/DeferredTaskHandler.h
index b145642b82ea96eb3bd9de6e5d1ab3f3de8955c8..184ee1c0a6d5a8374055941802a0063243e35b98 100644
--- a/third_party/WebKit/Source/modules/webaudio/DeferredTaskHandler.h
+++ b/third_party/WebKit/Source/modules/webaudio/DeferredTaskHandler.h
@@ -38,6 +38,7 @@
namespace blink {
class AbstractAudioContext;
+class OfflineAudioContext;
class AudioHandler;
class AudioNodeOutput;
class AudioSummingJunction;
@@ -110,6 +111,11 @@ public:
void lock();
bool tryLock();
void unlock();
+
+ // This locks the audio render thread for OfflineAudioContext rendering.
+ // MUST NOT be used in the real-time audio context.
+ void offlineLock();
+
#if ENABLE(ASSERT)
// Returns true if this thread owns the context's lock.
bool isGraphOwner();
@@ -131,6 +137,21 @@ public:
DeferredTaskHandler& m_handler;
};
+ // This is for locking offline render thread (which is considered as the
+ // audio thread) with unlocking on self-destruction at the end of the scope.
+ // Also note that it uses lock() rather than tryLock() because the timing
+ // MUST be accurate on offline rendering.
+ class MODULES_EXPORT OfflineGraphAutoLocker {
+ STACK_ALLOCATED();
+ public:
+ explicit OfflineGraphAutoLocker(OfflineAudioContext*);
+
+ ~OfflineGraphAutoLocker() { m_handler.unlock(); }
+
+ private:
+ DeferredTaskHandler& m_handler;
+ };
+
private:
DeferredTaskHandler();
void updateAutomaticPullNodes();

Powered by Google App Engine
This is Rietveld 408576698