feat: implement 3-state DAC badge and hardware sample rate detection

Backend changes:
- Add audio_diagnostics module to read actual hardware sample rate from /proc/asound
- New command get_hardware_audio_status() parses hw_params for real-time monitoring
- Add glob dependency for file pattern matching

Frontend (AudioOutputBadges):
- Implement 3-state DAC badge system:
  - Green: DAC passthrough working correctly (rates match)
  - Yellow: DAC passthrough ON but resampling detected (warning)
  - Gray: DAC passthrough OFF (intentionally disabled)
- Dynamic tooltips showing actual hardware sample rate
- Compare file sample rate vs hardware sample rate
- Increase tooltip z-index to 9999 to prevent occlusion issues
- Add pointer-events: none to tooltip to prevent interaction issues

Frontend (SettingsView):
- Replace hardcoded "192 kHz" with dynamic hardware sample rate
- Load and display actual hardware audio status
- Show format details (e.g., S32_LE) when available
- Display "No active playback" when no audio is playing
- Add muted styling for inactive state

Frontend (QualityBadge):
- Add native tooltip showing tier and format
- Add cursor: help to indicate interactivity

i18n:
- Add "noActivePlayback" translations (EN/ES)

This allows users to verify bit-perfect playback is working and detect
resampling issues that would compromise audio quality.
This commit is contained in:
vicrodh committed 2026-01-16 21:14:22 -06:00
1 parent 09881856d0
commit c810663c6f
9 files changed
+202 -14

No files matched your search

+33 -1
View File
@@ -65,6 +65,12 @@
is_default: boolean;
}
interface HardwareAudioStatus {
hardware_sample_rate: number | null;
hardware_format: string | null;
is_active: boolean;
}
let { onBack, onLogout, userName = 'User', userEmail = '', subscription = 'Qobuz' }: Props = $props();
// Cache state (memory cache)
@@ -141,6 +147,7 @@
// Audio device state - use PipeWire sinks directly for friendly names
let pipewireSinks = $state<PipewireSink[]>([]);
let hardwareStatus = $state<HardwareAudioStatus | null>(null);
// Map of description -> sink name (for looking up sink name when user selects)
const sinkDescriptionToName = $derived.by(() => {
@@ -764,7 +771,12 @@
const sinks = await invoke<PipewireSink[]>('get_pipewire_sinks').catch(() => [] as PipewireSink[]);
pipewireSinks = sinks;
// Load hardware audio status
const hwStatus = await invoke<HardwareAudioStatus>('get_hardware_audio_status').catch(() => null);
hardwareStatus = hwStatus;
console.log('[Audio] PipeWire sinks:', sinks.map(s => ({ name: s.name, desc: s.description })));
console.log('[Audio] Hardware status:', hwStatus);
} catch (err) {
console.error('Failed to load audio devices:', err);
}
@@ -1161,7 +1173,16 @@
</div>
<div class="setting-row last">
<span class="setting-label">{$t('settings.audio.currentSampleRate')}</span>
<span class="setting-value">192 kHz</span>
<span class="setting-value" class:muted={!hardwareStatus?.is_active}>
{#if hardwareStatus?.is_active && hardwareStatus.hardware_sample_rate}
{(hardwareStatus.hardware_sample_rate / 1000).toFixed(1)} kHz
{#if hardwareStatus.hardware_format}
<span class="format-detail">({hardwareStatus.hardware_format})</span>
{/if}
{:else}
{$t('settings.audio.noActivePlayback')}
{/if}
</span>
</div>
</section>
@@ -1909,6 +1930,17 @@
color: var(--text-muted);
}
.setting-value.muted {
opacity: 0.5;
font-style: italic;
}
.format-detail {
font-size: 12px;
opacity: 0.7;
margin-left: 4px;
}
.label-with-tooltip {
display: flex;
align-items: center;