diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-04-27 08:57:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-27 08:57:04 -0400 |
commit | 10bee0db5df3af32151c1f268fb2cd99f151efa9 (patch) | |
tree | b0a0970bdd812dc2b6155625eaedd2b8f2379cc7 /components/script | |
parent | 7607f3c9953f9982e0ec4ec24f7c5da173da719a (diff) | |
parent | b519a0b941a20ae4e0e0c4214c57001074d8a47d (diff) | |
download | servo-10bee0db5df3af32151c1f268fb2cd99f151efa9.tar.gz servo-10bee0db5df3af32151c1f268fb2cd99f151efa9.zip |
Auto merge of #23259 - Akhilesh1996:master, r=Manishearth
Implement AudioParam.setValueCurveAtTime #22897
<!-- Please describe your changes on the following line: -->
Updated audioparam.rs to send the new UserAutomationEvent SetValueCurveAtTime to the audio engine and updated test results.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #22897 (GitHub issue number if applicable)
<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23259)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/audioparam.rs | 34 | ||||
-rw-r--r-- | components/script/dom/webidls/AudioParam.webidl | 6 |
2 files changed, 37 insertions, 3 deletions
diff --git a/components/script/dom/audioparam.rs b/components/script/dom/audioparam.rs index 08ab6f32d10..f4e42264225 100644 --- a/components/script/dom/audioparam.rs +++ b/components/script/dom/audioparam.rs @@ -231,6 +231,40 @@ impl AudioParamMethods for AudioParam { Ok(DomRoot::from_ref(self)) } + // https://webaudio.github.io/web-audio-api/#dom-audioparam-setvaluecurveattime + fn SetValueCurveAtTime( + &self, + values: Vec<Finite<f32>>, + start_time: Finite<f64>, + end_time: Finite<f64>, + ) -> Fallible<DomRoot<AudioParam>> { + if *start_time < 0. { + return Err(Error::Range(format!( + "start time {} should not be negative", + *start_time + ))); + } + if values.len() < 2. as usize { + return Err(Error::InvalidState); + } + + if *end_time < 0. { + return Err(Error::Range(format!( + "end time {} should not be negative", + *end_time + ))); + } + self.message_node(AudioNodeMessage::SetParam( + self.param, + UserAutomationEvent::SetValueCurveAtTime( + values.into_iter().map(|v| *v).collect(), + *start_time, + *end_time, + ), + )); + Ok(DomRoot::from_ref(self)) + } + // https://webaudio.github.io/web-audio-api/#dom-audioparam-cancelscheduledvalues fn CancelScheduledValues(&self, cancel_time: Finite<f64>) -> Fallible<DomRoot<AudioParam>> { if *cancel_time < 0. { diff --git a/components/script/dom/webidls/AudioParam.webidl b/components/script/dom/webidls/AudioParam.webidl index f191a6848f3..42f1012539c 100644 --- a/components/script/dom/webidls/AudioParam.webidl +++ b/components/script/dom/webidls/AudioParam.webidl @@ -24,9 +24,9 @@ interface AudioParam { [Throws] AudioParam setTargetAtTime(float target, double startTime, float timeConstant); -// AudioParam setValueCurveAtTime(sequence<float> values, -// double startTime, -// double duration); + [Throws] AudioParam setValueCurveAtTime(sequence<float> values, + double startTime, + double duration); [Throws] AudioParam cancelScheduledValues(double cancelTime); [Throws] AudioParam cancelAndHoldAtTime(double cancelTime); }; |