[FFmpeg-devel] avformat/utils.c: allows av_read_frame to return after a timeout period.

Submitted by Gonzalo Garramuño on Nov. 29, 2019, 11:52 p.m.

Details

Message ID 20191129235215.2289-1-ggarra13@gmail.com
State New
Headers show

Commit Message

Gonzalo Garramuño Nov. 29, 2019, 11:52 p.m.
From: Gonzalo Garramuño <ggarra13@gmail.com>

Moved the check inside and at the end of the if (pktl) as per Michael Niedermayer's suggestion.
This patch is based on one from bsenftner at earthlink.net.

The hanging in av_read_frame can be reproduced with an rtmp stream that is aborted midway and ffplay (for example) playing that stream.
---
 libavformat/utils.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Carl Eugen Hoyos Nov. 30, 2019, 12:01 a.m.
Am Sa., 30. Nov. 2019 um 00:52 Uhr schrieb <ggarra13@gmail.com>:
>
> From: Gonzalo Garramuño <ggarra13@gmail.com>
>
> Moved the check inside and at the end of the if (pktl) as per Michael Niedermayer's suggestion.

> This patch is based on one from bsenftner at earthlink.net.

Please mention his name as suggested.

Carl Eugen

Patch hide | download patch | download mbox

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8196442dd1..653918d5a5 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1836,6 +1836,11 @@  int av_read_frame(AVFormatContext *s, AVPacket *pkt)
                                                &s->internal->packet_buffer_end, pkt);
                 goto return_packet;
             }
+
+            if (ff_check_interrupt(&s->interrupt_callback)) {
+                av_log(s, AV_LOG_DEBUG, "interrupted\n");
+                return AVERROR_EXIT;
+            }
         }
 
         ret = read_frame_internal(s, pkt);