Skip to content

Commit b65dcb8

Browse files
author
bobo1on1
committed
fixed: adpcm codec could crash on 64 bit because it stored a pointer in int
1 parent e5fe718 commit b65dcb8

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

lib/DllAdpcm.h

+16-16
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@ class DllADPCMInterface
2727
{
2828
public:
2929
virtual ~DllADPCMInterface() {}
30-
virtual int LoadXWAV(const char* szFileName)=0;
31-
virtual void FreeXWAV(int)=0;
32-
virtual long FillBuffer(int nsf, char* buffer, int size)=0;
33-
virtual int GetPlaybackRate(int nsf)=0;
34-
virtual int GetNumberOfChannels(int info)=0;
35-
virtual int GetSampleSize(int info)=0;
36-
virtual int GetLength(int info)=0;
37-
virtual int Seek(int info, int pos)=0;
30+
virtual void* LoadXWAV(const char* szFileName)=0;
31+
virtual void FreeXWAV(void*)=0;
32+
virtual long FillBuffer(void* nsf, char* buffer, int size)=0;
33+
virtual int GetPlaybackRate(void* nsf)=0;
34+
virtual int GetNumberOfChannels(void* info)=0;
35+
virtual int GetSampleSize(void* info)=0;
36+
virtual int GetLength(void* info)=0;
37+
virtual int Seek(void* info, int pos)=0;
3838
};
3939

4040
class DllADPCM : public DllDynamic, DllADPCMInterface
4141
{
4242
DECLARE_DLL_WRAPPER(DllADPCM, DLL_PATH_ADPCM_CODEC)
43-
DEFINE_METHOD1(int, LoadXWAV, (const char* p1))
44-
DEFINE_METHOD1(void, FreeXWAV, (int p1))
45-
DEFINE_METHOD3(long, FillBuffer, (int p1, char* p2, int p3))
46-
DEFINE_METHOD1(int, GetPlaybackRate, (int p1))
47-
DEFINE_METHOD1(int, GetNumberOfChannels, (int p1))
48-
DEFINE_METHOD1(int, GetSampleSize, (int p1))
49-
DEFINE_METHOD1(int, GetLength, (int p1))
50-
DEFINE_METHOD2(int, Seek, (int p1, int p2))
43+
DEFINE_METHOD1(void*, LoadXWAV, (const char* p1))
44+
DEFINE_METHOD1(void, FreeXWAV, (void* p1))
45+
DEFINE_METHOD3(long, FillBuffer, (void* p1, char* p2, int p3))
46+
DEFINE_METHOD1(int, GetPlaybackRate, (void* p1))
47+
DEFINE_METHOD1(int, GetNumberOfChannels, (void* p1))
48+
DEFINE_METHOD1(int, GetSampleSize, (void* p1))
49+
DEFINE_METHOD1(int, GetLength, (void* p1))
50+
DEFINE_METHOD2(int, Seek, (void* p1, int p2))
5151

5252
BEGIN_METHOD_RESOLVE()
5353
RESOLVE_METHOD_RENAME(DLL_LoadXWAV, LoadXWAV)

lib/xbadpcm/ADPCMDll.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -64,39 +64,39 @@ extern "C"
6464
}
6565

6666

67-
long __declspec(dllexport) DLL_LoadXWAV(const char* szFileName)
67+
void* __declspec(dllexport) DLL_LoadXWAV(const char* szFileName)
6868
{
6969
ADPCMInfo* info = (ADPCMInfo*)malloc(sizeof(ADPCMInfo));
7070
info->f = fopen(szFileName,"rb");
7171
if (!info->f)
7272
{
7373
free(info);
74-
return 0;
74+
return NULL;
7575
}
7676

7777
int iResult = getwavinfo(info);
7878
if (iResult == -1)
7979
{
8080
fclose(info->f);
8181
free(info);
82-
return 0;
82+
return NULL;
8383
}
8484

8585
info->szBuf = (char*)malloc(XBOX_ADPCM_DSTSIZE*info->fmt.wChannels*4);
8686
info->szInputBuffer = (char*)malloc(XBOX_ADPCM_SRCSIZE*info->fmt.wChannels*4);
8787
info->szStartOfBuf = info->szBuf+XBOX_ADPCM_DSTSIZE*info->fmt.wChannels*4;
8888
info->bufLen = XBOX_ADPCM_DSTSIZE*info->fmt.wChannels*4;
89-
return (long)info;
89+
return (void*)info;
9090
}
9191

92-
void __declspec(dllexport) DLL_FreeXWAV(int info)
92+
void __declspec(dllexport) DLL_FreeXWAV(void* info)
9393
{
9494
ADPCMInfo* pInfo = (ADPCMInfo*)info;
9595
fclose(pInfo->f);
9696
free(pInfo);
9797
}
9898

99-
int __declspec(dllexport) DLL_Seek(int info, int pos)
99+
int __declspec(dllexport) DLL_Seek(void* info, int pos)
100100
{
101101
ADPCMInfo* pInfo = (ADPCMInfo*)info;
102102
int offs = pInfo->data_offset + ((((pos/ 1000) * pInfo->fmt.dwSamplesPerSec) / XBOX_ADPCM_DSTSIZE) * XBOX_ADPCM_SRCSIZE * pInfo->fmt.wChannels * (16 >> 3));
@@ -107,7 +107,7 @@ extern "C"
107107
return pos;
108108
}
109109

110-
long __declspec(dllexport) DLL_FillBuffer(int info, char* buffer, int size)
110+
long __declspec(dllexport) DLL_FillBuffer(void* info, char* buffer, int size)
111111
{
112112
ADPCMInfo* pInfo = (ADPCMInfo*)info;
113113
int iCurrSize = size;
@@ -138,25 +138,25 @@ extern "C"
138138
return size-iCurrSize;
139139
}
140140

141-
int __declspec(dllexport) DLL_GetPlaybackRate(int info)
141+
int __declspec(dllexport) DLL_GetPlaybackRate(void* info)
142142
{
143143
ADPCMInfo* pInfo = (ADPCMInfo*)info;
144144
return pInfo->fmt.dwSamplesPerSec;
145145
}
146146

147-
int __declspec(dllexport) DLL_GetNumberOfChannels(int info)
147+
int __declspec(dllexport) DLL_GetNumberOfChannels(void* info)
148148
{
149149
ADPCMInfo* pInfo = (ADPCMInfo*)info;
150150
return pInfo->fmt.wChannels;
151151
}
152152

153-
int __declspec(dllexport) DLL_GetSampleSize(int info)
153+
int __declspec(dllexport) DLL_GetSampleSize(void* info)
154154
{
155155
ADPCMInfo* pInfo = (ADPCMInfo*)info;
156156
return pInfo->fmt.wBitsPerSample;
157157
}
158158

159-
int __declspec(dllexport) DLL_GetLength(int info)
159+
int __declspec(dllexport) DLL_GetLength(void* info)
160160
{
161161
ADPCMInfo* pInfo = (ADPCMInfo*)info;
162162
return pInfo->length;

xbmc/cores/paplayer/ADPCMCodec.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
ADPCMCodec::ADPCMCodec()
2626
{
2727
m_CodecName = "ADPCM";
28-
m_adpcm = 0;
28+
m_adpcm = NULL;
2929
m_bIsPlaying = false;
3030
}
3131

@@ -62,7 +62,7 @@ void ADPCMCodec::DeInit()
6262
if (m_adpcm)
6363
m_dll.FreeXWAV(m_adpcm);
6464

65-
m_adpcm = 0;
65+
m_adpcm = NULL;
6666
m_bIsPlaying = false;
6767
}
6868

xbmc/cores/paplayer/ADPCMCodec.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ADPCMCodec : public ICodec
3737
virtual bool CanInit();
3838

3939
private:
40-
int m_adpcm;
40+
void* m_adpcm;
4141
bool m_bIsPlaying;
4242

4343
DllADPCM m_dll;

0 commit comments

Comments
 (0)