diff --git a/src/lib/components/AudioOutputBadges.svelte b/src/lib/components/AudioOutputBadges.svelte index edbaf939a..f87e62f7d 100644 --- a/src/lib/components/AudioOutputBadges.svelte +++ b/src/lib/components/AudioOutputBadges.svelte @@ -196,17 +196,18 @@ ● {#if dacBadgeState === 'warning'} - ⚠ DAC Passthrough: Resampling detected + ⚠ ERROR: PipeWire is resampling {#if hardwareStatus?.hardware_sample_rate && samplingRate} -
{samplingRate} kHz → {(hardwareStatus.hardware_sample_rate / 1000).toFixed(1)} kHz +
File: {samplingRate} kHz → Hardware: {(hardwareStatus.hardware_sample_rate / 1000).toFixed(1)} kHz +
Fix: Configure PipeWire sample rate switching {/if} {:else if dacBadgeState === 'active'} - DAC Passthrough: Bit-perfect + ✓ DAC Passthrough: Bit-perfect {#if hardwareStatus?.hardware_sample_rate} -
{(hardwareStatus.hardware_sample_rate / 1000).toFixed(1)} kHz +
{(hardwareStatus.hardware_sample_rate / 1000).toFixed(1)} kHz native {/if} {:else} - DAC Passthrough: Off + DAC Passthrough: Disabled {/if}
diff --git a/src/lib/components/views/SettingsView.svelte b/src/lib/components/views/SettingsView.svelte index 31c14258b..0ef032565 100644 --- a/src/lib/components/views/SettingsView.svelte +++ b/src/lib/components/views/SettingsView.svelte @@ -765,6 +765,14 @@ preferred_sample_rate: number | null; } + // Helper to get the current selected device sink name (or null for system default) + function getCurrentDeviceSinkName(): string | null { + if (outputDevice === 'System Default') { + return null; + } + return sinkDescriptionToName.get(outputDevice) ?? null; + } + async function loadAudioDevices() { try { // Load PipeWire sinks - these have friendly descriptions already @@ -828,8 +836,9 @@ await invoke('set_pipewire_default_sink', { sinkName }); } - // Reinitialize audio to use the new default - await invoke('reinit_audio_device', { device: null }); + // Reinitialize audio to use the selected device + // IMPORTANT: Pass the actual sink name, not null + await invoke('reinit_audio_device', { device: deviceToStore }); console.log('Audio output device changed:', description, '(sink:', sinkName ?? 'default', ')'); } catch (err) { @@ -841,8 +850,9 @@ exclusiveMode = enabled; try { await invoke('set_audio_exclusive_mode', { enabled }); - // Reinitialize audio to apply/release exclusive mode (uses PipeWire default) - await invoke('reinit_audio_device', { device: null }); + // Reinitialize audio to apply/release exclusive mode + // IMPORTANT: Maintain the currently selected output device + await invoke('reinit_audio_device', { device: getCurrentDeviceSinkName() }); console.log('Exclusive mode changed and audio reinitialized:', enabled); } catch (err) { console.error('Failed to change exclusive mode:', err); @@ -861,8 +871,9 @@ try { await invoke('set_audio_dac_passthrough', { enabled }); - // DAC passthrough may also require reinit for proper effect (uses PipeWire default) - await invoke('reinit_audio_device', { device: null }); + // DAC passthrough may also require reinit for proper effect + // IMPORTANT: Maintain the currently selected output device + await invoke('reinit_audio_device', { device: getCurrentDeviceSinkName() }); console.log('DAC passthrough changed and audio reinitialized:', enabled); } catch (err) { console.error('Failed to change DAC passthrough:', err); @@ -878,7 +889,8 @@ console.log('Gapless playback enabled: disabled DAC passthrough'); try { await invoke('set_audio_dac_passthrough', { enabled: false }); - await invoke('reinit_audio_device', { device: null }); + // IMPORTANT: Maintain the currently selected output device + await invoke('reinit_audio_device', { device: getCurrentDeviceSinkName() }); } catch (err) { console.error('Failed to disable DAC passthrough:', err); } @@ -894,7 +906,8 @@ console.log('Crossfade enabled: disabled DAC passthrough'); try { await invoke('set_audio_dac_passthrough', { enabled: false }); - await invoke('reinit_audio_device', { device: null }); + // IMPORTANT: Maintain the currently selected output device + await invoke('reinit_audio_device', { device: getCurrentDeviceSinkName() }); } catch (err) { console.error('Failed to disable DAC passthrough:', err); }