diff --git a/ap2_buffered_audio_processor.c b/ap2_buffered_audio_processor.c index 290d30f0..c26bf372 100644 --- a/ap2_buffered_audio_processor.c +++ b/ap2_buffered_audio_processor.c @@ -338,20 +338,33 @@ void *rtp_buffered_audio_processor(void *arg) { debug(2, "immediate flush started at sequence number %u until sequence number of %u.", seq_no, conn->ap2_immediate_flush_until_sequence_number); } - if ((blocks_read != 0) && (seq_no == conn->ap2_immediate_flush_until_sequence_number)) { - debug(2, "immediate flush complete at seq_no of %u.", seq_no); + if ((blocks_read != 0) && ((a_minus_b_mod23(seq_no, conn->ap2_immediate_flush_until_sequence_number) > 0))) { + debug(1, "immediate flush may have escaped its endpoint! Seq_no is %u, conn->ap2_immediate_flush_until_sequence_number is %u.", seq_no, conn->ap2_immediate_flush_until_sequence_number); + } + + if ((blocks_read != 0) && ((a_minus_b_mod23(seq_no, conn->ap2_immediate_flush_until_sequence_number) >= 0))) { + debug(2, "immediate flush completed at seq_no: %u, conn->ap2_immediate_flush_until_sequence_number: %u.", seq_no, conn->ap2_immediate_flush_until_sequence_number); conn->ap2_immediate_flush_requested = 0; ap2_immediate_flush_requested = 0; - /* + // turn off all deferred requests. Not sure if this is right... unsigned int f = 0; for (f = 0; f < MAX_DEFERRED_FLUSH_REQUESTS; f++) { + if ((conn->ap2_deferred_flush_requests[f].inUse != 0) && (conn->ap2_deferred_flush_requests[f].active = 0)) { + debug(1, + "deferred flush cancelled by an immediate flush: flushFromTS: %12u, flushFromSeq: %12u, " + "flushUntilTS: %12u, flushUntilSeq: %12u, timestamp: %12u.", + conn->ap2_deferred_flush_requests[f].flushFromTS, + conn->ap2_deferred_flush_requests[f].flushFromSeq, + conn->ap2_deferred_flush_requests[f].flushUntilTS, + conn->ap2_deferred_flush_requests[f].flushUntilSeq, timestamp); + } conn->ap2_deferred_flush_requests[f].inUse = 0; conn->ap2_deferred_flush_requests[f].active = 0; } - */ + } else { debug(3, "immediate flush of block %u until block %u", seq_no, diff --git a/player.c b/player.c index 20366387..1062a78e 100644 --- a/player.c +++ b/player.c @@ -426,7 +426,7 @@ void clear_decoding_chain(rtsp_conn_info *conn) { pthread_cleanup_pop(1); // avcodec_open2_cleanup_handler pthread_cleanup_pop(1); // deallocate the malloc pthread_cleanup_pop(1); // avcodec_alloc_context3_cleanup_handler - conn->incoming_ssrc = 0; + conn->incoming_ssrc = SSRC_NONE; } } @@ -2771,7 +2771,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn, int resync_requested) { debug(2, "setting up software resampler for %s for the first time.", get_ssrc_name(curframe->ssrc)); } else { - debug(1, "Connection %d: incoming audio switching to \"%s\".", conn->connection_number, + debug(1, "Connection %d: queued audio buffers switching to \"%s\".", conn->connection_number, get_ssrc_name(curframe->ssrc)); clear_software_resampler(conn); // ask the backend if it can give us its best choice for an ffmpeg configuration: diff --git a/rtsp.c b/rtsp.c index df589ec9..8c6978b7 100644 --- a/rtsp.c +++ b/rtsp.c @@ -546,7 +546,7 @@ void cancel_all_RTSP_threads(airplay_stream_c stream_category, int except_this_o ((conns[i]->airplay_stream_category == stream_category) || (stream_category == unspecified_stream_category))) { pthread_cancel(conns[i]->thread); - debug(1, "Connection %d: %s cancelled.", conns[i]->connection_number, + debug(2, "Connection %d: %s cancelled.", conns[i]->connection_number, get_category_string(conns[i]->airplay_stream_category)); } } @@ -554,10 +554,10 @@ void cancel_all_RTSP_threads(airplay_stream_c stream_category, int except_this_o if ((conns[i] != NULL) && (conns[i]->connection_number != except_this_one) && ((conns[i]->airplay_stream_category == stream_category) || (stream_category == unspecified_stream_category))) { - debug(1, "Connection %d: %s joining....", conns[i]->connection_number, + debug(2, "Connection %d: %s joining....", conns[i]->connection_number, get_category_string(conns[i]->airplay_stream_category)); pthread_join(conns[i]->thread, NULL); - debug(1, "Connection %d: %s joined.", conns[i]->connection_number, + debug(2, "Connection %d: %s joined.", conns[i]->connection_number, get_category_string(conns[i]->airplay_stream_category)); free(conns[i]); conns[i] = NULL;