From b5e4b258f9c6b905d0248222fbdd6f627b91cd7a Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Sat, 7 Nov 2015 19:07:37 +0000 Subject: [PATCH] Hook up the mute function. --- audio_alsa.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/audio_alsa.c b/audio_alsa.c index 4a11260d..f2afc1a5 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -47,7 +47,6 @@ static void volume(double vol); static void linear_volume(double vol); static void parameters(audio_parameters *info); static void mute(int do_mute); -static int has_mute = 0; static double set_volume; audio_output audio_alsa = { @@ -60,6 +59,7 @@ audio_output audio_alsa = { .flush = &flush, .delay = &delay, .play = &play, + .mute = NULL, // to be set later on... .volume = NULL, // to be set later on... .parameters = NULL // to be set later on... }; @@ -252,7 +252,7 @@ static int init(int argc, char **argv) { } } if (snd_mixer_selem_has_playback_switch(alsa_mix_elem)) { - has_mute = 1; + audio_alsa.mute = &mute; // insert the mute function now we know it can do muting stuff debug(1, "Has mute ability."); } return 0; @@ -461,10 +461,11 @@ static void linear_volume(double vol) { } static void mute(int do_mute) { - if (has_mute) { - if (do_mute) - snd_mixer_selem_set_playback_switch_all(alsa_mix_elem, 0); - else - snd_mixer_selem_set_playback_switch_all(alsa_mix_elem, 1); - } + if (do_mute) { + // debug(1,"Mute"); + snd_mixer_selem_set_playback_switch_all(alsa_mix_elem, 0); + } else { + // debug(1,"Unmute"); + snd_mixer_selem_set_playback_switch_all(alsa_mix_elem, 1); + } }