From 08580cb05a7cd04e99f1ca4867c4d7daeb3c5e41 Mon Sep 17 00:00:00 2001 From: Benoit Fouet Date: Tue, 20 Oct 2009 06:40:01 +0000 Subject: [PATCH] Make url_resetbuf() assert on wrong flags passed and make it static on next version bump. See thread: [FFmpeg-devel] & vs. && Date: Mon, 12 Oct 2009 14:21:06 +0200 Originally committed as revision 20330 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/avio.h | 2 ++ libavformat/aviobuf.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/libavformat/avio.h b/libavformat/avio.h index d44e300..5aa24ca 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -333,11 +333,13 @@ int url_fdopen(ByteIOContext **s, URLContext *h); /** @warning must be called before any I/O */ int url_setbufsize(ByteIOContext *s, int buf_size); +#if LIBAVFORMAT_VERSION_MAJOR < 53 /** Reset the buffer for reading or writing. * @note Will drop any data currently in the buffer without transmitting it. * @param flags URL_RDONLY to set up the buffer for reading, or URL_WRONLY * to set up the buffer for writing. */ int url_resetbuf(ByteIOContext *s, int flags); +#endif /** @note when opened as read/write, the buffers are only used for writing */ diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 268326d..06c7a10 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -28,6 +28,9 @@ #define IO_BUFFER_SIZE 32768 static void fill_buffer(ByteIOContext *s); +#if LIBAVFORMAT_VERSION_MAJOR >= 53 +static int url_resetbuf(ByteIOContext *s, int flags); +#endif int init_put_byte(ByteIOContext *s, unsigned char *buffer, @@ -583,11 +586,19 @@ int url_setbufsize(ByteIOContext *s, int buf_size) return 0; } +#if LIBAVFORMAT_VERSION_MAJOR < 53 int url_resetbuf(ByteIOContext *s, int flags) +#else +static int url_resetbuf(ByteIOContext *s, int flags) +#endif { +#if LIBAVFORMAT_VERSION_MAJOR < 53 URLContext *h = s->opaque; if ((flags & URL_RDWR) || (h && h->flags != flags && !h->flags & URL_RDWR)) return AVERROR(EINVAL); +#else + assert(flags == URL_WRONLY || flags == URL_RDONLY); +#endif if (flags & URL_WRONLY) { s->buf_end = s->buffer + s->buffer_size; -- 2.7.4