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

Unified Diff: Source/modules/webaudio/AudioBuffer.cpp

Issue 1017183003: Make DOMTypedArray exported. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 5 years, 9 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
« no previous file with comments | « Source/modules/webaudio/AudioBuffer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/AudioBuffer.cpp
diff --git a/Source/modules/webaudio/AudioBuffer.cpp b/Source/modules/webaudio/AudioBuffer.cpp
index ba183853fafc03e1ecf7f00c73cff73e898ad393..49d67c3418d59109f9182503ce987c534dcdd338 100644
--- a/Source/modules/webaudio/AudioBuffer.cpp
+++ b/Source/modules/webaudio/AudioBuffer.cpp
@@ -38,6 +38,7 @@
#include "platform/audio/AudioBus.h"
#include "platform/audio/AudioFileReader.h"
#include "platform/audio/AudioUtilities.h"
+#include "wtf/Float32Array.h"
namespace blink {
@@ -133,6 +134,14 @@ bool AudioBuffer::createdSuccessfully(unsigned desiredNumberOfChannels) const
return numberOfChannels() == desiredNumberOfChannels;
}
+PassRefPtr<DOMFloat32Array> AudioBuffer::createFloat32ArrayOrNull(size_t length)
+{
+ RefPtr<WTF::Float32Array> bufferView = WTF::Float32Array::createOrNull(length);
+ if (!bufferView)
+ return nullptr;
+ return DOMFloat32Array::create(bufferView.release());
+}
+
AudioBuffer::AudioBuffer(unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
: m_sampleRate(sampleRate)
, m_length(numberOfFrames)
@@ -140,7 +149,7 @@ AudioBuffer::AudioBuffer(unsigned numberOfChannels, size_t numberOfFrames, float
m_channels.reserveCapacity(numberOfChannels);
for (unsigned i = 0; i < numberOfChannels; ++i) {
- RefPtr<DOMFloat32Array> channelDataArray = DOMFloat32Array::createOrNull(m_length);
+ RefPtr<DOMFloat32Array> channelDataArray = createFloat32ArrayOrNull(m_length);
// If the channel data array could not be created, just return. The caller will need to
// check that the desired number of channels were created.
if (!channelDataArray) {
@@ -160,7 +169,7 @@ AudioBuffer::AudioBuffer(AudioBus* bus)
unsigned numberOfChannels = bus->numberOfChannels();
m_channels.reserveCapacity(numberOfChannels);
for (unsigned i = 0; i < numberOfChannels; ++i) {
- RefPtr<DOMFloat32Array> channelDataArray = DOMFloat32Array::createOrNull(m_length);
+ RefPtr<DOMFloat32Array> channelDataArray = createFloat32ArrayOrNull(m_length);
// If the channel data array could not be created, just return. The caller will need to
// check that the desired number of channels were created.
if (!channelDataArray)
« no previous file with comments | « Source/modules/webaudio/AudioBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698