From ff71f6f21a18ab3d9b5528c843dc947e95b2fd8b Mon Sep 17 00:00:00 2001 From: csd4ni3l Date: Thu, 5 Feb 2026 20:24:50 +0100 Subject: [PATCH] Fix currently_playing push not working on Windows because normal_sink is in a different scope --- src/main.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index b60d448..981e2de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -233,7 +233,9 @@ fn play_sound(file_path: String, app_state: &mut AppState) { .total_duration() .expect("Could not get source duration") .as_secs_f32(); + sink.append(src); + sink.play(); #[cfg(target_os = "windows")] { @@ -241,16 +243,21 @@ fn play_sound(file_path: String, app_state: &mut AppState) { let src2 = Decoder::new(BufReader::new(file2)).unwrap(); let normal_sink = Sink::connect_new(&app_state.sound_system.normal_output_stream.mixer()); normal_sink.append(src2); - } - sink.play(); + app_state.currently_playing.push(PlayingSound { + file_path: file_path.clone(), + length, + sink, + normal_sink + }); + + return; + } app_state.currently_playing.push(PlayingSound { file_path: file_path.clone(), length, - sink, - #[cfg(target_os = "windows")] - normal_sink + sink }) }