-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmisc.go
94 lines (82 loc) · 1.87 KB
/
misc.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
package pulseaudio
import (
"io"
)
type formatInfo struct {
Encoding byte
PropList map[string]string
}
func (i *formatInfo) ReadFrom(r io.Reader) (int64, error) {
return 0, bread(r, formatInfoTag, uint8Tag, &i.Encoding, &i.PropList)
}
type cvolume []uint32
func (v *cvolume) ReadFrom(r io.Reader) (int64, error) {
var n byte
err := bread(r, cvolumeTag, &n)
if err != nil {
return 0, err
}
*v = make([]uint32, n)
return 0, bread(r, []uint32(*v))
}
type channelMap []byte
func (m *channelMap) ReadFrom(r io.Reader) (int64, error) {
var n byte
err := bread(r, channelMapTag, &n)
if err != nil {
return 0, err
}
*m = make([]byte, n)
_, err = r.Read(*m)
return 0, err
}
type sampleSpec struct {
Format byte
Channels byte
Rate uint32
}
func (s *sampleSpec) ReadFrom(r io.Reader) (int64, error) {
return 0, bread(r, sampleSpecTag, &s.Format, &s.Channels, &s.Rate)
}
type profile struct {
Name, Description string
Nsinks, Nsources uint32
Priority uint32
Available uint32
}
type port struct {
Card *Card `json:"-"`
Name, Description string
Pririty uint32
Available uint32
Direction byte
PropList map[string]string
Profiles []*profile
LatencyOffset int64
}
func (p *port) ReadFrom(r io.Reader) (int64, error) {
err := bread(r,
stringTag, &p.Name,
stringTag, &p.Description,
uint32Tag, &p.Pririty,
uint32Tag, &p.Available,
uint8Tag, &p.Direction,
&p.PropList)
if err != nil {
return 0, err
}
var portProfileCount uint32
err = bread(r, uint32Tag, &portProfileCount)
if err != nil {
return 0, err
}
for j := uint32(0); j < portProfileCount; j++ {
var profileName string
err = bread(r, stringTag, &profileName)
if err != nil {
return 0, err
}
p.Profiles = append(p.Profiles, p.Card.Profiles[profileName])
}
return 0, bread(r, int64Tag, &p.LatencyOffset)
}