bindings: Transition from ArrayBuffer to DOMArrayBuffer, part 3.

By this CL, all the uses of ArrayBuffer in modules/ have been rewritten
with DOMArrayBuffer.

BUG=235436

Review URL: https://codereview.chromium.org/723143002

git-svn-id: svn://svn.chromium.org/blink/trunk@185295 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7fdb53cc
......@@ -15,7 +15,6 @@
#include "modules/serviceworkers/Headers.h"
#include "platform/blob/BlobData.h"
#include "platform/network/FormData.h"
#include "wtf/ArrayBuffer.h"
namespace blink {
......
......@@ -28,13 +28,13 @@
#include "modules/webaudio/AsyncAudioDecoder.h"
#include "core/dom/DOMArrayBuffer.h"
#include "modules/webaudio/AudioBuffer.h"
#include "modules/webaudio/AudioBufferCallback.h"
#include "platform/Task.h"
#include "platform/audio/AudioBus.h"
#include "platform/audio/AudioFileReader.h"
#include "public/platform/Platform.h"
#include "wtf/ArrayBuffer.h"
#include "wtf/MainThread.h"
#include "wtf/PassOwnPtr.h"
......@@ -49,7 +49,7 @@ AsyncAudioDecoder::~AsyncAudioDecoder()
{
}
void AsyncAudioDecoder::decodeAsync(ArrayBuffer* audioData, float sampleRate, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback)
void AsyncAudioDecoder::decodeAsync(DOMArrayBuffer* audioData, float sampleRate, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback)
{
ASSERT(isMainThread());
ASSERT(audioData);
......@@ -57,13 +57,13 @@ void AsyncAudioDecoder::decodeAsync(ArrayBuffer* audioData, float sampleRate, Au
return;
// Add a ref to keep audioData alive until completion of decoding.
RefPtr<ArrayBuffer> audioDataRef(audioData);
RefPtr<DOMArrayBuffer> audioDataRef(audioData);
// The leak references to successCallback and errorCallback are picked up on notifyComplete.
m_thread->postTask(new Task(WTF::bind(&AsyncAudioDecoder::decode, audioDataRef.release().leakRef(), sampleRate, successCallback, errorCallback)));
}
void AsyncAudioDecoder::decode(ArrayBuffer* audioData, float sampleRate, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback)
void AsyncAudioDecoder::decode(DOMArrayBuffer* audioData, float sampleRate, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback)
{
RefPtr<AudioBus> bus = createBusFromInMemoryAudioFile(audioData->data(), audioData->byteLength(), false, sampleRate);
......@@ -72,10 +72,10 @@ void AsyncAudioDecoder::decode(ArrayBuffer* audioData, float sampleRate, AudioBu
callOnMainThread(WTF::bind(&AsyncAudioDecoder::notifyComplete, audioData, successCallback, errorCallback, bus.release().leakRef()));
}
void AsyncAudioDecoder::notifyComplete(ArrayBuffer* audioData, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback, AudioBus* audioBus)
void AsyncAudioDecoder::notifyComplete(DOMArrayBuffer* audioData, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback, AudioBus* audioBus)
{
// Adopt references, so everything gets correctly dereffed.
RefPtr<ArrayBuffer> audioDataRef = adoptRef(audioData);
RefPtr<DOMArrayBuffer> audioDataRef = adoptRef(audioData);
RefPtr<AudioBus> audioBusRef = adoptRef(audioBus);
AudioBuffer* audioBuffer = AudioBuffer::createFromAudioBus(audioBus);
......
......@@ -27,7 +27,6 @@
#include "platform/heap/Handle.h"
#include "public/platform/WebThread.h"
#include "wtf/Forward.h"
#include "wtf/OwnPtr.h"
namespace blink {
......@@ -35,8 +34,9 @@ namespace blink {
class AudioBuffer;
class AudioBufferCallback;
class AudioBus;
class DOMArrayBuffer;
// AsyncAudioDecoder asynchronously decodes audio file data from an ArrayBuffer in a worker thread.
// AsyncAudioDecoder asynchronously decodes audio file data from a DOMArrayBuffer in a worker thread.
// Upon successful decoding, a completion callback will be invoked with the decoded PCM data in an AudioBuffer.
class AsyncAudioDecoder {
......@@ -46,12 +46,12 @@ public:
~AsyncAudioDecoder();
// Must be called on the main thread.
void decodeAsync(ArrayBuffer* audioData, float sampleRate, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback);
void decodeAsync(DOMArrayBuffer* audioData, float sampleRate, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback);
private:
AudioBuffer* createAudioBufferFromAudioBus(AudioBus*);
static void decode(ArrayBuffer* audioData, float sampleRate, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback);
static void notifyComplete(ArrayBuffer* audioData, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback, AudioBus*);
static void decode(DOMArrayBuffer* audioData, float sampleRate, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback);
static void notifyComplete(DOMArrayBuffer* audioData, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback, AudioBus*);
OwnPtr<WebThread> m_thread;
};
......
......@@ -240,7 +240,7 @@ void AudioContext::decodeAudioData(DOMArrayBuffer* audioData, AudioBufferCallbac
"invalid ArrayBuffer for audioData.");
return;
}
m_audioDecoder.decodeAsync(audioData->buffer(), sampleRate(), successCallback, errorCallback);
m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCallback);
}
AudioBufferSourceNode* AudioContext::createBufferSource()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment