History

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().

Anton Khirnov committed 14 years ago

Commit 52660451 parent 3a7f7674 files · +27 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +4 −0
  2. libavformat/avformat.h +10 −0
  3. libavformat/utils.c +9 −0
  4. libavformat/version.h +4 −1
doc/APIchanges+4−0
@@ -13,6 +13,10 @@ libavutil: 2011-04-18 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2011-xx-xx - xxxxxxx - lavf 53.17.0
17+ Add avformat_open_input().
18+ Deprecate av_close_input_file() and av_close_input_stream().
19+
1620 2011-xx-xx - xxxxxxx - lavc 53.25.0
1721 Add nb_samples and extended_data fields to AVFrame.
1822 Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE.
libavformat/avformat.h+10−0
@@ -1570,12 +1570,22 @@ attribute_deprecated · 1569 unmodified lines
15701570 void av_close_input_stream(AVFormatContext *s);
15711571 #endif
15721572
1573+#if FF_API_CLOSE_INPUT_FILE
15731574 /**
1575+ * @deprecated use avformat_close_input()
15741576 * Close a media file (but not its codecs).
15751577 *
15761578 * @param s media file handle
15771579 */
1580+attribute_deprecated
15781581 void av_close_input_file(AVFormatContext *s);
1582+#endif
1583+
1584+/**
1585+ * Close an opened input AVFormatContext. Free it and all its contents
1586+ * and set *s to NULL.
1587+ */
1588+void avformat_close_input(AVFormatContext **s);
15791589 /**
15801590 * @}
15811591 */
libavformat/utils.c+9−0
@@ -2684,14 +2684,23 @@ void avformat_free_context(AVFormatContext *s) · 2683 unmodified lines
26842684 av_free(s);
26852685 }
26862686
2687+#if FF_API_CLOSE_INPUT_FILE
26872688 void av_close_input_file(AVFormatContext *s)
26882689 {
2690+ avformat_close_input(&s);
2691+}
2692+#endif
2693+
2694+void avformat_close_input(AVFormatContext **ps)
2695+{
2696+ AVFormatContext *s = *ps;
26892697 AVIOContext *pb = (s->iformat->flags & AVFMT_NOFILE) || (s->flags & AVFMT_FLAG_CUSTOM_IO) ?
26902698 NULL : s->pb;
26912699 flush_packet_queue(s);
26922700 if (s->iformat->read_close)
26932701 s->iformat->read_close(s);
26942702 avformat_free_context(s);
2703+ *ps = NULL;
26952704 if (pb)
26962705 avio_close(pb);
26972706 }
libavformat/version.h+4−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030 #include "libavutil/avutil.h"
3131
3232 #define LIBAVFORMAT_VERSION_MAJOR 53
33−#define LIBAVFORMAT_VERSION_MINOR 16
33+#define LIBAVFORMAT_VERSION_MINOR 17
3434 #define LIBAVFORMAT_VERSION_MICRO 0
3535
3636 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -122,5 +122,8 @@ · 85 unmodified lines
122122 #ifndef FF_API_SET_PTS_INFO
123123 #define FF_API_SET_PTS_INFO (LIBAVFORMAT_VERSION_MAJOR < 54)
124124 #endif
125+#ifndef FF_API_CLOSE_INPUT_FILE
126+#define FF_API_CLOSE_INPUT_FILE (LIBAVFORMAT_VERSION_MAJOR < 54)
127+#endif
125128
126129 #endif /* AVFORMAT_VERSION_H */

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