From 491f0bae7d50f536291ead070ffd24161b9497de Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Wed, 29 Apr 2020 15:43:21 -0500 Subject: [PATCH] Revert "Revert "res_rtp_asterisk: Resolve loop when receive buffer is flushed"" This reverts commit a75317ce247b913d1cb92b9ffa47a49aa56b172a. Reason for revert: This will be merged once 16.8-cert1 is released. Change-Id: Ic2f4dbb19c5756fabe71b9e35c5a924214f5af08 --- res/res_rtp_asterisk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index a5b7106345..e3f4e54441 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -7734,6 +7734,14 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc ast_debug(2, "Inserted just received packet with sequence number '%d' in correct order on RTP instance '%p'\n", seqno, instance); } + /* It is possible due to packet retransmission for this packet to also exist in the receive + * buffer so we explicitly remove it in case this occurs, otherwise the receive buffer will + * never be empty. + */ + payload = (struct ast_rtp_rtcp_nack_payload *)ast_data_buffer_remove(rtp->recv_buffer, seqno); + if (payload) { + ast_free(payload); + } rtp->expectedrxseqno++; if (rtp->expectedrxseqno == SEQNO_CYCLE_OVER) { rtp->expectedrxseqno = 0; -- 2.47.2