use CLOCK_REALTIME instead of CLOCK_MONOTONIC is the alsa library is older than 1.0.28.

This commit is contained in:
Mike Brady
2019-02-17 14:26:14 +00:00
3 changed files with 12 additions and 11 deletions
+7 -7
View File
@@ -114,7 +114,6 @@ int frame_size; // in bytes for interleaved stereo
int alsa_device_initialised; // boolean to ensure the initialisation is only
// done once
snd_pcm_t *alsa_handle = NULL;
int alsa_uses_monotonic_clock = 0;
static snd_pcm_hw_params_t *alsa_params = NULL;
static snd_pcm_sw_params_t *alsa_swparams = NULL;
static snd_ctl_t *ctl = NULL;
@@ -458,12 +457,6 @@ int actual_open_alsa_device(void) {
snd_strerror(ret));
return ret;
}
alsa_uses_monotonic_clock = snd_pcm_hw_params_is_monotonic(alsa_params);
debug(1,"alsa_uses_monotonic_clock is %d",alsa_uses_monotonic_clock);
debug (1,"sizeof time_t is: %d.", sizeof(time_t));
debug (1,"sizeof long is: %d.", sizeof(long));
ret = snd_pcm_sw_params_current(alsa_handle, alsa_swparams);
if (ret < 0) {
@@ -1158,7 +1151,14 @@ int delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay) {
if (*state == SND_PCM_STATE_DRAINING)
debug(1, "alsa: draining with a delay of %d.", delay);
// It seems that the alsa library uses CLOCK_REALTIME before 1.0.28, even though
// the check for monotonic returns true. Might have to watch out for this.
#if SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR < 28
clock_gettime(CLOCK_REALTIME, &tn);
#else
clock_gettime(CLOCK_MONOTONIC, &tn);
#endif
uint64_t time_now_ns = tn.tv_sec * (uint64_t)1000000000 + tn.tv_nsec;
uint64_t update_timestamp_ns =
update_timestamp.tv_sec * (uint64_t)1000000000 + update_timestamp.tv_nsec;
+1 -1
View File
@@ -29,7 +29,7 @@ general =
// volume_control_profile = "standard" ; // use this advanced setting to specify how the airplay volume is transferred to the mixer volume.
// "standard" makes the volume change more quickly at lower volumes and slower at higher volumes.
// "flat" makes the volume change at the same rate at all volumes.
// volume_range_hw_priority = "yes"; // when extending the volume range by combining the built-in software attenuator with the hardware mixer attenuator, set this to "yes" to reduce volume by using the hardware attenuator first, then the software attenuator.
// volume_range_combined_hardware_priority = "no"; // when extending the volume range by combining the built-in software attenuator with the hardware mixer attenuator, set this to "yes" to reduce volume by using the hardware mixer first, then the built-in software attenuator.
// run_this_when_volume_is_set = "/full/path/to/application/and/args"; // Run the specified application whenever the volume control is set or changed.
// The desired AirPlay volume is appended to the end of the command line – leave a space if you want it treated as an extra argument.
// AirPlay volume goes from 0 to -30 and -144 means "mute".
+4 -3
View File
@@ -344,8 +344,9 @@ int parse_options(int argc, char **argv) {
config.diagnostic_drop_packet_fraction = 0.0;
config.active_state_timeout = 10.0;
config.volume_range_hw_priority =
1; // if combining software and hardware volume control, give the hardware priority
// i.e. when reducing volume, reduce the hw first before reducing the software.
0; // if combining software and hardware volume control, give the software priority
// i.e. when reducing volume, reduce the sw first before reducing the software.
// this is because some hw mixers mute at the bottom of their range, and they don't always advertise this fact
#ifdef CONFIG_METADATA_HUB
config.cover_art_cache_dir = "/tmp/shairport-sync/.cache/coverart";
@@ -1568,7 +1569,7 @@ int main(int argc, char **argv) {
config.volume_range_db);
debug(
1,
"combined attenuators (0 -- software is / 1 -- hardware is top of attenuation range) is %d.",
"volume_range_combined_hardware_priority (1 means hardware mixer attenuation is used first) is %d.",
config.volume_range_hw_priority);
debug(1, "playback_mode is %d (0-stereo, 1-mono, 1-reverse_stereo, 2-both_left, 3-both_right).",
config.playback_mode);