add audio queue playing into the base main_loop wrapper

This commit is contained in:
Gered 2023-02-27 15:14:30 -05:00
parent a6f2d43009
commit 43333687a8

View file

@ -124,6 +124,7 @@
use thiserror::Error; use thiserror::Error;
use crate::audio::*;
use crate::events::*; use crate::events::*;
use crate::states::*; use crate::states::*;
use crate::system::*; use crate::system::*;
@ -176,6 +177,9 @@ pub enum MainLoopError {
#[error("System error: {0}")] #[error("System error: {0}")]
SystemError(#[from] SystemError), SystemError(#[from] SystemError),
#[error("AudioDevice error: {0}")]
AudioDeviceError(#[from] AudioDeviceError),
} }
pub fn main_loop<ContextType, State>( pub fn main_loop<ContextType, State>(
@ -194,6 +198,7 @@ where
while !app.core().system_mut().do_events() && !states.is_empty() { while !app.core().system_mut().do_events() && !states.is_empty() {
last_ticks = app.core().update_frame_delta(last_ticks); last_ticks = app.core().update_frame_delta(last_ticks);
states.update(&mut app)?; states.update(&mut app)?;
app.core().system_mut().apply_audio_queue()?;
states.render(&mut app); states.render(&mut app);
app.core().system_mut().display()?; app.core().system_mut().display()?;
} }