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

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioBuffer.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/AudioBuffer.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioBuffer.cpp b/third_party/WebKit/Source/modules/webaudio/AudioBuffer.cpp
index c4cef6671878b06b39468bc4ff3f0b3e0ab72597..7266aed4b2b123dfc6ea0369a93a1dd98bd715b4 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioBuffer.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioBuffer.cpp
@@ -31,6 +31,7 @@
#include "bindings/core/v8/ExceptionMessages.h"
#include "bindings/core/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
+#include "modules/webaudio/AudioBufferOptions.h"
#include "modules/webaudio/BaseAudioContext.h"
#include "platform/audio/AudioBus.h"
#include "platform/audio/AudioFileReader.h"
@@ -104,6 +105,37 @@ AudioBuffer* AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrame
return audioBuffer;
}
+AudioBuffer* AudioBuffer::create(BaseAudioContext* context, const AudioBufferOptions& options, ExceptionState& exceptionState)
+{
+ unsigned numberOfChannels;
+ size_t numberOfFrames;
+ float sampleRate;
+
+ if (!options.hasNumberOfChannels()) {
+ exceptionState.throwDOMException(
+ NotFoundError,
+ "AudioBufferOptions: numberOfChannels is required.");
+ return nullptr;
+ }
+
+ if (!options.hasLength()) {
+ exceptionState.throwDOMException(
+ NotFoundError,
+ "AudioBufferOptions: length is required.");
+ return nullptr;
+ }
+
+ numberOfChannels = options.numberOfChannels();
+ numberOfFrames = options.length();
+
+ if (options.hasSampleRate())
+ sampleRate = options.sampleRate();
+ else
+ sampleRate = context->sampleRate();
+
+ return create(numberOfChannels, numberOfFrames, sampleRate, exceptionState);
+}
+
AudioBuffer* AudioBuffer::createFromAudioFileData(const void* data, size_t dataSize, bool mixToMono, float sampleRate)
{
RefPtr<AudioBus> bus = createBusFromInMemoryAudioFile(data, dataSize, mixToMono, sampleRate);
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AudioBuffer.h ('k') | third_party/WebKit/Source/modules/webaudio/AudioBuffer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698