Add code to try to save your ears by handling a situation where the player volume was set very high some time ago and you have forgotten.

In that situation currenctly, when you play something, it will come out at the last volume set on the device, which will be that very high volume.
This could happen, for example, the morning after a loud party :).

The new code works as follows: If nothing has been played for a period, say a few hours, and the volume is higher than a threshold, new connections that ask
for the current volume setting will be offered the default (low) volume rather than the current (very high) one.
Most players, including the HomePod mini, iOS and iPadOS use this to set their initial volume.
The Mac Music app retains its own setting, and the Mac System Sounds preference sometimes seems to take its setting from the Music app,
but at least you can see the settings they will apply.

Existing connections are unaffected, so this facility should be unobtrusive.
This commit is contained in:
Mike Brady
2023-01-18 10:41:50 +00:00
parent d2ca8c84a4
commit 8201903a4e
7 changed files with 107 additions and 42 deletions
+6 -3
View File
@@ -636,11 +636,14 @@ gboolean notify_volume_callback(ShairportSync *skeleton,
debug(2, ">> setting volume to %7.4f.", iv);
lock_player();
config.airplay_volume = iv;
if (playing_conn != NULL)
if (playing_conn != NULL) {
player_volume(iv, playing_conn);
playing_conn->own_airplay_volume = iv;
playing_conn->own_airplay_volume_set = 1;
}
unlock_player();
config.airplay_volume = iv;
config.last_access_to_volume_info_time = get_absolute_time_in_ns();
} else {
debug(1, ">> invalid volume: %f. Ignored.", iv);
shairport_sync_set_volume(skeleton, config.airplay_volume);