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:
1 parent
20fc254769
commit
791ff7a73b
2 files changed
+73
-16
No files matched your search
+31
-14
@@ -639,29 +639,37 @@ impl Player {
|
||||
);
|
||||
*pause_suspend_deadline = None;
|
||||
|
||||
// Get DAC passthrough setting
|
||||
let dac_passthrough = thread_settings
|
||||
.lock()
|
||||
.ok()
|
||||
.map(|s| s.dac_passthrough)
|
||||
.unwrap_or(false);
|
||||
|
||||
// Check if we need to recreate the stream
|
||||
let needs_new_stream = stream_opt.is_none()
|
||||
|| *current_sample_rate != Some(sample_rate)
|
||||
// Only recreate on format change if DAC passthrough is enabled
|
||||
let format_changed = *current_sample_rate != Some(sample_rate)
|
||||
|| *current_channels != Some(channels);
|
||||
let needs_new_stream = stream_opt.is_none()
|
||||
|| (dac_passthrough && format_changed);
|
||||
|
||||
if needs_new_stream {
|
||||
if stream_opt.is_some() {
|
||||
log::info!(
|
||||
"Sample rate changed from {:?}Hz to {}Hz - recreating OutputStream",
|
||||
*current_sample_rate,
|
||||
sample_rate
|
||||
);
|
||||
if dac_passthrough && format_changed {
|
||||
log::info!(
|
||||
"Sample rate/channels changed from {:?}Hz/{:?}ch to {}Hz/{}ch - recreating OutputStream (DAC passthrough)",
|
||||
*current_sample_rate,
|
||||
*current_channels,
|
||||
sample_rate,
|
||||
channels
|
||||
);
|
||||
} else {
|
||||
log::info!("Creating initial OutputStream");
|
||||
}
|
||||
// Drop old stream
|
||||
drop(stream_opt.take());
|
||||
}
|
||||
|
||||
// Get audio settings (exclusive mode / DAC passthrough)
|
||||
let dac_passthrough = thread_settings
|
||||
.lock()
|
||||
.ok()
|
||||
.map(|s| s.dac_passthrough)
|
||||
.unwrap_or(false);
|
||||
|
||||
log::info!("DAC passthrough enabled: {}", dac_passthrough);
|
||||
|
||||
// Get the audio device
|
||||
@@ -741,6 +749,15 @@ impl Player {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if format_changed {
|
||||
// Format changed but DAC passthrough is disabled - reuse existing stream
|
||||
log::info!(
|
||||
"Audio format changed from {:?}Hz/{:?}ch to {}Hz/{}ch - reusing OutputStream (DAC passthrough disabled, gapless enabled)",
|
||||
*current_sample_rate,
|
||||
*current_channels,
|
||||
sample_rate,
|
||||
channels
|
||||
);
|
||||
}
|
||||
|
||||
let Some(ref stream) = *stream_opt else {
|
||||
|
||||
Reference in new issue
Block a user