Small tracing improvement in DSB.SetFormat

Francois Gouget fgouget at codeweavers.com
Thu Jan 9 18:44:47 CST 2003


Changelog:

     Francois Gouget <fgouget at codeweavers.com>

   * dlls/dsound/dsound_main.c,
     dlls/dsound/primary.c

     DSB.SetFormat:Trace the requested format as soon as possible in case
it is not supported and simplify validity check
     Initialize the buffer format, and only from the fields we checked
     DirectSoundCreate8 fully initialize the buffer format (just in case)

-- 
Francois Gouget
fgouget at codeweavers.com



-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/dsound/dsound_main.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/dsound_main.c,v
retrieving revision 1.69
diff -u -r1.69 dsound_main.c
--- dlls/dsound/dsound_main.c	7 Jan 2003 19:43:18 -0000	1.69
+++ dlls/dsound/dsound_main.c	9 Jan 2003 23:28:26 -0000
@@ -644,6 +642,7 @@
         (*ippDS)->wfx.nChannels = 2;
         (*ippDS)->wfx.nBlockAlign = (*ippDS)->wfx.wBitsPerSample * (*ippDS)->wfx.nChannels / 8;
         (*ippDS)->wfx.nAvgBytesPerSec = (*ippDS)->wfx.nSamplesPerSec * (*ippDS)->wfx.nBlockAlign;
+        (*ippDS)->wfx.cbSize = 0;
 
 	/* If the driver requests being opened through MMSYSTEM
 	 * (which is recommended by the DDK), it is supposed to happen
Index: dlls/dsound/primary.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/primary.c,v
retrieving revision 1.4
diff -u -r1.4 primary.c
--- dlls/dsound/primary.c	13 Dec 2002 20:26:23 -0000	1.4
+++ dlls/dsound/primary.c	9 Jan 2003 08:18:27 -0000
@@ -109,7 +109,7 @@
 		if (newbuf == NULL) {
 			ERR("failed to allocate primary buffer\n");
 			merr = DSERR_OUTOFMEMORY;
-			/* but the old buffer might still exists and must be re-prepared */
+			/* but the old buffer might still exist and must be re-prepared */
 		} else {
 			This->buffer = newbuf;
 			This->buflen = buflen;
@@ -281,13 +304,21 @@
 	}
 
 	/* Let's be pedantic! */
-	if ((wfex == NULL) ||
-	    (wfex->wFormatTag != WAVE_FORMAT_PCM) ||
+	if (wfex == NULL) {
+		TRACE("wfex==NULL!\n");
+		return DSERR_INVALIDPARAM;
+	}
+	TRACE("(formattag=0x%04x,chans=%d,samplerate=%ld,"
+	      "bytespersec=%ld,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
+	      wfex->wFormatTag, wfex->nChannels, wfex->nSamplesPerSec,
+	      wfex->nAvgBytesPerSec, wfex->nBlockAlign,
+	      wfex->wBitsPerSample, wfex->cbSize);
+
+	if ((wfex->wFormatTag != WAVE_FORMAT_PCM) ||
 	    (wfex->nChannels < 1) || (wfex->nChannels > 2) ||
 	    (wfex->nSamplesPerSec < 1) ||
-	    (wfex->nBlockAlign < 1) || (wfex->nChannels > 4) ||
 	    ((wfex->wBitsPerSample != 8) && (wfex->wBitsPerSample != 16))) {
-		TRACE("failed pedantic check!\n");
+		TRACE("unsupported format!\n");
 		return DSERR_INVALIDPARAM;
 	}
 
@@ -308,14 +339,10 @@
 		}
 	}
 
-	memcpy(&(dsound->wfx), wfex, sizeof(dsound->wfx));
-
-	TRACE("(formattag=0x%04x,chans=%d,samplerate=%ld,"
-		   "bytespersec=%ld,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
-		   wfex->wFormatTag, wfex->nChannels, wfex->nSamplesPerSec,
-		   wfex->nAvgBytesPerSec, wfex->nBlockAlign,
-		   wfex->wBitsPerSample, wfex->cbSize);
-
+	dsound->wfx.nSamplesPerSec = wfex->nSamplesPerSec;
+	dsound->wfx.nChannels = wfex->nChannels;
+	dsound->wfx.wBitsPerSample = wfex->wBitsPerSample;
+	dsound->wfx.nBlockAlign = dsound->wfx.wBitsPerSample * dsound->wfx.nChannels;
 	dsound->wfx.nAvgBytesPerSec =
 		dsound->wfx.nSamplesPerSec * dsound->wfx.nBlockAlign;
 



More information about the wine-patches mailing list