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:
@@ -122,7 +122,14 @@ typedef struct {
|
||||
config_t *cfg;
|
||||
int endianness;
|
||||
double airplay_volume; // stored here for reloading when necessary
|
||||
char *appName; // normally the app is called shairport-syn, but it may be symlinked
|
||||
double default_airplay_volume;
|
||||
double high_threshold_airplay_volume;
|
||||
uint64_t last_access_to_volume_info_time;
|
||||
int limit_to_high_volume_threshold_time_in_minutes; // revert to the high threshold volume level
|
||||
// if the existing volume level exceeds this
|
||||
// and hasn't been used for this amount of
|
||||
// time (0 means never revert)
|
||||
char *appName; // normally the app is called shairport-syn, but it may be symlinked
|
||||
char *password;
|
||||
char *service_name; // the name for the shairport service, e.g. "Shairport Sync Version %v running
|
||||
// on host %h"
|
||||
@@ -169,10 +176,10 @@ typedef struct {
|
||||
int ignore_volume_control;
|
||||
int volume_max_db_set; // set to 1 if a maximum volume db has been set
|
||||
int volume_max_db;
|
||||
int no_sync; // disable synchronisation, even if it's available
|
||||
int no_mmap; // disable use of mmap-based output, even if it's available
|
||||
double resync_threshold; // if it gets out of whack by more than this number of seconds, do a
|
||||
// resync. if zero, never do a resync.
|
||||
int no_sync; // disable synchronisation, even if it's available
|
||||
int no_mmap; // disable use of mmap-based output, even if it's available
|
||||
double resync_threshold; // if it gets out of whack by more than this number of seconds, do a
|
||||
// resync. if zero, never do a resync.
|
||||
double resync_recovery_time; // if sync is late, drop the delay but also drop the following frames
|
||||
// up to the resync_recovery_time
|
||||
int allow_session_interruption;
|
||||
@@ -318,10 +325,6 @@ typedef struct {
|
||||
int unfixable_error_reported; // only report once.
|
||||
} shairport_cfg;
|
||||
|
||||
// accessors to config for multi-thread access
|
||||
double get_config_airplay_volume();
|
||||
void set_config_airplay_volume(double v);
|
||||
|
||||
uint32_t nctohl(const uint8_t *p); // read 4 characters from *p and do ntohl on them
|
||||
uint16_t nctohs(const uint8_t *p); // read 2 characters from *p and do ntohs on them
|
||||
uint64_t nctoh64(const uint8_t *p); // read 8 characters from *p to a uint64_t
|
||||
|
||||
Reference in New Issue
Block a user