diff --git a/dacp.c b/dacp.c index d1522cc0..8f9f8fdc 100644 --- a/dacp.c +++ b/dacp.c @@ -304,12 +304,22 @@ 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"); 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(1, "got lock"); dacp_server.players_connection_thread_index = conn->connection_number; - if (strcmp(conn->dacp_id, dacp_server.dacp_id) != 0) { - strncpy(dacp_server.dacp_id, conn->dacp_id, sizeof(dacp_server.dacp_id)); + debug(1, "do comparison"); + debug(1, "conn->dacp_id is \"%s\"", conn->dacp_id); + debug(1, "dacp_server.dacp_id is \"%s\"", dacp_server.dacp_id); + + if ((conn->dacp_id == NULL) || (strcmp(conn->dacp_id, dacp_server.dacp_id) != 0)) { + debug(1, "comparison failed"); + if (conn->dacp_id) + strncpy(dacp_server.dacp_id, conn->dacp_id, sizeof(dacp_server.dacp_id)); + else + dacp_server.dacp_id[0] = '\0'; dacp_server.port = 0; dacp_server.scan_enable = 0; dacp_server.connection_family = conn->connection_ip_family; @@ -321,7 +331,8 @@ void set_dacp_server_information(rtsp_conn_info *conn) { if (dacp_server.port_monitor_private_storage) // if there's is a monitor already active... mdns_dacp_dont_monitor(dacp_server.port_monitor_private_storage); // let it go. dacp_server.port_monitor_private_storage = - mdns_dacp_monitor(dacp_server.dacp_id); // create a new one for us + mdns_dacp_monitor(dacp_server.dacp_id); // create a new one for us if a DACP-ID is provided, + // otherwise will return a NULL metadata_hub_modify_prolog(); int ch = metadata_store.dacp_server_active != dacp_server.scan_enable; @@ -336,6 +347,7 @@ void set_dacp_server_information(rtsp_conn_info *conn) { } metadata_hub_modify_epilog(ch); } else { + debug(1, "comparison succeeded"); if (dacp_server.port) { // debug(1, "Re-enable scanning."); dacp_server.scan_enable = 1; @@ -345,12 +357,14 @@ void set_dacp_server_information(rtsp_conn_info *conn) { // metadata_hub_modify_epilog(ch); } } + debug(1, "doing something else"); dacp_server.active_remote_id = conn->dacp_active_remote; // even if the dacp_id remains the same, // the active remote will change. 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(1, "Done gettin' Ready"); } void dacp_monitor_port_update_callback(char *dacp_id, uint16_t port) { diff --git a/mdns.c b/mdns.c index 220478a8..855f3c3e 100644 --- a/mdns.c +++ b/mdns.c @@ -106,6 +106,9 @@ void mdns_unregister(void) { void *mdns_dacp_monitor(char *dacp_id) { void *reply = NULL; + if ((dacp_id==NULL) || (*dacp_id=='\0')) + debug(1, "A null or zero-length DACP-ID string was provided for monitoring -- nothing done."); + else { if ((config.mdns) && (config.mdns->mdns_dacp_monitor)) { reply = config.mdns->mdns_dacp_monitor(dacp_id); if (reply == NULL) { @@ -113,6 +116,7 @@ void *mdns_dacp_monitor(char *dacp_id) { } } else debug(1, "Can't start a DACP monitor -- none registered."); + } return reply; } diff --git a/rtsp.c b/rtsp.c index b874bfe7..3fb6ba39 100644 --- a/rtsp.c +++ b/rtsp.c @@ -774,15 +774,25 @@ static void handle_setup(rtsp_conn_info *conn, rtsp_message *req, rtsp_message * #ifdef CONFIG_METADATA send_metadata('ssnc', 'acre', ar, strlen(ar), req, 1); #endif + } else { + debug(2, "Note: no Active-Remote information the SETUP Record."); + conn->dacp_active_remote = 0; } ar = msg_get_header(req, "DACP-ID"); if (ar) { debug(2, "DACP-ID string seen: \"%s\".", ar); + if (conn->dacp_id) // this is in case SETUP was previously called + free(conn->dacp_id); conn->dacp_id = strdup(ar); #ifdef CONFIG_METADATA send_metadata('ssnc', 'daid', ar, strlen(ar), req, 1); #endif + } else { + debug(2, "Note: no DACP-ID string information in the SETUP Record."); + if (conn->dacp_id) // this is in case SETUP was previously called + free(conn->dacp_id); + conn->dacp_id = NULL; } char *hdr = msg_get_header(req, "Transport");