Handle muting streams
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
nemunaire 2023-11-15 12:10:32 +01:00
commit 9926248109
2 changed files with 31 additions and 18 deletions

View file

@ -154,18 +154,18 @@ func (s *PulseaudioInput) SetMixer(stream string, volume *inputs.InputMixer) err
for _, input := range sinkinputs {
if strconv.FormatInt(input.Index, 10) == stream {
cmd := exec.Command("pactl", "set-sink-input-volume", stream, strconv.FormatUint(uint64(volume.Volume), 10))
err := cmd.Run()
if err != nil {
return fmt.Errorf("unable to set volume: %w", err)
}
if input.Mute != volume.Mute {
cmd := exec.Command("pactl", "set-sink-input-mute", stream, "toggle")
err := cmd.Run()
if err != nil {
return fmt.Errorf("unable to change mute state: %w", err)
}
} else {
cmd := exec.Command("pactl", "set-sink-input-volume", stream, strconv.FormatUint(uint64(volume.Volume), 10))
err := cmd.Run()
if err != nil {
return fmt.Errorf("unable to set volume: %w", err)
}
}
return nil