mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 08:15:02 -05:00
[outputs] Fix issue where RTP packet is not available for retransmit
Check for sequence number did not account for wrap around, so e.g. a request for seqnum 65335 when first was 65100 and last was 100 would not work.
This commit is contained in:
parent
5307c6d94b
commit
cf173df805
@ -208,7 +208,14 @@ rtp_packet_get(struct rtp_session *session, uint16_t seqnum)
|
||||
|
||||
last = session->seqnum - 1;
|
||||
first = session->seqnum - session->pktbuf_len;
|
||||
if (seqnum < first || seqnum > last)
|
||||
|
||||
// Rules of programming:
|
||||
// 1) Make your code easy to read
|
||||
// 2) Disregard rule number one if you can use XOR
|
||||
//
|
||||
// The below should be the same as this (a check that works with int wrap-around):
|
||||
// (first <= last && (first <= seqnum && seqnum <= last)) || (first > last && (first <= seqnum || seqnum <= last))
|
||||
if (! ((first <= last) ^ (first <= seqnum) ^ (seqnum <= last)))
|
||||
{
|
||||
DPRINTF(E_DBG, L_PLAYER, "Seqnum %" PRIu16 " not in buffer (have seqnum %" PRIu16 " to %" PRIu16 ")\n", seqnum, first, last);
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user