Clear a new hardware buffer to proper silence values based on format.

Allows dxdiag to play 8 bit sounds in hardware primary buffer now.
This commit is contained in:
Robert Reif 2003-10-27 22:00:10 +00:00 committed by Alexandre Julliard
parent ae8ca36b99
commit 4824460772
1 changed files with 10 additions and 5 deletions

View File

@ -1981,6 +1981,7 @@ struct IDsDriverBufferImpl
/* IDsDriverBufferImpl fields */ /* IDsDriverBufferImpl fields */
IDsDriverImpl* drv; IDsDriverImpl* drv;
DWORD buflen; DWORD buflen;
WAVEFORMATEX wfx;
}; };
static HRESULT DSDB_MapPrimary(IDsDriverBufferImpl *dsdb) static HRESULT DSDB_MapPrimary(IDsDriverBufferImpl *dsdb)
@ -2003,8 +2004,10 @@ static HRESULT DSDB_MapPrimary(IDsDriverBufferImpl *dsdb)
* memset(wwo->mapping,0, wwo->maplen); * memset(wwo->mapping,0, wwo->maplen);
*/ */
{ {
char* p1 = wwo->mapping; unsigned char* p1 = wwo->mapping;
unsigned len = wwo->maplen; unsigned len = wwo->maplen;
unsigned char silence = (dsdb->wfx.wBitsPerSample == 8) ? 128 : 0;
unsigned long ulsilence = (dsdb->wfx.wBitsPerSample == 8) ? 0x80808080 : 0;
if (len >= 16) /* so we can have at least a 4 long area to store... */ if (len >= 16) /* so we can have at least a 4 long area to store... */
{ {
@ -2014,13 +2017,13 @@ static HRESULT DSDB_MapPrimary(IDsDriverBufferImpl *dsdb)
int b = len >> 2; int b = len >> 2;
unsigned long* p4 = (unsigned long*)p1; unsigned long* p4 = (unsigned long*)p1;
while (b--) *p4++ = 0; while (b--) *p4++ = ulsilence;
/* prepare for filling the rest */ /* prepare for filling the rest */
len &= 3; len &= 3;
p1 = (unsigned char*)p4; p1 = (unsigned char*)p4;
} }
/* in all cases, fill the remaining bytes */ /* in all cases, fill the remaining bytes */
while (len-- != 0) *p1++ = 0; while (len-- != 0) *p1++ = silence;
} }
} }
return DS_OK; return DS_OK;
@ -2373,7 +2376,8 @@ static HRESULT WINAPI IDsDriverImpl_GetCaps(PIDSDRIVER iface, PDSDRIVERCAPS pCap
static HRESULT WINAPI IDsDriverImpl_CreateSoundBuffer(PIDSDRIVER iface, static HRESULT WINAPI IDsDriverImpl_CreateSoundBuffer(PIDSDRIVER iface,
LPWAVEFORMATEX pwfx, LPWAVEFORMATEX pwfx,
DWORD dwFlags, DWORD dwCardAddress, DWORD dwFlags,
DWORD dwCardAddress,
LPDWORD pdwcbBufferSize, LPDWORD pdwcbBufferSize,
LPBYTE *ppbBuffer, LPBYTE *ppbBuffer,
LPVOID *ppvObj) LPVOID *ppvObj)
@ -2399,6 +2403,7 @@ static HRESULT WINAPI IDsDriverImpl_CreateSoundBuffer(PIDSDRIVER iface,
(*ippdsdb)->lpVtbl = &dsdbvt; (*ippdsdb)->lpVtbl = &dsdbvt;
(*ippdsdb)->ref = 1; (*ippdsdb)->ref = 1;
(*ippdsdb)->drv = This; (*ippdsdb)->drv = This;
(*ippdsdb)->wfx = *pwfx;
/* check how big the DMA buffer is now */ /* check how big the DMA buffer is now */
if (ioctl(WOutDev[This->wDevID].ossdev->fd, SNDCTL_DSP_GETOSPACE, &info) < 0) { if (ioctl(WOutDev[This->wDevID].ossdev->fd, SNDCTL_DSP_GETOSPACE, &info) < 0) {