MCPcopy
hub / github.com/ebitengine/oto / deviceCandidates

Function deviceCandidates

driver_unix.go:54–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52}
53
54func deviceCandidates() []string {
55 const getAllDevices = -1
56
57 cPCMInterfaceName := C.CString("pcm")
58 defer C.free(unsafe.Pointer(cPCMInterfaceName))
59
60 var hints *unsafe.Pointer
61 err := C.snd_device_name_hint(getAllDevices, cPCMInterfaceName, &hints)
62 if err != 0 {
63 return []string{"default", "plug:default"}
64 }
65 defer C.snd_device_name_free_hint(hints)
66
67 var devices []string
68
69 cIoHintName := C.CString("IOID")
70 defer C.free(unsafe.Pointer(cIoHintName))
71 cNameHintName := C.CString("NAME")
72 defer C.free(unsafe.Pointer(cNameHintName))
73
74 for it := hints; *it != nil; it = (*unsafe.Pointer)(unsafe.Pointer(uintptr(unsafe.Pointer(it)) + unsafe.Sizeof(uintptr(0)))) {
75 io := C.snd_device_name_get_hint(*it, cIoHintName)
76 defer func() {
77 if io != nil {
78 C.free(unsafe.Pointer(io))
79 }
80 }()
81 if C.GoString(io) == "Input" {
82 continue
83 }
84
85 name := C.snd_device_name_get_hint(*it, cNameHintName)
86 defer func() {
87 if name != nil {
88 C.free(unsafe.Pointer(name))
89 }
90 }()
91 if name == nil {
92 continue
93 }
94 goName := C.GoString(name)
95 if goName == "null" {
96 continue
97 }
98 if goName == "default" {
99 continue
100 }
101 devices = append(devices, goName)
102 }
103
104 devices = append([]string{"default", "plug:default"}, devices...)
105
106 return devices
107}
108
109func newContext(sampleRate int, channelCount int, format mux.Format, bufferSizeInBytes int) (*context, chan struct{}, error) {
110 c := &context{

Callers 1

newContextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…