forked from omriharel/deej
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsession.go
54 lines (40 loc) · 1.03 KB
/
session.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
package deej
import (
"strings"
"go.uber.org/zap"
)
// Session represents a single addressable audio session
type Session interface {
GetVolume() float32
SetVolume(v float32) error
// TODO: future mute support
// GetMute() bool
// SetMute(m bool) error
Key() string
Release()
}
const (
// ideally these would share a common ground in baseSession
// but it will not call the child GetVolume correctly :/
sessionCreationLogMessage = "Created audio session instance"
// format this with s.humanReadableDesc and whatever the current volume is
sessionStringFormat = "<session: %s, vol: %.2f>"
)
type baseSession struct {
logger *zap.SugaredLogger
system bool
master bool
// used by Key(), needs to be set by child
name string
// used by String(), needs to be set by child
humanReadableDesc string
}
func (s *baseSession) Key() string {
if s.system {
return systemSessionName
}
if s.master {
return strings.ToLower(s.name) // could be master or mic, or any device's friendly name
}
return strings.ToLower(s.name)
}