debug(log_level, "PCM handle name = '%s'", snd_pcm_name(alsa_handle));
- // ret = snd_pcm_hw_params_any(alsa_handle, alsa_params);
- // if (ret < 0) {
- // die("audio_alsa: Cannpot get configuration for
+ // ret = snd_pcm_hw_params_any(alsa_handle, alsa_params);
+ // if (ret < 0) {
+ // die("audio_alsa: Cannpot get configuration for
// device
//\"%s\":
// no
// configurations
//"
- // "available",
- // alsa_out_dev);
- // }
+ // "available",
+ // alsa_out_dev);
+ // }
debug(log_level, "alsa device parameters:");
}
int do_alsa_device_init_if_needed() {
- debug(1, "do_alsa_device_init_if_needed()");
int response = 0;
// do any alsa device initialisation (general case) if needed
// at present, this is only needed if a hardware mixer is being used
if (alsa_device_initialised == 0) {
alsa_device_initialised = 1;
if (hardware_mixer) {
+ debug(2, "alsa: hardware mixer init");
int oldState;
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldState); // make this un-cancellable
}
int set_mute_state() {
- debug(1, "set_mute_state");
- int response = 1; // some problem expected, e.g. no mixer or not allowed to use it
- if (config.alsa_use_hardware_mute == 1) {
+ int response = 1; // some problem expected, e.g. no mixer or not allowed to use it or disconnected
+ if ((alsa_backend_state != abm_disconnected) && (config.alsa_use_hardware_mute == 1) && (open_mixer() == 1)) {
+ response = 0; // okay if actually using the mute facility
+ debug(1, "set_mute_state");
int mute = 0;
if ((mute_requested_externally != 0) || (mute_requested_internally != 0))
- mute = 1;
- if (open_mixer() == 1) {
- response = 0; // okay if actually using the mute facility
- if (mute == 1) {
- debug(1, "Hardware mute switched on");
- if (snd_mixer_selem_has_playback_switch(alsa_mix_elem))
- snd_mixer_selem_set_playback_switch_all(alsa_mix_elem, 0);
- else {
- volume_based_mute_is_active = 1;
- do_snd_mixer_selem_set_playback_dB_all(alsa_mix_elem, alsa_mix_mute);
- }
- } else {
- debug(1, "Hardware mute switched off");
- if (snd_mixer_selem_has_playback_switch(alsa_mix_elem))
- snd_mixer_selem_set_playback_switch_all(alsa_mix_elem, 1);
- else {
- volume_based_mute_is_active = 0;
- do_snd_mixer_selem_set_playback_dB_all(alsa_mix_elem, set_volume);
- }
+ mute = 1;
+ if (mute == 1) {
+ debug(1, "Hardware mute switched on");
+ if (snd_mixer_selem_has_playback_switch(alsa_mix_elem))
+ snd_mixer_selem_set_playback_switch_all(alsa_mix_elem, 0);
+ else {
+ volume_based_mute_is_active = 1;
+ do_snd_mixer_selem_set_playback_dB_all(alsa_mix_elem, alsa_mix_mute);
+ }
+ } else {
+ debug(1, "Hardware mute switched off");
+ if (snd_mixer_selem_has_playback_switch(alsa_mix_elem))
+ snd_mixer_selem_set_playback_switch_all(alsa_mix_elem, 1);
+ else {
+ volume_based_mute_is_active = 0;
+ do_snd_mixer_selem_set_playback_dB_all(alsa_mix_elem, set_volume);
}
- close_mixer();
}
+ close_mixer();
}
return response;
}
+
static void start(int i_sample_rate, int i_sample_format) {
- debug(1, "audio_alsa start called.");
+ debug(3, "audio_alsa start called.");
if (i_sample_rate == 0)
desired_sample_rate = 44100; // default
else
stall_monitor_start_time = 0;
stall_monitor_frame_count = 0;
if (alsa_device_initialised == 0) {
- debug(1, "alsa: start() calling do_alsa_device_init_if_needed.");
+ debug(2, "alsa: start() calling do_alsa_device_init_if_needed.");
do_alsa_device_init_if_needed();
}
}
if (audio_alsa.volume)
do_volume(set_volume);
if (audio_alsa.mute) {
- debug(1, "do_open() set_mute_state");
+ debug(2, "do_open() set_mute_state");
set_mute_state(); // the mute_requested_externally flag will have been
// set accordingly
// do_mute(0); // complete unmute
alsa_backend_state = abm_playing;
mute_requested_internally = 0; // stop requesting a mute for backend's own
// reasons, which might have been a flush
- debug(1, "play() set_mute_state");
+ debug(2, "play() set_mute_state");
set_mute_state(); // try to action the request and return a status
// do_mute(0); // unmute for backend's reason
}
// debug(2,"audio_alsa flush called.");
pthread_cleanup_debug_mutex_lock(&alsa_mutex, 10000, 1);
mute_requested_internally = 1; // request a mute for backend's reasons
- debug(1, "flush() set_mute_state");
+ debug(2, "flush() set_mute_state");
set_mute_state();
// do_mute(1); // mute for backend's own reasons
if (alsa_backend_state != abm_disconnected) { // must be playing or connected...
int mute(int mute_state_requested) { // these would be for external reasons, not
// because of the
// state of the backend.
- debug(1, "alsa: mute(%d)", mute_state_requested);
mute_requested_externally = mute_state_requested; // request a mute for external reasons
- debug(1, "mute(%d) set_mute_state", mute_state_requested);
+ debug(2, "mute(%d) set_mute_state", mute_state_requested);
return set_mute_state();
}
/*
void *alsa_buffer_monitor_thread_code(__attribute__((unused)) void *arg) {
while (1) {
if ((config.keep_dac_busy != 0) && (alsa_device_initialised == 0)) {
- debug(1, "alsa: alsa_buffer_monitor_thread_code() calling "
+ debug(2, "alsa: alsa_buffer_monitor_thread_code() calling "
"do_alsa_device_init_if_needed.");
do_alsa_device_init_if_needed();
}
}
void player_volume_without_notification(double airplay_volume, rtsp_conn_info *conn) {
- debug(1, "player_volume_without_notification %f", airplay_volume);
+ debug(2, "player_volume_without_notification %f", airplay_volume);
// first, see if we are hw only, sw only, both with hw attenuation on the top or both with sw
// attenuation on top
if (airplay_volume == -144.0) {
if ((config.output->mute) && (config.output->mute(1) == 0))
- debug(1, "player: hardware mute is enabled.");
+ debug(2, "player_volume_without_notification: volume mode is %d, airplay_volume is %f, hardware mute is enabled.", volume_mode, airplay_volume);
else {
conn->software_mute_enabled = 1;
- debug(1, "player: software mute is enabled.");
+ debug(2, "player_volume_without_notification: volume mode is %d, airplay_volume is %f, software mute is enabled.", volume_mode, airplay_volume);
}
} else {
min_db = 0;
break;
default:
- debug(1, "error in pv -- not in a volume mode");
+ debug(1, "player_volume_without_notification: error: not in a volume mode");
break;
}
double scaled_attenuation = 0.0;
scaled_attenuation =
flat_vol2attn(airplay_volume, max_db, min_db); // no cancellation points
else
- debug(1, "Unrecognised volume control profile");
+ debug(1, "player_volume_without_notification: unrecognised volume control profile");
// so here we have the scaled attenuation. If it's for hw or sw only, it's straightforward.
double hardware_attenuation = 0.0;
}
break;
default:
- debug(1, "error in pv -- not in a volume mode");
+ debug(1, "player_volume_without_notification: error: not in a volume mode");
break;
}
config.output->mute(0);
conn->software_mute_enabled = 0;
- debug(1, "pv: volume mode is %d, software_attenuation: %f, hardware_attenuation: %f, muting "
+ debug(2, "player_volume_without_notification: volume mode is %d, airplay volume is %f, software_attenuation: %f, hardware_attenuation: %f, muting "
"is disabled.",
- volume_mode, software_attenuation, hardware_attenuation);
+ volume_mode, airplay_volume, software_attenuation, hardware_attenuation);
}
}
config.airplay_volume = airplay_volume;