From b10bc7b4fd59478da60b1d3faaf340b9626f6173 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Wed, 18 Aug 2021 16:34:26 -0500 Subject: [PATCH] chore(main): add flag that enables audio --- src/main.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 06b2d29..360a589 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,7 @@ use winit::window::{Window, WindowBuilder}; use winit_input_helper::WinitInputHelper; const WINDOW_SCALE: f64 = 2.0; +const AUDIO_ENABLED: bool = true; fn main() -> Result<()> { let app = App::new(crate_name!()) @@ -63,16 +64,18 @@ fn main() -> Result<()> { }; // Initialize Audio - let spsc: AudioSPSC = Default::default(); - let (prod, cons) = spsc.init(); - let (_stream, stream_handle) = OutputStream::try_default().expect("Initialized Audio"); - let sink = Sink::try_new(&stream_handle)?; - sink.append(cons); - game_boy.apu_mut().attach_producer(prod); + if AUDIO_ENABLED { + let spsc: AudioSPSC = Default::default(); + let (prod, cons) = spsc.init(); + let (_stream, stream_handle) = OutputStream::try_default().expect("Initialized Audio"); + let sink = Sink::try_new(&stream_handle)?; + sink.append(cons); + game_boy.apu_mut().attach_producer(prod); - std::thread::spawn(move || { - sink.sleep_until_end(); - }); + std::thread::spawn(move || { + sink.sleep_until_end(); + }); + } let mut start = Instant::now(); let frame_time = Duration::from_secs_f64(1.0 / 59.73); // 59.73 Hz on Host