]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Begin to debug the DACP scanner starting and stopping.
authorMike Brady <mikebrady@eircom.net>
Wed, 4 Apr 2018 21:44:46 +0000 (22:44 +0100)
committerMike Brady <mikebrady@eircom.net>
Wed, 4 Apr 2018 21:44:46 +0000 (22:44 +0100)
dacp.c
shairport.c

diff --git a/dacp.c b/dacp.c
index c204f8caf4ca63b1b5d1e03a672bc1d815892be5..b67138a0738ed21c630653b097b257a7a536e152 100644 (file)
--- a/dacp.c
+++ b/dacp.c
@@ -302,7 +302,7 @@ void relinquish_dacp_server_information(rtsp_conn_info *conn) {
 // the conversation number
 // 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.");  
+  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);
@@ -332,6 +332,15 @@ void set_dacp_server_information(rtsp_conn_info *conn) {
       ch = 1;
     }
     metadata_hub_modify_epilog(ch);
+  } else {
+    if (dacp_server.port) {
+      debug(1,"Enable scanning.");
+      dacp_server.scan_enable = 1;
+      metadata_hub_modify_prolog();
+      int ch = metadata_store.dacp_server_active != dacp_server.scan_enable;
+      metadata_store.dacp_server_active = dacp_server.scan_enable;
+      metadata_hub_modify_epilog(ch);
+    }
   }
   dacp_server.active_remote_id = conn->dacp_active_remote; // even if the dacp_id remains the same, the active remote will change.
   pthread_cond_signal(&dacp_server_information_cv);
@@ -339,8 +348,8 @@ void set_dacp_server_information(rtsp_conn_info *conn) {
 }
 
 void dacp_monitor_port_update_callback(char *dacp_id, uint16_t port) {
-  //debug(1, "dacp_monitor_port_update_callback with Remote ID \"%s\" and port number %d.", dacp_id,
-  //      port);
+  debug(1, "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!.",
@@ -359,6 +368,7 @@ void dacp_monitor_port_update_callback(char *dacp_id, uint16_t port) {
   } else {
     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);
 }
 void *dacp_monitor_thread_code(__attribute__((unused)) void *na) {
@@ -377,6 +387,7 @@ void *dacp_monitor_thread_code(__attribute__((unused)) void *na) {
     while (dacp_server.scan_enable == 0) {
       // debug(1, "Wait for a valid DACP port");
       pthread_cond_wait(&dacp_server_information_cv, &dacp_server_information_lock);
+      debug(1,"Wake up with dacp_server.scan_enable == %d.",dacp_server.scan_enable);
     }
     scan_index++;
     int32_t the_volume;
@@ -393,7 +404,7 @@ void *dacp_monitor_thread_code(__attribute__((unused)) void *na) {
     else
       idle_scan_count = 0;
       
-    // debug(1,"Bad Scan Count: %d, Idle Scan Count: %d.",bad_result_count,idle_scan_count);
+    debug(1,"Bad Scan Count: %d, Idle Scan Count: %d.",bad_result_count,idle_scan_count);
 
     if ((bad_result_count == config.scan_max_bad_response_count) || (idle_scan_count == config.scan_max_inactive_count)) {
       debug(1,"DACP server status scanning stopped.");
@@ -403,6 +414,7 @@ void *dacp_monitor_thread_code(__attribute__((unused)) void *na) {
       metadata_hub_modify_prolog();
       int ch = metadata_store.dacp_server_active != 0;
       metadata_store.dacp_server_active = 0;
+      debug(1,"setting dacp_server_active to %d with an update flag value of %d",metadata_store.dacp_server_active,ch);
       metadata_hub_modify_epilog(ch);
     }
     pthread_mutex_unlock(&dacp_server_information_lock);
index 5a18e4fa8350690ac6f1991761b89a387a08617c..cd890bb6f5e4789d1019b81e75dc9e93c7922fe2 100644 (file)
@@ -337,7 +337,8 @@ int parse_options(int argc, char **argv) {
   config.scan_interval_when_active = 1; // number of seconds between DACP server scans when playing something
   config.scan_interval_when_inactive = 3; // number of seconds between DACP server scans playing nothing
   config.scan_max_bad_response_count = 10; // number of successive bad results to ignore before giving up 
-  config.scan_max_inactive_count = (15*60)/config.scan_interval_when_inactive; // number of scans to do before stopping if not made active again (15 minutes )
+//  config.scan_max_inactive_count = (15*60)/config.scan_interval_when_inactive; // number of scans to do before stopping if not made active again (15 minutes )
+  config.scan_max_inactive_count = 5; // number of scans to do before stopping if not made active again (15 minutes )
 #endif
 
   // config_setting_t *setting;