From dc1713068fb5e323a4b77e5613dbbbfaddf74688 Mon Sep 17 00:00:00 2001 From: Sharrnah <55756126+Sharrnah@users.noreply.github.com> Date: Sun, 11 Dec 2022 21:58:06 +0100 Subject: [PATCH] [BUGFIX] Device index counting compared to python --- FyneApp.toml | 2 +- Pages/Profiles.go | 10 +++++----- Utilities/AudioDevices.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/FyneApp.toml b/FyneApp.toml index c9baeb7..8d65b1a 100644 --- a/FyneApp.toml +++ b/FyneApp.toml @@ -5,4 +5,4 @@ Website = "https://github.com/Sharrnah/whispering" Name = "Whispering Tiger" ID = "tiger.whispering" Version = "1.0.0" - Build = 11 + Build = 12 diff --git a/Pages/Profiles.go b/Pages/Profiles.go index 2b21e80..48218f8 100644 --- a/Pages/Profiles.go +++ b/Pages/Profiles.go @@ -101,7 +101,7 @@ func (c *CurrentPlaybackDevice) InitDevices() { for index, deviceInfo := range playbackDevices { if deviceInfo.Name() == c.OutputDeviceName { selectedPlaybackDeviceIndex = index - fmt.Println("Found input device: ", deviceInfo.Name(), " at index: ", index) + fmt.Println("Found output device: ", deviceInfo.Name(), " at index: ", index) break } } @@ -247,9 +247,9 @@ func (c *CurrentPlaybackDevice) Init() { } -func GetAudioDevices(deviceType malgo.DeviceType) ([]CustomWidget.TextValueOption, error) { +func GetAudioDevices(deviceType malgo.DeviceType, deviceIndexStartPoint int) ([]CustomWidget.TextValueOption, error) { - deviceList, _ := Utilities.GetAudioDevices(deviceType) + deviceList, _ := Utilities.GetAudioDevices(deviceType, deviceIndexStartPoint) if deviceList == nil { return nil, fmt.Errorf("no devices found") @@ -277,8 +277,8 @@ func CreateProfileWindow(onClose func()) fyne.CanvasObject { go playBackDevice.Init() - audioInputDevices, _ := GetAudioDevices(malgo.Capture) - audioOutputDevices, _ := GetAudioDevices(malgo.Playback) + audioInputDevices, _ := GetAudioDevices(malgo.Capture, 0) + audioOutputDevices, _ := GetAudioDevices(malgo.Playback, len(audioInputDevices)) BuildProfileForm := func() fyne.CanvasObject { profileForm := widget.NewForm() diff --git a/Utilities/AudioDevices.go b/Utilities/AudioDevices.go index 6e3f477..b973306 100644 --- a/Utilities/AudioDevices.go +++ b/Utilities/AudioDevices.go @@ -17,7 +17,7 @@ type AudioDeviceList struct { Devices []AudioDevice } -func GetAudioDevices(deviceType malgo.DeviceType) ([]AudioDevice, error) { +func GetAudioDevices(deviceType malgo.DeviceType, deviceIndexStartPoint int) ([]AudioDevice, error) { //a.DeviceType = deviceType // initialize malgo @@ -50,7 +50,7 @@ func GetAudioDevices(deviceType malgo.DeviceType) ([]AudioDevice, error) { } deviceList = append(deviceList, AudioDevice{ Name: deviceInfo.Name(), - Index: index, + Index: index + deviceIndexStartPoint, ID: deviceInfo.ID.String(), IsDefault: fullInfo.IsDefault != 0, })