Skip to content

Commit

Permalink
[BUGFIX] Device index counting compared to python
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharrnah committed Dec 11, 2022
1 parent af1e817 commit dc17130
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion FyneApp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Website = "https://github.com/Sharrnah/whispering"
Name = "Whispering Tiger"
ID = "tiger.whispering"
Version = "1.0.0"
Build = 11
Build = 12
10 changes: 5 additions & 5 deletions Pages/Profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions Utilities/AudioDevices.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
})
Expand Down

0 comments on commit dc17130

Please sign in to comment.