fix: active device highlight incorrect when using default device

- mixer.Init: convert database 'default' to '' for SDL default device
- AudioOptions.Init: fallback to first SDL device when current device is default
  and config stores 'default'

Fixes known issue from changelog.txt
This commit is contained in:
NeilClack
2026-07-12 18:15:41 -05:00
parent cbb10ecda3
commit c98b84a3a8
2 changed files with 17 additions and 1 deletions
+5 -1
View File
@@ -64,7 +64,11 @@ func Init(cfg *db.AppConfig, onUpdate func()) error {
logger.Error("Failed to initialize MP3/OGG support: %v", err) logger.Error("Failed to initialize MP3/OGG support: %v", err)
} }
if err := openDeviceLocked(cfg.SelectedAudioDevice); err != nil { deviceName := cfg.SelectedAudioDevice
if deviceName == "default" {
deviceName = ""
}
if err := openDeviceLocked(deviceName); err != nil {
sdl.QuitSubSystem(sdl.INIT_AUDIO) sdl.QuitSubSystem(sdl.INIT_AUDIO)
return err return err
} }
+12
View File
@@ -169,12 +169,24 @@ func (p *AudioOptions) Init(ctx *PageCtx) error {
// Set active device index based on mixer's current device // Set active device index based on mixer's current device
currentName := mixer.CurrentDevice() currentName := mixer.CurrentDevice()
config, err = db.GetConfig(p.Context.DbPtr)
if err != nil {
panic(err)
}
p.activeDeviceIndex = -1 // default to not found
for i, dev := range p.AudioDevices { for i, dev := range p.AudioDevices {
if dev.Label == currentName { if dev.Label == currentName {
p.activeDeviceIndex = i p.activeDeviceIndex = i
break break
} }
} }
// If not found and current device is default (""), check saved config
if p.activeDeviceIndex == -1 && currentName == "" && config.SelectedAudioDevice == "default" {
// Default device is selected - first device in SDL list is typically the default
if len(p.AudioDevices) > 0 {
p.activeDeviceIndex = 0
}
}
// Make sure the audio_files table is populated. // Make sure the audio_files table is populated.
if err = p.seedAudioFiles(); err != nil { if err = p.seedAudioFiles(); err != nil {