From 38b7ea7aefc4ff976477e667df081df795d26074 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sat, 31 Jan 2026 23:15:09 -0600 Subject: [PATCH] fix: enforce streaming quality setting by clearing cache on change Issue #34 - Max quality setting not respected Changes: - Remove 'Prefer Highest Available' toggle (was dead code, conflicted with quality dropdown) - Clear playback cache (L1+L2) when streaming quality changes - Show toast notification when cache is cleared - Add description to streaming quality setting - Update i18n for new messages (en/es) This ensures the quality setting takes effect immediately, important for: - Users with metered internet connections - Users with hardware sample rate limitations (e.g., DACs limited to 96kHz) The Qobuz API respects format_id and downsamples server-side, so this change guarantees the correct quality is fetched for new streams. --- src/lib/components/views/SettingsView.svelte | 37 ++++++++++---------- src/lib/i18n/locales/en.json | 4 +-- src/lib/i18n/locales/es.json | 4 +-- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/lib/components/views/SettingsView.svelte b/src/lib/components/views/SettingsView.svelte index 42ffc89e7..9567d4306 100644 --- a/src/lib/components/views/SettingsView.svelte +++ b/src/lib/components/views/SettingsView.svelte @@ -379,8 +379,7 @@ const availableLanguages = ['Auto', 'English', 'Español']; // Audio settings - let streamingQuality = $state('Hi-Res'); - let preferHighest = $state(true); + let streamingQuality = $state('Hi-Res+'); let outputDevice = $state('System Default'); let exclusiveMode = $state(false); let dacPassthrough = $state(false); @@ -604,12 +603,6 @@ streamingQuality = savedQuality; } - // Load prefer highest setting - const savedPreferHighest = localStorage.getItem('qbz-prefer-highest'); - if (savedPreferHighest !== null) { - preferHighest = savedPreferHighest === 'true'; - } - // Load language setting from i18n locale const currentLocale = get(locale); if (currentLocale && localeToLanguage[currentLocale]) { @@ -954,14 +947,23 @@ } } - function handleQualityChange(quality: string) { + async function handleQualityChange(quality: string) { + const previousQuality = streamingQuality; streamingQuality = quality; localStorage.setItem('qbz-streaming-quality', quality); - } - function handlePreferHighestChange(enabled: boolean) { - preferHighest = enabled; - localStorage.setItem('qbz-prefer-highest', String(enabled)); + // Clear playback cache when quality changes (issue #34) + // This ensures cached tracks don't play at wrong quality + // Important for users with hardware sample rate limitations + if (previousQuality !== quality) { + try { + await invoke('clear_cache'); + await loadCacheStats(); + showToast($t('settings.audio.qualityChangedCacheCleared'), 'success'); + } catch (err) { + console.error('Failed to clear cache after quality change:', err); + } + } } // Offline mode handlers @@ -1902,17 +1904,16 @@

{$t('settings.audio.title')}

- {$t('settings.audio.streamingQuality')} +
+ {$t('settings.audio.streamingQuality')} + {$t('settings.audio.streamingQualityDesc')} +
-
- {$t('settings.audio.preferHighest')} - -
Audio Backend diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index 39198cf2d..8203c62a0 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -360,8 +360,8 @@ "audio": { "title": "Audio", "streamingQuality": "Streaming Quality", - "preferHighest": "Prefer Highest Available", - "preferHighestDesc": "Automatically select highest quality for your subscription", + "streamingQualityDesc": "Maximum quality for streaming and playback cache", + "qualityChangedCacheCleared": "Quality changed. Playback cache cleared.", "outputDevice": "Output Device", "audioDevice": "Audio Device", "exclusiveMode": "Exclusive Mode", diff --git a/src/lib/i18n/locales/es.json b/src/lib/i18n/locales/es.json index 606b65db2..eff765eb8 100644 --- a/src/lib/i18n/locales/es.json +++ b/src/lib/i18n/locales/es.json @@ -360,8 +360,8 @@ "audio": { "title": "Audio", "streamingQuality": "Calidad de Streaming", - "preferHighest": "Preferir Máxima Calidad", - "preferHighestDesc": "Seleccionar automáticamente la mejor calidad para tu suscripción", + "streamingQualityDesc": "Calidad máxima para streaming y caché de reproducción", + "qualityChangedCacheCleared": "Calidad cambiada. Caché de reproducción limpiado.", "outputDevice": "Dispositivo de Salida", "audioDevice": "Dispositivo de Audio", "exclusiveMode": "Modo Exclusivo",