[PATCH] Do not overwrite format until format has changed (in case it doesn't).

Torbjörn Söderstedt torbjrn at users.sourceforge.net
Sun Sep 21 14:44:29 CDT 2008


---
 dlls/dsound/primary.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c
index 4e80778..161704f 100644
--- a/dlls/dsound/primary.c
+++ b/dlls/dsound/primary.c
@@ -434,6 +434,7 @@ HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex,
 	HRESULT err = DSERR_BUFFERLOST;
 	int i, alloc_size, cp_size;
 	DWORD nSamplesPerSec, bpp, chans;
+        WAVEFORMATEX wfex2;
 	TRACE("(%p,%p)\n", device, wfex);
 
 	if (device->priolevel == DSSCL_NORMAL) {
@@ -468,16 +469,16 @@ HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex,
 	bpp = device->pwfx->wBitsPerSample;
 	chans = device->pwfx->nChannels;
 
-        CopyMemory(device->pwfx, wfex, cp_size);
+        CopyMemory(&wfex2, wfex, cp_size);
 
 	if (!(device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMSETFORMAT) && device->hwbuf) {
-		err = IDsDriverBuffer_SetFormat(device->hwbuf, device->pwfx);
+		err = IDsDriverBuffer_SetFormat(device->hwbuf, &wfex2);
 
 		/* On bad format, try to re-create, big chance it will work then, only do this if we <HAVE> to */
-		if (forced && (device->pwfx->nSamplesPerSec/100 != wfex->nSamplesPerSec/100 || err == DSERR_BADFORMAT))
+		if (forced && (wfex2.nSamplesPerSec/100 != wfex->nSamplesPerSec/100 || err == DSERR_BADFORMAT))
 		{
 			err = DSERR_BUFFERLOST;
-		        CopyMemory(device->pwfx, wfex, cp_size);
+		        CopyMemory(&wfex2, wfex, cp_size);
 		}
 
 		if (err != DSERR_BUFFERLOST && FAILED(err)) {
@@ -505,6 +506,8 @@ HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex,
 		DSOUND_RecalcPrimary(device);
 	}
 
+        CopyMemory(device->pwfx, &wfex2, cp_size);
+
 	if (err == DSERR_BUFFERLOST)
 	{
 		DSOUND_PrimaryClose(device);
-- 
1.5.4.3


--ZPt4rx8FFjLCG7dd--



More information about the wine-patches mailing list