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

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp

Issue 2102133002: Add constructors for WebAudio nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and prefix use counter names with WebAudio Created 4 years, 3 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/AudioBufferSourceNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp b/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp
index 79b2151d9eef084b6ad8e7a3eef0498a32de9b38..80011822b69576d53f25b5da60fa525b21138b29 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp
@@ -27,6 +27,7 @@
#include "core/dom/ExceptionCode.h"
#include "core/frame/UseCounter.h"
#include "modules/webaudio/AudioBufferSourceNode.h"
+#include "modules/webaudio/AudioBufferSourceOptions.h"
#include "modules/webaudio/AudioNodeOutput.h"
#include "modules/webaudio/BaseAudioContext.h"
#include "platform/audio/AudioUtilities.h"
@@ -613,6 +614,31 @@ AudioBufferSourceNode* AudioBufferSourceNode::create(BaseAudioContext& context,
return new AudioBufferSourceNode(context);
}
+AudioBufferSourceNode* AudioBufferSourceNode::create(BaseAudioContext* context, AudioBufferSourceOptions& options, ExceptionState& exceptionState)
+{
+ DCHECK(isMainThread());
+
+ AudioBufferSourceNode* node = create(*context, exceptionState);
+
+ if (!node)
+ return nullptr;
+
+ if (options.hasBuffer())
+ node->setBuffer(options.buffer(), exceptionState);
+ if (options.hasDetune())
+ node->detune()->setValue(options.detune());
+ if (options.hasLoop())
+ node->setLoop(options.loop());
+ if (options.hasLoopEnd())
+ node->setLoopEnd(options.loopEnd());
+ if (options.hasLoopStart())
+ node->setLoopStart(options.loopStart());
+ if (options.hasPlaybackRate())
+ node->playbackRate()->setValue(options.playbackRate());
+
+ return node;
+}
+
DEFINE_TRACE(AudioBufferSourceNode)
{
visitor->trace(m_playbackRate);

Powered by Google App Engine
This is Rietveld 408576698