forked from gen2brain/malgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice_config.go
85 lines (74 loc) · 2 KB
/
device_config.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
package malgo
// #include "malgo.h"
import "C"
import "unsafe"
// DeviceConfig type.
type DeviceConfig struct {
DeviceType DeviceType
SampleRate uint32
PeriodSizeInFrames uint32
PeriodSizeInMilliseconds uint32
Periods uint32
PerformanceProfile PerformanceProfile
NoPreZeroedOutputBuffer uint32
NoClip uint32
DataCallback *[0]byte
StopCallback *[0]byte
PUserData *byte
Resampling ResampleConfig
Playback SubConfig
Capture SubConfig
Wasapi WasapiDeviceConfig
Alsa AlsaDeviceConfig
Pulse PulseDeviceConfig
}
// DefaultDeviceConfig returns a default device config.
func DefaultDeviceConfig(deviceType DeviceType) DeviceConfig {
config := C.ma_device_config_init(C.ma_device_type(deviceType))
return *(*DeviceConfig)(unsafe.Pointer(&config))
}
func (d *DeviceConfig) cptr() *C.ma_device_config {
return (*C.ma_device_config)(unsafe.Pointer(d))
}
// SubConfig type.
type SubConfig struct {
DeviceID unsafe.Pointer
Format FormatType
Channels uint32
ChannelMap [C.MA_MAX_CHANNELS]uint8
ShareMode ShareMode
_ [4]byte // cgo padding
}
// WasapiDeviceConfig type.
type WasapiDeviceConfig struct {
NoAutoConvertSRC uint32
NoDefaultQualitySRC uint32
NoAutoStreamRouting uint32
NoHardwareOffloading uint32
}
// AlsaDeviceConfig type.
type AlsaDeviceConfig struct {
NoMMap uint32
NoAutoFormat uint32
NoAutoChannles uint32
NoAutoResample uint32
}
// PulseDeviceConfig type.
type PulseDeviceConfig struct {
StreamNamePlayback *int8
StreamNameCapture *int8
}
// ResampleConfig type.
type ResampleConfig struct {
Algorithm ResampleAlgorithm
Linear ResampleLinearConfig
Speex ResampleSpeexConfig
}
// ResampleLinearConfig type.
type ResampleLinearConfig struct {
LpfOrder uint32
}
// ResampleSpeexConfig type.
type ResampleSpeexConfig struct {
Quality int
}