Bug 1113925 - Don't return null in AudioContext.decodeAudioData. r=bz
authorPaul Adenot <paul@paul.cx>
Mon, 05 Jan 2015 13:43:00 +0100
changeset 222013 c4ea7a2518fc05082dd81b0542b1d088f92f7046
parent 222012 99d7aacbdd3b5cd96585ae4062f49c4d5e3f82be
child 222014 0c9f97ebf7ead3d855b24f3e7d213eaf74f2c3df
push id28055
push userkwierso@gmail.com
push dateTue, 06 Jan 2015 00:19:38 +0000
treeherdermozilla-central@72d7ae169b09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1113925
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1113925 - Don't return null in AudioContext.decodeAudioData. r=bz
dom/media/webaudio/AudioContext.cpp
dom/media/webaudio/AudioContext.h
dom/webidl/AudioContext.webidl
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -445,28 +445,28 @@ AudioContext::Listener()
     mListener = new AudioListener(this);
   }
   return mListener;
 }
 
 already_AddRefed<Promise>
 AudioContext::DecodeAudioData(const ArrayBuffer& aBuffer,
                               const Optional<OwningNonNull<DecodeSuccessCallback> >& aSuccessCallback,
-                              const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback)
+                              const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback,
+                              ErrorResult& aRv)
 {
-  ErrorResult rv;
   nsCOMPtr<nsIGlobalObject> parentObject = do_QueryInterface(GetParentObject());
   nsRefPtr<Promise> promise;
   AutoJSAPI jsapi;
   jsapi.Init();
   JSContext* cx = jsapi.cx();
   JSAutoCompartment ac(cx, aBuffer.Obj());
 
-  promise = Promise::Create(parentObject, rv);
-  if (rv.Failed()) {
+  promise = Promise::Create(parentObject, aRv);
+  if (aRv.Failed()) {
     return nullptr;
   }
 
   aBuffer.ComputeLengthAndData();
 
   // Neuter the array buffer
   size_t length = aBuffer.Length();
   JS::RootedObject obj(cx, aBuffer.Obj());
--- a/dom/media/webaudio/AudioContext.h
+++ b/dom/media/webaudio/AudioContext.h
@@ -187,17 +187,18 @@ public:
 
   already_AddRefed<PeriodicWave>
   CreatePeriodicWave(const Float32Array& aRealData, const Float32Array& aImagData,
                      ErrorResult& aRv);
 
   already_AddRefed<Promise>
   DecodeAudioData(const ArrayBuffer& aBuffer,
                   const Optional<OwningNonNull<DecodeSuccessCallback> >& aSuccessCallback,
-                  const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback);
+                  const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback,
+                  ErrorResult& aRv);
 
   // OfflineAudioContext methods
   already_AddRefed<Promise> StartRendering(ErrorResult& aRv);
   IMPL_EVENT_HANDLER(complete)
 
   bool IsOffline() const { return mIsOffline; }
 
   MediaStreamGraph* Graph() const;
--- a/dom/webidl/AudioContext.webidl
+++ b/dom/webidl/AudioContext.webidl
@@ -20,16 +20,17 @@ interface AudioContext : EventTarget {
     readonly attribute AudioDestinationNode destination;
     readonly attribute float sampleRate;
     readonly attribute double currentTime;
     readonly attribute AudioListener listener;
 
     [NewObject, Throws]
     AudioBuffer createBuffer(unsigned long numberOfChannels, unsigned long length, float sampleRate);
 
+    [Throws]
     Promise<AudioBuffer> decodeAudioData(ArrayBuffer audioData,
                                          optional DecodeSuccessCallback successCallback,
                                          optional DecodeErrorCallback errorCallback);
 
     // AudioNode creation
     [NewObject]
     AudioBufferSourceNode createBufferSource();