Bug 1421091 - Update AudioParam.setValueCurveAtTime to take sequence<float> instead of a Float32Array. r=baku,karlt draft
authorPaul Adenot <paul@paul.cx>
Tue, 03 Jul 2018 18:00:27 +0200
changeset 817793 af03d4a0996ae6694aaaeb5ab320e0d652ce224b
parent 817669 e951f4ad123aa87d1d392c286db14cabb41a8560
child 817794 7dc9bcda2af91025c8a7cdc673630df7747b409d
push id116164
push userpaul@paul.cx
push dateFri, 13 Jul 2018 13:14:53 +0000
reviewersbaku, karlt
bugs1421091
milestone63.0a1
Bug 1421091 - Update AudioParam.setValueCurveAtTime to take sequence<float> instead of a Float32Array. r=baku,karlt Link to the standard: https://webaudio.github.io/web-audio-api/#dom-audioparam-setvaluecurveattime MozReview-Commit-ID: 8GwaIbQkfr2
dom/media/webaudio/AudioEventTimeline.h
dom/media/webaudio/AudioParam.h
dom/webidl/AudioParam.webidl
--- a/dom/media/webaudio/AudioEventTimeline.h
+++ b/dom/media/webaudio/AudioEventTimeline.h
@@ -148,22 +148,16 @@ public:
       return false;
     }
 
     if (aEvent.mType == AudioTimelineEvent::SetValueCurve) {
       if (!aEvent.mCurve || !aEvent.mCurveLength) {
         aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
         return false;
       }
-      for (uint32_t i = 0; i < aEvent.mCurveLength; ++i) {
-        if (!IsValid(aEvent.mCurve[i])) {
-          aRv.Throw(NS_ERROR_TYPE_ERR);
-          return false;
-        }
-      }
     }
 
     bool timeAndValueValid = IsValid(aEvent.mValue) &&
                              IsValid(aEvent.mDuration);
     if (!timeAndValueValid) {
       aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
       return false;
     }
--- a/dom/media/webaudio/AudioParam.h
+++ b/dom/media/webaudio/AudioParam.h
@@ -40,30 +40,28 @@ public:
   {
     return mNode->Context();
   }
 
   JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   // We override SetValueCurveAtTime to convert the Float32Array to the wrapper
   // object.
-  AudioParam* SetValueCurveAtTime(const Float32Array& aValues,
+  AudioParam* SetValueCurveAtTime(const nsTArray<float>& aValues,
                                   double aStartTime,
                                   double aDuration,
                                   ErrorResult& aRv)
   {
     if (!WebAudioUtils::IsTimeValid(aStartTime)) {
       aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
       return this;
     }
-    aValues.ComputeLengthAndData();
-
     aStartTime = std::max(aStartTime, GetParentObject()->CurrentTime());
     EventInsertionHelper(aRv, AudioTimelineEvent::SetValueCurve,
-                         aStartTime, 0.0f, 0.0f, aDuration, aValues.Data(),
+                         aStartTime, 0.0f, 0.0f, aDuration, aValues.Elements(),
                          aValues.Length());
     return this;
   }
 
   void SetValue(float aValue)
   {
     AudioTimelineEvent event(AudioTimelineEvent::SetValue, 0.0f, aValue);
 
--- a/dom/webidl/AudioParam.webidl
+++ b/dom/webidl/AudioParam.webidl
@@ -28,17 +28,17 @@ interface AudioParam {
 
     // Exponentially approach the target value with a rate having the given time constant. 
     [Throws]
     AudioParam setTargetAtTime(float target, double startTime, double timeConstant);
 
     // Sets an array of arbitrary parameter values starting at time for the given duration. 
     // The number of values will be scaled to fit into the desired duration. 
     [Throws]
-    AudioParam setValueCurveAtTime(Float32Array values, double startTime, double duration);
+    AudioParam setValueCurveAtTime(sequence<float> values, double startTime, double duration);
 
     // Cancels all scheduled parameter changes with times greater than or equal to startTime. 
     [Throws]
     AudioParam cancelScheduledValues(double startTime);
 
 };
 
 // Mozilla extension