forked from xthexder/go-jack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallbacks.go
70 lines (59 loc) · 1.98 KB
/
callbacks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package jack
import "C"
import "unsafe"
type ProcessCallback func(uint32) int
type BufferSizeCallback func(uint32) int
type SampleRateCallback func(uint32) int
type PortRegistrationCallback func(PortId, bool)
type PortRenameCallback func(PortId, string, string)
type PortConnectCallback func(PortId, PortId, bool)
type ShutdownCallback func()
type ErrorFunction func(string)
type InfoFunction func(string)
//export goProcess
func goProcess(nframes uint, arg unsafe.Pointer) int {
client := (*C.struct__jack_client)(arg)
return clientMap[client].processCallback(uint32(nframes))
}
//export goBufferSize
func goBufferSize(nframes uint, arg unsafe.Pointer) int {
client := (*C.struct__jack_client)(arg)
return clientMap[client].bufferSizeCallback(uint32(nframes))
}
//export goSampleRate
func goSampleRate(nframes uint, arg unsafe.Pointer) int {
client := (*C.struct__jack_client)(arg)
return clientMap[client].sampleRateCallback(uint32(nframes))
}
//export goPortRegistration
func goPortRegistration(port uint, register int, arg unsafe.Pointer) {
client := (*C.struct__jack_client)(arg)
clientMap[client].portRegistrationCallback(PortId(port), register != 0)
}
//export goPortRename
func goPortRename(port uint, oldName, newName *C.char, arg unsafe.Pointer) {
client := (*C.struct__jack_client)(arg)
clientMap[client].portRenameCallback(PortId(port), C.GoString(oldName), C.GoString(newName))
}
//export goPortConnect
func goPortConnect(aport, bport uint, connect int, arg unsafe.Pointer) {
client := (*C.struct__jack_client)(arg)
clientMap[client].portConnectCallback(PortId(aport), PortId(bport), connect != 0)
}
//export goShutdown
func goShutdown(arg unsafe.Pointer) {
client := (*C.struct__jack_client)(arg)
clientMap[client].shutdownCallback()
}
//export goErrorFunction
func goErrorFunction(msg *C.char) {
if errorFunction != nil {
errorFunction(C.GoString(msg))
}
}
//export goInfoFunction
func goInfoFunction(msg *C.char) {
if infoFunction != nil {
infoFunction(C.GoString(msg))
}
}