diff --git a/src/audio.rs b/src/audio.rs index a9fb2b4..00f45b4 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -185,13 +185,13 @@ impl Audio { /// Automatically rotates through the four eating sound assets. The sound plays on channel 0 and the internal sound index /// advances to the next variant. Silently returns if audio is disabled, muted, /// or no sounds were loaded successfully. - pub fn eat(&mut self) { + pub fn waka(&mut self) { if self.disabled || self.muted || self.sounds.is_empty() { return; } if let Some(chunk) = self.sounds.get(&Sound::Waka(self.next_waka_index)) { - match mixer::Channel(0).play(chunk, 0) { + match mixer::Channel::all().play(chunk, 0) { Ok(channel) => { tracing::trace!("Playing sound #{} on channel {:?}", self.next_waka_index + 1, channel); } @@ -203,14 +203,14 @@ impl Audio { self.next_waka_index = (self.next_waka_index + 1) & 3; } - /// Plays the death sound effect. - pub fn death(&mut self) { + /// Plays the provided sound effect once. + pub fn play(&mut self, sound: Sound) { if self.disabled || self.muted { return; } - if let Some(chunk) = self.sounds.get(&Sound::PacmanDeath) { - mixer::Channel::all().play(chunk, 0).ok(); + if let Some(chunk) = self.sounds.get(&sound) { + let _ = mixer::Channel::all().play(chunk, 0); } } diff --git a/src/systems/audio.rs b/src/systems/audio.rs index b2ad2b3..b2b337b 100644 --- a/src/systems/audio.rs +++ b/src/systems/audio.rs @@ -64,7 +64,7 @@ pub fn audio_system( AudioEvent::PlayEat => { if !audio.0.is_disabled() && !audio_state.muted { trace!(sound_index = audio_state.sound_index, "Playing eat sound"); - audio.0.eat(); + audio.0.waka(); // Update the sound index for cycling through sounds audio_state.sound_index = (audio_state.sound_index + 1) % 4; // 4 eat sounds available @@ -79,7 +79,7 @@ pub fn audio_system( AudioEvent::PlayDeath => { if !audio.0.is_disabled() && !audio_state.muted { trace!("Playing death sound"); - audio.0.death(); + audio.0.play(crate::audio::Sound::PacmanDeath); } else { debug!( disabled = audio.0.is_disabled(),