mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Throw if time given to AudioScheduledSourceNode.stop is negative
This commit is contained in:
parent
bbc3565900
commit
bc6586a9d0
2 changed files with 8 additions and 4 deletions
|
@ -200,10 +200,6 @@ impl AudioBufferSourceNodeMethods for AudioBufferSourceNode {
|
|||
offset: Option<Finite<f64>>,
|
||||
duration: Option<Finite<f64>>,
|
||||
) -> Fallible<()> {
|
||||
if *when < 0. {
|
||||
return Err(Error::Range("'when' must be a positive value".to_owned()));
|
||||
}
|
||||
|
||||
if let Some(offset) = offset {
|
||||
if *offset < 0. {
|
||||
return Err(Error::Range("'offset' must be a positive value".to_owned()));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue