Skip to content
This repository
Browse code

DVDAudioCodecLPcm: Do not use AVCODEC_MAX_AUDIO_FRAME_SIZE which has …

…been removed from FFmpeg 2.0 and dynamically allocate buffers as needed.
  • Loading branch information...
commit d603014f9944c279d89af52bbb72989bbfe5cfac 1 parent 23c645d
Alexis Ballier authored July 25, 2013
18  xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecLPcm.cpp
@@ -24,8 +24,13 @@
24 24
 CDVDAudioCodecLPcm::CDVDAudioCodecLPcm() : CDVDAudioCodecPcm()
25 25
 {
26 26
   m_codecID = AV_CODEC_ID_NONE;
27  
-  m_bufferSize = LPCM_BUFFER_SIZE;
28  
-  memset(m_buffer, 0, sizeof(m_buffer));
  27
+  m_bufferSize = 0;
  28
+  m_buffer = NULL;
  29
+}
  30
+
  31
+CDVDAudioCodecLPcm::~CDVDAudioCodecLPcm()
  32
+{
  33
+  delete m_buffer;
29 34
 }
30 35
 
31 36
 bool CDVDAudioCodecLPcm::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
@@ -48,7 +53,14 @@ int CDVDAudioCodecLPcm::Decode(uint8_t* pData, int iSize)
48 53
   uint8_t* d = m_buffer;
49 54
   uint8_t* s = pData;
50 55
 
51  
-  if (iSize > m_bufferSize) iSize = m_bufferSize;
  56
+  if (iSize > m_bufferSize)
  57
+  {
  58
+    delete m_buffer;
  59
+    d = m_buffer = new uint8_t[iSize];
  60
+    if(!m_buffer)
  61
+      return -1;
  62
+    m_bufferSize = iSize;
  63
+  }
52 64
 
53 65
   if (iSize >= 12)
54 66
   {
6  xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecLPcm.h
@@ -24,13 +24,11 @@
24 24
 #include "DVDCodecs/DVDCodecs.h"
25 25
 #include "DVDAudioCodecPcm.h"
26 26
 
27  
-#define LPCM_BUFFER_SIZE (AVCODEC_MAX_AUDIO_FRAME_SIZE / 2)
28  
-
29 27
 class CDVDAudioCodecLPcm : public CDVDAudioCodecPcm
30 28
 {
31 29
 public:
32 30
   CDVDAudioCodecLPcm();
33  
-  virtual ~CDVDAudioCodecLPcm() {}
  31
+  virtual ~CDVDAudioCodecLPcm();
34 32
   virtual bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options);
35 33
   virtual int Decode(uint8_t* pData, int iSize);
36 34
   virtual const char* GetName()  { return "lpcm"; }
@@ -38,7 +36,7 @@ class CDVDAudioCodecLPcm : public CDVDAudioCodecPcm
38 36
 protected:
39 37
 
40 38
   int m_bufferSize;
41  
-  uint8_t m_buffer[LPCM_BUFFER_SIZE];
  39
+  uint8_t *m_buffer;
42 40
 
43 41
   AVCodecID m_codecID;
44 42
 };

0 notes on commit d603014

Please sign in to comment.
Something went wrong with that request. Please try again.