From 6b85a837491e88d77665578ea68833bc16096194 Mon Sep 17 00:00:00 2001 From: Tal <83217276+talwat@users.noreply.github.com> Date: Wed, 2 Oct 2024 22:58:41 +0200 Subject: [PATCH] fix: only run the hack on linux targets --- src/player.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/player.rs b/src/player.rs index d1f787c..8d95848 100644 --- a/src/player.rs +++ b/src/player.rs @@ -86,8 +86,8 @@ unsafe impl Send for Player {} unsafe impl Sync for Player {} impl Player { - /// This gets the output stream while also shutting up alsa. - fn get_output_stream() -> eyre::Result<(OutputStream, OutputStreamHandle)> { + /// This gets the output stream while also shutting up alsa with [libc]. + fn silent_get_output_stream() -> eyre::Result<(OutputStream, OutputStreamHandle)> { extern "C" { static stderr: *mut libc::FILE; } @@ -110,7 +110,12 @@ impl Player { /// Initializes the entire player, including audio devices & sink. pub async fn new() -> eyre::Result { - let (_stream, handle) = Self::get_output_stream()?; + let (_stream, handle) = if cfg!(target_os = "linux") { + Self::silent_get_output_stream()? + } else { + OutputStream::try_default()? + }; + let sink = Sink::try_new(&handle)?; let player = Self {