mirror of
https://github.com/talwat/lowfi
synced 2025-04-12 05:33:23 +00:00
fix: make wiser use of the cfg macro
This commit is contained in:
parent
b87a525c74
commit
1e491bb36f
@ -102,6 +102,9 @@ enum Commands {
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> eyre::Result<()> {
|
async fn main() -> eyre::Result<()> {
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
compile_error!("Android Audio API not supported due to threading shenanigans");
|
||||||
|
|
||||||
let cli = Args::parse();
|
let cli = Args::parse();
|
||||||
|
|
||||||
if let Some(command) = cli.command {
|
if let Some(command) = cli.command {
|
||||||
|
@ -125,6 +125,11 @@ unsafe impl Sync for Player {}
|
|||||||
|
|
||||||
impl Player {
|
impl Player {
|
||||||
/// This gets the output stream while also shutting up alsa with [libc].
|
/// 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)> {
|
fn silent_get_output_stream() -> eyre::Result<(OutputStream, OutputStreamHandle)> {
|
||||||
// Get the file descriptor to stderr from libc.
|
// Get the file descriptor to stderr from libc.
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -184,13 +189,18 @@ impl Player {
|
|||||||
// Load the track list.
|
// Load the track list.
|
||||||
let list = List::load(&args.tracks).await?;
|
let list = List::load(&args.tracks).await?;
|
||||||
|
|
||||||
// We should only shut up alsa forcefully if we really have to.
|
// We should only shut up alsa forcefully on Linux if we really have to.
|
||||||
let (_stream, handle) = if cfg!(target_os = "linux") && !args.alternate && !args.debug {
|
#[cfg(target_os = "linux")]
|
||||||
|
let (_stream, handle) = if !args.alternate && !args.debug {
|
||||||
Self::silent_get_output_stream()?
|
Self::silent_get_output_stream()?
|
||||||
} else {
|
} else {
|
||||||
OutputStream::try_default()?
|
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)?;
|
let sink = Sink::try_new(&handle)?;
|
||||||
if args.paused {
|
if args.paused {
|
||||||
sink.pause();
|
sink.pause();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user