use shorter variable for host's lpwfxFormat
This commit is contained in:
parent
d9fcc83ade
commit
c71d1be2a5
|
@ -211,7 +211,7 @@ inline void GeneratePCMFormat(
|
|||
if (lpwfxFormat != xbnullptr) {
|
||||
|
||||
//TODO: RadWolfie - Need implement support for WAVEFORMATEXTENSIBLE as stated in CDirectSoundStream_SetFormat function note below
|
||||
// Do we need to convert it? Or just only do the WAVEFORMATEX only?
|
||||
// Do we need to convert it? Or just do the WAVEFORMATEX only?
|
||||
|
||||
// NOTE: pwfxFormat is not always a WAVEFORMATEX structure, it can
|
||||
// be WAVEFORMATEXTENSIBLE if that's what the programmer(s) wanted
|
||||
|
@ -222,23 +222,24 @@ inline void GeneratePCMFormat(
|
|||
// Only allocate extra value for setting extra values later on. WAVEFORMATEXTENSIBLE is the highest size I had seen.
|
||||
DSBufferDesc.lpwfxFormat = (WAVEFORMATEX*)calloc(1, sizeof(WAVEFORMATEXTENSIBLE));
|
||||
}
|
||||
WAVEFORMATEX* lpwfxFormatHost = DSBufferDesc.lpwfxFormat;
|
||||
|
||||
if (lpwfxFormat->wFormatTag == WAVE_FORMAT_PCM) {
|
||||
// Test case: Hulk crash due to cbSize is not a valid size.
|
||||
memcpy(DSBufferDesc.lpwfxFormat, lpwfxFormat, sizeof(WAVEFORMATEX));
|
||||
DSBufferDesc.lpwfxFormat->cbSize = 0; // Let's enforce this value to prevent any other exception later on.
|
||||
memcpy(lpwfxFormatHost, lpwfxFormat, sizeof(WAVEFORMATEX));
|
||||
lpwfxFormatHost->cbSize = 0; // Let's enforce this value to prevent any other exception later on.
|
||||
}
|
||||
else if (lpwfxFormat->wFormatTag == 0 && (DSBufferDesc.dwFlags & DSBCAPS_LOCDEFER) > 0) {
|
||||
// NOTE: This is currently a hack for ability to create buffer class with DSBCAPS_LOCDEFER flag.
|
||||
DSBufferDesc.lpwfxFormat->wFormatTag = WAVE_FORMAT_PCM;
|
||||
DSBufferDesc.lpwfxFormat->nChannels = 2;
|
||||
DSBufferDesc.lpwfxFormat->nSamplesPerSec = 44100;
|
||||
DSBufferDesc.lpwfxFormat->wBitsPerSample = 8;
|
||||
DSBufferDesc.lpwfxFormat->nBlockAlign = (DSBufferDesc.lpwfxFormat->wBitsPerSample / 8 * DSBufferDesc.lpwfxFormat->nChannels);
|
||||
DSBufferDesc.lpwfxFormat->nAvgBytesPerSec = DSBufferDesc.lpwfxFormat->nSamplesPerSec * DSBufferDesc.lpwfxFormat->nBlockAlign;
|
||||
lpwfxFormatHost->wFormatTag = WAVE_FORMAT_PCM;
|
||||
lpwfxFormatHost->nChannels = 2;
|
||||
lpwfxFormatHost->nSamplesPerSec = 44100;
|
||||
lpwfxFormatHost->wBitsPerSample = 8;
|
||||
lpwfxFormatHost->nBlockAlign = (lpwfxFormatHost->wBitsPerSample / 8 * lpwfxFormatHost->nChannels);
|
||||
lpwfxFormatHost->nAvgBytesPerSec = lpwfxFormatHost->nSamplesPerSec * lpwfxFormatHost->nBlockAlign;
|
||||
}
|
||||
else {
|
||||
memcpy(DSBufferDesc.lpwfxFormat, lpwfxFormat, sizeof(WAVEFORMATEX) + lpwfxFormat->cbSize);
|
||||
memcpy(lpwfxFormatHost, lpwfxFormat, sizeof(WAVEFORMATEX) + lpwfxFormat->cbSize);
|
||||
}
|
||||
|
||||
dwEmuFlags = dwEmuFlags & ~DSE_FLAG_AUDIO_CODECS;
|
||||
|
|
Loading…
Reference in New Issue