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
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162011-xx-xx - xxxxxxx - lavf 53.17.0
17 Add avformat_open_input().
18 Deprecate av_close_input_file() and av_close_input_stream().
19
162011-xx-xx - xxxxxxx - lavc 53.25.0202011-xx-xx - xxxxxxx - lavc 53.25.0
17 Add nb_samples and extended_data fields to AVFrame.21 Add nb_samples and extended_data fields to AVFrame.
18 Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE.22 Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE.
libavformat/avformat.h+10−0
@@ -1570,12 +1570,22 @@ attribute_deprecated · 1569 unmodified lines
1570void av_close_input_stream(AVFormatContext *s);1570void av_close_input_stream(AVFormatContext *s);
1571#endif1571#endif
1572 1572
1573#if FF_API_CLOSE_INPUT_FILE
1573/**1574/**
1575 * @deprecated use avformat_close_input()
1574 * Close a media file (but not its codecs).1576 * Close a media file (but not its codecs).
1575 *1577 *
1576 * @param s media file handle1578 * @param s media file handle
1577 */1579 */
1580attribute_deprecated
1578void av_close_input_file(AVFormatContext *s);1581void 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 */
1588void avformat_close_input(AVFormatContext **s);
1579/**1589/**
1580 * @}1590 * @}
1581 */1591 */
libavformat/utils.c+9−0
@@ -2684,14 +2684,23 @@ void avformat_free_context(AVFormatContext *s) · 2683 unmodified lines
2684 av_free(s);2684 av_free(s);
2685}2685}
2686 2686
2687#if FF_API_CLOSE_INPUT_FILE
2687void av_close_input_file(AVFormatContext *s)2688void av_close_input_file(AVFormatContext *s)
2688{2689{
2690 avformat_close_input(&s);
2691}
2692#endif
2693
2694void avformat_close_input(AVFormatContext **ps)
2695{
2696 AVFormatContext *s = *ps;
2689 AVIOContext *pb = (s->iformat->flags & AVFMT_NOFILE) || (s->flags & AVFMT_FLAG_CUSTOM_IO) ?2697 AVIOContext *pb = (s->iformat->flags & AVFMT_NOFILE) || (s->flags & AVFMT_FLAG_CUSTOM_IO) ?
2690 NULL : s->pb;2698 NULL : s->pb;
2691 flush_packet_queue(s);2699 flush_packet_queue(s);
2692 if (s->iformat->read_close)2700 if (s->iformat->read_close)
2693 s->iformat->read_close(s);2701 s->iformat->read_close(s);
2694 avformat_free_context(s);2702 avformat_free_context(s);
2703 *ps = NULL;
2695 if (pb)2704 if (pb)
2696 avio_close(pb);2705 avio_close(pb);
2697}2706}
libavformat/version.h+4−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
30#include "libavutil/avutil.h"30#include "libavutil/avutil.h"
31 31
32#define LIBAVFORMAT_VERSION_MAJOR 5332#define LIBAVFORMAT_VERSION_MAJOR 53
33#define LIBAVFORMAT_VERSION_MINOR 1633#define LIBAVFORMAT_VERSION_MINOR 17
34#define LIBAVFORMAT_VERSION_MICRO 034#define LIBAVFORMAT_VERSION_MICRO 0
35 35
36#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \36#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -122,5 +122,8 @@ · 85 unmodified lines
122#ifndef FF_API_SET_PTS_INFO122#ifndef FF_API_SET_PTS_INFO
123#define FF_API_SET_PTS_INFO (LIBAVFORMAT_VERSION_MAJOR < 54)123#define FF_API_SET_PTS_INFO (LIBAVFORMAT_VERSION_MAJOR < 54)
124#endif124#endif
125#ifndef FF_API_CLOSE_INPUT_FILE
126#define FF_API_CLOSE_INPUT_FILE (LIBAVFORMAT_VERSION_MAJOR < 54)
127#endif
125 128
126#endif /* AVFORMAT_VERSION_H */129#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