2014-08-03 19:38:53 +06:00
|
|
|
#include "StdAfxSA.h"
|
|
|
|
#include "AudioHardwareSA.h"
|
2014-06-10 22:31:19 +06:00
|
|
|
|
2014-08-23 04:07:08 +06:00
|
|
|
bool CAEDataStream::m_bUseNewStruct;
|
|
|
|
|
2014-08-22 04:10:23 +06:00
|
|
|
static void* CAEDataStream__Initialise = AddressByVersion<void*>(0x4DC2B0, 0x4DC7A0, 0x4E7550);
|
2014-08-03 19:38:53 +06:00
|
|
|
WRAPPER bool CAEDataStream::Initialise() { VARJMP(CAEDataStream__Initialise); }
|
2014-06-10 22:31:19 +06:00
|
|
|
|
2014-06-14 06:15:14 +06:00
|
|
|
unsigned int CAEStreamingDecoder::nMallocRefCount = 0;
|
|
|
|
|
2017-03-02 04:40:55 +05:00
|
|
|
void* pMalloc = nullptr;
|
|
|
|
unsigned int nBlockSize = 0;
|
|
|
|
unsigned int nLastMallocSize = 0;
|
2014-06-14 06:15:14 +06:00
|
|
|
|
2014-08-23 04:07:08 +06:00
|
|
|
unsigned int CAEDataStreamOld::Seek(long nToSeek, int nPoint)
|
|
|
|
{
|
|
|
|
switch ( nPoint )
|
|
|
|
{
|
|
|
|
case FILE_BEGIN:
|
|
|
|
nToSeek = nToSeek + dwStartPosition;
|
|
|
|
break;
|
|
|
|
case FILE_END:
|
|
|
|
nPoint = FILE_BEGIN;
|
|
|
|
nToSeek = dwStartPosition + dwLength - nToSeek;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwCurrentPosition = SetFilePointer(hHandle, nToSeek, nullptr, nPoint);
|
|
|
|
|
|
|
|
return dwCurrentPosition - dwStartPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int CAEDataStreamOld::FillBuffer(void* pBuf, unsigned long nLen)
|
|
|
|
{
|
|
|
|
ReadFile(hHandle, pBuf, nLen, &nLen, nullptr);
|
|
|
|
|
|
|
|
dwCurrentPosition += nLen;
|
|
|
|
return nLen;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int CAEDataStreamNew::Seek(long nToSeek, int nPoint)
|
2014-06-14 06:15:14 +06:00
|
|
|
{
|
|
|
|
switch ( nPoint )
|
|
|
|
{
|
|
|
|
case FILE_BEGIN:
|
2014-06-16 01:54:14 +06:00
|
|
|
nToSeek = nToSeek + dwStartPosition;
|
2014-06-14 06:15:14 +06:00
|
|
|
break;
|
|
|
|
case FILE_END:
|
|
|
|
nPoint = FILE_BEGIN;
|
2014-06-16 01:54:14 +06:00
|
|
|
nToSeek = dwStartPosition + dwLength - nToSeek;
|
2014-06-14 06:15:14 +06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-06-16 01:54:14 +06:00
|
|
|
dwCurrentPosition = SetFilePointer(hHandle, nToSeek, nullptr, nPoint);
|
2014-06-14 06:15:14 +06:00
|
|
|
|
|
|
|
return dwCurrentPosition - dwStartPosition;
|
|
|
|
}
|
|
|
|
|
2014-08-23 04:07:08 +06:00
|
|
|
unsigned int CAEDataStreamNew::FillBuffer(void* pBuf, unsigned long nLen)
|
2014-06-14 06:15:14 +06:00
|
|
|
{
|
|
|
|
ReadFile(hHandle, pBuf, nLen, &nLen, nullptr);
|
|
|
|
|
|
|
|
dwCurrentPosition += nLen;
|
|
|
|
return nLen;
|
|
|
|
}
|
|
|
|
|
|
|
|
CAEStreamingDecoder::~CAEStreamingDecoder()
|
|
|
|
{
|
2014-08-23 04:07:08 +06:00
|
|
|
if ( CAEDataStream::IsNew() )
|
|
|
|
delete reinterpret_cast<CAEDataStreamNew*>(pStream);
|
|
|
|
else
|
|
|
|
delete reinterpret_cast<CAEDataStreamOld*>(pStream);
|
2014-06-14 06:15:14 +06:00
|
|
|
pStream = nullptr;
|
|
|
|
|
|
|
|
if ( --nMallocRefCount == 0 )
|
|
|
|
{
|
|
|
|
operator delete(pMalloc);
|
|
|
|
pMalloc = nullptr;
|
|
|
|
|
|
|
|
nLastMallocSize = 0;
|
|
|
|
}
|
2014-06-10 22:31:19 +06:00
|
|
|
}
|