Commit ef0a0d8b authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

Revert "dsound: Only initialize one guid for capture and renderer."

Reverts b474649e. Some games use pointers to the guid rather than copying the guid even after the enumeration function returns. Allocating on the stack breaks those games.
parent d34aba2a
...@@ -1059,10 +1059,13 @@ static HRESULT DirectSoundCaptureDevice_Initialize( ...@@ -1059,10 +1059,13 @@ static HRESULT DirectSoundCaptureDevice_Initialize(
return DSERR_NODRIVER; return DSERR_NODRIVER;
} }
wid = devGUID.Data4[7]; /* enumerate WINMM audio devices and find the one we want */
if (!memcmp(&devGUID, &DSOUND_capture_guid, sizeof(GUID)-1) for (wid=0; wid<widn; wid++) {
&& wid < widn) if (IsEqualGUID( &devGUID, &DSOUND_capture_guids[wid]) ) {
found = TRUE; found = TRUE;
break;
}
}
if (found == FALSE) { if (found == FALSE) {
WARN("No device found matching given ID!\n"); WARN("No device found matching given ID!\n");
......
...@@ -1373,10 +1373,12 @@ HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGUID lpcG ...@@ -1373,10 +1373,12 @@ HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGUID lpcG
return DSERR_NODRIVER; return DSERR_NODRIVER;
} }
wod = devGUID.Data4[7]; for (wod=0; wod<wodn; wod++) {
if (!memcmp(&devGUID, &DSOUND_renderer_guid, sizeof(GUID)-1) if (IsEqualGUID( &devGUID, &DSOUND_renderer_guids[wod])) {
&& wod < wodn) found = TRUE;
found = TRUE; break;
}
}
if (found == FALSE) { if (found == FALSE) {
WARN("No device found matching given ID!\n"); WARN("No device found matching given ID!\n");
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(dsound); WINE_DEFAULT_DEBUG_CHANNEL(dsound);
DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS]; DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
GUID DSOUND_renderer_guid = { 0xbd6dd71a,0x3deb,0x11d1, {0xb1,0x71,0x00,0xc0,0x4f,0xc2,0x00,0x00} }; GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
GUID DSOUND_capture_guid = { 0xbd6dd71b,0x3deb,0x11d1, {0xb1,0x71,0x00,0xc0,0x4f,0xc2,0x00,0x00} }; GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
HRESULT mmErr(UINT err) HRESULT mmErr(UINT err)
{ {
...@@ -253,19 +253,17 @@ HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest) ...@@ -253,19 +253,17 @@ HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest)
} }
if ( IsEqualGUID( &DSDEVID_DefaultPlayback, pGuidSrc ) || if ( IsEqualGUID( &DSDEVID_DefaultPlayback, pGuidSrc ) ||
IsEqualGUID( &DSDEVID_DefaultVoicePlayback, pGuidSrc ) ) { IsEqualGUID( &DSDEVID_DefaultVoicePlayback, pGuidSrc ) ) {
*pGuidDest = DSOUND_renderer_guid; *pGuidDest = DSOUND_renderer_guids[ds_default_playback];
pGuidDest->Data4[7] = ds_default_playback;
TRACE("returns %s\n", get_device_id(pGuidDest)); TRACE("returns %s\n", get_device_id(pGuidDest));
return DS_OK; return DS_OK;
} }
if ( IsEqualGUID( &DSDEVID_DefaultCapture, pGuidSrc ) || if ( IsEqualGUID( &DSDEVID_DefaultCapture, pGuidSrc ) ||
IsEqualGUID( &DSDEVID_DefaultVoiceCapture, pGuidSrc ) ) { IsEqualGUID( &DSDEVID_DefaultVoiceCapture, pGuidSrc ) ) {
*pGuidDest = DSOUND_capture_guid; *pGuidDest = DSOUND_capture_guids[ds_default_capture];
pGuidDest->Data4[7] = ds_default_capture;
TRACE("returns %s\n", get_device_id(pGuidDest)); TRACE("returns %s\n", get_device_id(pGuidDest));
return DS_OK; return DS_OK;
} }
*pGuidDest = *pGuidSrc; *pGuidDest = *pGuidSrc;
...@@ -357,16 +355,17 @@ HRESULT WINAPI DirectSoundEnumerateW( ...@@ -357,16 +355,17 @@ HRESULT WINAPI DirectSoundEnumerateW(
if (devs > 0) { if (devs > 0) {
if (GetDeviceID(&DSDEVID_DefaultPlayback, &guid) == DS_OK) { if (GetDeviceID(&DSDEVID_DefaultPlayback, &guid) == DS_OK) {
static const WCHAR empty[] = { 0 }; static const WCHAR empty[] = { 0 };
wod = guid.Data4[7]; for (wod = 0; wod < devs; ++wod) {
if (wod < devs) { if (IsEqualGUID( &guid, &DSOUND_renderer_guids[wod] ) ) {
err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0)); err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) { if (err == DS_OK) {
TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n", TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
"Primary Sound Driver",desc.szDrvname,lpContext); "Primary Sound Driver",desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, "Primary Sound Driver", -1, MultiByteToWideChar( CP_ACP, 0, "Primary Sound Driver", -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) ); wDesc, sizeof(wDesc)/sizeof(WCHAR) );
if (lpDSEnumCallback(NULL, wDesc, empty, lpContext) == FALSE) if (lpDSEnumCallback(NULL, wDesc, empty, lpContext) == FALSE)
return DS_OK; return DS_OK;
}
} }
} }
} }
...@@ -375,14 +374,13 @@ HRESULT WINAPI DirectSoundEnumerateW( ...@@ -375,14 +374,13 @@ HRESULT WINAPI DirectSoundEnumerateW(
for (wod = 0; wod < devs; ++wod) { for (wod = 0; wod < devs; ++wod) {
err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0)); err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) { if (err == DS_OK) {
guid.Data4[7] = wod;
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n", TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
debugstr_guid(&guid),desc.szDesc,desc.szDrvname,lpContext); debugstr_guid(&DSOUND_renderer_guids[wod]),desc.szDesc,desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) ); wDesc, sizeof(wDesc)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
wName, sizeof(wName)/sizeof(WCHAR) ); wName, sizeof(wName)/sizeof(WCHAR) );
if (lpDSEnumCallback(&guid, wDesc, wName, lpContext) == FALSE) if (lpDSEnumCallback(&DSOUND_renderer_guids[wod], wDesc, wName, lpContext) == FALSE)
return DS_OK; return DS_OK;
} }
} }
...@@ -454,18 +452,19 @@ DirectSoundCaptureEnumerateW( ...@@ -454,18 +452,19 @@ DirectSoundCaptureEnumerateW(
devs = waveInGetNumDevs(); devs = waveInGetNumDevs();
if (devs > 0) { if (devs > 0) {
if (GetDeviceID(&DSDEVID_DefaultCapture, &guid) == DS_OK) { if (GetDeviceID(&DSDEVID_DefaultCapture, &guid) == DS_OK) {
wid = guid.Data4[7]; for (wid = 0; wid < devs; ++wid) {
if (wid < devs) { if (IsEqualGUID( &guid, &DSOUND_capture_guids[wid] ) ) {
err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0)); err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) { if (err == DS_OK) {
TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n", TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
"Primary Sound Capture Driver",desc.szDrvname,lpContext); "Primary Sound Capture Driver",desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, "Primary Sound Capture Driver", -1, MultiByteToWideChar( CP_ACP, 0, "Primary Sound Capture Driver", -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) ); wDesc, sizeof(wDesc)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
wName, sizeof(wName)/sizeof(WCHAR) ); wName, sizeof(wName)/sizeof(WCHAR) );
if (lpDSEnumCallback(NULL, wDesc, wName, lpContext) == FALSE) if (lpDSEnumCallback(NULL, wDesc, wName, lpContext) == FALSE)
return DS_OK; return DS_OK;
}
} }
} }
} }
...@@ -474,14 +473,13 @@ DirectSoundCaptureEnumerateW( ...@@ -474,14 +473,13 @@ DirectSoundCaptureEnumerateW(
for (wid = 0; wid < devs; ++wid) { for (wid = 0; wid < devs; ++wid) {
err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0)); err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) { if (err == DS_OK) {
guid.Data4[7] = wid;
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n", TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
debugstr_guid(&guid),desc.szDesc,desc.szDrvname,lpContext); debugstr_guid(&DSOUND_capture_guids[wid]),desc.szDesc,desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) ); wDesc, sizeof(wDesc)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
wName, sizeof(wName)/sizeof(WCHAR) ); wName, sizeof(wName)/sizeof(WCHAR) );
if (lpDSEnumCallback(&guid, wDesc, wName, lpContext) == FALSE) if (lpDSEnumCallback(&DSOUND_capture_guids[wid], wDesc, wName, lpContext) == FALSE)
return DS_OK; return DS_OK;
} }
} }
...@@ -659,6 +657,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) ...@@ -659,6 +657,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
for (i = 0; i < MAXWAVEDRIVERS; i++) { for (i = 0; i < MAXWAVEDRIVERS; i++) {
DSOUND_renderer[i] = NULL; DSOUND_renderer[i] = NULL;
DSOUND_capture[i] = NULL; DSOUND_capture[i] = NULL;
INIT_GUID(DSOUND_renderer_guids[i], 0xbd6dd71a, 0x3deb, 0x11d1, 0xb1, 0x71, 0x00, 0xc0, 0x4f, 0xc2, 0x00, 0x00 + i);
INIT_GUID(DSOUND_capture_guids[i], 0xbd6dd71b, 0x3deb, 0x11d1, 0xb1, 0x71, 0x00, 0xc0, 0x4f, 0xc2, 0x00, 0x00 + i);
} }
DisableThreadLibraryCalls(hInstDLL); DisableThreadLibraryCalls(hInstDLL);
/* Increase refcount on dsound by 1 */ /* Increase refcount on dsound by 1 */
......
...@@ -414,9 +414,10 @@ HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8); ...@@ -414,9 +414,10 @@ HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8);
#define DSOUND_FREQSHIFT (20) #define DSOUND_FREQSHIFT (20)
extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS]; extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS]; extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS];
extern GUID DSOUND_capture_guid; extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
extern GUID DSOUND_renderer_guid;
HRESULT mmErr(UINT err); HRESULT mmErr(UINT err);
void setup_dsound_options(void); void setup_dsound_options(void);
......
...@@ -116,8 +116,7 @@ static HRESULT DSPROPERTY_WaveDeviceMappingW( ...@@ -116,8 +116,7 @@ static HRESULT DSPROPERTY_WaveDeviceMappingW(
res = waveOutGetDevCapsW(wod, &capsW, sizeof(capsW)); res = waveOutGetDevCapsW(wod, &capsW, sizeof(capsW));
if (res == MMSYSERR_NOERROR) { if (res == MMSYSERR_NOERROR) {
if (lstrcmpW(capsW.szPname, ppd->DeviceName) == 0) { if (lstrcmpW(capsW.szPname, ppd->DeviceName) == 0) {
ppd->DeviceId = DSOUND_renderer_guid; ppd->DeviceId = DSOUND_renderer_guids[wod];
ppd->DeviceId.Data4[7] = wod;
hr = DS_OK; hr = DS_OK;
TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId), TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
debugstr_w(ppd->DeviceName)); debugstr_w(ppd->DeviceName));
...@@ -136,8 +135,7 @@ static HRESULT DSPROPERTY_WaveDeviceMappingW( ...@@ -136,8 +135,7 @@ static HRESULT DSPROPERTY_WaveDeviceMappingW(
res = waveInGetDevCapsW(wid, &capsW, sizeof(capsW)); res = waveInGetDevCapsW(wid, &capsW, sizeof(capsW));
if (res == MMSYSERR_NOERROR) { if (res == MMSYSERR_NOERROR) {
if (lstrcmpW(capsW.szPname, ppd->DeviceName) == 0) { if (lstrcmpW(capsW.szPname, ppd->DeviceName) == 0) {
ppd->DeviceId = DSOUND_capture_guid; ppd->DeviceId = DSOUND_capture_guids[wid];
ppd->DeviceId.Data4[7] = wid;
hr = DS_OK; hr = DS_OK;
TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId), TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
debugstr_w(ppd->DeviceName)); debugstr_w(ppd->DeviceName));
...@@ -222,13 +220,13 @@ static HRESULT DSPROPERTY_DescriptionW( ...@@ -222,13 +220,13 @@ static HRESULT DSPROPERTY_DescriptionW(
wodn = waveOutGetNumDevs(); wodn = waveOutGetNumDevs();
widn = waveInGetNumDevs(); widn = waveInGetNumDevs();
wid = wod = dev_guid.Data4[7]; wid = wod = dev_guid.Data4[7];
if (!memcmp(&dev_guid, &DSOUND_renderer_guid, sizeof(GUID)-1) if (!memcmp(&dev_guid, &DSOUND_renderer_guids[0], sizeof(GUID)-1)
&& wod < wodn) && wod < wodn)
{ {
ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER; ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
ppd->WaveDeviceId = wod; ppd->WaveDeviceId = wod;
} }
else if (!memcmp(&dev_guid, &DSOUND_capture_guid, sizeof(GUID)-1) else if (!memcmp(&dev_guid, &DSOUND_capture_guids[0], sizeof(GUID)-1)
&& wid < widn) && wid < widn)
{ {
ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE; ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
...@@ -308,7 +306,7 @@ static HRESULT DSPROPERTY_EnumerateW( ...@@ -308,7 +306,7 @@ static HRESULT DSPROPERTY_EnumerateW(
wodn = waveOutGetNumDevs(); wodn = waveOutGetNumDevs();
widn = waveInGetNumDevs(); widn = waveInGetNumDevs();
data.DeviceId = DSOUND_renderer_guid; data.DeviceId = DSOUND_renderer_guids[0];
for (i = 0; i < wodn; ++i) for (i = 0; i < wodn; ++i)
{ {
HRESULT hr; HRESULT hr;
...@@ -326,7 +324,7 @@ static HRESULT DSPROPERTY_EnumerateW( ...@@ -326,7 +324,7 @@ static HRESULT DSPROPERTY_EnumerateW(
return S_OK; return S_OK;
} }
data.DeviceId = DSOUND_capture_guid; data.DeviceId = DSOUND_capture_guids[0];
for (i = 0; i < widn; ++i) for (i = 0; i < widn; ++i)
{ {
HRESULT hr; HRESULT hr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment