}
void *rtp_buffered_audio_processor(void *arg) {
- // #include <syscall.h>
- // debug(1, "rtp_buffered_audio_processor PID %d", syscall(SYS_gettid));
rtsp_conn_info *conn = (rtsp_conn_info *)arg;
-
+#include <syscall.h>
+ 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;
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);
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];
} 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, "
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));
}
}
} 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
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);
}
} 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");
}
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);
// 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",
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",
#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) {