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

@ -200,10 +200,6 @@ impl AudioBufferSourceNodeMethods for AudioBufferSourceNode {
offset: Option<Finite<f64>>, offset: Option<Finite<f64>>,
duration: Option<Finite<f64>>, duration: Option<Finite<f64>>,
) -> Fallible<()> { ) -> Fallible<()> {
if *when < 0. {
return Err(Error::Range("'when' must be a positive value".to_owned()));
}
if let Some(offset) = offset { if let Some(offset) = offset {
if *offset < 0. { if *offset < 0. {
return Err(Error::Range("'offset' must be a positive value".to_owned())); return Err(Error::Range("'offset' must be a positive value".to_owned()));

View file

@ -59,6 +59,10 @@ impl AudioScheduledSourceNodeMethods for AudioScheduledSourceNode {
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-start // https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-start
fn Start(&self, when: Finite<f64>) -> Fallible<()> { 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() { if self.started.get() || self.stopped.get() {
return Err(Error::InvalidState); return Err(Error::InvalidState);
} }
@ -99,6 +103,10 @@ impl AudioScheduledSourceNodeMethods for AudioScheduledSourceNode {
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-stop // https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-stop
fn Stop(&self, when: Finite<f64>) -> Fallible<()> { 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() { if !self.started.get() {
return Err(Error::InvalidState); return Err(Error::InvalidState);
} }