From: Mike Brady Date: Fri, 1 Feb 2019 21:08:41 +0000 (+0000) Subject: add a volume control mutex to serialise multiple attempts to change the volume, stop... X-Git-Tag: 3.3RC0~66^2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=601ac4d760b2fefb2892f651b988aa59f3ad3322;p=thirdparty%2Fshairport-sync.git add a volume control mutex to serialise multiple attempts to change the volume, stop setting the fixed volume to max if using hybrid volume setup --- diff --git a/player.c b/player.c index fa2e2c3c..c0b4b54f 100644 --- a/player.c +++ b/player.c @@ -2542,6 +2542,7 @@ void *player_thread_func(void *arg) { } void player_volume_without_notification(double airplay_volume, rtsp_conn_info *conn) { + debug_mutex_lock(&conn->volume_control_mutex, 5000, 1); 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 @@ -2632,8 +2633,8 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c min_db = sw_min_db; break; case vol_both: - debug(1, "dB range passed is hw: %d, sw: %d, total: %d", hw_max_db - hw_min_db, - sw_max_db - sw_min_db, (hw_max_db - hw_min_db) + (sw_max_db - sw_min_db)); + //debug(1, "dB range passed is hw: %d, sw: %d, total: %d", hw_max_db - hw_min_db, + // sw_max_db - sw_min_db, (hw_max_db - hw_min_db) + (sw_max_db - sw_min_db)); max_db = (hw_max_db - hw_min_db) + (sw_max_db - sw_min_db); // this should be the range requested min_db = 0; @@ -2671,7 +2672,8 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c // volume to its lowest // before using the hw attenuation. // one imagines that hw priority is likely to be much better - if (config.volume_range_hw_priority) { + // if (config.volume_range_hw_priority) { + if (1) { // hw priority if ((sw_max_db - sw_min_db) > scaled_attenuation) { software_attenuation = sw_min_db + scaled_attenuation; @@ -2700,7 +2702,8 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c config.output->volume(hardware_attenuation); // otherwise set the output to the lowest value // debug(1,"Hardware attenuation set to %f for airplay volume of // %f.",hardware_attenuation,airplay_volume); - conn->fix_volume = 0x10000; + if (volume_mode == vol_hw_only) + conn->fix_volume = 0x10000; } if ((volume_mode == vol_sw_only) || (volume_mode == vol_both)) { @@ -2709,7 +2712,6 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c // %f",software_attenuation,temp_fix_volume,airplay_volume); conn->fix_volume = temp_fix_volume; - memory_barrier(); // no cancellation points if (config.loudness) loudness_set_volume(software_attenuation / 100); @@ -2743,6 +2745,7 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c } } config.airplay_volume = airplay_volume; + debug_mutex_unlock(&conn->volume_control_mutex, 3); } void player_volume(double airplay_volume, rtsp_conn_info *conn) {