History

avio: add a destructor for AVIOContext

Before this commit, AVIOContext is to be freed with a plain av_free(), which prevents us from adding any deeper structure to it. (cherry picked from commit 99684f3ae752fc8bfb44a2dd1482f8d7a3d8536d) Signed-off-by: James Almer <jamrial@gmail.com>

Anton Khirnov committed 9 years ago

Commit b12e4d31 parent 837580f4 files · +26 −4Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavformat/avio.h +8 −0
  3. libavformat/aviobuf.c +14 −3
  4. libavformat/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2015-08-28 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182017-09-01 - xxxxxxx - lavf 57.80.100 / 57.11.0 - avio.h
19 Add avio_context_free(). From now on it must be used for freeing AVIOContext.
20
182017-08-08 - xxxxxxx - lavu 55.74.100 - pixdesc.h212017-08-08 - xxxxxxx - lavu 55.74.100 - pixdesc.h
19 Add AV_PIX_FMT_FLAG_FLOAT pixel format flag.22 Add AV_PIX_FMT_FLAG_FLOAT pixel format flag.
20 23
libavformat/avio.h+8−0
@@ -467,6 +467,14 @@ AVIOContext *avio_alloc_context( · 466 unmodified lines
467 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),467 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
468 int64_t (*seek)(void *opaque, int64_t offset, int whence));468 int64_t (*seek)(void *opaque, int64_t offset, int whence));
469 469
470/**
471 * Free the supplied IO context and everything associated with it.
472 *
473 * @param s Double pointer to the IO context. This function will write NULL
474 * into s.
475 */
476void avio_context_free(AVIOContext **s);
477
470void avio_w8(AVIOContext *s, int b);478void avio_w8(AVIOContext *s, int b);
471void avio_write(AVIOContext *s, const unsigned char *buf, int size);479void avio_write(AVIOContext *s, const unsigned char *buf, int size);
472void avio_wl64(AVIOContext *s, uint64_t val);480void avio_wl64(AVIOContext *s, uint64_t val);
libavformat/aviobuf.c+14−3
@@ -143,6 +143,11 @@ AVIOContext *avio_alloc_context( · 142 unmodified lines
143 return s;143 return s;
144}144}
145 145
146void avio_context_free(AVIOContext **ps)
147{
148 av_freep(ps);
149}
150
146static void writeout(AVIOContext *s, const uint8_t *data, int len)151static void writeout(AVIOContext *s, const uint8_t *data, int len)
147{152{
148 if (!s->error) {153 if (!s->error) {
@@ -1123,7 +1128,9 @@ int avio_close(AVIOContext *s) · 974 unmodified lines
1123 else1128 else
1124 av_log(s, AV_LOG_DEBUG, "Statistics: %"PRId64" bytes read, %d seeks\n", s->bytes_read, s->seek_count);1129 av_log(s, AV_LOG_DEBUG, "Statistics: %"PRId64" bytes read, %d seeks\n", s->bytes_read, s->seek_count);
1125 av_opt_free(s);1130 av_opt_free(s);
1126 av_free(s);1131
1132 avio_context_free(&s);
1133
1127 return ffurl_close(h);1134 return ffurl_close(h);
1128}1135}
1129 1136
@@ -1356,7 +1363,9 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) · 226 unmodified lines
1356 *pbuffer = d->buffer;1363 *pbuffer = d->buffer;
1357 size = d->size;1364 size = d->size;
1358 av_free(d);1365 av_free(d);
1359 av_free(s);1366
1367 avio_context_free(&s);
1368
1360 return size - padding;1369 return size - padding;
1361}1370}
1362 1371
@@ -1399,6 +1408,8 @@ int ffio_close_null_buf(AVIOContext *s) · 36 unmodified lines
1399 1408
1400 size = d->size;1409 size = d->size;
1401 av_free(d);1410 av_free(d);
1402 av_free(s);1411
1412 avio_context_free(&s);
1413
1403 return size;1414 return size;
1404}1415}
libavformat/version.h+1−1
@@ -32,7 +32,7 @@ · 31 unmodified lines
32// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)32// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
33// Also please add any ticket numbers that you believe might be affected here33// Also please add any ticket numbers that you believe might be affected here
34#define LIBAVFORMAT_VERSION_MAJOR 5734#define LIBAVFORMAT_VERSION_MAJOR 57
35#define LIBAVFORMAT_VERSION_MINOR 7935#define LIBAVFORMAT_VERSION_MINOR 80
36#define LIBAVFORMAT_VERSION_MICRO 10036#define LIBAVFORMAT_VERSION_MICRO 100
37 37
38#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \38#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t