]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Fix a bug where the dacp notification handlers are called
authorMike Brady <mikebrady@eircom.net>
Sat, 21 Jul 2018 14:35:07 +0000 (15:35 +0100)
committerMike Brady <mikebrady@eircom.net>
Sat, 21 Jul 2018 14:35:07 +0000 (15:35 +0100)
dacp.c
metadata_hub.c
player.c
rtsp.c
shairport.c

diff --git a/dacp.c b/dacp.c
index 81a6f4d20e03f0c5c82f8f615cae017e6b2665ee..667ac19ca0562fc670a7faed187f604a2c8dc380 100644 (file)
--- a/dacp.c
+++ b/dacp.c
@@ -294,12 +294,10 @@ void relinquish_dacp_server_information(rtsp_conn_info *conn) {
   // as the conn's connection number
   // this is to signify that the player has stopped, but only if another thread (with a different
   // index) hasn't already taken over the dacp service
-  sps_pthread_mutex_timedlock(
-      &dacp_server_information_lock, 500000,
-      "set_dacp_server_information couldn't get DACP server information lock in 0.5 second!.", 2);
+  debug_mutex_lock(&dacp_server_information_lock, 500000, 2);
   if (dacp_server.players_connection_thread_index == conn->connection_number)
     dacp_server.players_connection_thread_index = 0;
-  pthread_mutex_unlock(&dacp_server_information_lock);
+  debug_mutex_unlock(&dacp_server_information_lock, 3);
 }
 
 // this will be running on the thread of its caller, not of the conversation thread...
@@ -309,9 +307,7 @@ void relinquish_dacp_server_information(rtsp_conn_info *conn) {
 // Thus, we can keep the DACP port that might have previously been discovered
 void set_dacp_server_information(rtsp_conn_info *conn) {
   // debug(1, "set_dacp_server_information");
-  sps_pthread_mutex_timedlock(
-      &dacp_server_information_lock, 500000,
-      "set_dacp_server_information couldn't get DACP server information lock in 0.5 second!.", 2);
+  debug_mutex_lock(&dacp_server_information_lock, 500000, 2);
   dacp_server.players_connection_thread_index = conn->connection_number;
 
   if ((conn->dacp_id == NULL) || (strcmp(conn->dacp_id, dacp_server.dacp_id) != 0)) {
@@ -360,23 +356,20 @@ void set_dacp_server_information(rtsp_conn_info *conn) {
   debug(2, "set_dacp_server_information set active-remote id to %" PRIu32 ".",
         dacp_server.active_remote_id);
   pthread_cond_signal(&dacp_server_information_cv);
-  pthread_mutex_unlock(&dacp_server_information_lock);
+  debug_mutex_unlock(&dacp_server_information_lock, 3);
 }
 
 void dacp_monitor_port_update_callback(char *dacp_id, uint16_t port) {
   debug(2, "dacp_monitor_port_update_callback with Remote ID \"%s\" and port number %d.", dacp_id,
         port);
-  sps_pthread_mutex_timedlock(
-      &dacp_server_information_lock, 500000,
-      "dacp_monitor_port_update_callback couldn't get DACP server information lock in 0.5 second!.",
-      2);
+  debug_mutex_lock(&dacp_server_information_lock, 500000, 2);
   if (strcmp(dacp_id, dacp_server.dacp_id) == 0) {
     dacp_server.port = port;
     if (port == 0)
       dacp_server.scan_enable = 0;
     else {
       dacp_server.scan_enable = 1;
-      debug(2, "dacp_monitor_port_update_callback enables scan");
+      // debug(2, "dacp_monitor_port_update_callback enables scan");
     }
     //    metadata_hub_modify_prolog();
     //    int ch = metadata_store.dacp_server_active != dacp_server.scan_enable;
@@ -386,11 +379,11 @@ void dacp_monitor_port_update_callback(char *dacp_id, uint16_t port) {
     debug(1, "dacp port monitor reporting on an out-of-use remote.");
   }
   pthread_cond_signal(&dacp_server_information_cv);
-  pthread_mutex_unlock(&dacp_server_information_lock);
+  debug_mutex_unlock(&dacp_server_information_lock, 3);
 }
 
 void dacp_monitor_thread_code_cleanup(__attribute__((unused)) void *arg) {
-  debug(1, "dacp_monitor_thread_code_cleanup called.");
+  // debug(1, "dacp_monitor_thread_code_cleanup called.");
   pthread_mutex_unlock(&dacp_server_information_lock);
 }
 
index 3892e30ae072c61aae80f8d295818c02cf6c34ab..8c957b763ac6a80f06711a217d05cbbbbc472693 100644 (file)
@@ -127,8 +127,8 @@ void add_metadata_watcher(metadata_watcher fn, void *userdata) {
 }
 
 void metadata_hub_unlock_hub_mutex_cleanup(__attribute__((unused)) void *arg) {
-  debug(1, "metadata_hub_unlock_hub_mutex_cleanup called.");
-  pthread_rwlock_wrlock(&metadata_hub_re_lock);
+  // debug(1, "metadata_hub_unlock_hub_mutex_cleanup called.");
+  pthread_rwlock_unlock(&metadata_hub_re_lock);
 }
 
 void run_metadata_watchers(void) {
index 6a2f40aaf4807d852f7da3b203b0d73bdaf5a8ae..5b1fc41929191bc68d4b09312517bf4af161d0d1 100644 (file)
--- a/player.c
+++ b/player.c
@@ -1683,6 +1683,7 @@ void *player_thread_func(void *arg) {
 
 // stop looking elsewhere for DACP stuff
 #ifdef HAVE_DACP_CLIENT
+  debug(1, "Set dacp server info");
   // this does not have pthread cancellation points in it (assuming avahi doesn't)
   set_dacp_server_information(conn); //  this will start scanning when a port is registered by the
                                      // code initiated by the mdns_dacp_monitor
@@ -1696,6 +1697,7 @@ void *player_thread_func(void *arg) {
     // this does not have pthread cancellation points in it (assuming avahi doesn't)
     conn->dapo_private_storage = mdns_dacp_monitor(conn->dacp_id); // ??
 #endif
+  debug(1, "Get radio");
 
   conn->framesProcessedInThisEpoch = 0;
   conn->framesGeneratedInThisEpoch = 0;
diff --git a/rtsp.c b/rtsp.c
index 95b685227ccd0e6ec2317943e8a81cdf96d6a8f5..435c4e6e9128fdc86917c195cb0ec97ec912670d 100644 (file)
--- a/rtsp.c
+++ b/rtsp.c
@@ -1276,7 +1276,7 @@ void metadata_thread_cleanup_function(__attribute__((unused)) void *arg) {
 }
 
 void metadata_pack_cleanup_function(void *arg) {
-  debug(1, "metadata_pack_cleanup_function called");
+  // debug(1, "metadata_pack_cleanup_function called");
   metadata_package *pack = (metadata_package *)arg;
   if (pack->carrier)
     msg_free(pack->carrier); // release the message
@@ -1944,6 +1944,7 @@ void rtsp_conversation_thread_cleanup_function(void *arg) {
   rtsp_conn_info *conn = (rtsp_conn_info *)arg;
   debug(1, "Connection %d: rtsp_conversation_thread_func_cleanup_function called.",
         conn->connection_number);
+  player_stop(conn);
   if (conn->fd > 0)
     close(conn->fd);
   if (conn->auth_nonce) {
@@ -1979,7 +1980,7 @@ void rtsp_conversation_thread_cleanup_function(void *arg) {
 }
 
 void msg_cleanup_function(void *arg) {
-  debug(1, "msg_cleanup_function called.");
+  // debug(1, "msg_cleanup_function called.");
   msg_free((rtsp_message *)arg);
 }
 
@@ -2133,6 +2134,7 @@ static const char *format_address(struct sockaddr *fsa) {
 
 void rtsp_listen_loop_cleanup_handler(__attribute__((unused)) void *arg) {
   debug(1, "rtsp_listen_loop_cleanup_handler called.");
+  cancel_all_RTSP_threads();
   int *sockfd = (int *)arg;
   mdns_unregister();
   if (sockfd)
index 1b4b42503f7c1b0c27f79c07be7b1472fb5cb827..b413631427cdb0e329660cf5b6cc006ed4565959 100644 (file)
@@ -1121,7 +1121,7 @@ const char *pid_file_proc(void) {
 
 void exit_function() {
   debug(1, "exit function called...");
-  cancel_all_RTSP_threads();
+  // cancel_all_RTSP_threads();
   if (conns)
     free(conns); // make sure the connections have been deleted first
   if (config.service_name)