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

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

Issue 1405413004: Implement suspend() and resume() for OfflineAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarifying error messages in layout tests Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.h
diff --git a/third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.h b/third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.h
index 736810419fec638606130531b0f0b04ff8aef2c2..6f8e32529cd07f20f5c4aecbdf6e674210a1fb62 100644
--- a/third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.h
+++ b/third_party/WebKit/Source/modules/webaudio/OfflineAudioDestinationNode.h
@@ -27,6 +27,7 @@
#include "modules/webaudio/AudioBuffer.h"
#include "modules/webaudio/AudioDestinationNode.h"
+#include "modules/webaudio/OfflineAudioContext.h"
#include "public/platform/WebThread.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h"
@@ -35,6 +36,7 @@ namespace blink {
class AbstractAudioContext;
class AudioBus;
+class OfflineAudioContext;
class OfflineAudioDestinationHandler final : public AudioDestinationHandler {
public:
@@ -46,20 +48,47 @@ public:
void initialize() override;
void uninitialize() override;
+ OfflineAudioContext* context() const final;
+
// AudioDestinationHandler
void startRendering() override;
void stopRendering() override;
float sampleRate() const override { return m_renderTarget->sampleRate(); }
+ size_t renderQuantumFrames() const;
+
+ WebThread* offlineRenderThread();
+
private:
OfflineAudioDestinationHandler(AudioNode&, AudioBuffer* renderTarget);
- void offlineRender();
- void offlineRenderInternal();
- // For completion callback on main thread.
+ // Set up the rendering and start. After setting the context up, it will
+ // eventually call |doOfflineRendering|.
+ void startOfflineRendering();
+
+ // Suspend the rendering loop and notify the main thread to resolve the
+ // associated promise.
+ void suspendOfflineRendering();
+
+ // Start the rendering loop.
+ void doOfflineRendering();
+
+ // Finish the rendering loop and notify the main thread to resolve the
+ // promise with the rendered buffer.
+ void finishOfflineRendering();
+
+ // Suspend/completion callbacks for the main thread.
+ void notifySuspend();
void notifyComplete();
+ // The offline version of render() method. virtual/override were not used
Raymond Toy 2015/10/21 18:22:46 How is virtual/override relevant? Could another c
hongchan 2015/10/22 18:23:49 I thought about overriding render() method - but I
+ // for this method to ensure the optimum performance.
+ // If the rendering needs to be suspended after checking, this stops the
+ // rendering and returns true. Otherwise, it returns false after completing
+ // the render quantum.
+ bool checkSuspendsAndRender(AudioBus* sourceBus, AudioBus* destinationBus, size_t numberOfFrames);
+
// This AudioHandler renders into this AudioBuffer.
// This Persistent doesn't make a reference cycle including the owner
// OfflineAudioDestinationNode.
@@ -69,7 +98,19 @@ private:
// Rendering thread.
OwnPtr<WebThread> m_renderThread;
- bool m_startedRendering;
+
+ // These variables are for counting the number of frames for the current
+ // progress and the remaining frames to be processed.
+ size_t m_framesProcessed;
+ size_t m_framesToProcess;
+
+ // This flag is necessary to distinguish the state of the context between
+ // 'created' and 'suspended'. If this flag is false and the current state
+ // is 'suspended', it means the context is created and have not started yet.
+ bool m_isRenderingStarted;
+
+ // This flag indicates whether the rendering should be suspended or not.
+ bool m_shouldSuspend;
};
class OfflineAudioDestinationNode final : public AudioDestinationNode {

Powered by Google App Engine
This is Rietveld 408576698