コード例 #1
0
ファイル: jack.go プロジェクト: padster/go-jack
func (port *Port) GetConnections() []string {
	var ports []string
	cports := C.jack_port_get_connections(port.handler)
	if cports != nil {
		defer C.jack_free(unsafe.Pointer(cports))
		ptr := uintptr(unsafe.Pointer(cports))
		for {
			cport := (**C.char)(unsafe.Pointer(ptr))
			if *cport == nil {
				break
			}

			str := C.GoString(*cport)
			ports = append(ports, str)
			ptr += unsafe.Sizeof(cport)
		}
	}
	return ports
}
コード例 #2
0
ファイル: jack.go プロジェクト: padster/go-jack
func (client *Client) GetPorts(portName, portType string, flags uint64) []string {
	cname := C.CString(portName)
	defer C.free(unsafe.Pointer(cname))
	ctype := C.CString(portType)
	defer C.free(unsafe.Pointer(ctype))

	var ports []string
	cports := C.jack_get_ports(client.handler, cname, ctype, C.ulong(flags))
	if cports != nil {
		defer C.jack_free(unsafe.Pointer(cports))
		ptr := uintptr(unsafe.Pointer(cports))
		for {
			cport := (**C.char)(unsafe.Pointer(ptr))
			if *cport == nil {
				break
			}

			str := C.GoString(*cport)
			ports = append(ports, str)
			ptr += unsafe.Sizeof(cport)
		}
	}
	return ports
}