diff --git a/content/html/content/public/HTMLAudioElement.h b/content/html/content/public/HTMLAudioElement.h
index 7f9cc434b547..68509e4db5f6 100644
--- a/content/html/content/public/HTMLAudioElement.h
+++ b/content/html/content/public/HTMLAudioElement.h
@@ -7,8 +7,8 @@
#define mozilla_dom_HTMLAudioElement_h
#include "nsIDOMHTMLAudioElement.h"
-#include "nsIJSNativeInitializer.h"
#include "mozilla/dom/HTMLMediaElement.h"
+#include "mozilla/dom/TypedArray.h"
typedef uint16_t nsMediaNetworkState;
typedef uint16_t nsMediaReadyState;
@@ -39,9 +39,6 @@ public:
using HTMLMediaElement::GetPaused;
NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(HTMLMediaElement::)
- // nsIDOMHTMLAudioElement
- NS_DECL_NSIDOMHTMLAUDIOELEMENT
-
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsresult SetAcceptHeader(nsIHttpChannel* aChannel);
@@ -57,7 +54,16 @@ public:
void MozSetup(uint32_t aChannels, uint32_t aRate, ErrorResult& aRv);
- uint32_t MozWriteAudio(JSContext* aCx, JS::Value aData, ErrorResult& aRv);
+ uint32_t MozWriteAudio(const Float32Array& aData, ErrorResult& aRv)
+ {
+ return MozWriteAudio(aData.Data(), aData.Length(), aRv);
+ }
+ uint32_t MozWriteAudio(const Sequence& aData, ErrorResult& aRv)
+ {
+ return MozWriteAudio(aData.Elements(), aData.Length(), aRv);
+ }
+ uint32_t MozWriteAudio(const float* aData, uint32_t aLength,
+ ErrorResult& aRv);
uint64_t MozCurrentSampleOffset(ErrorResult& aRv);
diff --git a/content/html/content/src/HTMLAudioElement.cpp b/content/html/content/src/HTMLAudioElement.cpp
index 7e8bacbd647d..eb4ba8eaf7b8 100644
--- a/content/html/content/src/HTMLAudioElement.cpp
+++ b/content/html/content/src/HTMLAudioElement.cpp
@@ -130,16 +130,9 @@ HTMLAudioElement::MozSetup(uint32_t aChannels, uint32_t aRate, ErrorResult& aRv)
mAudioStream->SetVolume(mVolume);
}
-NS_IMETHODIMP
-HTMLAudioElement::MozSetup(uint32_t aChannels, uint32_t aRate)
-{
- ErrorResult rv;
- MozSetup(aChannels, aRate, rv);
- return rv.ErrorCode();
-}
-
uint32_t
-HTMLAudioElement::MozWriteAudio(JSContext* aCx, JS::Value aData, ErrorResult& aRv)
+HTMLAudioElement::MozWriteAudio(const float* aData, uint32_t aLength,
+ ErrorResult& aRv)
{
if (!IsAudioAPIEnabled()) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
@@ -151,50 +144,22 @@ HTMLAudioElement::MozWriteAudio(JSContext* aCx, JS::Value aData, ErrorResult& aR
return 0;
}
- if (!aData.isObject()) {
- aRv.Throw(NS_ERROR_DOM_TYPE_MISMATCH_ERR);
- return 0;
- }
-
- JSObject* darray = &aData.toObject();
- JS::AutoObjectRooter tvr(aCx);
- JSObject* tsrc = nullptr;
-
- // Allow either Float32Array or plain JS Array
- if (JS_IsFloat32Array(darray)) {
- tsrc = darray;
- } else if (JS_IsArrayObject(aCx, darray)) {
- JSObject* nobj = JS_NewFloat32ArrayFromArray(aCx, darray);
- if (!nobj) {
- aRv.Throw(NS_ERROR_DOM_TYPE_MISMATCH_ERR);
- return 0;
- }
- tsrc = nobj;
- } else {
- aRv.Throw(NS_ERROR_DOM_TYPE_MISMATCH_ERR);
- return 0;
- }
- tvr.setObject(tsrc);
-
- uint32_t dataLength = JS_GetTypedArrayLength(tsrc);
-
// Make sure that we are going to write the correct amount of data based
// on number of channels.
- if (dataLength % mChannels != 0) {
+ if (aLength % mChannels != 0) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return 0;
}
// Don't write more than can be written without blocking.
- uint32_t writeLen = std::min(mAudioStream->Available(), dataLength / mChannels);
+ uint32_t writeLen = std::min(mAudioStream->Available(), aLength / mChannels);
- float* frames = JS_GetFloat32ArrayData(tsrc);
// Convert the samples back to integers as we are using fixed point audio in
// the AudioStream.
// This could be optimized to avoid allocation and memcpy when
// AudioDataValue is 'float', but it's not worth it for this deprecated API.
nsAutoArrayPtr audioData(new AudioDataValue[writeLen * mChannels]);
- ConvertAudioSamples(frames, audioData.get(), writeLen * mChannels);
+ ConvertAudioSamples(aData, audioData.get(), writeLen * mChannels);
aRv = mAudioStream->Write(audioData.get(), writeLen);
if (aRv.Failed()) {
return 0;
@@ -205,14 +170,6 @@ HTMLAudioElement::MozWriteAudio(JSContext* aCx, JS::Value aData, ErrorResult& aR
return writeLen * mChannels;
}
-NS_IMETHODIMP
-HTMLAudioElement::MozWriteAudio(const JS::Value& aData, JSContext* aCx, uint32_t* aRetVal)
-{
- ErrorResult rv;
- *aRetVal = MozWriteAudio(aCx, aData, rv);
- return rv.ErrorCode();
-}
-
uint64_t
HTMLAudioElement::MozCurrentSampleOffset(ErrorResult& aRv)
{
@@ -234,14 +191,6 @@ HTMLAudioElement::MozCurrentSampleOffset(ErrorResult& aRv)
return position * mChannels;
}
-NS_IMETHODIMP
-HTMLAudioElement::MozCurrentSampleOffset(uint64_t *aRetVal)
-{
- ErrorResult rv;
- *aRetVal = MozCurrentSampleOffset(rv);
- return rv.ErrorCode();
-}
-
nsresult HTMLAudioElement::SetAcceptHeader(nsIHttpChannel* aChannel)
{
nsAutoCString value(
diff --git a/dom/interfaces/html/nsIDOMHTMLAudioElement.idl b/dom/interfaces/html/nsIDOMHTMLAudioElement.idl
index 4c057f22573a..198dfba444cd 100644
--- a/dom/interfaces/html/nsIDOMHTMLAudioElement.idl
+++ b/dom/interfaces/html/nsIDOMHTMLAudioElement.idl
@@ -6,10 +6,6 @@
#include "nsIDOMHTMLMediaElement.idl"
-%{C++
-#include "jsapi.h"
-%}
-
/**
* The nsIDOMHTMLAudioElement interface is the interface to a HTML
*