diff --git a/crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po index 39eabbd7c..043424911 100644 --- a/crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po @@ -4339,3 +4339,19 @@ msgstr "DSD: {}" msgid "Cannot play DSD file" msgstr "DSD-Datei kann nicht wiedergegeben werden" + +# DSD Phases 2-3: delivery mode (2026-07-03) +msgid "DSD playback" +msgstr "DSD-Wiedergabe" + +msgid "How DSD tracks reach the DAC. WARNING: choose DoP or Native only if your DAC supports it — on any other DAC they play as loud noise. Volume is fixed and seeking is disabled in DoP/Native mode. Native additionally needs kernel support for the DAC." +msgstr "Wie DSD-Titel den DAC erreichen. WARNUNG: DoP oder Nativ nur wählen, wenn der DAC es unterstützt — auf jedem anderen DAC wird lautes Rauschen wiedergegeben. Lautstärke ist fest und Suchen ist im DoP/Nativ-Modus deaktiviert. Nativ erfordert zusätzlich Kernel-Unterstützung für den DAC." + +msgid "Convert to PCM (works everywhere)" +msgstr "Zu PCM konvertieren (funktioniert überall)" + +msgid "DoP — DSD over PCM (bit-perfect)" +msgstr "DoP — DSD über PCM (bit-perfekt)" + +msgid "Native DSD (kernel support required)" +msgstr "Natives DSD (Kernel-Unterstützung erforderlich)" diff --git a/crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po index 958853ab3..67dc45113 100644 --- a/crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po @@ -4369,3 +4369,19 @@ msgstr "DSD: {}" msgid "Cannot play DSD file" msgstr "No se puede reproducir el archivo DSD" + +# DSD Phases 2-3: delivery mode (2026-07-03) +msgid "DSD playback" +msgstr "Reproducción DSD" + +msgid "How DSD tracks reach the DAC. WARNING: choose DoP or Native only if your DAC supports it — on any other DAC they play as loud noise. Volume is fixed and seeking is disabled in DoP/Native mode. Native additionally needs kernel support for the DAC." +msgstr "Cómo llegan las pistas DSD al DAC. ADVERTENCIA: elige DoP o Nativo solo si tu DAC lo soporta — en cualquier otro DAC se reproducen como ruido fuerte. El volumen queda fijo y la búsqueda se desactiva en modo DoP/Nativo. Nativo además requiere soporte del kernel para el DAC." + +msgid "Convert to PCM (works everywhere)" +msgstr "Convertir a PCM (funciona en todos lados)" + +msgid "DoP — DSD over PCM (bit-perfect)" +msgstr "DoP — DSD sobre PCM (bit-perfect)" + +msgid "Native DSD (kernel support required)" +msgstr "DSD nativo (requiere soporte del kernel)" diff --git a/crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po index ae3922888..40e4a99cc 100644 --- a/crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po @@ -4339,3 +4339,19 @@ msgstr "DSD: {}" msgid "Cannot play DSD file" msgstr "Impossible de lire le fichier DSD" + +# DSD Phases 2-3: delivery mode (2026-07-03) +msgid "DSD playback" +msgstr "Lecture DSD" + +msgid "How DSD tracks reach the DAC. WARNING: choose DoP or Native only if your DAC supports it — on any other DAC they play as loud noise. Volume is fixed and seeking is disabled in DoP/Native mode. Native additionally needs kernel support for the DAC." +msgstr "Comment les pistes DSD atteignent le DAC. ATTENTION : ne choisissez DoP ou Natif que si votre DAC le prend en charge — sur tout autre DAC, cela produit un bruit fort. Le volume est fixe et la recherche est désactivée en mode DoP/Natif. Le mode Natif nécessite en plus la prise en charge du noyau pour le DAC." + +msgid "Convert to PCM (works everywhere)" +msgstr "Convertir en PCM (fonctionne partout)" + +msgid "DoP — DSD over PCM (bit-perfect)" +msgstr "DoP — DSD sur PCM (bit-perfect)" + +msgid "Native DSD (kernel support required)" +msgstr "DSD natif (prise en charge du noyau requise)" diff --git a/crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po index 009eac4f0..81f3a0755 100644 --- a/crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po @@ -4328,3 +4328,19 @@ msgstr "DSD: {}" msgid "Cannot play DSD file" msgstr "DSDファイルを再生できません" + +# DSD Phases 2-3: delivery mode (2026-07-03) +msgid "DSD playback" +msgstr "DSD再生" + +msgid "How DSD tracks reach the DAC. WARNING: choose DoP or Native only if your DAC supports it — on any other DAC they play as loud noise. Volume is fixed and seeking is disabled in DoP/Native mode. Native additionally needs kernel support for the DAC." +msgstr "DSDトラックをDACへ送る方法。警告:DACが対応している場合のみDoPまたはネイティブを選択してください。対応していないDACでは大きなノイズとして再生されます。DoP/ネイティブモード中は音量が固定され、シークは無効になります。ネイティブはさらにDAC用のカーネルサポートが必要です。" + +msgid "Convert to PCM (works everywhere)" +msgstr "PCMに変換(すべての環境で動作)" + +msgid "DoP — DSD over PCM (bit-perfect)" +msgstr "DoP — PCM上のDSD(ビットパーフェクト)" + +msgid "Native DSD (kernel support required)" +msgstr "ネイティブDSD(カーネルサポートが必要)" diff --git a/crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po index a609048fd..8f17c1eea 100644 --- a/crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po @@ -4339,3 +4339,19 @@ msgstr "DSD: {}" msgid "Cannot play DSD file" msgstr "Não é possível reproduzir o ficheiro DSD" + +# DSD Phases 2-3: delivery mode (2026-07-03) +msgid "DSD playback" +msgstr "Reprodução DSD" + +msgid "How DSD tracks reach the DAC. WARNING: choose DoP or Native only if your DAC supports it — on any other DAC they play as loud noise. Volume is fixed and seeking is disabled in DoP/Native mode. Native additionally needs kernel support for the DAC." +msgstr "Como as faixas DSD chegam ao DAC. AVISO: escolha DoP ou Nativo apenas se o seu DAC o suportar — em qualquer outro DAC reproduzem-se como ruído alto. O volume fica fixo e a procura é desativada no modo DoP/Nativo. O Nativo requer ainda suporte do kernel para o DAC." + +msgid "Convert to PCM (works everywhere)" +msgstr "Converter para PCM (funciona em todo o lado)" + +msgid "DoP — DSD over PCM (bit-perfect)" +msgstr "DoP — DSD sobre PCM (bit-perfect)" + +msgid "Native DSD (kernel support required)" +msgstr "DSD nativo (requer suporte do kernel)" diff --git a/crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po index ed85a9c39..5dbe602e2 100644 --- a/crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po @@ -4352,3 +4352,19 @@ msgstr "DSD: {}" msgid "Cannot play DSD file" msgstr "Не удаётся воспроизвести файл DSD" + +# DSD Phases 2-3: delivery mode (2026-07-03) +msgid "DSD playback" +msgstr "Воспроизведение DSD" + +msgid "How DSD tracks reach the DAC. WARNING: choose DoP or Native only if your DAC supports it — on any other DAC they play as loud noise. Volume is fixed and seeking is disabled in DoP/Native mode. Native additionally needs kernel support for the DAC." +msgstr "Как DSD-треки попадают на ЦАП. ВНИМАНИЕ: выбирайте DoP или Native только если ваш ЦАП это поддерживает — на любом другом ЦАПе это воспроизводится как громкий шум. Громкость фиксирована, перемотка отключена в режиме DoP/Native. Native дополнительно требует поддержки ядра для ЦАПа." + +msgid "Convert to PCM (works everywhere)" +msgstr "Конвертировать в PCM (работает везде)" + +msgid "DoP — DSD over PCM (bit-perfect)" +msgstr "DoP — DSD поверх PCM (бит-перфект)" + +msgid "Native DSD (kernel support required)" +msgstr "Нативный DSD (требуется поддержка ядра)" diff --git a/crates/qbz-ui/ui/settings/AudioSettings.slint b/crates/qbz-ui/ui/settings/AudioSettings.slint index f108c9186..697c2bb8a 100644 --- a/crates/qbz-ui/ui/settings/AudioSettings.slint +++ b/crates/qbz-ui/ui/settings/AudioSettings.slint @@ -180,6 +180,23 @@ export component AudioSettings inherits VerticalLayout { } } } + // DSD delivery (DSD plan Phases 2-3). DoP/native support is NOT + // detectable up front, so the warning lives permanently in the row copy; + // the default (Convert) works on every DAC. ALSA-direct only — any + // mixing/resampling path would corrupt the DSD stream. + if SettingsState.backend-is-alsa: SettingRow { + label: @tr("DSD playback"); + description: @tr("How DSD tracks reach the DAC. WARNING: choose DoP or Native only if your DAC supports it — on any other DAC they play as loud noise. Volume is fixed and seeking is disabled in DoP/Native mode. Native additionally needs kernel support for the DAC."); + QbzSelect { + menu-width: 280px; + options: SettingsState.dsd-modes; + current-index: SettingsState.dsd-mode-index; + selected(i) => { + SettingsState.dsd-mode-index = i; + root.settings-select("dsd-mode", i); + } + } + } Rectangle { height: 12px; } Divider { } diff --git a/crates/qbz-ui/ui/state.slint b/crates/qbz-ui/ui/state.slint index c04e40bfc..71106e6e8 100644 --- a/crates/qbz-ui/ui/state.slint +++ b/crates/qbz-ui/ui/state.slint @@ -2801,6 +2801,10 @@ export global SettingsState { // Audio — toggles. in-out property limit-quality-to-device: false; in-out property alsa-hardware-volume: false; + // DSD delivery mode (DSD plan Phases 2-3): Convert to PCM / DoP / + // Native DSD. Only meaningful on the ALSA direct backend. + in-out property <[string]> dsd-modes: []; + in-out property dsd-mode-index: 0; in-out property exclusive-mode: false; in-out property reserve-dac: false; in-out property dac-passthrough: false; diff --git a/crates/qbz/Cargo.toml b/crates/qbz/Cargo.toml index 22ab0b645..652a56a5a 100644 --- a/crates/qbz/Cargo.toml +++ b/crates/qbz/Cargo.toml @@ -79,6 +79,7 @@ qconnect-transport-ws = { path = "../qconnect-transport-ws" } futures-util = { workspace = true } uuid = { version = "1", features = ["v4"] } qbz-library = { path = "../qbz-library" } +qbz-dsd = { path = "../qbz-dsd" } qbz-plex = { path = "../qbz-plex" } qbz-offline-cache = { path = "../qbz-offline-cache" } qbz-models = { path = "../qbz-models" } diff --git a/crates/qbz/src/local_library.rs b/crates/qbz/src/local_library.rs index 59042b487..04d931bf1 100644 --- a/crates/qbz/src/local_library.rs +++ b/crates/qbz/src/local_library.rs @@ -158,6 +158,12 @@ fn local_quality(bit_depth: Option, sample_rate_hz: f64) -> (String, String let Some(bd) = bit_depth else { return (String::new(), String::new()); }; + // DSD tracks store bit_depth = 1 and the DSD bit rate as sample_rate. + if bd == 1 { + let label = crate::quality::dsd_multiple_label(Some(sample_rate_hz)); + let tooltip = qbz_i18n::t_args("DSD: {}", &[&label]); + return (label, tooltip); + } let khz = if sample_rate_hz >= 1000.0 { sample_rate_hz / 1000.0 } else { diff --git a/crates/qbz/src/playback.rs b/crates/qbz/src/playback.rs index 071787c31..147f18654 100644 --- a/crates/qbz/src/playback.rs +++ b/crates/qbz/src/playback.rs @@ -635,6 +635,42 @@ async fn play_local_file_audible( clear_loading(weak, row_id); return; }; + // DSD (.dsf/.dff): converted to PCM on the fly by the player (qbz-dsd + // Phase 1) — streamed from disk, never slurped through play_data. Errors + // here are expected user-facing cases (DST-compressed DFF, >2ch) → toast + // + stop, the queue stays usable. + if qbz_dsd::is_dsd_path(std::path::Path::new(&path)) { + let exists_path = path.clone(); + let exists = tokio::task::spawn_blocking(move || { + std::path::Path::new(&exists_path).exists() + }) + .await + .unwrap_or(false); + if !exists { + log::error!("[qbz-slint] local play: DSD file not available at {path}"); + crate::toast::show_weak( + weak, + qbz_i18n::t("File not available — is the drive mounted?"), + crate::ToastKind::Warning, + ); + clear_loading(weak, row_id); + return; + } + if let Err(e) = runtime + .core() + .player() + .play_dsd_file(std::path::PathBuf::from(&path), row_id) + { + log::error!("[qbz-slint] local play: play_dsd_file {row_id} failed: {e}"); + crate::toast::show_weak( + weak, + format!("{}: {e}", qbz_i18n::t("Cannot play DSD file")), + crate::ToastKind::Warning, + ); + clear_loading(weak, row_id); + } + return; + } // PLAYBACK LOCK (owner verdict 2026-06-10): the library never hides // network-folder content, so an unmounted drive surfaces HERE — one cheap // `Path::exists()` stat before the read, with friendly feedback instead @@ -1543,7 +1579,10 @@ pub(crate) async fn refresh_now_playing_meta(runtime: &Runtime, weak: &slint::We let preview_artwork = track.artwork_ref_with_plex(&plex.base_url, &plex.token, Some(1000)); // Quality badge: tier from bit depth (24-bit+ = Hi-Res), exact detail line // reused from the shared formatter so it matches the track-row badges. + // bit_depth == 1 marks DSD (1-bit stream, sample_rate = DSD bit rate) — + // the generic detail would read "1-bit / 2.8224 kHz". let quality_tier = match track.bit_depth { + Some(1) => "hires", Some(d) if d >= 24 => "hires", Some(_) => "cd", None if track.hires => "hires", @@ -1551,6 +1590,8 @@ pub(crate) async fn refresh_now_playing_meta(runtime: &Runtime, weak: &slint::We }; let quality_detail = if quality_tier.is_empty() { String::new() + } else if track.bit_depth == Some(1) { + crate::quality::dsd_multiple_label(track.sample_rate) } else { crate::quality::detail(track.bit_depth, track.sample_rate) }; @@ -4088,6 +4129,59 @@ pub fn start_poll_loop( } } }); + } else if next.id != track_id && next.is_local { + // LOCAL gapless (DSD plan Phase 2): resolve the file + // path and hand it to the engine's gapless queue — + // DSD goes through play_next_dsd (DoP append when a + // DoP stream is live, else an in-memory converted + // WAV); other local formats feed their raw bytes to + // the normal play_next. CUE virtual tracks are + // skipped (they share one album image file). + gapless_requested_for = track_id; + let runtime = runtime.clone(); + let next_id = next.id; + tokio::spawn(async move { + let info = if crate::ephemeral::is_ephemeral_id(next_id as i64) { + crate::ephemeral::get_track(next_id as i64) + .map(|t| (t.file_path, t.cue_start_secs)) + } else { + tokio::task::spawn_blocking(move || { + crate::library_db::with_db(|db| db.get_track(next_id as i64)) + }) + .await + .ok() + .flatten() + .flatten() + .map(|t| (t.file_path, t.cue_start_secs)) + }; + let Some((path, cue)) = info else { return }; + if cue.is_some() { + return; + } + let rt2 = runtime.clone(); + let res = tokio::task::spawn_blocking(move || { + let p = std::path::PathBuf::from(&path); + let player = rt2.core().player(); + if qbz_dsd::is_dsd_path(&p) { + player.play_next_dsd(p, next_id) + } else { + let bytes = std::fs::read(&p).map_err(|e| e.to_string())?; + player.play_next(bytes, next_id) + } + }) + .await; + match res { + Ok(Ok(())) => log::info!( + "[qbz-slint] [GAPLESS] queued local track {next_id} for gapless" + ), + Ok(Err(e)) => log::info!( + "[qbz-slint] [GAPLESS] local pre-queue {next_id} skipped: {e}" + ), + Err(e) => log::warn!( + "[qbz-slint] [GAPLESS] local pre-queue task failed: {e}" + ), + } + }); } } } diff --git a/crates/qbz/src/quality.rs b/crates/qbz/src/quality.rs index 730d16392..5cb9326b2 100644 --- a/crates/qbz/src/quality.rs +++ b/crates/qbz/src/quality.rs @@ -36,9 +36,28 @@ pub fn is_lossless_format(format: &str) -> bool { ) } +/// DSD container/format names. +pub fn is_dsd_format(format: &str) -> bool { + matches!( + format.trim().to_ascii_lowercase().as_str(), + "dsd" | "dsf" | "dff" + ) +} + +/// "DSD64" / "DSD128" / … from the DSD bit rate. Accepts Hz (2 822 400) or +/// kHz (2 822.4) — some surfaces normalize the stored rate to kHz upstream. +pub fn dsd_multiple_label(sample_rate: Option) -> String { + let hz = match sample_rate { + Some(r) if r >= 1_000_000.0 => r, + Some(r) if r >= 1_000.0 => r * 1000.0, + _ => return "DSD".to_string(), + }; + format!("DSD{}", ((hz / 2_822_400.0).round() as u32).saturating_mul(64)) +} + /// Badge tier from a container/codec + (possibly-unknown) max bit depth: /// - `"mp3"` lossy -/// - `"hires"` >= 24-bit +/// - `"hires"` >= 24-bit (and DSD, whose nominal depth is 1 bit) /// - `"cd"` known bit depth < 24 /// - `"lossless"` bit depth UNKNOWN but the container IS lossless (un-hydrated /// Plex FLAC etc.) — show the filetype; better than no badge at all @@ -47,6 +66,9 @@ pub fn tier(format: &str, bit_depth: Option) -> &'static str { if format.trim().eq_ignore_ascii_case("mp3") { return "mp3"; } + if is_dsd_format(format) { + return "hires"; + } match bit_depth { Some(b) if b >= 24 => "hires", Some(_) => "cd", @@ -69,6 +91,16 @@ pub fn badge( bit_depth: Option, sample_rate: Option, ) -> (&'static str, String, String) { + // DSD first: nominal depth is 1 bit and sample_rate is the DSD bit rate, + // so the generic detail would read "1-bit / 2822.4 kHz". + if is_dsd_format(format) { + let label = dsd_multiple_label(sample_rate); + return ( + "hires", + label.clone(), + qbz_i18n::t_args("DSD: {}", &[&label]), + ); + } let t = tier(format, bit_depth); match t { "" | "mp3" => (t, String::new(), String::new()), diff --git a/crates/qbz/src/settings.rs b/crates/qbz/src/settings.rs index e0598df06..63889e089 100644 --- a/crates/qbz/src/settings.rs +++ b/crates/qbz/src/settings.rs @@ -47,6 +47,14 @@ const MAX_SAMPLE_RATES: &[(&str, Option)] = &[ ]; /// ALSA-plugin dropdown options. +/// DSD delivery modes (DSD plan Phases 2-3). Value strings are the +/// AudioSettings.dsd_mode contract ("convert" | "dop" | "native"). +const DSD_MODES: &[(&str, &str)] = &[ + (qbz_i18n::mark("Convert to PCM (works everywhere)"), "convert"), + (qbz_i18n::mark("DoP — DSD over PCM (bit-perfect)"), "dop"), + (qbz_i18n::mark("Native DSD (kernel support required)"), "native"), +]; + const ALSA_PLUGINS: &[(&str, AlsaPlugin)] = &[ (qbz_i18n::mark("hw (Direct Hardware)"), AlsaPlugin::Hw), (qbz_i18n::mark("plughw (Auto-convert)"), AlsaPlugin::PlugHw), @@ -137,6 +145,8 @@ pub struct SettingsSnapshot { // Audio — toggles. limit_quality_to_device: bool, alsa_hardware_volume: bool, + dsd_modes: Vec, + dsd_mode_index: i32, exclusive_mode: bool, reserve_dac: bool, dac_passthrough: bool, @@ -518,6 +528,11 @@ fn build_snapshot( alsa_plugin_index: alsa_plugin_index as i32, limit_quality_to_device: audio.limit_quality_to_device, alsa_hardware_volume: audio.alsa_hardware_volume, + dsd_modes: DSD_MODES.iter().map(|(l, _)| qbz_i18n::t(l)).collect(), + dsd_mode_index: DSD_MODES + .iter() + .position(|(_, v)| *v == audio.dsd_mode) + .unwrap_or(0) as i32, exclusive_mode: audio.exclusive_mode, reserve_dac: audio.reserve_dac_while_running, dac_passthrough: audio.dac_passthrough, @@ -589,6 +604,8 @@ pub fn apply_snapshot(window: &AppWindow, snap: SettingsSnapshot) { // Audio — toggles. st.set_limit_quality_to_device(snap.limit_quality_to_device); st.set_alsa_hardware_volume(snap.alsa_hardware_volume); + st.set_dsd_modes(string_model(snap.dsd_modes)); + st.set_dsd_mode_index(snap.dsd_mode_index); st.set_exclusive_mode(snap.exclusive_mode); st.set_reserve_dac(snap.reserve_dac); st.set_dac_passthrough(snap.dac_passthrough); @@ -1140,6 +1157,16 @@ pub async fn handle_select( } apply_audio(&ctx, &runtime, Apply::Reinit); } + "dsd-mode" => { + let Some((_, mode)) = DSD_MODES.get(index) else { + return; + }; + if let Err(e) = with_audio(&ctx.audio, |s| s.set_dsd_mode(mode)) { + log::error!("[qbz-slint] persist DSD mode failed: {e}"); + return; + } + apply_audio(&ctx, &runtime, Apply::Reinit); + } "alsa-plugin" => { let plugin = ALSA_PLUGINS.get(index).map(|(_, p)| *p); let Some(plugin) = plugin else {