diff --git a/src/main.rs b/src/main.rs index b24cf4d..c6a20f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -102,6 +102,9 @@ enum Commands { #[tokio::main] async fn main() -> eyre::Result<()> { + #[cfg(target_os = "android")] + compile_error!("Android Audio API not supported due to threading shenanigans"); + let cli = Args::parse(); if let Some(command) = cli.command { diff --git a/src/player.rs b/src/player.rs index 3f86a1a..fe2a132 100644 --- a/src/player.rs +++ b/src/player.rs @@ -125,6 +125,11 @@ unsafe impl Sync for Player {} impl Player { /// This gets the output stream while also shutting up alsa with [libc]. + /// Uses raw libc calls, and therefore is functional only on Linux. + /// + /// In other words, for the younger generation, we're telling alsa + /// to simply just the audio in the bag, lil api. + #[cfg(target_os = "linux")] fn silent_get_output_stream() -> eyre::Result<(OutputStream, OutputStreamHandle)> { // Get the file descriptor to stderr from libc. extern "C" { @@ -184,13 +189,18 @@ impl Player { // Load the track list. let list = List::load(&args.tracks).await?; - // We should only shut up alsa forcefully if we really have to. - let (_stream, handle) = if cfg!(target_os = "linux") && !args.alternate && !args.debug { + // We should only shut up alsa forcefully on Linux if we really have to. + #[cfg(target_os = "linux")] + let (_stream, handle) = if !args.alternate && !args.debug { Self::silent_get_output_stream()? } else { OutputStream::try_default()? }; + // If we're not on Linux, then there's no problem. + #[cfg(not(target_os = "linux"))] + let (_stream, handle) = OutputStream::try_default()?; + let sink = Sink::try_new(&handle)?; if args.paused { sink.pause();