dsound patch

Ove Kaaven ovehk at ping.uio.no
Sat Sep 28 12:54:07 CDT 2002


Some sound chips (like most ac97 stuff) don't support 8-bit audio, here's
a patch to dsound to check for such cards when selecting default audio
format.

Log:
Ove Kaaven <ovek at transgaming.com>
Fix for soundcards that can't do 8-bit audio, only 16-bit.
(Also checked for soundcards that can't do stereo while I was at it)

Index: dlls/dsound/dsound_main.c
===================================================================
RCS file: /cvsroot/winex/wine/dlls/dsound/dsound_main.c,v
retrieving revision 1.1.1.18
retrieving revision 1.70
diff -u -r1.1.1.18 -r1.70
--- dlls/dsound/dsound_main.c	25 Sep 2002 19:17:47 -0000	1.1.1.18
+++ dlls/dsound/dsound_main.c	25 Sep 2002 20:50:29 -0000	1.70
@@ -495,11 +509,23 @@
 
 	/* Set default wave format (may need it for waveOutOpen) */
 	(*ippDS)->wfx.wFormatTag	= WAVE_FORMAT_PCM;
-	(*ippDS)->wfx.nChannels		= 2;
+	/* default to stereo, if the sound card can do it */
+	if (wcaps.wChannels > 1)
+		(*ippDS)->wfx.nChannels		= 2;
+	else
+		(*ippDS)->wfx.nChannels		= 1;
+	/* default to 8, if the sound card can do it */
+	if (wcaps.dwFormats & (WAVE_FORMAT_4M08 | WAVE_FORMAT_2M08 | WAVE_FORMAT_1M08 |
+			       WAVE_FORMAT_4S08 | WAVE_FORMAT_2S08 | WAVE_FORMAT_1S08)) {
+		(*ippDS)->wfx.wBitsPerSample	= 8;
+		(*ippDS)->wfx.nBlockAlign	= 1 * (*ippDS)->wfx.nChannels;
+	} else {
+		/* it's probably a 16-bit-only card */
+		(*ippDS)->wfx.wBitsPerSample	= 16;
+		(*ippDS)->wfx.nBlockAlign	= 2 * (*ippDS)->wfx.nChannels;
+	}
 	(*ippDS)->wfx.nSamplesPerSec	= 22050;
-	(*ippDS)->wfx.nAvgBytesPerSec	= 44100;
-	(*ippDS)->wfx.nBlockAlign	= 2;
-	(*ippDS)->wfx.wBitsPerSample	= 8;
+	(*ippDS)->wfx.nAvgBytesPerSec	= 22050 * (*ippDS)->wfx.nBlockAlign;
 
 	/* If the driver requests being opened through MMSYSTEM
 	 * (which is recommended by the DDK), it is supposed to happen




More information about the wine-patches mailing list