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