Fixes from owner testing of the Slice 9 playback test: - No audio: removed the incomplete reinit_device(node) that routed output to the selected DAC (the proper switch is set_output_device -> reload_settings -> reinit; doing it half-way broke playback). The test now plays through the current output; route QBZ to the DAC under test in Settings > Audio. - Bit-perfect read-back: dropped the pw-top panel (batch snapshot never reflected the live nodes) and enriched the N6 read-back to show the DAC's real /proc/asound hw_params — rate + ALSA container format (S32_LE etc.) + channels. That container format is the bit-perfect proof. Probe scans for the actively playing card, so it's DAC-agnostic (answers the multi-DAC case: one output at a time). - Track jump: clicking a test row now re-sets the queue at that index via the working play_tracks path (play_index alone only moved the pointer). Resolved tracks are stashed for this. - "Use my own music" button: starts the read-back + resumes the user's own queue for those who don't want the curated tracks. - Row hover no longer changes the row height (fixed-size glyph slot; the ♪->▶ swap can't reflow what's below). cc
106 lines
4.1 KiB
Rust
106 lines
4.1 KiB
Rust
//! QBZ Audio - Audio backend system for bit-perfect playback
|
|
//!
|
|
//! This crate provides the audio backend abstraction layer:
|
|
//! - Backend trait and implementations (PipeWire, ALSA, PulseAudio)
|
|
//! - Audio device enumeration and selection
|
|
//! - Loudness analysis and normalization
|
|
//! - Diagnostic tools
|
|
//!
|
|
//! # CRITICAL: This code is IMMUTABLE
|
|
//!
|
|
//! The audio backend system was carefully designed for bit-perfect playback.
|
|
//! Do NOT modify the logic in these files without understanding the full
|
|
//! architecture. See `qbz-nix-docs/AUDIO_BACKENDS.md` for details.
|
|
//!
|
|
//! # Architecture
|
|
//!
|
|
//! ```text
|
|
//! ┌─────────────────────────────────────────────────────────────┐
|
|
//! │ qbz-audio (Tier 1) │
|
|
//! │ Audio backends, device management, loudness analysis │
|
|
//! └─────────────────────────────────────────────────────────────┘
|
|
//! ↑
|
|
//! ┌───────┴───────┐
|
|
//! │ qbz-models │
|
|
//! │ (Tier 0) │
|
|
//! └───────────────┘
|
|
//! ```
|
|
|
|
pub mod backend;
|
|
#[cfg(target_os = "linux")]
|
|
pub mod pipewire_backend;
|
|
#[cfg(target_os = "linux")]
|
|
pub mod alsa_backend;
|
|
#[cfg(target_os = "linux")]
|
|
pub mod alsa_error_handler;
|
|
#[cfg(target_os = "linux")]
|
|
pub mod pulse_backend;
|
|
#[cfg(target_os = "linux")]
|
|
pub mod jack_backend;
|
|
pub mod alsa_direct;
|
|
pub mod coreaudio_direct;
|
|
pub mod dac_capabilities;
|
|
pub mod dac_probe;
|
|
pub mod health;
|
|
pub mod analysis;
|
|
pub mod analyzer_tap;
|
|
pub mod device_filter;
|
|
pub mod device_reservation;
|
|
pub mod diagnostic;
|
|
pub mod dynamic_amplify;
|
|
pub mod loudness;
|
|
pub mod loudness_analyzer;
|
|
pub mod loudness_cache;
|
|
pub mod network_throttle;
|
|
pub mod output_sinks;
|
|
pub mod settings;
|
|
pub mod visualizer;
|
|
|
|
// Re-export commonly used types
|
|
#[cfg(target_os = "linux")]
|
|
pub use alsa_backend::{
|
|
device_supports_sample_rate, get_device_supported_rates, normalize_device_id_to_stable,
|
|
resolve_stable_to_current_hw,
|
|
};
|
|
pub use alsa_direct::AlsaDirectStream;
|
|
#[cfg(target_os = "linux")]
|
|
pub use jack_backend::JackStream;
|
|
pub use analysis::SpectralAnalyzer;
|
|
pub use analyzer_tap::{AnalyzerMessage, AnalyzerTap};
|
|
pub use backend::{
|
|
AlsaDirectError, AlsaPlugin, AudioBackend, AudioBackendType, AudioDevice, BackendConfig,
|
|
BackendManager, BackendResult, BitPerfectMode,
|
|
};
|
|
pub use coreaudio_direct::CoreAudioExclusiveGuard;
|
|
pub use dac_capabilities::{query_dac_capabilities, DacCapabilities};
|
|
pub use dac_probe::{negotiated_active_rate, negotiated_stream_rate, NegotiatedRate};
|
|
pub use health::{
|
|
audio_stack_health, detect_distro, detect_init, detect_sandbox, AudioStackHealth, Distro,
|
|
InitSystem, Sandbox,
|
|
};
|
|
pub use device_reservation::{DeviceReservation, ReservationError};
|
|
pub use diagnostic::{AudioDiagnostic, BitDepthResult, DiagnosticSource};
|
|
pub use dynamic_amplify::DynamicAmplify;
|
|
pub use loudness::{calculate_gain_factor, db_to_linear, extract_replaygain, ReplayGainData};
|
|
pub use loudness_analyzer::LoudnessAnalyzer;
|
|
pub use loudness_cache::LoudnessCache;
|
|
pub use output_sinks::{list_output_sinks, OutputSinkInfo};
|
|
pub use settings::AudioSettings;
|
|
pub use visualizer::{RingBuffer, TappedSource, VisualizerTap};
|
|
|
|
/// Stub: returns the ID unchanged on non-Linux (no ALSA normalization needed).
|
|
#[cfg(not(target_os = "linux"))]
|
|
pub fn normalize_device_id_to_stable(id: &str) -> String { id.to_string() }
|
|
|
|
/// Stub: no ALSA device resolution on non-Linux.
|
|
#[cfg(not(target_os = "linux"))]
|
|
pub fn resolve_stable_to_current_hw(_stable: &str) -> Option<String> { None }
|
|
|
|
/// Stub: no ALSA sample rate probing on non-Linux.
|
|
#[cfg(not(target_os = "linux"))]
|
|
pub fn device_supports_sample_rate(_device_id: &str, _sample_rate: u32) -> Option<bool> { None }
|
|
|
|
/// Stub: no ALSA rate enumeration on non-Linux.
|
|
#[cfg(not(target_os = "linux"))]
|
|
pub fn get_device_supported_rates(_device_id: &str) -> Option<Vec<u32>> { None }
|