// HostApiDeviceIndexToDeviceIndex function as declared in portaudio/portaudio.h:331 func HostApiDeviceIndexToDeviceIndex(hostApi HostApiIndex, hostApiDeviceIndex int32) DeviceIndex { chostApi, _ := (C.PaHostApiIndex)(hostApi), cgoAllocsUnknown chostApiDeviceIndex, _ := (C.int)(hostApiDeviceIndex), cgoAllocsUnknown __ret := C.Pa_HostApiDeviceIndexToDeviceIndex(chostApi, chostApiDeviceIndex) __v := (DeviceIndex)(__ret) return __v }
func hostsAndDevices() ([]*HostApiInfo, []*DeviceInfo, error) { if !cached { nhosts := C.Pa_GetHostApiCount() ndevs := C.Pa_GetDeviceCount() if nhosts < 0 { return nil, nil, newError(C.PaError(nhosts)) } if ndevs < 0 { return nil, nil, newError(C.PaError(ndevs)) } devices = make([]*DeviceInfo, ndevs) hosti := make([]C.PaHostApiIndex, ndevs) for i := range devices { i := C.PaDeviceIndex(i) paDev := C.Pa_GetDeviceInfo(i) devices[i] = &DeviceInfo{ index: i, Name: C.GoString(paDev.name), MaxInputChannels: int(paDev.maxInputChannels), MaxOutputChannels: int(paDev.maxOutputChannels), DefaultLowInputLatency: duration(paDev.defaultLowInputLatency), DefaultLowOutputLatency: duration(paDev.defaultLowOutputLatency), DefaultHighInputLatency: duration(paDev.defaultHighInputLatency), DefaultHighOutputLatency: duration(paDev.defaultHighOutputLatency), DefaultSampleRate: float64(paDev.defaultSampleRate), } hosti[i] = paDev.hostApi } hostApis = make([]*HostApiInfo, nhosts) for i := range hostApis { i := C.PaHostApiIndex(i) paHost := C.Pa_GetHostApiInfo(i) devs := make([]*DeviceInfo, paHost.deviceCount) for j := range devs { devs[j] = devices[C.Pa_HostApiDeviceIndexToDeviceIndex(i, C.int(j))] } hostApis[i] = &HostApiInfo{ Type: HostApiType(paHost._type), Name: C.GoString(paHost.name), DefaultInputDevice: lookupDevice(devices, paHost.defaultInputDevice), DefaultOutputDevice: lookupDevice(devices, paHost.defaultOutputDevice), Devices: devs, } } for i := range devices { devices[i].HostApi = hostApis[hosti[i]] } cached = true } return hostApis, devices, nil }