Skip to content

Commit

Permalink
avm1: Improve loops treatment in Sound.start
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
relrelb authored and Herschel committed Dec 6, 2020
1 parent b76d76d commit 989bfb8
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions core/src/avm1/globals/sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,8 @@ fn start<'gc>(
.unwrap_or(&Value::Number(1.0))
.coerce_to_f64(activation)?;

let loops = if loops >= 1.0 && loops <= f64::from(std::i16::MAX) {
loops as u16
} else {
1
};
// TODO: Handle loops > std::u16::MAX.
let loops = (loops as u16).max(1);

use swf::{SoundEvent, SoundInfo};
if let Some(sound_object) = this.as_sound_object() {
Expand Down

0 comments on commit 989bfb8

Please sign in to comment.