Throw if time given to AudioScheduledSourceNode.stop is negative

This commit is contained in:
Fernando Jiménez Moreno 2018-09-24 11:53:36 +02:00
parent bbc3565900
commit bc6586a9d0
2 changed files with 8 additions and 4 deletions

View file

@ -59,6 +59,10 @@ impl AudioScheduledSourceNodeMethods for AudioScheduledSourceNode {
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-start
fn Start(&self, when: Finite<f64>) -> Fallible<()> {
if *when < 0. {
return Err(Error::Range("'when' must be a positive value".to_owned()));
}
if self.started.get() || self.stopped.get() {
return Err(Error::InvalidState);
}
@ -99,6 +103,10 @@ impl AudioScheduledSourceNodeMethods for AudioScheduledSourceNode {
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-stop
fn Stop(&self, when: Finite<f64>) -> Fallible<()> {
if *when < 0. {
return Err(Error::Range("'when' must be a positive value".to_owned()));
}
if !self.started.get() {
return Err(Error::InvalidState);
}