Browse Source

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().
tags/n0.10
Anton Khirnov 14 years ago
parent
commit
526604545f
4 changed files with 27 additions and 1 deletions
  1. +4
    -0
      doc/APIchanges
  2. +10
    -0
      libavformat/avformat.h
  3. +9
    -0
      libavformat/utils.c
  4. +4
    -1
      libavformat/version.h

+ 4
- 0
doc/APIchanges View File

@@ -13,6 +13,10 @@ libavutil: 2011-04-18


API changes, most recent first: API changes, most recent first:


2011-xx-xx - xxxxxxx - lavf 53.17.0
Add avformat_open_input().
Deprecate av_close_input_file() and av_close_input_stream().

2011-xx-xx - xxxxxxx - lavc 53.25.0 2011-xx-xx - xxxxxxx - lavc 53.25.0
Add nb_samples and extended_data fields to AVFrame. Add nb_samples and extended_data fields to AVFrame.
Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE. Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE.


+ 10
- 0
libavformat/avformat.h View File

@@ -1570,12 +1570,22 @@ attribute_deprecated
void av_close_input_stream(AVFormatContext *s); void av_close_input_stream(AVFormatContext *s);
#endif #endif


#if FF_API_CLOSE_INPUT_FILE
/** /**
* @deprecated use avformat_close_input()
* Close a media file (but not its codecs). * Close a media file (but not its codecs).
* *
* @param s media file handle * @param s media file handle
*/ */
attribute_deprecated
void av_close_input_file(AVFormatContext *s); 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);
/** /**
* @} * @}
*/ */


+ 9
- 0
libavformat/utils.c View File

@@ -2684,14 +2684,23 @@ void avformat_free_context(AVFormatContext *s)
av_free(s); av_free(s);
} }


#if FF_API_CLOSE_INPUT_FILE
void av_close_input_file(AVFormatContext *s) 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) ? AVIOContext *pb = (s->iformat->flags & AVFMT_NOFILE) || (s->flags & AVFMT_FLAG_CUSTOM_IO) ?
NULL : s->pb; NULL : s->pb;
flush_packet_queue(s); flush_packet_queue(s);
if (s->iformat->read_close) if (s->iformat->read_close)
s->iformat->read_close(s); s->iformat->read_close(s);
avformat_free_context(s); avformat_free_context(s);
*ps = NULL;
if (pb) if (pb)
avio_close(pb); avio_close(pb);
} }


+ 4
- 1
libavformat/version.h View File

@@ -30,7 +30,7 @@
#include "libavutil/avutil.h" #include "libavutil/avutil.h"


#define LIBAVFORMAT_VERSION_MAJOR 53 #define LIBAVFORMAT_VERSION_MAJOR 53
#define LIBAVFORMAT_VERSION_MINOR 16
#define LIBAVFORMAT_VERSION_MINOR 17
#define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_MICRO 0


#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -122,5 +122,8 @@
#ifndef FF_API_SET_PTS_INFO #ifndef FF_API_SET_PTS_INFO
#define FF_API_SET_PTS_INFO (LIBAVFORMAT_VERSION_MAJOR < 54) #define FF_API_SET_PTS_INFO (LIBAVFORMAT_VERSION_MAJOR < 54)
#endif #endif
#ifndef FF_API_CLOSE_INPUT_FILE
#define FF_API_CLOSE_INPUT_FILE (LIBAVFORMAT_VERSION_MAJOR < 54)
#endif


#endif /* AVFORMAT_VERSION_H */ #endif /* AVFORMAT_VERSION_H */

Loading…
Cancel
Save