[FFmpeg-devel] av_read_frame timeout

Michael Niedermayer michael at niedermayer.cc
Tue Nov 19 19:30:19 EET 2019


On Sun, Nov 17, 2019 at 06:37:58PM -0300, gga wrote:
> The following patch adds a timeout interrupt to av_read_frame to prevent it
> from hanging up the application.  This patch was proposed some years ago but
> was not applied back then.  I believe it is useful and should be considered
> for approval.
> 

> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 8196442dd1..d98ebe46a4 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -1792,6 +1792,12 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
>      }
>  
>      for (;;) {
> +        if (ff_check_interrupt(&s->interrupt_callback)) {
> +           ret = AVERROR_EXIT;
> +           av_log(s, AV_LOG_DEBUG, "interrupted\n");
> +           return ret;
> +        }
> +
>          AVPacketList *pktl = s->internal->packet_buffer;

In principle i dont see why this change would be bad (if it fixes some
use case)
but a few things needs to be corrected
the author of the commit has to be corrected
the indention is inconsistent
the ret variable is unneeded
also this mixes declarations and statements, it should be moved down

and i would move this so ff_check_interrupt() is only called if the loop
iterates and not on the first iteration

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20191119/43a5e17b/attachment.sig>


More information about the ffmpeg-devel mailing list