#![forbid(unsafe_code)]

use std::sync::atomic::{AtomicBool, Ordering};

/// Sleep the current thread for 1ms. Used to avoid busy looping
pub(crate) fn wait() {
    std::thread::sleep(std::time::Duration::from_millis(1));
}

// IPC
pub mod client;

// Config
pub mod config;

// Engines
/// Defaults to `false`, if `true`, a shutdown has been requested due to a critical thread returning
pub(crate) static SHUTDOWN: AtomicBool = AtomicBool::new(false);
pub(crate) static STATE_CHANGED: AtomicBool = AtomicBool::new(false);

pub(crate) fn changed_state() {
    STATE_CHANGED.store(true, Ordering::Relaxed);
}

pub mod player;

mod decoder;
mod event_handler;
mod listener;

// Features
#[cfg(feature = "mpris")]
mod mpris;

// Other
mod playlist;

mod shuffle_mode;
pub use shuffle_mode::*;

mod loop_mode;
pub use loop_mode::*;
