-
Notifications
You must be signed in to change notification settings - Fork 13
/
server.go
44 lines (40 loc) · 978 Bytes
/
server.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
package pulseaudio
import "io"
// Server contains information about the pulseaudio server
type Server struct {
PackageName string
PackageVersion string
User string
Hostname string
SampleSpec sampleSpec
DefaultSink string
DefaultSource string
Cookie uint32
ChannelMap channelMap
}
// ReadFrom deserializes a pulseaudio server info packet
func (s *Server) ReadFrom(r io.Reader) (int64, error) {
return 0, bread(r,
stringTag, &s.PackageName,
stringTag, &s.PackageVersion,
stringTag, &s.User,
stringTag, &s.Hostname,
&s.SampleSpec,
stringTag, &s.DefaultSink,
stringTag, &s.DefaultSource,
uint32Tag, &s.Cookie,
&s.ChannelMap)
}
// ServerInfo queries the pulseaudio server for its information
func (c *Client) ServerInfo() (*Server, error) {
r, err := c.request(commandGetServerInfo)
if err != nil {
return nil, err
}
var s Server
err = bread(r, &s)
if err != nil {
return nil, err
}
return &s, nil
}