New setting: Max volume
This commit is contained in:
parent
41f8092419
commit
11163f059b
4 changed files with 24 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ var CommonPlayer *Player
|
|||
type Player struct {
|
||||
Playlist []string
|
||||
MaxRunTime time.Duration
|
||||
MaxVolume uint16
|
||||
Stopper chan bool
|
||||
currentCmd *exec.Cmd
|
||||
currentCmdCh chan bool
|
||||
|
|
@ -77,6 +78,7 @@ func NewPlayer(cfg *config.Config, routines []reveil.Identifier) (*Player, error
|
|||
Stopper: make(chan bool, 1),
|
||||
currentCmdCh: make(chan bool, 1),
|
||||
MaxRunTime: settings.MaxRunTime * time.Minute,
|
||||
MaxVolume: uint16(settings.MaxVolume),
|
||||
weatherTime: settings.WeatherDelay * time.Minute,
|
||||
weatherAction: wact,
|
||||
claironTime: settings.GongInterval * time.Minute,
|
||||
|
|
@ -270,7 +272,11 @@ func (p *Player) NextTrack() {
|
|||
}
|
||||
|
||||
func (p *Player) SetVolume(volume uint16) error {
|
||||
cmd := exec.Command("amixer", "-D", mixerCard, "set", mixerName, fmt.Sprintf("%d", volume))
|
||||
if p.MaxVolume == 0 {
|
||||
p.MaxVolume = 65535
|
||||
}
|
||||
|
||||
cmd := exec.Command("amixer", "-D", mixerCard, "set", mixerName, fmt.Sprintf("%d", uint32(volume)*uint32(p.MaxVolume)/65535))
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue