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().
This commit is contained in:
Anton Khirnov
2011-12-11 10:34:08 +01:00
parent 3a7f7678eb
commit 526604545f
4 changed files with 27 additions and 1 deletions

View File

@@ -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);
}