[dsound] set default primary buffer sample rate and bits per sample
Robert Reif
reif at earthlink.net
Wed Apr 5 19:48:44 CDT 2006
Programs that are written specifically for 2000 and xp don't
bother to set the primary buffer format because it's a noop.
However wine is patterned after win9x and DirectX 7 or
earlier which has a real primary buffer and expects the
program to change the primary buffer format if necessary.
This patch provides a way to change the primary buffer format
from 22050x8 to an application specific value or a system wide
value for programs that don't.
This should address bugs 4908 and 3502.
-------------- next part --------------
Index: dlls/dsound/dsound.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/dsound.c,v
retrieving revision 1.48
diff -p -u -r1.48 dsound.c
--- dlls/dsound/dsound.c 17 Jan 2006 15:32:51 -0000 1.48
+++ dlls/dsound/dsound.c 6 Apr 2006 00:22:33 -0000
@@ -1141,8 +1141,8 @@ HRESULT DirectSoundDevice_Create(DirectS
* WAVE_DIRECTSOUND flag.
*/
device->pwfx->wFormatTag = WAVE_FORMAT_PCM;
- device->pwfx->nSamplesPerSec = 22050;
- device->pwfx->wBitsPerSample = 8;
+ device->pwfx->nSamplesPerSec = ds_default_sample_rate;
+ device->pwfx->wBitsPerSample = ds_default_bits_per_sample;
device->pwfx->nChannels = 2;
device->pwfx->nBlockAlign = device->pwfx->wBitsPerSample * device->pwfx->nChannels / 8;
device->pwfx->nAvgBytesPerSec = device->pwfx->nSamplesPerSec * device->pwfx->nBlockAlign;
Index: dlls/dsound/dsound_main.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/dsound_main.c,v
retrieving revision 1.130
diff -p -u -r1.130 dsound_main.c
--- dlls/dsound/dsound_main.c 10 Nov 2005 12:14:59 -0000 1.130
+++ dlls/dsound/dsound_main.c 6 Apr 2006 00:22:33 -0000
@@ -108,6 +108,8 @@ int ds_snd_queue_min = DS_SND_QUEUE_MIN;
int ds_hw_accel = DS_HW_ACCEL_FULL;
int ds_default_playback = 0;
int ds_default_capture = 0;
+int ds_default_sample_rate = 22050;
+int ds_default_bits_per_sample = 8;
/*
* Get a config key from either the app-specific or the default config
@@ -188,6 +190,12 @@ void setup_dsound_options(void)
if (!get_config_key( hkey, appkey, "DefaultCapture", buffer, MAX_PATH ))
ds_default_capture = atoi(buffer);
+ if (!get_config_key( hkey, appkey, "DefaultSampleRate", buffer, MAX_PATH ))
+ ds_default_sample_rate = atoi(buffer);
+
+ if (!get_config_key( hkey, appkey, "DefaultBitsPerSample", buffer, MAX_PATH ))
+ ds_default_bits_per_sample = atoi(buffer);
+
if (appkey) RegCloseKey( appkey );
if (hkey) RegCloseKey( hkey );
@@ -212,6 +220,10 @@ void setup_dsound_options(void)
WARN("ds_default_playback = %d (default=0)\n",ds_default_playback);
if (ds_default_capture != 0)
WARN("ds_default_capture = %d (default=0)\n",ds_default_playback);
+ if (ds_default_sample_rate != 22050)
+ WARN("ds_default_sample_rate = %d (default=22050)\n",ds_default_sample_rate);
+ if (ds_default_bits_per_sample != 8)
+ WARN("ds_default_bits_per_sample = %d (default=8)\n",ds_default_bits_per_sample);
}
const char * get_device_id(LPCGUID pGuid)
Index: dlls/dsound/dsound_private.h
===================================================================
RCS file: /home/wine/wine/dlls/dsound/dsound_private.h,v
retrieving revision 1.43
diff -p -u -r1.43 dsound_private.h
--- dlls/dsound/dsound_private.h 17 Jan 2006 15:32:59 -0000 1.43
+++ dlls/dsound/dsound_private.h 6 Apr 2006 00:22:33 -0000
@@ -40,6 +40,8 @@ extern int ds_snd_queue_min;
extern int ds_hw_accel;
extern int ds_default_playback;
extern int ds_default_capture;
+extern int ds_default_sample_rate;
+extern int ds_default_bits_per_sample;
/*****************************************************************************
* Predeclare the interface implementation structures
More information about the wine-patches
mailing list