/
ds.go
86 lines (76 loc) · 2.23 KB
/
ds.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package dsound
import (
"syscall"
"unsafe"
)
var (
dsoundDLL = syscall.NewLazyDLL("dsound")
procDirectSoundEnumerate = dsoundDLL.NewProc("DirectSoundEnumerateW")
procDirectSoundCaptureEnumerate = dsoundDLL.NewProc("DirectSoundCaptureEnumerateW")
procDirectSoundCreate = dsoundDLL.NewProc("DirectSoundCreate")
//procDirectSoundCreate8 = dsoundDLL.NewProc("DirectSoundCreate8")
//procDirectSoundCaptureCreate = dsoundDLL.NewProc("DirectSoundCaptureCreate")
//procDirectSoundCaptureCreate8 = dsoundDLL.NewProc("DirectSoundCaptureCreate8")
)
func DirectSoundEnumerate(dsEnumCallback func(guid *GUID, description string, module string) bool) error {
return dllDSResult(procDirectSoundEnumerate.Call(syscall.NewCallback(func(guid *GUID, description *[maxInt >> 1]uint16, module *[maxInt >> 1]uint16, context uintptr) int {
b := dsEnumCallback(
guid,
syscall.UTF16ToString(description[:]),
syscall.UTF16ToString(module[:]),
)
if b {
return 1
}
return 0
}), 0))
}
func DirectSoundCaptureEnumerate(dsEnumCallback func(guid *GUID, description string, module string) bool) error {
return dllDSResult(procDirectSoundCaptureEnumerate.Call(syscall.NewCallback(func(guid *GUID, description *[maxInt >> 1]uint16, module *[maxInt >> 1]uint16, context uintptr) int {
b := dsEnumCallback(
guid,
syscall.UTF16ToString(description[:]),
syscall.UTF16ToString(module[:]),
)
if b {
return 1
}
return 0
}), 0))
}
func DirectSoundCreate(guid *GUID) (*IDirectSound, error) {
var ds *IDirectSound
err := dllDSResult(procDirectSoundCreate.Call(
uintptr(unsafe.Pointer(guid)),
uintptr(unsafe.Pointer(&ds)),
0,
))
if err != nil {
return nil, err
}
return ds, nil
}
/*
func DirectSoundCreate8(guid *GUID) (*IDirectSound8, error) {
var ds *IDirectSound8
err := dllDSResult(procDirectSoundCreate8.Call(
uintptr(unsafe.Pointer(guid)),
uintptr(unsafe.Pointer(&ds)),
0,
))
if err != nil {
return nil, err
}
return ds, nil
}
func DirectSoundCaptureCreate(guid *GUID) (*DirectSoundCapture, error) {
return nil, nil
}
func DirectSoundCaptureCreate8(guid *GUID) (*IDirectSoundCapture8, error) {
return nil, nil
}
func DirectSoundFullDuplexCreate8(){
}
func GetDeviceID(){
}
*/