Index: third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp |
diff --git a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp |
index d58dd559ce6a1a4871c576f3b48cb98b926b381f..fd5b34af1c88ff68a20c64d87cb28ed6a46e324a 100644 |
--- a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp |
+++ b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp |
@@ -285,25 +285,34 @@ ScriptPromise BaseAudioContext::decodeAudioData( |
DCHECK_GT(rate, 0); |
- if (audio_data->IsNeutered()) { |
+ DOMException* error = nullptr; |
+ v8::Isolate* isolate = script_state->GetIsolate(); |
+ if (audio_data->IsNeuterable(isolate)) { |
+ // Detach the audio array buffer from the main thread and start |
+ // async decoding of the data. |
+ WTF::ArrayBufferContents buffer_contents; |
+ if (audio_data->Transfer(isolate, buffer_contents)) { |
+ DOMArrayBuffer* audio = DOMArrayBuffer::Create(buffer_contents); |
+ |
+ decode_audio_resolvers_.insert(resolver); |
+ audio_decoder_.DecodeAsync(audio, rate, success_callback, error_callback, |
+ resolver, this); |
+ } else { |
+ error = |
+ DOMException::Create(kDataCloneError, "Cannot transfer ArrayBuffer"); |
+ } |
+ } else { |
// If audioData is detached (neutered) we need to reject the |
// promise with an error. |
- DOMException* error = DOMException::Create( |
- kDataCloneError, "Cannot decode detached ArrayBuffer"); |
+ error = DOMException::Create(kDataCloneError, |
+ "Cannot decode detached ArrayBuffer"); |
+ } |
+ |
+ if (error) { |
resolver->Reject(error); |
if (error_callback) { |
error_callback->handleEvent(error); |
} |
- } else { |
- // Detach the audio array buffer from the main thread and start |
- // async decoding of the data. |
- WTF::ArrayBufferContents buffer_contents; |
- audio_data->Transfer(buffer_contents); |
- DOMArrayBuffer* audio = DOMArrayBuffer::Create(buffer_contents); |
- |
- decode_audio_resolvers_.insert(resolver); |
- audio_decoder_.DecodeAsync(audio, rate, success_callback, error_callback, |
- resolver, this); |
} |
return promise; |