]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Try to ensure that any alsa command sequences are uncancellable. Leave a little time...
authorMike Brady <mikebrady@eircom.net>
Mon, 3 Dec 2018 17:00:12 +0000 (17:00 +0000)
committerMike Brady <mikebrady@eircom.net>
Mon, 3 Dec 2018 17:00:12 +0000 (17:00 +0000)
audio_alsa.c
rtsp.c

index 98182989943dee8fbe22a2b7bcabd47b9f493562..c233a67b4a03e7da793e34d598dd7f4c5525870b 100644 (file)
@@ -506,7 +506,8 @@ static int init(int argc, char **argv) {
   } else {
     debug(1, "alsa: no hardware mixer selected.");
   }
-
+  
+  usleep(200000); // see if it makes a difference
   alsa_mix_handle = NULL;
   return response;
 }
@@ -883,7 +884,7 @@ int actual_open_alsa_device(void) {
       break;
     }
   }
-
+  usleep(200000); // see if it makes a difference
   return 0;
 }
 
@@ -910,6 +911,7 @@ static void start(int i_sample_rate, int i_sample_format) {
 
   frame_index = 0;
   measurement_data_is_valid = 0;
+  usleep(200000); // see if it makes a difference
 }
 
 //assuming pthread cancellation is disabled
@@ -1163,6 +1165,7 @@ static void flush(void) {
     measurement_data_is_valid = 0;
     alsa_handle = NULL;
   }
+  usleep(200000); // see if it makes a difference
   debug_mutex_unlock(&alsa_mutex, 3);
   pthread_cleanup_pop(0); // release the mutex
   pthread_setcancelstate(oldState, NULL);
diff --git a/rtsp.c b/rtsp.c
index 11266c7d5989638ef517cafade073d04501e9ce2..81b380f099992e0cd2d4fbc6db15f96b7dae9bec 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
@@ -265,7 +265,7 @@ int have_player(rtsp_conn_info *conn) {
 
 void player_watchdog_thread_cleanup_handler(void *arg) {
   rtsp_conn_info *conn = (rtsp_conn_info *)arg;
-  debug(2, "Connection %d: Watchdog Exit.", conn->connection_number);
+  debug(1, "Connection %d: Watchdog Exit.", conn->connection_number);
 }
 
 void *player_watchdog_thread_code(void *arg) {
@@ -2116,13 +2116,6 @@ void rtsp_conversation_thread_cleanup_function(void *arg) {
   if (rc)
     debug(1, "Connection %d: error %d destroying flush_mutex.", conn->connection_number, rc);
 
-  debug(2, "Cancel watchdog thread.");
-  pthread_cancel(conn->player_watchdog_thread);
-  debug(2, "Join watchdog thread.");
-  pthread_join(conn->player_watchdog_thread, NULL);
-  debug(2, "Delete watchdog mutex.");
-  pthread_mutex_destroy(&conn->watchdog_mutex);
-
   debug(3, "Connection %d: Checking play lock.", conn->connection_number);
   debug_mutex_lock(&playing_conn_lock, 1000000, 3); // get it
   if (playing_conn == conn) {                       // if it's ours
@@ -2131,6 +2124,13 @@ void rtsp_conversation_thread_cleanup_function(void *arg) {
   }
   debug_mutex_unlock(&playing_conn_lock, 3);
 
+  debug(2, "Cancel watchdog thread.");
+  pthread_cancel(conn->player_watchdog_thread);
+  debug(2, "Join watchdog thread.");
+  pthread_join(conn->player_watchdog_thread, NULL);
+  debug(2, "Delete watchdog mutex.");
+  pthread_mutex_destroy(&conn->watchdog_mutex);
+
   debug(2, "Connection %d: RTSP thread terminated.", conn->connection_number);
   conn->running = 0;
   pthread_setcancelstate(oldState, NULL);