From e8e81a8b079f2a14b5b1f7274bca555478368af6 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Wed, 12 May 2021 10:57:50 +0100 Subject: [PATCH] fix a couple of compilation errors. --- common.c | 2 ++ common.h | 2 ++ player.c | 91 ++++++++++++++++++++++++++------------------------------ rtsp.c | 1 + 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/common.c b/common.c index 068f78b8..69270cb9 100644 --- a/common.c +++ b/common.c @@ -1560,10 +1560,12 @@ void malloc_cleanup(void *arg) { free(arg); } +#ifdef CONFIG_AIRPLAY_2 void plist_cleanup(void *arg) { // debug(1, "plist cleanup called."); plist_free((plist_t)arg); } +#endif void socket_cleanup(void *arg) { intptr_t fdp = (intptr_t)arg; diff --git a/common.h b/common.h index 8ff0978c..4d8dcc1d 100644 --- a/common.h +++ b/common.h @@ -471,7 +471,9 @@ void mutex_unlock(void *arg); void mutex_cleanup(void *arg); void cv_cleanup(void *arg); void thread_cleanup(void *arg); +#ifdef CONFIG_AIRPLAY_2 void plist_cleanup(void *arg); +#endif char *debug_malloc_hex_cstring(void *packet, size_t nread); diff --git a/player.c b/player.c index 799e9e25..eb6e4b4a 100644 --- a/player.c +++ b/player.c @@ -1035,51 +1035,49 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) { notified_buffer_empty = 0; // at least one buffer now -- diagnostic only. if (conn->ab_buffering) { // if we are getting packets but not yet forwarding them to the // player - if (conn->first_packet_timestamp == 0) { // if this is the very first packet - if (have_timestamp_timing_information(conn)) { // if we have a reference time - // debug(1,"First frame seen with timestamp..."); - conn->first_packet_timestamp = - curframe->given_timestamp; // we will keep buffering until we are - // supposed to start playing this + if (conn->first_packet_timestamp == 0) { // if this is the very first packet + // debug(1,"First frame seen with timestamp..."); + conn->first_packet_timestamp = + curframe->given_timestamp; // we will keep buffering until we are + // supposed to start playing this #ifdef CONFIG_METADATA - // say we have started receiving frames here - debug(2, "pffr"); - send_ssnc_metadata( - 'pffr', NULL, 0, - 0); // "first frame received", but don't wait if the queue is locked + // say we have started receiving frames here + debug(2, "pffr"); + send_ssnc_metadata( + 'pffr', NULL, 0, + 0); // "first frame received", but don't wait if the queue is locked #endif - // Here, calculate when we should start playing. We need to know when to allow the - // packets to be sent to the player. + // Here, calculate when we should start playing. We need to know when to allow the + // packets to be sent to the player. - // every second or so, we get a reference on when a particular packet should be - // played. + // every second or so, we get a reference on when a particular packet should be + // played. - // It probably won't be the timestamp of our first packet, however, so we might - // have to do some calculations. + // It probably won't be the timestamp of our first packet, however, so we might + // have to do some calculations. - // To calculate when the first packet will be played, we figure out the exact time - // the packet should be played according to its timestamp and the reference time. - // The desired latency, typically 88200 frames, will be calculated for in rtp.c, - // and any desired backend latency offset included in it there. + // To calculate when the first packet will be played, we figure out the exact time + // the packet should be played according to its timestamp and the reference time. + // The desired latency, typically 88200 frames, will be calculated for in rtp.c, + // and any desired backend latency offset included in it there. - uint64_t should_be_time; + uint64_t should_be_time; - frame_to_local_time(conn->first_packet_timestamp, // this will go modulo 2^32 - &should_be_time, conn); + frame_to_local_time(conn->first_packet_timestamp, // this will go modulo 2^32 + &should_be_time, conn); - conn->first_packet_time_to_play = should_be_time; + conn->first_packet_time_to_play = should_be_time; - int64_t lt = conn->first_packet_time_to_play - local_time_now; + int64_t lt = conn->first_packet_time_to_play - local_time_now; - debug(1, "Connection %d: Lead time for first frame %" PRId64 ": %f seconds.", - conn->connection_number, conn->first_packet_timestamp, lt * 0.000000001); + debug(1, "Connection %d: Lead time for first frame %" PRId64 ": %f seconds.", + conn->connection_number, conn->first_packet_timestamp, lt * 0.000000001); - int64_t lateness = local_time_now - conn->first_packet_time_to_play; - if (lateness > 0) { - debug(1, "First packet is %" PRId64 " nanoseconds late! Flushing 0.5 seconds", - lateness); - do_flush(conn->first_packet_timestamp + 5 * 4410, conn); - } + int64_t lateness = local_time_now - conn->first_packet_time_to_play; + if (lateness > 0) { + debug(1, "First packet is %" PRId64 " nanoseconds late! Flushing 0.5 seconds", + lateness); + do_flush(conn->first_packet_timestamp + 5 * 4410, conn); } } @@ -1230,21 +1228,19 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) { } } } - } - // Here, we work out whether to release a packet or wait - // We release a packet when the time is right. - // To work out when the time is right, we need to take account of (1) the actual time the packet - // should be released, - // (2) the latency requested, (3) the audio backend latency offset and (4) the desired length of - // the audio backend's buffer + // Here, we work out whether to release a packet or wait + // We release a packet when the time is right. - // The time is right if the current time is later or the same as - // The packet time + (latency + latency offset - backend_buffer_length). - // Note: the last three items are expressed in frames and must be converted to time. + // To work out when the time is right, we need to take account of (1) the actual time the + // packet should be released, (2) the latency requested, (3) the audio backend latency offset + // and (4) the desired length of the audio backend's buffer - int do_wait = 0; // don't wait unless we can really prove we must - if (have_timestamp_timing_information(conn)) { + // The time is right if the current time is later or the same as + // The packet time + (latency + latency offset - backend_buffer_length). + // Note: the last three items are expressed in frames and must be converted to time. + + int do_wait = 0; // don't wait unless we can really prove we must if ((conn->ab_synced) && (curframe) && (curframe->ready) && (curframe->given_timestamp)) { do_wait = 1; // if the current frame exists and is ready, then wait unless it's time to let // it go... @@ -1305,8 +1301,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) { } wait = (conn->ab_buffering || (do_wait != 0) || (!conn->ab_synced)); } else { - wait = 1; - // debug(1,"don't yet have timing information"); + wait = 1; // keep waiting until the timing information becomes available } if (wait) { uint64_t time_to_wait_for_wakeup_ns = diff --git a/rtsp.c b/rtsp.c index 6eef9789..a5564f1e 100644 --- a/rtsp.c +++ b/rtsp.c @@ -1411,6 +1411,7 @@ void handle_setrateanchori(rtsp_conn_info *conn, rtsp_message *req, rtsp_message } } else { player_full_flush(conn); + ptp_send_control_message_string("T"); // ensure an obsolete clock isn't picked up later. } } pthread_cleanup_pop(1); // plist_free the messagePlist;