From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Thu, 4 Dec 2025 11:35:00 +0000 (+0000) Subject: Balking when connecting to HPM. X-Git-Tag: 5.0-post-dev~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e274eb7603796dc4e9a2abf3028c292dae78005;p=thirdparty%2Fshairport-sync.git Balking when connecting to HPM. --- diff --git a/ap2_buffered_audio_processor.c b/ap2_buffered_audio_processor.c index b09000c1..0ef4beef 100644 --- a/ap2_buffered_audio_processor.c +++ b/ap2_buffered_audio_processor.c @@ -99,10 +99,9 @@ void rtp_buffered_audio_cleanup_handler(__attribute__((unused)) void *arg) { } void *rtp_buffered_audio_processor(void *arg) { - // #include - // debug(1, "rtp_buffered_audio_processor PID %d", syscall(SYS_gettid)); rtsp_conn_info *conn = (rtsp_conn_info *)arg; - +#include + debug(1, "Connection %d: rtp_buffered_audio_processor PID %d start", conn->connection_number, syscall(SYS_gettid)); conn->incoming_ssrc = 0; // reset conn->resampler_ssrc = 0; @@ -126,7 +125,8 @@ void *rtp_buffered_audio_processor(void *arg) { buffered_tcp_desc *buffered_audio = malloc(sizeof(buffered_tcp_desc)); if (buffered_audio == NULL) debug(1, "cannot allocate a buffered_tcp_desc!"); - // initialise the descriptor + // initialise the + memset(buffered_audio, 0, sizeof(buffered_tcp_desc)); pthread_cleanup_push(malloc_cleanup, &buffered_audio); @@ -314,7 +314,7 @@ void *rtp_buffered_audio_processor(void *arg) { if (nread == 0) { // nread is 0 -- the port has been closed - debug(1, "buffered audio port closed!"); + debug(1, "Connection %d: buffered audio port closed!", conn->connection_number); finished = 1; } else if (nread < 0) { char errorstring[1024]; @@ -516,7 +516,7 @@ void *rtp_buffered_audio_processor(void *arg) { } else { timestamp_difference = timestamp - expected_timestamp; if (timestamp_difference != 0) { - debug(2, + debug(1, "Connection %d: " "unexpected timestamp in block %u. Actual: %u, expected: %u " "difference: %d, " @@ -541,7 +541,7 @@ void *rtp_buffered_audio_processor(void *arg) { int32_t abs_timestamp_difference = -timestamp_difference; if ((size_t)abs_timestamp_difference > get_ssrc_block_length(payload_ssrc)) { skip_this_block = 1; - debug(2, + debug(1, "skipping block %u because it was too far in the past. Timestamp " "difference: %d, length of block: %u.", seq_no, timestamp_difference, get_ssrc_block_length(payload_ssrc)); @@ -587,7 +587,7 @@ void *rtp_buffered_audio_processor(void *arg) { } } } while (finished == 0); - debug(2, "Buffered Audio Receiver RTP thread \"normal\" exit."); + debug(1, "Connection %d: rtp_buffered_audio_processor PID %d exiting", conn->connection_number, syscall(SYS_gettid)); pthread_cleanup_pop(1); // buffered_tcp_reader thread creation pthread_cleanup_pop(1); // buffer malloc pthread_cleanup_pop(1); // not_full_cv @@ -596,5 +596,6 @@ void *rtp_buffered_audio_processor(void *arg) { pthread_cleanup_pop(1); // descriptor malloc pthread_cleanup_pop(1); // pthread_t malloc pthread_cleanup_pop(1); // do the cleanup. + debug(1, "Connection %d: rtp_buffered_audio_processor PID %d finish", conn->connection_number, syscall(SYS_gettid)); pthread_exit(NULL); } diff --git a/player.c b/player.c index 18f1e12c..1b76331b 100644 --- a/player.c +++ b/player.c @@ -3322,12 +3322,14 @@ void player_thread_cleanup_handler(void *arg) { } else if (conn->airplay_stream_type == buffered_stream) { - debug(2, + debug(1, "Connection %d: Delete Buffered Audio Stream thread by player_thread_cleanup_handler", conn->connection_number); pthread_cancel(conn->rtp_buffered_audio_thread); pthread_join(conn->rtp_buffered_audio_thread, NULL); - + debug(1, + "Connection %d: Deleted Buffered Audio Stream thread by player_thread_cleanup_handler", + conn->connection_number); } else { die("Unrecognised Stream Type"); } diff --git a/rtsp.c b/rtsp.c index 742d80de..ae169ecb 100644 --- a/rtsp.c +++ b/rtsp.c @@ -430,10 +430,10 @@ int get_play_lock(rtsp_conn_info *conn, int allow_session_interruption) { if (principal_conn->fd > 0) { debug(1, - "Connection %d: get_play_lock forced termination. Closing RTSP connection socket %d: " + "Connection %d: get_play_lock forced termination in favour of connection %d. Closing RTSP connection socket %d: " "from %s:%u to self at " "%s:%u.", - principal_conn->connection_number, principal_conn->fd, principal_conn->client_ip_string, + principal_conn->connection_number, conn->connection_number, principal_conn->fd, principal_conn->client_ip_string, principal_conn->client_rtsp_port, principal_conn->self_ip_string, principal_conn->self_rtsp_port); close(principal_conn->fd); @@ -2995,7 +2995,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) // debug(1,"initial timing peer command: \"%s\".", timing_list_message); // ptp_send_control_message_string(timing_list_message); set_client_as_ptp_clock(conn); - // ptp_send_control_message_string("B"); // signify clock dependability period is + ptp_send_control_message_string("B"); // signify clock dependability period is // "B"eginning (or continuing) plist_dict_set_item(timingPeerInfoPlist, "Addresses", addresses); plist_dict_set_item(timingPeerInfoPlist, "ID", @@ -3294,9 +3294,14 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) activity_monitor_signify_activity(1); + debug(1, "Connection %d: create rtp_buffered_audio_thread", conn->connection_number); + named_pthread_create_with_priority(&conn->rtp_buffered_audio_thread, 2, &rtp_buffered_audio_processor, (void *)conn, "ap2_bat_%d", conn->connection_number); + + + usleep(1000000); plist_dict_set_item(stream0dict, "type", plist_new_uint(103)); plist_dict_set_item(stream0dict, "dataPort", diff --git a/utilities/buffered_read.c b/utilities/buffered_read.c index 0ff7faff..faaf8b62 100644 --- a/utilities/buffered_read.c +++ b/utilities/buffered_read.c @@ -92,7 +92,7 @@ ssize_t buffered_read(buffered_tcp_desc *descriptor, void *buf, size_t count, #define STANDARD_PACKET_SIZE 4096 void buffered_tcp_reader_cleanup_handler(__attribute__((unused)) void *arg) { - debug(2, "Buffered TCP Reader Thread Exit via Cleanup."); + debug(1, "Buffered TCP Reader Thread Exit via Cleanup."); } void *buffered_tcp_reader(void *arg) {