DVDAudioCodecFFmpeg: do not reopen the resample context for each frame.
authorAnton Khirnov <anton@khirnov.net>
Sat, 20 Apr 2013 11:16:11 +0000 (13:16 +0200)
committerAlexis Ballier <aballier@gentoo.org>
Thu, 13 Jun 2013 16:33:29 +0000 (12:33 -0400)
There is no point in doing this and opening an already opened context
leaks memory in lavr.

xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp

index 9be5de4..bee341a 100644 (file)
@@ -202,14 +202,14 @@ void CDVDAudioCodecFFmpeg::ConvertToFloat()
                       m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels), AV_SAMPLE_FMT_FLT, m_pCodecContext->sample_rate,
                       m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels), m_pCodecContext->sample_fmt, m_pCodecContext->sample_rate,
                       0, NULL);
-    }
 
-    if(!m_pConvert || m_dllSwResample.swr_init(m_pConvert) < 0)
-    {
-      CLog::Log(LOGERROR, "CDVDAudioCodecFFmpeg::Decode - Unable to convert %d to AV_SAMPLE_FMT_FLT", m_pCodecContext->sample_fmt);
-      m_iBufferSize1 = 0;
-      m_iBufferSize2 = 0;
-      return;
+      if(!m_pConvert || m_dllSwResample.swr_init(m_pConvert) < 0)
+      {
+          CLog::Log(LOGERROR, "CDVDAudioCodecFFmpeg::Decode - Unable to convert %d to AV_SAMPLE_FMT_FLT", m_pCodecContext->sample_fmt);
+          m_iBufferSize1 = 0;
+          m_iBufferSize2 = 0;
+          return;
+      }
     }
 
     int len = m_iBufferSize1 / m_dllAvUtil.av_get_bytes_per_sample(m_pCodecContext->sample_fmt);