From 689cd9d4dcf8cc2df7a466a2414dcedf20f3612d Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Mon, 8 Apr 2024 11:32:39 -0600 Subject: [PATCH] Added device enumeration to client --- cmd/client/main.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/cmd/client/main.go b/cmd/client/main.go index 7dd4f94..6fcc8b5 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -17,6 +17,42 @@ func main() { defer ctx.Free() defer ctx.Uninit() + // Playback devices. + infos, err := ctx.Devices(malgo.Playback) + if err != nil { + panic(err) + } + + fmt.Println("Playback Devices") + for i, info := range infos { + e := "ok" + full, err := ctx.DeviceInfo(malgo.Playback, info.ID, malgo.Shared) + if err != nil { + e = err.Error() + } + fmt.Printf(" %d: %v, %s, [%s], formats: %+v\n", + i, info.ID, info.Name(), e, full.Formats) + } + + fmt.Println() + + // Capture devices. + infos, err = ctx.Devices(malgo.Capture) + if err != nil { + panic(err) + } + + fmt.Println("Capture Devices") + for i, info := range infos { + e := "ok" + full, err := ctx.DeviceInfo(malgo.Capture, info.ID, malgo.Shared) + if err != nil { + e = err.Error() + } + fmt.Printf(" %d: %v, %s, [%s], formats: %+v\n", + i, info.ID, info.Name(), e, full.Formats) + } + inDeviceConfig := malgo.DefaultDeviceConfig(malgo.Capture) inDeviceConfig.Capture.Format = malgo.FormatF32 inDeviceConfig.Capture.Channels = 1