Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@aballier aballier authored
View
18 xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecLPcm.cpp
@@ -24,8 +24,13 @@
CDVDAudioCodecLPcm::CDVDAudioCodecLPcm() : CDVDAudioCodecPcm()
{
m_codecID = AV_CODEC_ID_NONE;
- m_bufferSize = LPCM_BUFFER_SIZE;
- memset(m_buffer, 0, sizeof(m_buffer));
+ m_bufferSize = 0;
+ m_buffer = NULL;
+}
+
+CDVDAudioCodecLPcm::~CDVDAudioCodecLPcm()
+{
+ delete m_buffer;
}
bool CDVDAudioCodecLPcm::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
@@ -48,7 +53,14 @@ int CDVDAudioCodecLPcm::Decode(uint8_t* pData, int iSize)
uint8_t* d = m_buffer;
uint8_t* s = pData;
- if (iSize > m_bufferSize) iSize = m_bufferSize;
+ if (iSize > m_bufferSize)
+ {
+ delete m_buffer;
+ d = m_buffer = new uint8_t[iSize];
+ if(!m_buffer)
+ return -1;
+ m_bufferSize = iSize;
+ }
if (iSize >= 12)
{
View
6 xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecLPcm.h
@@ -24,13 +24,11 @@
#include "DVDCodecs/DVDCodecs.h"
#include "DVDAudioCodecPcm.h"
-#define LPCM_BUFFER_SIZE (AVCODEC_MAX_AUDIO_FRAME_SIZE / 2)
-
class CDVDAudioCodecLPcm : public CDVDAudioCodecPcm
{
public:
CDVDAudioCodecLPcm();
- virtual ~CDVDAudioCodecLPcm() {}
+ virtual ~CDVDAudioCodecLPcm();
virtual bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options);
virtual int Decode(uint8_t* pData, int iSize);
virtual const char* GetName() { return "lpcm"; }
@@ -38,7 +36,7 @@ class CDVDAudioCodecLPcm : public CDVDAudioCodecPcm
protected:
int m_bufferSize;
- uint8_t m_buffer[LPCM_BUFFER_SIZE];
+ uint8_t *m_buffer;
AVCodecID m_codecID;
};
Please sign in to comment.
Something went wrong with that request. Please try again.