feat(slint): DSD playback mode setting, DSD badges and local gapless

Settings > Audio gains a 'DSD playback' dropdown (Convert to PCM /
DoP / Native DSD, ALSA-direct only, permanent warning copy since DoP
and native support cannot be detected). Local .dsf/.dff files route to
the player's DSD path with toasts on unsupported files. Quality badges
read DSD64/128/256 from the stored bit rate on every surface including
the now-playing stamp. The gapless prefetch now pre-queues LOCAL
tracks too: DSD via the DoP/native append or an in-memory converted
WAV, other local formats via their raw bytes (fixes local FLAC
gapless); CUE virtual tracks are excluded. Six new locale strings.

cc
This commit is contained in:
vicrodh committed 2026-07-03 17:56:48 -06:00
1 parent d6b4d43043
commit e288e4aaee
13 files changed
+278 -1

No files matched your search

@@ -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)"
@@ -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)"
@@ -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)"
@@ -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(カーネルサポートが必要)"
@@ -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)"
@@ -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 (требуется поддержка ядра)"
@@ -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 { }
+4
View File
@@ -2801,6 +2801,10 @@ export global SettingsState {
// Audio — toggles.
in-out property <bool> limit-quality-to-device: false;
in-out property <bool> 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 <int> dsd-mode-index: 0;
in-out property <bool> exclusive-mode: false;
in-out property <bool> reserve-dac: false;
in-out property <bool> dac-passthrough: false;
+1
View File
@@ -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" }
+6
View File
@@ -158,6 +158,12 @@ fn local_quality(bit_depth: Option<u32>, 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 {
+94
View File
@@ -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}"
),
}
});
}
}
}
+33 -1
View File
@@ -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<f64>) -> 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<u32>) -> &'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<u32>,
sample_rate: Option<f64>,
) -> (&'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()),
+27
View File
@@ -47,6 +47,14 @@ const MAX_SAMPLE_RATES: &[(&str, Option<u32>)] = &[
];
/// 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<String>,
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 {