Refactor HRESULT -> int

This commit is contained in:
Aaron Culliney 2015-06-07 10:52:58 -07:00
parent 20bbfcd286
commit 87e7ec24ff
6 changed files with 42 additions and 45 deletions

View File

@ -20,30 +20,30 @@ typedef struct IDirectSoundBuffer {
void *_this;
HRESULT (*SetVolume)(void* _this, LONG lVolume);
int (*SetVolume)(void* _this, LONG lVolume);
HRESULT (*GetVolume)(void* _this, LPLONG lplVolume);
int (*GetVolume)(void* _this, LPLONG lplVolume);
HRESULT (*GetCurrentPosition)(void* _this, LPDWORD lpdwCurrentPlayCursor, LPDWORD lpdwCurrentWriteCursor);
int (*GetCurrentPosition)(void* _this, LPDWORD lpdwCurrentPlayCursor, LPDWORD lpdwCurrentWriteCursor);
HRESULT (*Stop)(void* _this);
int (*Stop)(void* _this);
// This method restores the memory allocation for a lost sound buffer for the specified DirectSoundBuffer object.
HRESULT (*Restore)(void *_this);
int (*Restore)(void *_this);
HRESULT (*Play)(void* _this, DWORD dwReserved1, DWORD dwReserved2, DWORD dwFlags);
int (*Play)(void* _this, DWORD dwReserved1, DWORD dwReserved2, DWORD dwFlags);
// This method obtains a valid write pointer to the sound buffer's audio data
HRESULT (*Lock)(void* _this, DWORD dwWriteCursor, DWORD dwWriteBytes, LPVOID* lplpvAudioPtr1, LPDWORD lpdwAudioBytes1, LPVOID* lplpvAudioPtr2, LPDWORD lpdwAudioBytes2, DWORD dwFlags);
int (*Lock)(void* _this, DWORD dwWriteCursor, DWORD dwWriteBytes, LPVOID* lplpvAudioPtr1, LPDWORD lpdwAudioBytes1, LPVOID* lplpvAudioPtr2, LPDWORD lpdwAudioBytes2, DWORD dwFlags);
// This method releases a locked sound buffer.
HRESULT (*Unlock)(void* _this, LPVOID lpvAudioPtr1, DWORD dwAudioBytes1, LPVOID lpvAudioPtr2, DWORD dwAudioBytes2);
int (*Unlock)(void* _this, LPVOID lpvAudioPtr1, DWORD dwAudioBytes1, LPVOID lpvAudioPtr2, DWORD dwAudioBytes2);
HRESULT (*GetStatus)(void* _this, LPDWORD lpdwStatus);
int (*GetStatus)(void* _this, LPDWORD lpdwStatus);
HRESULT (*UnlockStaticBuffer)(void* _this, DWORD dwAudioBytes);
int (*UnlockStaticBuffer)(void* _this, DWORD dwAudioBytes);
HRESULT (*Replay)(void* _this);
int (*Replay)(void* _this);
} IDirectSoundBuffer, *LPDIRECTSOUNDBUFFER, **LPLPDIRECTSOUNDBUFFER;
@ -139,8 +139,8 @@ typedef struct IDirectSoundBuffer {
#if defined(SUCCEEDED)
#undef SUCCEEDED
#endif
static inline bool FAILED(HRESULT x) { return x != DS_OK; }
static inline bool SUCCEEDED(HRESULT x) { return x == DS_OK; }
static inline bool FAILED(int x) { return x != DS_OK; }
static inline bool SUCCEEDED(int x) { return x == DS_OK; }
#define WAVE_FORMAT_PCM 0x0001
#define DSBCAPS_GETCURRENTPOSITION2 0x00010000
@ -203,8 +203,8 @@ typedef struct IDirectSound {
void *implementation_specific;
#define LPUNKNOWN void*
HRESULT (*CreateSoundBuffer)(DSBUFFERDESC *pcDSBufferDesc, LPDIRECTSOUNDBUFFER * ppDSBuffer, LPUNKNOWN pUnkOuter);
HRESULT (*DestroySoundBuffer)(LPDIRECTSOUNDBUFFER * ppDSBuffer);
int (*CreateSoundBuffer)(DSBUFFERDESC *pcDSBufferDesc, LPDIRECTSOUNDBUFFER * ppDSBuffer, LPUNKNOWN pUnkOuter);
int (*DestroySoundBuffer)(LPDIRECTSOUNDBUFFER * ppDSBuffer);
} IDirectSound, *LPDIRECTSOUND;

View File

@ -891,9 +891,9 @@ static void MB_Update()
DWORD dwCurrentPlayCursor, dwCurrentWriteCursor;
#ifdef APPLE2IX
HRESULT hr = MockingboardVoice.lpDSBvoice->GetCurrentPosition(MockingboardVoice.lpDSBvoice->_this, &dwCurrentPlayCursor, &dwCurrentWriteCursor);
int hr = MockingboardVoice.lpDSBvoice->GetCurrentPosition(MockingboardVoice.lpDSBvoice->_this, &dwCurrentPlayCursor, &dwCurrentWriteCursor);
#else
HRESULT hr = MockingboardVoice.lpDSBvoice->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor);
int hr = MockingboardVoice.lpDSBvoice->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor);
#endif
if(FAILED(hr))
return;
@ -1170,7 +1170,7 @@ static void SSI263_Play(unsigned int nPhoneme)
{
return; // SSI263 voices are currently deadc0de
#if 1
HRESULT hr;
int hr;
if(g_nCurrentActivePhoneme >= 0)
{
@ -1199,7 +1199,7 @@ static void SSI263_Play(unsigned int nPhoneme)
SSI263Voice[g_nCurrentActivePhoneme].bActive = true;
#else
HRESULT hr;
int hr;
bool bPause;
if(nPhoneme == 1)
@ -1293,7 +1293,7 @@ static bool MB_DSInit()
if(!g_bDSAvailable)
return false;
HRESULT hr = DSGetSoundBuffer(&MockingboardVoice, DSBCAPS_CTRLVOLUME, g_dwDSBufferSize, SAMPLE_RATE, 2);
int hr = DSGetSoundBuffer(&MockingboardVoice, DSBCAPS_CTRLVOLUME, g_dwDSBufferSize, SAMPLE_RATE, 2);
LogFileOutput("MB_DSInit: DSGetSoundBuffer(), hr=0x%08X\n", (unsigned int)hr);
if(FAILED(hr))
{

View File

@ -138,8 +138,8 @@ long SoundSystemCreate(const char *sound_device, SoundSystemStruct **sound_struc
}
(*sound_struct)->implementation_specific = ctx;
(*sound_struct)->CreateSoundBuffer = (HRESULT (*)(DSBUFFERDESC *, LPDIRECTSOUNDBUFFER *, void *))OpenALCreateSoundBuffer;
(*sound_struct)->DestroySoundBuffer = (HRESULT (*)(LPDIRECTSOUNDBUFFER *))OpenALDestroySoundBuffer;
(*sound_struct)->CreateSoundBuffer = (int (*)(DSBUFFERDESC *, LPDIRECTSOUNDBUFFER *, void *))OpenALCreateSoundBuffer;
(*sound_struct)->DestroySoundBuffer = (int (*)(LPDIRECTSOUNDBUFFER *))OpenALDestroySoundBuffer;
return 0;
} while(0);
@ -724,19 +724,19 @@ static long OpenALCreateSoundBuffer(ALBufferParamsStruct *params, ALSoundBufferS
}
(*soundbuf_struct)->_this = voice;
(*soundbuf_struct)->SetVolume = (HRESULT (*)(void *, LONG))ALSetVolume;
(*soundbuf_struct)->GetVolume = (HRESULT (*)(void *, LPLONG))ALGetVolume;
(*soundbuf_struct)->GetCurrentPosition = (HRESULT (*)(void *, LPDWORD, LPDWORD))ALGetPosition;
(*soundbuf_struct)->Stop = (HRESULT (*)(void *))ALStop;
(*soundbuf_struct)->Restore = (HRESULT (*)(void *))ALRestore;
(*soundbuf_struct)->Play = (HRESULT (*)(void *, DWORD, DWORD, DWORD))ALPlay;
(*soundbuf_struct)->Lock = (HRESULT (*)(void *, DWORD, DWORD, LPVOID *, LPDWORD, LPVOID *, LPDWORD, DWORD))ALBegin;
(*soundbuf_struct)->Unlock = (HRESULT (*)(void *, LPVOID, DWORD, LPVOID, DWORD))ALCommit;
(*soundbuf_struct)->GetStatus = (HRESULT (*)(void *, LPDWORD))ALGetStatus;
(*soundbuf_struct)->SetVolume = (int (*)(void *, LONG))ALSetVolume;
(*soundbuf_struct)->GetVolume = (int (*)(void *, LPLONG))ALGetVolume;
(*soundbuf_struct)->GetCurrentPosition = (int (*)(void *, LPDWORD, LPDWORD))ALGetPosition;
(*soundbuf_struct)->Stop = (int (*)(void *))ALStop;
(*soundbuf_struct)->Restore = (int (*)(void *))ALRestore;
(*soundbuf_struct)->Play = (int (*)(void *, DWORD, DWORD, DWORD))ALPlay;
(*soundbuf_struct)->Lock = (int (*)(void *, DWORD, DWORD, LPVOID *, LPDWORD, LPVOID *, LPDWORD, DWORD))ALBegin;
(*soundbuf_struct)->Unlock = (int (*)(void *, LPVOID, DWORD, LPVOID, DWORD))ALCommit;
(*soundbuf_struct)->GetStatus = (int (*)(void *, LPDWORD))ALGetStatus;
// mockingboard-specific hacks
(*soundbuf_struct)->UnlockStaticBuffer = (HRESULT (*)(void *, DWORD))ALCommitStaticBuffer;
(*soundbuf_struct)->Replay = (HRESULT (*)(void *))ALReplay;
(*soundbuf_struct)->UnlockStaticBuffer = (int (*)(void *, DWORD))ALCommitStaticBuffer;
(*soundbuf_struct)->Replay = (int (*)(void *))ALReplay;
return 0;
} while(0);

View File

@ -62,7 +62,7 @@ bool DSGetLock(LPDIRECTSOUNDBUFFER pVoice, DWORD dwOffset, DWORD dwBytes,
SHORT** ppDSLockedBuffer1, DWORD* pdwDSLockedBufferSize1)
{
DWORD nStatus = 0;
HRESULT hr = pVoice->GetStatus(pVoice->_this, &nStatus);
int hr = pVoice->GetStatus(pVoice->_this, &nStatus);
if(hr != DS_OK)
return false;
@ -100,7 +100,7 @@ bool DSGetLock(LPDIRECTSOUNDBUFFER pVoice, DWORD dwOffset, DWORD dwBytes,
//-----------------------------------------------------------------------------
HRESULT DSGetSoundBuffer(VOICE* pVoice, DWORD dwFlags, DWORD dwBufferSize, DWORD nSampleRate, int nChannels)
int DSGetSoundBuffer(VOICE* pVoice, DWORD dwFlags, DWORD dwBufferSize, DWORD nSampleRate, int nChannels)
{
WAVEFORMATEX wavfmt;
DSBUFFERDESC dsbdesc;
@ -127,7 +127,7 @@ HRESULT DSGetSoundBuffer(VOICE* pVoice, DWORD dwFlags, DWORD dwBufferSize, DWORD
g_lpDS->DestroySoundBuffer(&pVoice->lpDSBvoice);
//DSReleaseSoundBuffer(pVoice);
}
HRESULT hr = g_lpDS->CreateSoundBuffer(&dsbdesc, &pVoice->lpDSBvoice, g_lpDS);
int hr = g_lpDS->CreateSoundBuffer(&dsbdesc, &pVoice->lpDSBvoice, g_lpDS);
if(FAILED(hr))
return hr;
@ -174,7 +174,7 @@ bool DSZeroVoiceBuffer(PVOICE Voice, char* pszDevName, DWORD dwBufferSize)
DWORD argX = 0;
HRESULT hr = Voice->lpDSBvoice->Stop(Voice->lpDSBvoice->_this);
int hr = Voice->lpDSBvoice->Stop(Voice->lpDSBvoice->_this);
if(FAILED(hr))
{
LOG("%s: DSStop failed (%08X)\n",pszDevName,(unsigned int)hr);
@ -215,7 +215,7 @@ bool DSZeroVoiceWritableBuffer(PVOICE Voice, char* pszDevName, DWORD dwBufferSiz
SHORT *pDSLockedBuffer0, *pDSLockedBuffer1;
HRESULT hr = DSGetLock(Voice->lpDSBvoice,
int hr = DSGetLock(Voice->lpDSBvoice,
0, dwBufferSize,
&pDSLockedBuffer0, &dwDSLockedBufferSize0,
&pDSLockedBuffer1, &dwDSLockedBufferSize1);
@ -268,7 +268,7 @@ bool DSInit()
_destroy_enumerated_sound_devices();
num_sound_devices = SoundSystemEnumerate(&sound_devices, MAX_SOUND_DEVICES);
HRESULT hr = (num_sound_devices <= 0);
int hr = (num_sound_devices <= 0);
if(FAILED(hr))
{
LOG("DSEnumerate failed (%08X)\n",(unsigned int)hr);

View File

@ -45,7 +45,7 @@ bool DSGetLock(LPDIRECTSOUNDBUFFER pVoice, DWORD dwOffset, DWORD dwBytes,
SHORT** ppDSLockedBuffer0, DWORD* pdwDSLockedBufferSize0,
SHORT** ppDSLockedBuffer1, DWORD* pdwDSLockedBufferSize1);
HRESULT DSGetSoundBuffer(VOICE* pVoice, DWORD dwFlags, DWORD dwBufferSize, DWORD nSampleRate, int nChannels);
int DSGetSoundBuffer(VOICE* pVoice, DWORD dwFlags, DWORD dwBufferSize, DWORD nSampleRate, int nChannels);
void DSReleaseSoundBuffer(VOICE* pVoice);
bool DSZeroVoiceBuffer(PVOICE Voice, char* pszDevName, DWORD dwBufferSize);

View File

@ -28,13 +28,10 @@
typedef unsigned long DWORD;
#ifdef __APPLE__
typedef UInt32 ULONG;
typedef SInt32 HRESULT;
typedef signed char BOOL;
#else
typedef unsigned long ULONG;
typedef long HRESULT;
typedef bool BOOL;
#endif
typedef unsigned long ULONG;
typedef bool BOOL;
typedef long LONG;
typedef unsigned int UINT;
typedef uint32_t UINT32;