From c98b84a3a8f3b3e42667a8982e8c5b42576f692b Mon Sep 17 00:00:00 2001 From: NeilClack Date: Sun, 12 Jul 2026 18:15:41 -0500 Subject: [PATCH] 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 --- internal/mixer/mixer.go | 6 +++++- internal/page/AudioOptions.go | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/mixer/mixer.go b/internal/mixer/mixer.go index 0f761dc..747da3f 100644 --- a/internal/mixer/mixer.go +++ b/internal/mixer/mixer.go @@ -64,7 +64,11 @@ func Init(cfg *db.AppConfig, onUpdate func()) error { 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) return err } diff --git a/internal/page/AudioOptions.go b/internal/page/AudioOptions.go index b8dc09c..c38a093 100644 --- a/internal/page/AudioOptions.go +++ b/internal/page/AudioOptions.go @@ -169,12 +169,24 @@ func (p *AudioOptions) Init(ctx *PageCtx) error { // Set active device index based on mixer's current device 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 { if dev.Label == currentName { p.activeDeviceIndex = i 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. if err = p.seedAudioFiles(); err != nil {