Signal presence or absence of hardware volume and mute abilities properly. Fix software-only mute.

This commit is contained in:
Mike Brady
2017-05-04 14:06:24 +01:00
parent 0f9e3af373
commit 721a624c53
2 changed files with 17 additions and 9 deletions
+8 -5
View File
@@ -62,8 +62,8 @@ audio_output audio_alsa = {.name = "alsa",
.flush = &flush,
.delay = &delay,
.play = &play,
.mute = &mute,
.volume = &volume,
.mute = NULL, // a function will be provided if it can, and is allowed to, do hardware mute
.volume = NULL, // a function will be provided if it can do hardware volume
.parameters = &parameters};
static pthread_mutex_t alsa_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -440,10 +440,13 @@ static int init(int argc, char **argv) {
}
if ((config.alsa_use_playback_switch_for_mute==1) && (snd_mixer_selem_has_playback_switch(alsa_mix_elem))) {
audio_alsa.mute = &mute; // insert the mute function now we know it can do muting stuff
debug(1, "Has mute ability we will use.");
}
// debug(1, "Has mixer and mute ability we will use.");
} else {
// debug(1, "Has mixer but not using hardware mute.");
}
close_mixer();
} else {
// debug(1, "Has no mixer and thus no hardware mute.");
}
alsa_mix_handle = NULL;
+9 -4
View File
@@ -2222,13 +2222,18 @@ void player_volume(double airplay_volume, rtsp_conn_info* conn) {
// do a mute
// needed even with hardware mute, as when sound is unmuted it might otherwise be very loud.
hardware_attenuation = hw_min_db;
// software_attenuation = sw_min_db;
software_attenuation = sw_max_db - (max_db - hw_max_db); // e.g. if the hw_max_db is +4 and
if (config.output->mute) {
// allow the audio material to reach the mixer, but mute the mixer
// it the mute is removed externally, the material with be there
software_attenuation = sw_max_db - (max_db - hw_max_db); // e.g. if the hw_max_db is +4 and
// the max is +40, this will be -36
// (all by 100, of course)
if (config.output->mute)
// debug(1,"Mute, with hardware mute and software_attenuation set to %d.",software_attenuation);
config.output->mute(1); // use real mute if it's there
} else {
software_attenuation = sw_min_db; // set any software output to zero too
// debug(1,"Mute, with no hardware mute and software_attenuation set to %d.",software_attenuation);
}
} else {
if (config.output->mute)
config.output->mute(0); // unmute mute if it's there