From d3479018db4c8d61b2dca497a547615f02c2a42d Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 7 Nov 2019 15:28:50 +0100 Subject: stream: change buffer argument types from char* to void* This is slightly better, although not much, and ultimately doesn't matter. The public API in stream_cb.h also uses char*, but can't change that. --- stream/stream.c | 12 ++++++------ stream/stream.h | 12 ++++++------ stream/stream_bluray.c | 2 +- stream/stream_cb.c | 2 +- stream/stream_cdda.c | 2 +- stream/stream_concat.c | 2 +- stream/stream_dvb.c | 4 ++-- stream/stream_dvdnav.c | 2 +- stream/stream_file.c | 4 ++-- stream/stream_lavf.c | 4 ++-- stream/stream_libarchive.c | 2 +- stream/stream_memory.c | 2 +- stream/stream_smb.c | 4 ++-- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/stream/stream.c b/stream/stream.c index 504d217b46..1f77a5dd1e 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -538,7 +538,7 @@ static bool stream_read_more(struct stream *s, int forward) // Read between 1..buf_size bytes of data, return how much data has been read. // Return 0 on EOF, error, or if buf_size was 0. -int stream_read_partial(stream_t *s, char *buf, int buf_size) +int stream_read_partial(stream_t *s, void *buf, int buf_size) { assert(s->buf_cur <= s->buf_end); assert(buf_size >= 0); @@ -562,14 +562,14 @@ int stream_read_char_fallback(stream_t *s) return stream_read_partial(s, &c, 1) ? c : -256; } -int stream_read(stream_t *s, char *mem, int total) +int stream_read(stream_t *s, void *mem, int total) { int len = total; while (len > 0) { int read = stream_read_partial(s, mem, len); if (read <= 0) break; // EOF - mem += read; + mem = (char *)mem + read; len -= read; } total -= len; @@ -578,13 +578,13 @@ int stream_read(stream_t *s, char *mem, int total) // Like stream_read(), but do not advance the current position. This may resize // the buffer to satisfy the read request. -int stream_read_peek(stream_t *s, void* buf, int buf_size) +int stream_read_peek(stream_t *s, void *buf, int buf_size) { while (stream_read_more(s, buf_size)) {} return ring_copy(s, buf, buf_size, s->buf_cur); } -int stream_write_buffer(stream_t *s, unsigned char *buf, int len) +int stream_write_buffer(stream_t *s, void *buf, int len) { if (!s->write_buffer) return -1; @@ -594,7 +594,7 @@ int stream_write_buffer(stream_t *s, unsigned char *buf, int len) if (w <= 0) return -1; s->pos += w; - buf += w; + buf = (char *)buf + w; len -= w; } return orig_len; diff --git a/stream/stream.h b/stream/stream.h index 61c5e12303..081313cdc8 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -110,9 +110,9 @@ typedef struct stream { const struct stream_info_st *info; // Read - int (*fill_buffer)(struct stream *s, char *buffer, int max_len); + int (*fill_buffer)(struct stream *s, void *buffer, int max_len); // Write - int (*write_buffer)(struct stream *s, char *buffer, int len); + int (*write_buffer)(struct stream *s, void *buffer, int len); // Seek int (*seek)(struct stream *s, int64_t pos); // Control @@ -177,7 +177,7 @@ typedef struct stream { // Non-inline version of stream_read_char(). int stream_read_char_fallback(stream_t *s); -int stream_write_buffer(stream_t *s, unsigned char *buf, int len); +int stream_write_buffer(stream_t *s, void *buf, int len); inline static int stream_read_char(stream_t *s) { @@ -195,9 +195,9 @@ inline static int64_t stream_tell(stream_t *s) bool stream_skip(stream_t *s, int64_t len); bool stream_seek(stream_t *s, int64_t pos); -int stream_read(stream_t *s, char *mem, int total); -int stream_read_partial(stream_t *s, char *buf, int buf_size); -int stream_read_peek(stream_t *s, void* buf, int buf_size); +int stream_read(stream_t *s, void *mem, int total); +int stream_read_partial(stream_t *s, void *buf, int buf_size); +int stream_read_peek(stream_t *s, void *buf, int buf_size); void stream_drop_buffers(stream_t *s); int64_t stream_get_size(stream_t *s); diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index 8614a26a5c..6e7663d638 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -161,7 +161,7 @@ static void handle_event(stream_t *s, const BD_EVENT *ev) } } -static int bluray_stream_fill_buffer(stream_t *s, char *buf, int len) +static int bluray_stream_fill_buffer(stream_t *s, void *buf, int len) { struct bluray_priv_s *b = s->priv; BD_EVENT event; diff --git a/stream/stream_cb.c b/stream/stream_cb.c index fa52935a4b..5a946a6369 100644 --- a/stream/stream_cb.c +++ b/stream/stream_cb.c @@ -24,7 +24,7 @@ struct priv { struct mp_cancel *cancel; }; -static int fill_buffer(stream_t *s, char *buffer, int max_len) +static int fill_buffer(stream_t *s, void *buffer, int max_len) { struct priv *p = s->priv; return (int)p->info.read_fn(p->info.cookie, buffer, (size_t)max_len); diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index ed7725107b..cc1c7646a3 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -153,7 +153,7 @@ static void cdparanoia_callback(long int inpos, paranoia_cb_mode_t function) { } -static int fill_buffer(stream_t *s, char *buffer, int max_len) +static int fill_buffer(stream_t *s, void *buffer, int max_len) { cdda_priv *p = (cdda_priv *)s->priv; int16_t *buf; diff --git a/stream/stream_concat.c b/stream/stream_concat.c index a646f1c155..339f1cf56c 100644 --- a/stream/stream_concat.c +++ b/stream/stream_concat.c @@ -29,7 +29,7 @@ struct priv { int cur; // streams[cur] is the stream for current stream.pos }; -static int fill_buffer(struct stream *s, char* buffer, int len) +static int fill_buffer(struct stream *s, void *buffer, int len) { struct priv *p = s->priv; diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index eb8adcf927..3bb6f081ff 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -730,7 +730,7 @@ void dvb_free_state(dvb_state_t *state) free(state); } -static int dvb_streaming_read(stream_t *stream, char *buffer, int size) +static int dvb_streaming_read(stream_t *stream, void *buffer, int size) { struct pollfd pfds[1]; int pos = 0, tries, rk, fd; @@ -742,7 +742,7 @@ static int dvb_streaming_read(stream_t *stream, char *buffer, int size) tries = state->retry; fd = state->dvr_fd; while (pos < size) { - rk = read(fd, &buffer[pos], (size - pos)); + rk = read(fd, (char *)buffer + pos, (size - pos)); if (rk <= 0) { if (pos || tries == 0) break; diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index b4b0dc21b2..d5090cfa69 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -257,7 +257,7 @@ static int mp_dvdnav_number_of_subs(stream_t *stream) return n; } -static int fill_buffer(stream_t *s, char *buf, int max_len) +static int fill_buffer(stream_t *s, void *buf, int max_len) { struct priv *priv = s->priv; dvdnav_t *dvdnav = priv->dvdnav; diff --git a/stream/stream_file.c b/stream/stream_file.c index dd7bfba581..6a46c1c2c7 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -80,7 +80,7 @@ static int64_t get_size(stream_t *s) return size == (off_t)-1 ? -1 : size; } -static int fill_buffer(stream_t *s, char *buffer, int max_len) +static int fill_buffer(stream_t *s, void *buffer, int max_len) { struct priv *p = s->priv; @@ -120,7 +120,7 @@ static int fill_buffer(stream_t *s, char *buffer, int max_len) return 0; } -static int write_buffer(stream_t *s, char *buffer, int len) +static int write_buffer(stream_t *s, void *buffer, int len) { struct priv *p = s->priv; return write(p->fd, buffer, len); diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c index 9bd0bcfe63..98c66e4f71 100644 --- a/stream/stream_lavf.c +++ b/stream/stream_lavf.c @@ -77,7 +77,7 @@ static const char *const http_like[]; static int open_f(stream_t *stream); static struct mp_tags *read_icy(stream_t *stream); -static int fill_buffer(stream_t *s, char *buffer, int max_len) +static int fill_buffer(stream_t *s, void *buffer, int max_len) { AVIOContext *avio = s->priv; #if LIBAVFORMAT_VERSION_MICRO >= 100 && LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 81, 100) @@ -88,7 +88,7 @@ static int fill_buffer(stream_t *s, char *buffer, int max_len) return (r <= 0) ? -1 : r; } -static int write_buffer(stream_t *s, char *buffer, int len) +static int write_buffer(stream_t *s, void *buffer, int len) { AVIOContext *avio = s->priv; avio_write(avio, buffer, len); diff --git a/stream/stream_libarchive.c b/stream/stream_libarchive.c index 35ac4d5528..0e136c175d 100644 --- a/stream/stream_libarchive.c +++ b/stream/stream_libarchive.c @@ -385,7 +385,7 @@ static int reopen_archive(stream_t *s) return STREAM_ERROR; } -static int archive_entry_fill_buffer(stream_t *s, char *buffer, int max_len) +static int archive_entry_fill_buffer(stream_t *s, void *buffer, int max_len) { struct priv *p = s->priv; if (!p->mpa) diff --git a/stream/stream_memory.c b/stream/stream_memory.c index 2fa4538e2d..f329da4850 100644 --- a/stream/stream_memory.c +++ b/stream/stream_memory.c @@ -22,7 +22,7 @@ struct priv { bstr data; }; -static int fill_buffer(stream_t *s, char* buffer, int len) +static int fill_buffer(stream_t *s, void *buffer, int len) { struct priv *p = s->priv; bstr data = p->data; diff --git a/stream/stream_smb.c b/stream/stream_smb.c index 630da0f757..bc1c00a8ef 100644 --- a/stream/stream_smb.c +++ b/stream/stream_smb.c @@ -75,7 +75,7 @@ static int seek(stream_t *s,int64_t newpos) { return 1; } -static int fill_buffer(stream_t *s, char* buffer, int max_len){ +static int fill_buffer(stream_t *s, void *buffer, int max_len){ struct priv *p = s->priv; pthread_mutex_lock(&smb_lock); int r = smbc_read(p->fd,buffer,max_len); @@ -83,7 +83,7 @@ static int fill_buffer(stream_t *s, char* buffer, int max_len){ return (r <= 0) ? -1 : r; } -static int write_buffer(stream_t *s, char* buffer, int len) { +static int write_buffer(stream_t *s, void *buffer, int len) { struct priv *p = s->priv; int wr; pthread_mutex_lock(&smb_lock); -- cgit v1.2.3