From: Mike Brady Date: Mon, 17 Dec 2018 16:44:19 +0000 (+0000) Subject: Need to use an untimed play for the silence buffer filler. X-Git-Tag: 3.3RC0~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a96d28c4e5e7dbc187ab3aaff1239982e6a5f7f1;p=thirdparty%2Fshairport-sync.git Need to use an untimed play for the silence buffer filler. --- diff --git a/audio_alsa.c b/audio_alsa.c index 17fc672a..f9ce5840 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -133,7 +133,7 @@ static uint64_t frames_played_at_measurement_start_time; static uint64_t measurement_time; static uint64_t frames_played_at_measurement_time; -static uint64_t most_recent_write_time; +volatile uint64_t most_recent_write_time; static uint64_t frames_sent_for_playing; static uint64_t frame_index; @@ -1135,7 +1135,8 @@ int get_rate_information(uint64_t *elapsed_time, uint64_t *frames_played) { return response; } -static int play(void *buf, int samples) { +int untimed_play(void *buf, int samples) { + // debug(3,"audio_alsa play called."); int oldState; pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldState); // make this un-cancellable @@ -1178,7 +1179,6 @@ static int play(void *buf, int samples) { debug(1, "empty buffer being passed to pcm_writei -- skipping it"); if ((samples != 0) && (buf != NULL)) { // debug(3, "write %d frames.", samples); - most_recent_write_time = get_absolute_time_in_fp(); err = alsa_pcm_write(alsa_handle, buf, samples); stall_monitor_frame_count += samples; @@ -1283,6 +1283,11 @@ static void flush(void) { pthread_setcancelstate(oldState, NULL); } +static int play(void *buf, int samples) { + most_recent_write_time = get_absolute_time_in_fp(); // this is to regulate access by the silence filler threrad + return untimed_play(buf,samples); +} + static void stop(void) { // debug(2,"audio_alsa stop called."); // when we want to stop, we want the alsa device