From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 31 May 2021 16:12:20 +0000 (+0100) Subject: Restore ability to compile without AIRPLAY-2 flag (duh). Begin to split player_play... X-Git-Tag: 4.1-dev~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1464c4ed04ee2b0b970a8b2b3e061422a2cd6633;p=thirdparty%2Fshairport-sync.git Restore ability to compile without AIRPLAY-2 flag (duh). Begin to split player_play into player_prepare and player_play. --- diff --git a/player.c b/player.c index c8402524..c307a9cc 100644 --- a/player.c +++ b/player.c @@ -3039,6 +3039,7 @@ void player_flush(uint32_t timestamp, rtsp_conn_info *conn) { #endif } +/* void player_full_flush(rtsp_conn_info *conn) { debug(3, "player_full_flush"); // this basically flushes everything from the player @@ -3068,8 +3069,13 @@ void player_full_flush(rtsp_conn_info *conn) { if (flush_needed) player_flush(rtpTimestamp, conn); } +*/ -int player_play(rtsp_conn_info *conn) { +// perpare_to_play and play are split so that we can get the capabilities of the +// dac etc. before initialising any decoders etc. +// for example, if we have 32-bit DACs, we can ask for 32 bit decodes + +int player_prepare_to_play(rtsp_conn_info *conn) { // need to use conn in place of stream below. Need to put the stream as a parameter to he if (conn->player_thread != NULL) die("Trying to create a second player thread for this RTSP session"); @@ -3082,7 +3088,10 @@ int player_play(rtsp_conn_info *conn) { // call on the output device to prepare itself if ((config.output) && (config.output->prepare)) config.output->prepare(); + return 0; +} +int player_play(rtsp_conn_info *conn) { pthread_t *pt = malloc(sizeof(pthread_t)); if (pt == NULL) die("Couldn't allocate space for pthread_t"); diff --git a/player.h b/player.h index fc8e9bce..a21deec6 100644 --- a/player.h +++ b/player.h @@ -395,13 +395,14 @@ void get_audio_buffer_size_and_occupancy(unsigned int *size, unsigned int *occup int32_t modulo_32_offset(uint32_t from, uint32_t to); +int player_prepare_to_play(rtsp_conn_info *conn); int player_play(rtsp_conn_info *conn); int player_stop(rtsp_conn_info *conn); void player_volume(double f, rtsp_conn_info *conn); void player_volume_without_notification(double f, rtsp_conn_info *conn); void player_flush(uint32_t timestamp, rtsp_conn_info *conn); -void player_full_flush(rtsp_conn_info *conn); +// void player_full_flush(rtsp_conn_info *conn); void player_put_packet(int original_format, seq_t seqno, uint32_t actual_timestamp, uint8_t *data, int len, rtsp_conn_info *conn); int64_t monotonic_timestamp(uint32_t timestamp, diff --git a/rtsp.c b/rtsp.c index 88bf2125..079d6df6 100644 --- a/rtsp.c +++ b/rtsp.c @@ -513,49 +513,6 @@ void cleanup_threads(void) { } } -void add_flush_request(int flushNow, uint32_t flushFromSeq, uint32_t flushFromTS, - uint32_t flushUntilSeq, uint32_t flushUntilTS, rtsp_conn_info *conn) { - // immediate flush requests are added sequentially. Don't know how more than one could arise, TBH - flush_request_t **t = &conn->flush_requests; - int done = 0; - do { - flush_request_t *u = *t; - if ((u == NULL) || ((u->flushNow == 0) && (flushNow != 0)) || - (flushFromSeq < u->flushFromSeq) || - ((flushFromSeq == u->flushFromSeq) && (flushFromTS < u->flushFromTS))) { - flush_request_t *n = (flush_request_t *)calloc(sizeof(flush_request_t), 1); - n->flushNow = flushNow; - n->flushFromSeq = flushFromSeq; - n->flushFromTS = flushFromTS; - n->flushUntilSeq = flushUntilSeq; - n->flushUntilTS = flushUntilTS; - n->next = u; - *t = n; - done = 1; - } else { - t = &u->next; - } - } while (done == 0); -} - -void display_all_flush_requests(rtsp_conn_info *conn) { - if (conn->flush_requests == NULL) { - debug(1, "No flush requests."); - } else { - flush_request_t *t = conn->flush_requests; - do { - if (t->flushNow) { - debug(1, "immediate flush to untilSeq: %u, untilTS: %u.", t->flushUntilSeq, - t->flushUntilTS); - } else { - debug(1, "fromSeq: %u, fromTS: %u, to untilSeq: %u, untilTS: %u.", t->flushFromSeq, - t->flushFromTS, t->flushUntilSeq, t->flushUntilTS); - } - t = t->next; - } while (t != NULL); - } -} - // park a null at the line ending, and return the next line pointer // accept \r, \n, or \r\n static char *nextline(char *in, int inbuf) { @@ -758,6 +715,49 @@ fail: #ifdef CONFIG_AIRPLAY_2 +void add_flush_request(int flushNow, uint32_t flushFromSeq, uint32_t flushFromTS, + uint32_t flushUntilSeq, uint32_t flushUntilTS, rtsp_conn_info *conn) { + // immediate flush requests are added sequentially. Don't know how more than one could arise, TBH + flush_request_t **t = &conn->flush_requests; + int done = 0; + do { + flush_request_t *u = *t; + if ((u == NULL) || ((u->flushNow == 0) && (flushNow != 0)) || + (flushFromSeq < u->flushFromSeq) || + ((flushFromSeq == u->flushFromSeq) && (flushFromTS < u->flushFromTS))) { + flush_request_t *n = (flush_request_t *)calloc(sizeof(flush_request_t), 1); + n->flushNow = flushNow; + n->flushFromSeq = flushFromSeq; + n->flushFromTS = flushFromTS; + n->flushUntilSeq = flushUntilSeq; + n->flushUntilTS = flushUntilTS; + n->next = u; + *t = n; + done = 1; + } else { + t = &u->next; + } + } while (done == 0); +} + +void display_all_flush_requests(rtsp_conn_info *conn) { + if (conn->flush_requests == NULL) { + debug(1, "No flush requests."); + } else { + flush_request_t *t = conn->flush_requests; + do { + if (t->flushNow) { + debug(1, "immediate flush to untilSeq: %u, untilTS: %u.", t->flushUntilSeq, + t->flushUntilTS); + } else { + debug(1, "fromSeq: %u, fromTS: %u, to untilSeq: %u, untilTS: %u.", t->flushFromSeq, + t->flushFromTS, t->flushUntilSeq, t->flushUntilTS); + } + t = t->next; + } while (t != NULL); + } +} + int rtsp_message_contains_plist(rtsp_message *message) { int reply = 0; // assume there is no plist in the message if ((message->contentlength >= strlen("bplist00")) && @@ -1213,8 +1213,10 @@ void handle_record(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) if (have_play_lock(conn)) { if (conn->player_thread) warn("Connection %d: RECORD: Duplicate RECORD message -- ignored", conn->connection_number); - else + else { + player_prepare_to_play(conn); player_play(conn); // the thread better be 0 + } resp->respcode = 200; // I think this is for telling the client what the absolute minimum latency @@ -2047,6 +2049,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) else debug(1, "No timing peer list!"); + player_prepare_to_play(conn); player_play(conn); conn->rtp_running = 1; // hack! @@ -2082,6 +2085,7 @@ void handle_setup_2(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) conn->input_bit_depth = 16; conn->input_bytes_per_frame = conn->input_num_channels * ((conn->input_bit_depth + 7) / 8); + player_prepare_to_play(conn); player_play(conn); conn->rtp_running = 1; // hack!