-
Notifications
You must be signed in to change notification settings - Fork 21
/
param.go
122 lines (111 loc) · 2.22 KB
/
param.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package alsa
import (
"fmt"
"strings"
"github.com/yobert/alsa/pcm"
)
type param uint32
const (
paramAccess param = 0
paramFormat param = 1
paramSubformat param = 2
paramFirstMask param = paramAccess
paramLastMask param = paramSubformat
paramSampleBits param = 8
paramFrameBits param = 9
paramChannels param = 10
paramRate param = 11
paramPeriodTime param = 12
paramPeriodSize param = 13
paramPeriodBytes param = 14
paramPeriods param = 15
paramBufferTime param = 16
paramBufferSize param = 17
paramBufferBytes param = 18
paramTickTime param = 19
paramFirstInterval param = paramSampleBits
paramLastInterval param = paramTickTime
)
type Flags uint32
const (
OpenMin Flags = 1 << iota
OpenMax
Integer
Empty
)
func (f Flags) String() string {
r := ""
if f&OpenMin != 0 {
r += "OpenMin "
}
if f&OpenMax != 0 {
r += "OpenMax "
}
if f&Integer != 0 {
r += "Integer "
}
if f&Empty != 0 {
r += "Empty "
}
return strings.TrimSpace(r)
}
func (p param) IsMask() bool {
return p >= paramFirstMask && p <= paramLastMask
}
func (p param) IsInterval() bool {
return p >= paramFirstInterval && p <= paramLastInterval
}
func (p param) String() string {
if p.IsMask() {
return "≡" + p.name()
}
if p.IsInterval() {
return "±" + p.name()
}
return "Invalid"
}
func (p param) name() string {
switch p {
case paramAccess:
return "Access"
case paramFormat:
return "Format"
case paramSubformat:
return "Subfmt"
case paramSampleBits:
return "SampleBits"
case paramFrameBits:
return "FrameBits"
case paramChannels:
return "Channels"
case paramRate:
return "Rate"
case paramPeriodTime:
return "PeriodTime"
case paramPeriodSize:
return "PeriodSize"
case paramPeriodBytes:
return "PeriodBytes"
case paramPeriods:
return "Periods"
case paramBufferTime:
return "BufferTime"
case paramBufferSize:
return "BufferSize"
case paramBufferBytes:
return "BufferBytes"
case paramTickTime:
return "TickTime"
default:
return "Invalid"
}
}
func get_status(fd uintptr) error {
var status pcm.Status
err := ioctl(fd, ioctl_encode(cmdRead, pcm.StatusSize, cmdPCMStatus), &status)
if err != nil {
return err
}
fmt.Println(status)
return nil
}