]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Only ask for delay if device is running or draining.
authorMike Brady <mikebrady@eircom.net>
Tue, 26 Mar 2019 12:36:51 +0000 (12:36 +0000)
committerMike Brady <mikebrady@eircom.net>
Tue, 26 Mar 2019 12:36:51 +0000 (12:36 +0000)
audio_alsa.c

index 1ff9f341b93ecae3c6e81e366f8fd607b374e0ec..31316a2283e3bd9298dc938d58d00f431f386f89 100644 (file)
@@ -88,7 +88,7 @@ static pthread_mutex_t alsa_mixer_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 pthread_t alsa_buffer_monitor_thread;
 
-int delay_type_notifier = 0; // used to tell us whether the delay is being estimated from the last update or directly. 
+int delay_type_notifier = -1; // used to tell us whether the delay is being estimated from the last update or directly. 
 
 // for deciding when to activate mute
 // there are two sources of requests to mute -- the backend itself, e.g. when it
@@ -1149,6 +1149,11 @@ int delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay) {
       snd_pcm_status_get_driver_htstamp(alsa_snd_pcm_status, &update_timestamp);
 #endif
 
+  
+    *state = snd_pcm_status_get_state(alsa_snd_pcm_status);
+
+    if ((*state == SND_PCM_STATE_RUNNING) || (*state == SND_PCM_STATE_DRAINING)) {
+
       uint64_t update_timestamp_ns =
           update_timestamp.tv_sec * (uint64_t)1000000000 + update_timestamp.tv_nsec;
 
@@ -1168,13 +1173,6 @@ int delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay) {
           delay_type_notifier = 0;
         }
       }
-  
-  
-    *state = snd_pcm_status_get_state(alsa_snd_pcm_status);
-
-    if ((*state == SND_PCM_STATE_RUNNING) || (*state == SND_PCM_STATE_DRAINING)) {
-
-
                
       if (delay_type_notifier == 1) {
         ret = snd_pcm_delay    (alsa_handle,delay);