Fix a bug where the dacp notification handlers are called

This commit is contained in:
Mike Brady
2018-07-21 15:35:07 +01:00
parent f1d4503431
commit 2eaaa9cdb3
5 changed files with 17 additions and 20 deletions
+8 -15
View File
@@ -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);
}
+2 -2
View 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) {
+2
View File
@@ -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;
+4 -2
View File
@@ -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)
+1 -1
View 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)