avm1: Improve loops treatment in Sound.start
The second argument of Sound.start, loops, can be greater than std::u16::MAX, but previously greater values were treated as 1. Ideally, the solution is to respect those values, but since SoundInfo holds a u16, a short-term solution is to treat them as std::u16::MAX instead.
This commit is contained in:
parent
b76d76d244
commit
989bfb8f3e
|
@ -378,11 +378,8 @@ fn start<'gc>(
|
||||||
.unwrap_or(&Value::Number(1.0))
|
.unwrap_or(&Value::Number(1.0))
|
||||||
.coerce_to_f64(activation)?;
|
.coerce_to_f64(activation)?;
|
||||||
|
|
||||||
let loops = if loops >= 1.0 && loops <= f64::from(std::i16::MAX) {
|
// TODO: Handle loops > std::u16::MAX.
|
||||||
loops as u16
|
let loops = (loops as u16).max(1);
|
||||||
} else {
|
|
||||||
1
|
|
||||||
};
|
|
||||||
|
|
||||||
use swf::{SoundEvent, SoundInfo};
|
use swf::{SoundEvent, SoundInfo};
|
||||||
if let Some(sound_object) = this.as_sound_object() {
|
if let Some(sound_object) = this.as_sound_object() {
|
||||||
|
|
Loading…
Reference in New Issue