// On Windows, suppress the extra console window for release GUI builds while
// keeping it in debug builds so stderr/panics stay visible during development.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

fn main() {
    // Tag the audio we play through ALSA (rodio's `ClipPlayer`: chat clips,
    // peer music, local playlist tracks) so the screen-share exclusion engine
    // can recognise it as ours and refuse to fan it back to the far end.
    //
    // First statement in the program, and that is load-bearing: this sets an
    // environment variable, which is only sound while the process is still
    // single-threaded, and PipeWire's ALSA plugin reads it when a stream is
    // opened. See `audio::ownership::tag_this_process_alsa_audio`.
    //
    // SAFETY: nothing has been spawned yet, so no thread can be reading the
    // environment concurrently.
    #[cfg(target_os = "linux")]
    unsafe {
        peerspeak::audio::ownership::tag_this_process_alsa_audio()
    };

    if let Err(e) = peerspeak::app::run_gui() {
        eprintln!("Error running GUI: {:?}", e);
    }
}
