From 3922f1c36f8d8e60f8537bcaead0422129ec58dd Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 1 Oct 2014 15:32:02 +0200 Subject: Add mute/unmute functions. REflect new functionality in aiomixer. --- src/mixer.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/mixer.cc') diff --git a/src/mixer.cc b/src/mixer.cc index 00cf156..dd9202c 100644 --- a/src/mixer.cc +++ b/src/mixer.cc @@ -336,3 +336,36 @@ bool Mixer::capture() return true; } + +void Mixer::setMuted(bool muted) +{ + if(!isPlayback()) return; + int p = muted?0:1; + int err; + err = snd_mixer_selem_set_playback_switch_all(elem, p); + if(err) { + printf("snd_mixer_selem_set_playback_switch_all: %s, %d\n", + snd_strerror(err), err); + } +} + +bool Mixer::muted() +{ + if(!isPlayback()) return false; + + int err; + + int num = numberOfChannels(); + for(int idx = 0; idx < num; idx++) { + int value; + err = snd_mixer_selem_get_playback_switch(elem, chanId(idx), &value); + if(err) { + printf(" snd_mixer_selem_get_playback_switch: %s, %d\n", + snd_strerror(err), err); + return true; + } + if(value == 0) return true; + } + + return false; +} -- cgit v1.2.3