[libav-devel] [PATCHv3] avio: Do not flush the buffer if a constant packet size is requested

Martin Storsjö martin at martin.st
Fri Feb 22 13:48:23 CET 2019


On Fri, 22 Feb 2019, Luca Barbato wrote:

> ---
>
> Now with a separate option to be explicit on what is the behaviour
> wanted.
>
> libavformat/aviobuf.c | 9 +++++++--
> libavformat/udp.c     | 8 ++++++++
> libavformat/url.h     | 1 +
> 3 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index 98e35f776c..aa9e2fc483 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -244,8 +244,13 @@ void avio_write(AVIOContext *s, const unsigned char *buf, int size)
>
> void avio_flush(AVIOContext *s)
> {
> -    flush_buffer(s);
> -    s->must_flush = 0;
> +    AVIOInternal *internal = s->opaque;
> +    URLContext *h = internal->h;
> +

No, this doesn't work. You can't assume that s->opaque exists and is an 
AVIOinternal struct. When AVIOContext has been allocated by 
avio_alloc_context, s->opaque is whatever custom pointer the caller 
provided.

The only place you can use AVIOInternal is within the callbacks you 
provide in ffio_fdopen when AVIOInternal is created.

To do this properly, you need to propagate the new value all the way into 
AVIOContext, just like the existing max_packet_size.

// Martin



More information about the libav-devel mailing list