Bug 1113925 - Don't return null in AudioContext.decodeAudioData. r=bz, a=sledru
authorPaul Adenot <paul@paul.cx>
Mon, 05 Jan 2015 13:43:00 +0100
changeset 242989 46ece3ef808e
parent 242988 c16ed656a43b
child 242990 ba67c22c1427
push id4355
push userryanvm@gmail.com
push date2015-01-22 18:54 +0000
treeherdermozilla-beta@ba67c22c1427 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sledru
bugs1113925
milestone36.0
Bug 1113925 - Don't return null in AudioContext.decodeAudioData. r=bz, a=sledru
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
@@ -437,28 +437,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
@@ -183,17 +183,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
   void 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();