Merge pull request #1995 from CookiePLMonster/dsound-improvements-split

Dsound improvements (split)
This commit is contained in:
RadWolfie 2020-10-17 05:37:41 -05:00 committed by GitHub
commit d9ec4342d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 11 deletions

View File

@ -748,11 +748,6 @@ xbox::hresult_xt WINAPI xbox::EMUPATCH(IDirectSoundBuffer_SetBufferData)
pThis->X_lock.dwLockBytes2); pThis->X_lock.dwLockBytes2);
} }
//TODO: Current workaround method since dwBufferBytes do set to zero. Otherwise it will produce lock error message.
if (dwBufferBytes == 0) {
return DS_OK;
}
HRESULT hRet = DSERR_OUTOFMEMORY; HRESULT hRet = DSERR_OUTOFMEMORY;
DWORD dwStatus; DWORD dwStatus;
@ -765,6 +760,12 @@ xbox::hresult_xt WINAPI xbox::EMUPATCH(IDirectSoundBuffer_SetBufferData)
pThis->EmuDirectSoundBuffer8->GetStatus(&dwStatus); pThis->EmuDirectSoundBuffer8->GetStatus(&dwStatus);
} }
//TODO: Current workaround method since dwBufferBytes do set to zero. Otherwise it will produce lock error message.
if (dwBufferBytes == 0) {
return DS_OK;
}
// Allocate memory whenever made request internally // Allocate memory whenever made request internally
if (pvBufferData == xbox::zeroptr && DSoundSGEMenAllocCheck(dwBufferBytes)) { if (pvBufferData == xbox::zeroptr && DSoundSGEMenAllocCheck(dwBufferBytes)) {

View File

@ -28,22 +28,26 @@
// Interface for get format // Interface for get format
template<class T> template<class T>
void GetFormat_4034_lower(T& settings, xbox::audio_format& format) xbox::audio_format GetFormat_4034_lower(T& settings)
{ {
format.audio_codec = settings.p_audio_format->wfx.wFormatTag = format.audio_codec; xbox::audio_format format;
format.audio_codec = settings.p_audio_format->wfx.wFormatTag;
format.nChannels = settings.p_audio_format->wfx.nChannels; format.nChannels = settings.p_audio_format->wfx.nChannels;
format.cbSize = settings.p_audio_format->wfx.cbSize; format.cbSize = settings.p_audio_format->wfx.cbSize;
format.nSamplesPerSec = settings.p_audio_format->wfx.nSamplesPerSec; format.nSamplesPerSec = settings.p_audio_format->wfx.nSamplesPerSec;
format.bitsPerSample = settings.p_audio_format->wfx.wBitsPerSample; format.bitsPerSample = settings.p_audio_format->wfx.wBitsPerSample;
return format;
} }
template<class T> template<class T>
void GetFormat_4039_upper(T& settings, xbox::audio_format& format) xbox::audio_format GetFormat_4039_upper(T& settings)
{ {
xbox::audio_format format;
format.audio_codec = settings.audio_codec; format.audio_codec = settings.audio_codec;
format.nChannels = settings.nChannels; format.nChannels = settings.nChannels;
format.cbSize = settings.cbSize; format.cbSize = settings.cbSize;
format.nSamplesPerSec = settings.nSamplesPerSec_default; format.nSamplesPerSec = settings.nSamplesPerSec_default;
format.bitsPerSample = settings.bitsPerSample; format.bitsPerSample = settings.bitsPerSample;
return format;
} }
// Interface for set format // Interface for set format

View File

@ -146,7 +146,7 @@ struct CDirectSoundVoice : CUnknownGenericManager {
static_assert(sizeof(_settings) == 0x300); // Not really require static_assert(sizeof(_settings) == 0x300); // Not really require
// Generic interface without need to check xdk's build revision every time. // Generic interface without need to check xdk's build revision every time.
typedef void (*pGetFormat)(_settings& settings, audio_format& format); typedef audio_format (*pGetFormat)(_settings& settings);
typedef void (*pSetFormat)(_settings& settings, audio_format format); typedef void (*pSetFormat)(_settings& settings, audio_format format);
typedef uint32_t (*pGetUint32)(_settings& settings); typedef uint32_t (*pGetUint32)(_settings& settings);
typedef void (*pSetUint32)(_settings& settings, uint32_t value); typedef void (*pSetUint32)(_settings& settings, uint32_t value);
@ -165,8 +165,8 @@ struct CDirectSoundVoice : CUnknownGenericManager {
} funcs; } funcs;
static_assert(sizeof(funcs) == 0x24); // Not really require static_assert(sizeof(funcs) == 0x24); // Not really require
inline void GetFormat(audio_format& format) { inline audio_format GetFormat() {
funcs.GetFormat(settings, format); return funcs.GetFormat(settings);
}; };
inline void SetFormat(audio_format format) { inline void SetFormat(audio_format format) {
funcs.SetFormat(settings, format); funcs.SetFormat(settings, format);