SilentPatch/SilentPatchSA/AudioHardwareSA.cpp

90 lines
2.0 KiB
C++
Raw Normal View History

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;
void* pMalloc = nullptr;
unsigned int nBlockSize = 0;
unsigned int nLastMallocSize = 0;
2014-06-14 02:15:14 +02:00
DWORD CAEDataStreamOld::Seek(LONG nToSeek, DWORD nPoint)
2014-08-23 00:07:08 +02:00
{
LARGE_INTEGER filePosition;
2014-08-23 00:07:08 +02:00
switch ( nPoint )
{
case FILE_BEGIN:
filePosition.QuadPart = nToSeek + dwStartPosition;
2014-08-23 00:07:08 +02:00
break;
case FILE_END:
nPoint = FILE_BEGIN;
filePosition.QuadPart = dwStartPosition + dwLength - nToSeek;
break;
default:
filePosition.QuadPart = nToSeek;
2014-08-23 00:07:08 +02:00
break;
}
SetFilePointerEx(hHandle, filePosition, &filePosition, nPoint);
dwCurrentPosition = filePosition.LowPart;
2014-08-23 00:07:08 +02:00
return dwCurrentPosition - dwStartPosition;
}
DWORD CAEDataStreamOld::FillBuffer(void* pBuf, DWORD nLen)
2014-08-23 00:07:08 +02:00
{
ReadFile(hHandle, pBuf, nLen, &nLen, nullptr);
dwCurrentPosition += nLen;
return nLen;
}
DWORD CAEDataStreamNew::Seek(LONG nToSeek, DWORD nPoint)
2014-06-14 02:15:14 +02:00
{
LARGE_INTEGER filePosition;
2014-06-14 02:15:14 +02:00
switch ( nPoint )
{
case FILE_BEGIN:
filePosition.QuadPart = nToSeek + dwStartPosition;
2014-06-14 02:15:14 +02:00
break;
case FILE_END:
nPoint = FILE_BEGIN;
filePosition.QuadPart = dwStartPosition + dwLength - nToSeek;
break;
default:
filePosition.QuadPart = nToSeek;
2014-06-14 02:15:14 +02:00
break;
}
SetFilePointerEx(hHandle, filePosition, &filePosition, nPoint);
dwCurrentPosition = filePosition.LowPart;
2014-06-14 02:15:14 +02:00
return dwCurrentPosition - dwStartPosition;
}
DWORD CAEDataStreamNew::FillBuffer(void* pBuf, DWORD 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
}