[FFmpeg-devel] [PATCH] avformat/async, cache: Use more unique context names

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri May 24 09:24:58 EEST 2024


Andreas Rheinhardt:
> Otherwise Doxygen thinks any text like "Context for foo"
> is a link to the async protocol's struct called "Context".
> 
> Reported-by: Andrew Sayers <ffmpeg-devel at pileofstuff.org>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  libavformat/async.c | 22 +++++++++++-----------
>  libavformat/cache.c | 18 +++++++++---------
>  2 files changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/libavformat/async.c b/libavformat/async.c
> index e096b0bc6f..e0329e23ec 100644
> --- a/libavformat/async.c
> +++ b/libavformat/async.c
> @@ -53,7 +53,7 @@ typedef struct RingBuffer
>      int           read_pos;
>  } RingBuffer;
>  
> -typedef struct Context {
> +typedef struct AsyncContext {
>      AVClass        *class;
>      URLContext     *inner;
>  
> @@ -78,7 +78,7 @@ typedef struct Context {
>  
>      int             abort_request;
>      AVIOInterruptCB interrupt_callback;
> -} Context;
> +} AsyncContext;
>  
>  static int ring_init(RingBuffer *ring, unsigned int capacity, int read_back_capacity)
>  {
> @@ -132,7 +132,7 @@ static int ring_read(RingBuffer *ring, void *dest, int buf_size)
>  static int wrapped_url_read(void *src, void *dst, size_t *size)
>  {
>      URLContext *h   = src;
> -    Context    *c   = h->priv_data;
> +    AsyncContext *c = h->priv_data;
>      int         ret;
>  
>      ret = ffurl_read(c->inner, dst, *size);
> @@ -170,7 +170,7 @@ static int ring_drain(RingBuffer *ring, int offset)
>  static int async_check_interrupt(void *arg)
>  {
>      URLContext *h   = arg;
> -    Context    *c   = h->priv_data;
> +    AsyncContext *c = h->priv_data;
>  
>      if (c->abort_request)
>          return 1;
> @@ -184,7 +184,7 @@ static int async_check_interrupt(void *arg)
>  static void *async_buffer_task(void *arg)
>  {
>      URLContext   *h    = arg;
> -    Context      *c    = h->priv_data;
> +    AsyncContext *c    = h->priv_data;
>      RingBuffer   *ring = &c->ring;
>      int           ret  = 0;
>      int64_t       seek_ret;
> @@ -249,7 +249,7 @@ static void *async_buffer_task(void *arg)
>  
>  static int async_open(URLContext *h, const char *arg, int flags, AVDictionary **options)
>  {
> -    Context         *c = h->priv_data;
> +    AsyncContext *c = h->priv_data;
>      int              ret;
>      AVIOInterruptCB  interrupt_callback = {.callback = async_check_interrupt, .opaque = h};
>  
> @@ -316,7 +316,7 @@ fifo_fail:
>  
>  static int async_close(URLContext *h)
>  {
> -    Context *c = h->priv_data;
> +    AsyncContext *c = h->priv_data;
>      int      ret;
>  
>      pthread_mutex_lock(&c->mutex);
> @@ -339,7 +339,7 @@ static int async_close(URLContext *h)
>  
>  static int async_read_internal(URLContext *h, void *dest, int size)
>  {
> -    Context      *c       = h->priv_data;
> +    AsyncContext *c       = h->priv_data;
>      RingBuffer   *ring    = &c->ring;
>      int     read_complete = !dest;
>      int           to_read = size;
> @@ -391,7 +391,7 @@ static int async_read(URLContext *h, unsigned char *buf, int size)
>  
>  static int64_t async_seek(URLContext *h, int64_t pos, int whence)
>  {
> -    Context      *c    = h->priv_data;
> +    AsyncContext *c    = h->priv_data;
>      RingBuffer   *ring = &c->ring;
>      int64_t       ret;
>      int64_t       new_logical_pos;
> @@ -472,7 +472,7 @@ static int64_t async_seek(URLContext *h, int64_t pos, int whence)
>      return ret;
>  }
>  
> -#define OFFSET(x) offsetof(Context, x)
> +#define OFFSET(x) offsetof(AsyncContext, x)
>  #define D AV_OPT_FLAG_DECODING_PARAM
>  
>  static const AVOption options[] = {
> @@ -495,7 +495,7 @@ const URLProtocol ff_async_protocol = {
>      .url_read            = async_read,
>      .url_seek            = async_seek,
>      .url_close           = async_close,
> -    .priv_data_size      = sizeof(Context),
> +    .priv_data_size      = sizeof(AsyncContext),
>      .priv_data_class     = &async_context_class,
>  };
>  
> diff --git a/libavformat/cache.c b/libavformat/cache.c
> index 5f78adba9d..5d71e56f3d 100644
> --- a/libavformat/cache.c
> +++ b/libavformat/cache.c
> @@ -52,7 +52,7 @@ typedef struct CacheEntry {
>      int size;
>  } CacheEntry;
>  
> -typedef struct Context {
> +typedef struct CacheContext {
>      AVClass *class;
>      int fd;
>      char *filename;
> @@ -65,7 +65,7 @@ typedef struct Context {
>      URLContext *inner;
>      int64_t cache_hit, cache_miss;
>      int read_ahead_limit;
> -} Context;
> +} CacheContext;
>  
>  static int cmp(const void *key, const void *node)
>  {
> @@ -74,9 +74,9 @@ static int cmp(const void *key, const void *node)
>  
>  static int cache_open(URLContext *h, const char *arg, int flags, AVDictionary **options)
>  {
> +    CacheContext *c = h->priv_data;
>      int ret;
>      char *buffername;
> -    Context *c= h->priv_data;
>  
>      av_strstart(arg, "cache:", &arg);
>  
> @@ -99,7 +99,7 @@ static int cache_open(URLContext *h, const char *arg, int flags, AVDictionary **
>  
>  static int add_entry(URLContext *h, const unsigned char *buf, int size)
>  {
> -    Context *c= h->priv_data;
> +    CacheContext *c = h->priv_data;
>      int64_t pos = -1;
>      int ret;
>      CacheEntry *entry = NULL, *next[2] = {NULL, NULL};
> @@ -162,7 +162,7 @@ fail:
>  
>  static int cache_read(URLContext *h, unsigned char *buf, int size)
>  {
> -    Context *c= h->priv_data;
> +    CacheContext *c = h->priv_data;
>      CacheEntry *entry, *next[2] = {NULL, NULL};
>      int64_t r;
>  
> @@ -227,7 +227,7 @@ static int cache_read(URLContext *h, unsigned char *buf, int size)
>  
>  static int64_t cache_seek(URLContext *h, int64_t pos, int whence)
>  {
> -    Context *c= h->priv_data;
> +    CacheContext *c = h->priv_data;
>      int64_t ret;
>  
>      if (whence == AVSEEK_SIZE) {
> @@ -298,7 +298,7 @@ static int enu_free(void *opaque, void *elem)
>  
>  static int cache_close(URLContext *h)
>  {
> -    Context *c= h->priv_data;
> +    CacheContext *c = h->priv_data;
>      int ret;
>  
>      av_log(h, AV_LOG_INFO, "Statistics, cache hits:%"PRId64" cache misses:%"PRId64"\n",
> @@ -318,7 +318,7 @@ static int cache_close(URLContext *h)
>      return 0;
>  }
>  
> -#define OFFSET(x) offsetof(Context, x)
> +#define OFFSET(x) offsetof(CacheContext, x)
>  #define D AV_OPT_FLAG_DECODING_PARAM
>  
>  static const AVOption options[] = {
> @@ -339,6 +339,6 @@ const URLProtocol ff_cache_protocol = {
>      .url_read            = cache_read,
>      .url_seek            = cache_seek,
>      .url_close           = cache_close,
> -    .priv_data_size      = sizeof(Context),
> +    .priv_data_size      = sizeof(CacheContext),
>      .priv_data_class     = &cache_context_class,
>  };

Will apply tomorrow unless there are objections.

- Andreas



More information about the ffmpeg-devel mailing list