summaryrefslogtreecommitdiff
path: root/dacp.c
diff options
context:
space:
mode:
authorMike Brady <mikebrady@eircom.net>2018-04-07 17:13:04 +0100
committerMike Brady <mikebrady@eircom.net>2018-04-07 17:13:04 +0100
commitfb3f9f51eb7e08401ec23267cae099a8904891bd (patch)
tree71803091f417b5e03109a3a1efcc6f7e8ece1597 /dacp.c
parent1881beb54217506e19791ee33a6b6441560e457a (diff)
Handle situation when the Shairport Sync player is deselected.
Diffstat (limited to 'dacp.c')
-rw-r--r--dacp.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/dacp.c b/dacp.c
index 4eeafc7..327819c 100644
--- a/dacp.c
+++ b/dacp.c
@@ -352,7 +352,7 @@ 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,
+ 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,
@@ -389,10 +389,23 @@ void *dacp_monitor_thread_code(__attribute__((unused)) void *na) {
sps_pthread_mutex_timedlock(
&dacp_server_information_lock, 500000,
"dacp_monitor_thread_code couldn't get DACP server information lock in 0.5 second!.", 2);
- 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);
+ if (dacp_server.scan_enable == 0) {
+ metadata_hub_modify_prolog();
+ int ch = (metadata_store.dacp_server_active != 0) ||
+ (metadata_store.advanced_dacp_server_active != 0);
+ metadata_store.dacp_server_active = 0;
+ metadata_store.advanced_dacp_server_active = 0;
+ debug(1, "setting dacp_server_active and advanced_dacp_server_active to 0 with an update "
+ "flag value of %d",
+ ch);
+ metadata_hub_modify_epilog(ch);
+ while (dacp_server.scan_enable == 0) {
+ // debug(1, "dacp_monitor_thread_code wait for an event to possible enable scan");
+ pthread_cond_wait(&dacp_server_information_cv, &dacp_server_information_lock);
+ // debug(1,"dacp_monitor_thread_code wake up.");
+ }
+ bad_result_count = 0;
+ idle_scan_count = 0;
}
scan_index++;
int32_t the_volume;
@@ -416,17 +429,6 @@ void *dacp_monitor_thread_code(__attribute__((unused)) void *na) {
(idle_scan_count == config.scan_max_inactive_count)) {
debug(1, "DACP server status scanning stopped.");
dacp_server.scan_enable = 0;
- bad_result_count = 0;
- idle_scan_count = 0;
- metadata_hub_modify_prolog();
- int ch = (metadata_store.dacp_server_active != 0) ||
- (metadata_store.advanced_dacp_server_active != 0);
- metadata_store.dacp_server_active = 0;
- metadata_store.advanced_dacp_server_active = 0;
- debug(1, "setting dacp_server_active and advanced_dacp_server_active to 0 with an update "
- "flag value of %d",
- ch);
- metadata_hub_modify_epilog(ch);
}
pthread_mutex_unlock(&dacp_server_information_lock);
// debug(1, "DACP Server ID \"%u\" at \"%s:%u\", scan %d.", dacp_server.active_remote_id,