fix: resolve 4 critical audio mixer bugs (v0.5)
- SwitchDevice volume silently zeroed: Init uses cfg.SavedVolume, SwitchDevice restores saved volume after reopening device - SwitchDevice not persisted to database: caller saves SelectedAudioDevice - Device restore passes invalid 'system default' to SDL: now passes '' - Stop() no-op when audio toggled off: removed AudioEnabled guard Regression tests added for all 4 bugs. CI now runs go test before build.
This commit is contained in:
@@ -273,9 +273,22 @@ func (p *AudioOptions) SelectAudioDevice(deviceIndex int) error {
|
||||
return fmt.Errorf("invalid device index: %d", deviceIndex)
|
||||
}
|
||||
device := p.AudioDevices[deviceIndex]
|
||||
if err := mixer.SwitchDevice(device.Label); err != nil {
|
||||
|
||||
config, err := db.GetConfig(p.Context.DbPtr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get config for device switch: %w", err)
|
||||
}
|
||||
|
||||
if err := mixer.SwitchDevice(device.Label, config); err != nil {
|
||||
return fmt.Errorf("failed to switch to device %s: %w", device.Label, err)
|
||||
}
|
||||
|
||||
// Persist the selected device to the database
|
||||
config.SelectedAudioDevice = device.Label
|
||||
if err := p.Context.DbPtr.Save(config).Error; err != nil {
|
||||
logger.Error("failed to persist device selection: %v", err)
|
||||
}
|
||||
|
||||
p.activeDeviceIndex = deviceIndex
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user