feat: implement mutual exclusion for incompatible audio settings

Add auto-disable logic to prevent incompatible settings from being enabled simultaneously:

Frontend (SettingsView.svelte):
- DAC Passthrough ON → auto-disables Gapless Playback and Crossfade
- Gapless Playback ON → auto-disables DAC Passthrough
- Crossfade > 0 → auto-disables DAC Passthrough
- Added handleGaplessPlaybackChange() and handleCrossfadeChange() handlers
- Modified handleDacPassthroughChange() to disable incompatible settings

Backend (player/mod.rs):
- Only recreate OutputStream on format change when DAC passthrough is enabled
- When DAC passthrough is OFF: reuse existing stream for gapless transitions
- When DAC passthrough is ON: recreate stream for bit-perfect playback
- Added detailed logging for stream recreation decisions

This fixes the issue where Gapless Playback was enabled but gaps still occurred
due to DAC passthrough forcing stream recreation on sample rate changes.
This commit is contained in:
vicrodh committed 2026-01-16 20:41:53 -06:00
1 parent 20fc254769
commit 791ff7a73b
2 files changed
+73 -16

No files matched your search

+42 -2
View File
@@ -827,6 +827,14 @@
async function handleDacPassthroughChange(enabled: boolean) {
dacPassthrough = enabled;
// Auto-disable incompatible playback settings
if (enabled) {
gaplessPlayback = false;
crossfade = 0;
console.log('DAC passthrough enabled: disabled gapless playback and crossfade');
}
try {
await invoke('set_audio_dac_passthrough', { enabled });
// DAC passthrough may also require reinit for proper effect (uses PipeWire default)
@@ -837,6 +845,38 @@
}
}
async function handleGaplessPlaybackChange(enabled: boolean) {
gaplessPlayback = enabled;
// Auto-disable DAC passthrough if incompatible
if (enabled && dacPassthrough) {
dacPassthrough = false;
console.log('Gapless playback enabled: disabled DAC passthrough');
try {
await invoke('set_audio_dac_passthrough', { enabled: false });
await invoke('reinit_audio_device', { device: null });
} catch (err) {
console.error('Failed to disable DAC passthrough:', err);
}
}
}
async function handleCrossfadeChange(value: number) {
crossfade = value;
// Auto-disable DAC passthrough if crossfade > 0
if (value > 0 && dacPassthrough) {
dacPassthrough = false;
console.log('Crossfade enabled: disabled DAC passthrough');
try {
await invoke('set_audio_dac_passthrough', { enabled: false });
await invoke('reinit_audio_device', { device: null });
} catch (err) {
console.error('Failed to disable DAC passthrough:', err);
}
}
}
async function loadCacheStats() {
try {
cacheStats = await invoke<CacheStats>('get_cache_stats');
@@ -1130,12 +1170,12 @@
<h3 class="section-title">{$t('settings.playback.title')}</h3>
<div class="setting-row">
<span class="setting-label">{$t('settings.playback.gapless')}</span>
<Toggle enabled={gaplessPlayback} onchange={(v) => (gaplessPlayback = v)} />
<Toggle enabled={gaplessPlayback} onchange={handleGaplessPlaybackChange} />
</div>
<div class="setting-row">
<span class="setting-label">{$t('settings.playback.crossfade')}</span>
<div class="slider-container">
<VolumeSlider value={crossfade} onchange={(v) => (crossfade = v)} max={12} showValue />
<VolumeSlider value={crossfade} onchange={handleCrossfadeChange} max={12} showValue />
</div>
</div>
<div class="setting-row last">