feat: re-implement pausing mechanism with tick-perfect audio & state pauses

This commit is contained in:
Ryan Walters
2025-09-11 00:03:14 -05:00
parent 8b2d18b3da
commit 08c964c32e
4 changed files with 102 additions and 38 deletions

View File

@@ -31,6 +31,10 @@ pub enum AudioEvent {
PlayDeath,
/// Stop all currently playing sounds
StopAll,
/// Pause all sounds
Pause,
/// Resume all sounds
Resume,
}
/// Non-send resource wrapper for SDL2 audio system
@@ -92,6 +96,22 @@ pub fn audio_system(
debug!("Audio disabled, ignoring stop all request");
}
}
AudioEvent::Pause => {
if !audio.0.is_disabled() {
debug!("Pausing all audio");
audio.0.pause_all();
} else {
debug!("Audio disabled, ignoring pause all request");
}
}
AudioEvent::Resume => {
if !audio.0.is_disabled() {
debug!("Resuming all audio");
audio.0.resume_all();
} else {
debug!("Audio disabled, ignoring resume all request");
}
}
}
}
}