Merge av_close_input_{file,stream} into avformat_close_input.
authorAlexis Ballier <aballier@gentoo.org>
Thu, 1 Mar 2012 14:08:29 +0000 (11:08 -0300)
committerelupus <elupus@xbmc.org>
Sat, 31 Mar 2012 14:28:37 +0000 (16:28 +0200)
The formers are deprecated and gone in libavformat 54.
Moreover, this allows removing some code because avformat_close_input takes care of freeing relevant structures.

lib/DllAvFormat.h
xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp

index 4f9a60d..f6d6b70 100644 (file)
@@ -63,8 +63,7 @@ public:
   virtual void av_register_all_dont_call(void)=0;
   virtual AVInputFormat *av_find_input_format(const char *short_name)=0;
   virtual int url_feof(AVIOContext *s)=0;
-  virtual void av_close_input_file(AVFormatContext *s)=0;
-  virtual void av_close_input_stream(AVFormatContext *s)=0;
+  virtual void avformat_close_input(AVFormatContext **s)=0;
   virtual int av_read_frame(AVFormatContext *s, AVPacket *pkt)=0;
   virtual void av_read_frame_flush(AVFormatContext *s)=0;
   virtual int av_read_play(AVFormatContext *s)=0;
@@ -121,8 +120,7 @@ public:
   virtual void av_register_all_dont_call() { *(int* )0x0 = 0; } 
   virtual AVInputFormat *av_find_input_format(const char *short_name) { return ::av_find_input_format(short_name); }
   virtual int url_feof(AVIOContext *s) { return ::url_feof(s); }
-  virtual void av_close_input_file(AVFormatContext *s) { ::av_close_input_file(s); }
-  virtual void av_close_input_stream(AVFormatContext *s) { ::av_close_input_stream(s); }
+  virtual void avformat_close_input(AVFormatContext **s) { ::avformat_close_input(s); }
   virtual int av_read_frame(AVFormatContext *s, AVPacket *pkt) { return ::av_read_frame(s, pkt); }
   virtual void av_read_frame_flush(AVFormatContext *s) { ::av_read_frame_flush(s); }
   virtual int av_read_play(AVFormatContext *s) { return ::av_read_play(s); }
@@ -186,8 +184,7 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface
   DEFINE_METHOD0(void, av_register_all_dont_call)
   DEFINE_METHOD1(AVInputFormat*, av_find_input_format, (const char *p1))
   DEFINE_METHOD1(int, url_feof, (AVIOContext *p1))
-  DEFINE_METHOD1(void, av_close_input_file, (AVFormatContext *p1))
-  DEFINE_METHOD1(void, av_close_input_stream, (AVFormatContext *p1))
+  DEFINE_METHOD1(void, avformat_close_input, (AVFormatContext **p1))
   DEFINE_METHOD1(int, av_read_play, (AVFormatContext *p1))
   DEFINE_METHOD1(int, av_read_pause, (AVFormatContext *p1))
   DEFINE_METHOD1(void, av_read_frame_flush, (AVFormatContext *p1))
@@ -229,8 +226,7 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface
     RESOLVE_METHOD_RENAME(av_register_all, av_register_all_dont_call)
     RESOLVE_METHOD(av_find_input_format)
     RESOLVE_METHOD(url_feof)
-    RESOLVE_METHOD(av_close_input_file)
-    RESOLVE_METHOD(av_close_input_stream)
+    RESOLVE_METHOD(avformat_close_input)
     RESOLVE_METHOD(av_read_frame)
     RESOLVE_METHOD(av_read_play)
     RESOLVE_METHOD(av_read_pause)
index 991491c..f1fad8c 100644 (file)
@@ -502,20 +502,12 @@ void CDVDDemuxFFmpeg::Dispose()
 
   if (m_pFormatContext)
   {
-    if (m_ioContext)
+    if (m_ioContext && m_pFormatContext->pb && m_pFormatContext->pb != m_ioContext)
     {
-      if(m_pFormatContext->pb && m_pFormatContext->pb != m_ioContext)
-      {
-        CLog::Log(LOGWARNING, "CDVDDemuxFFmpeg::Dispose - demuxer changed our byte context behind our back, possible memleak");
-        m_ioContext = m_pFormatContext->pb;
-      }
-      m_dllAvFormat.av_close_input_stream(m_pFormatContext);
-      if (m_ioContext->buffer)
-        m_dllAvUtil.av_free(m_ioContext->buffer);
-      m_dllAvUtil.av_free(m_ioContext);
+      CLog::Log(LOGWARNING, "CDVDDemuxFFmpeg::Dispose - demuxer changed our byte context behind our back, possible memleak");
+      m_ioContext = m_pFormatContext->pb;
     }
-    else
-      m_dllAvFormat.av_close_input_file(m_pFormatContext);
+    m_dllAvFormat.avformat_close_input(&m_pFormatContext);
   }
   m_ioContext = NULL;
   m_pFormatContext = NULL;