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
--- 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