Fix currently_playing push not working on Windows because normal_sink is in a different scope

This commit is contained in:
csd4ni3l
2026-02-05 20:24:50 +01:00
parent ca6fc96f99
commit ff71f6f21a

View File

@@ -233,7 +233,9 @@ fn play_sound(file_path: String, app_state: &mut AppState) {
.total_duration() .total_duration()
.expect("Could not get source duration") .expect("Could not get source duration")
.as_secs_f32(); .as_secs_f32();
sink.append(src); sink.append(src);
sink.play();
#[cfg(target_os = "windows")] #[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 src2 = Decoder::new(BufReader::new(file2)).unwrap();
let normal_sink = Sink::connect_new(&app_state.sound_system.normal_output_stream.mixer()); let normal_sink = Sink::connect_new(&app_state.sound_system.normal_output_stream.mixer());
normal_sink.append(src2); 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 { app_state.currently_playing.push(PlayingSound {
file_path: file_path.clone(), file_path: file_path.clone(),
length, length,
sink, sink
#[cfg(target_os = "windows")]
normal_sink
}) })
} }