summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-12-11 10:34:08 +0100
committerAnton Khirnov <anton@khirnov.net>2011-12-12 20:23:56 +0100
commit526604545fb1cc0c11af356fbffd5cddf8cdc95f (patch)
tree1c3b0c53decd94ddd1c735283129c09af73b5938 /libavformat
parent3a7f7678eb3be1f9a28414c9908ed8d34b1b9846 (diff)
lavf: add avformat_close_input().
It sets the supplied AVFormatContext pointer to NULL after freeing it, which is safer and its name is consistent with other lavf functions. Also deprecate av_close_input_file().
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avformat.h10
-rw-r--r--libavformat/utils.c9
-rw-r--r--libavformat/version.h5
3 files changed, 23 insertions, 1 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 548bc186fb..2eb75df43a 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1570,12 +1570,22 @@ attribute_deprecated
void av_close_input_stream(AVFormatContext *s);
#endif
+#if FF_API_CLOSE_INPUT_FILE
/**
+ * @deprecated use avformat_close_input()
* Close a media file (but not its codecs).
*
* @param s media file handle
*/
+attribute_deprecated
void av_close_input_file(AVFormatContext *s);
+#endif
+
+/**
+ * Close an opened input AVFormatContext. Free it and all its contents
+ * and set *s to NULL.
+ */
+void avformat_close_input(AVFormatContext **s);
/**
* @}
*/
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8a76cb815e..a078d9c88b 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2684,14 +2684,23 @@ void avformat_free_context(AVFormatContext *s)
av_free(s);
}
+#if FF_API_CLOSE_INPUT_FILE
void av_close_input_file(AVFormatContext *s)
{
+ avformat_close_input(&s);
+}
+#endif
+
+void avformat_close_input(AVFormatContext **ps)
+{
+ AVFormatContext *s = *ps;
AVIOContext *pb = (s->iformat->flags & AVFMT_NOFILE) || (s->flags & AVFMT_FLAG_CUSTOM_IO) ?
NULL : s->pb;
flush_packet_queue(s);
if (s->iformat->read_close)
s->iformat->read_close(s);
avformat_free_context(s);
+ *ps = NULL;
if (pb)
avio_close(pb);
}
diff --git a/libavformat/version.h b/libavformat/version.h
index 7ba411c494..e80787b2ee 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 53
-#define LIBAVFORMAT_VERSION_MINOR 16
+#define LIBAVFORMAT_VERSION_MINOR 17
#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -122,5 +122,8 @@
#ifndef FF_API_SET_PTS_INFO
#define FF_API_SET_PTS_INFO (LIBAVFORMAT_VERSION_MAJOR < 54)
#endif
+#ifndef FF_API_CLOSE_INPUT_FILE
+#define FF_API_CLOSE_INPUT_FILE (LIBAVFORMAT_VERSION_MAJOR < 54)
+#endif
#endif /* AVFORMAT_VERSION_H */