diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index ef51993c26..2512239880 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -837,7 +837,7 @@ int ff_rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
         return -1;
     rv = rtp_parse_one_packet(s, pkt, bufptr, len);
     s->prev_ret = rv;
-    while (rv == AVERROR(EAGAIN) && has_next_packet(s))
+    while (rv < 0 && has_next_packet(s))
         rv = rtp_parse_queued_packet(s, pkt);
     return rv ? rv : has_next_packet(s);
 }