Compare commits

..

2 Commits

Author SHA1 Message Date
csd4ni3l
ff71f6f21a Fix currently_playing push not working on Windows because normal_sink is in a different scope 2026-02-05 20:24:50 +01:00
csd4ni3l
ca6fc96f99 Fix some windows compilation issues 2026-02-05 20:04:32 +01:00
2 changed files with 21 additions and 7 deletions

View File

@@ -81,6 +81,12 @@ fn create_virtual_mic() -> SoundSystem {
.expect("Unable to open device") .expect("Unable to open device")
.open_stream() .open_stream()
.expect("Failed to open stream"), .expect("Failed to open stream"),
// this is actually not needed here, since windows would exit by far. But, cargo doesnt like SoundSystem not getting the normal_output stream so...
#[cfg(target_os = "windows")]
normal_output_stream: OutputStreamBuilder::from_device(device)
.expect("Unable to open device")
.open_stream()
.expect("Failed to open stream"),
paused: false, paused: false,
} }
} }
@@ -227,24 +233,31 @@ 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")]
{ {
let file2 = File::open(&file_path).unwrap(); let file2 = File::open(&file_path).unwrap();
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());
sink2.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
}) })
} }
@@ -264,6 +277,7 @@ fn ui_system(mut contexts: EguiContexts, mut app_state: ResMut<AppState>) -> Res
let available_height = ui.available_height(); let available_height = ui.available_height();
let outputs = app_state.virt_outputs.clone(); let outputs = app_state.virt_outputs.clone();
#[allow(unused_mut)]
let mut mic_name = "Select inside apps".to_string(); let mut mic_name = "Select inside apps".to_string();
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]

View File

@@ -8,7 +8,7 @@ pub fn create_virtual_mic_windows() -> (OutputStream, OutputStream) {
}).unwrap_or(false) }).unwrap_or(false)
}).expect("Could not get default output device"); }).expect("Could not get default output device");
normal_output = host.default_output_device().expect("Could not get default output device"); let normal_output = host.default_output_device().expect("Could not get default output device");
return (OutputStreamBuilder::from_device(normal_output).expect("Unable to open default audio device").open_stream().expect("Failed to open stream"), OutputStreamBuilder::from_device(virtual_mic).expect("Unable to open default audio device").open_stream().expect("Failed to open stream")); return (OutputStreamBuilder::from_device(normal_output).expect("Unable to open default audio device").open_stream().expect("Failed to open stream"), OutputStreamBuilder::from_device(virtual_mic).expect("Unable to open default audio device").open_stream().expect("Failed to open stream"));
} }