avformat/avio: Avoid function pointer casts

It is undefined behaviour to use a different type for a call
than the actual type of the function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2024-03-02 19:29:27 +01:00
parent f0abb44fbf
commit 57e20dd6b6
5 changed files with 14 additions and 10 deletions

View File

@ -450,9 +450,8 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
(*s)->max_packet_size = max_packet_size; (*s)->max_packet_size = max_packet_size;
(*s)->min_packet_size = h->min_packet_size; (*s)->min_packet_size = h->min_packet_size;
if(h->prot) { if(h->prot) {
(*s)->read_pause = (int (*)(void *, int))h->prot->url_read_pause; (*s)->read_pause = h->prot->url_read_pause;
(*s)->read_seek = (*s)->read_seek = h->prot->url_read_seek;
(int64_t (*)(void *, int, int64_t, int))h->prot->url_read_seek;
if (h->prot->url_read_seek) if (h->prot->url_read_seek)
(*s)->seekable |= AVIO_SEEKABLE_TIME; (*s)->seekable |= AVIO_SEEKABLE_TIME;

View File

@ -220,8 +220,9 @@ static int rtmp_read(URLContext *s, uint8_t *buf, int size)
return ret; return ret;
} }
static int rtmp_read_pause(URLContext *s, int pause) static int rtmp_read_pause(void *opaque, int pause)
{ {
URLContext *s = opaque;
LibRTMPContext *ctx = s->priv_data; LibRTMPContext *ctx = s->priv_data;
RTMP *r = &ctx->rtmp; RTMP *r = &ctx->rtmp;
@ -230,9 +231,10 @@ static int rtmp_read_pause(URLContext *s, int pause)
return 0; return 0;
} }
static int64_t rtmp_read_seek(URLContext *s, int stream_index, static int64_t rtmp_read_seek(void *opaque, int stream_index,
int64_t timestamp, int flags) int64_t timestamp, int flags)
{ {
URLContext *s = opaque;
LibRTMPContext *ctx = s->priv_data; LibRTMPContext *ctx = s->priv_data;
RTMP *r = &ctx->rtmp; RTMP *r = &ctx->rtmp;

View File

@ -371,9 +371,10 @@ static int mmsh_read(URLContext *h, uint8_t *buf, int size)
return res; return res;
} }
static int64_t mmsh_read_seek(URLContext *h, int stream_index, static int64_t mmsh_read_seek(void *opaque, int stream_index,
int64_t timestamp, int flags) int64_t timestamp, int flags)
{ {
URLContext *h = opaque;
MMSHContext *mmsh_old = h->priv_data; MMSHContext *mmsh_old = h->priv_data;
MMSHContext *mmsh = av_mallocz(sizeof(*mmsh)); MMSHContext *mmsh = av_mallocz(sizeof(*mmsh));
int ret; int ret;

View File

@ -2952,9 +2952,10 @@ static int rtmp_read(URLContext *s, uint8_t *buf, int size)
return orig_size; return orig_size;
} }
static int64_t rtmp_seek(URLContext *s, int stream_index, int64_t timestamp, static int64_t rtmp_seek(void *opaque, int stream_index, int64_t timestamp,
int flags) int flags)
{ {
URLContext *s = opaque;
RTMPContext *rt = s->priv_data; RTMPContext *rt = s->priv_data;
int ret; int ret;
av_log(s, AV_LOG_DEBUG, av_log(s, AV_LOG_DEBUG,
@ -2972,8 +2973,9 @@ static int64_t rtmp_seek(URLContext *s, int stream_index, int64_t timestamp,
return timestamp; return timestamp;
} }
static int rtmp_pause(URLContext *s, int pause) static int rtmp_pause(void *opaque, int pause)
{ {
URLContext *s = opaque;
RTMPContext *rt = s->priv_data; RTMPContext *rt = s->priv_data;
int ret; int ret;
av_log(s, AV_LOG_DEBUG, "Pause at timestamp %d\n", av_log(s, AV_LOG_DEBUG, "Pause at timestamp %d\n",

View File

@ -76,8 +76,8 @@ typedef struct URLProtocol {
int (*url_write)(URLContext *h, const unsigned char *buf, int size); int (*url_write)(URLContext *h, const unsigned char *buf, int size);
int64_t (*url_seek)( URLContext *h, int64_t pos, int whence); int64_t (*url_seek)( URLContext *h, int64_t pos, int whence);
int (*url_close)(URLContext *h); int (*url_close)(URLContext *h);
int (*url_read_pause)(URLContext *h, int pause); int (*url_read_pause)(void *urlcontext, int pause);
int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t (*url_read_seek)(void *urlcontext, int stream_index,
int64_t timestamp, int flags); int64_t timestamp, int flags);
int (*url_get_file_handle)(URLContext *h); int (*url_get_file_handle)(URLContext *h);
int (*url_get_multi_file_handle)(URLContext *h, int **handles, int (*url_get_multi_file_handle)(URLContext *h, int **handles,