fix(audio): default alsa_plugin to Hw when switching to ALSA backend
When selecting ALSA Direct as backend, alsa_plugin was never persisted to the DB if the user didn't explicitly change it. The UI showed "hw (Direct Hardware)" as a visual default but the DB stayed NULL, causing isAlsaDirect to evaluate false and showing a gray DAC badge instead of the blue HW badge. cc
This commit is contained in:
1 file changed
+18
@@ -311,6 +311,24 @@ impl AudioSettingsStore {
|
||||
params![backend_json],
|
||||
)
|
||||
.map_err(|e| format!("Failed to set backend type: {}", e))?;
|
||||
|
||||
// When switching to ALSA, ensure alsa_plugin has a value (default to Hw)
|
||||
if backend == Some(AudioBackendType::Alsa) {
|
||||
let current_plugin: Option<String> = self
|
||||
.conn
|
||||
.query_row(
|
||||
"SELECT alsa_plugin FROM audio_settings WHERE id = 1",
|
||||
[],
|
||||
|row| row.get(0),
|
||||
)
|
||||
.map_err(|e| format!("Failed to check alsa_plugin: {}", e))?;
|
||||
|
||||
if current_plugin.is_none() {
|
||||
log::info!("[AudioSettings] ALSA backend selected with no plugin set, defaulting to Hw");
|
||||
self.set_alsa_plugin(Some(AlsaPlugin::Hw))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user