dsound: Only initialize one guid for capture and renderer.

This commit is contained in:
Maarten Lankhorst 2009-12-09 15:49:12 +01:00 committed by Alexandre Julliard
parent 891d025639
commit b474649e0e
5 changed files with 56 additions and 60 deletions

View File

@ -1059,13 +1059,10 @@ static HRESULT DirectSoundCaptureDevice_Initialize(
return DSERR_NODRIVER;
}
/* enumerate WINMM audio devices and find the one we want */
for (wid=0; wid<widn; wid++) {
if (IsEqualGUID( &devGUID, &DSOUND_capture_guids[wid]) ) {
found = TRUE;
break;
}
}
wid = devGUID.Data4[7];
if (!memcmp(&devGUID, &DSOUND_capture_guid, sizeof(GUID)-1)
&& wid < widn)
found = TRUE;
if (found == FALSE) {
WARN("No device found matching given ID!\n");

View File

@ -1373,12 +1373,10 @@ HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGUID lpcG
return DSERR_NODRIVER;
}
for (wod=0; wod<wodn; wod++) {
if (IsEqualGUID( &devGUID, &DSOUND_renderer_guids[wod])) {
found = TRUE;
break;
}
}
wod = devGUID.Data4[7];
if (!memcmp(&devGUID, &DSOUND_renderer_guid, sizeof(GUID)-1)
&& wod < wodn)
found = TRUE;
if (found == FALSE) {
WARN("No device found matching given ID!\n");

View File

@ -58,8 +58,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
GUID DSOUND_renderer_guid = { 0xbd6dd71a,0x3deb,0x11d1, {0xb1,0x71,0x00,0xc0,0x4f,0xc2,0x00,0x00} };
GUID DSOUND_capture_guid = { 0xbd6dd71b,0x3deb,0x11d1, {0xb1,0x71,0x00,0xc0,0x4f,0xc2,0x00,0x00} };
HRESULT mmErr(UINT err)
{
@ -253,17 +253,19 @@ HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest)
}
if ( IsEqualGUID( &DSDEVID_DefaultPlayback, pGuidSrc ) ||
IsEqualGUID( &DSDEVID_DefaultVoicePlayback, pGuidSrc ) ) {
*pGuidDest = DSOUND_renderer_guids[ds_default_playback];
IsEqualGUID( &DSDEVID_DefaultVoicePlayback, pGuidSrc ) ) {
*pGuidDest = DSOUND_renderer_guid;
pGuidDest->Data4[7] = ds_default_playback;
TRACE("returns %s\n", get_device_id(pGuidDest));
return DS_OK;
return DS_OK;
}
if ( IsEqualGUID( &DSDEVID_DefaultCapture, pGuidSrc ) ||
IsEqualGUID( &DSDEVID_DefaultVoiceCapture, pGuidSrc ) ) {
*pGuidDest = DSOUND_capture_guids[ds_default_capture];
IsEqualGUID( &DSDEVID_DefaultVoiceCapture, pGuidSrc ) ) {
*pGuidDest = DSOUND_capture_guid;
pGuidDest->Data4[7] = ds_default_capture;
TRACE("returns %s\n", get_device_id(pGuidDest));
return DS_OK;
return DS_OK;
}
*pGuidDest = *pGuidSrc;
@ -355,17 +357,16 @@ HRESULT WINAPI DirectSoundEnumerateW(
if (devs > 0) {
if (GetDeviceID(&DSDEVID_DefaultPlayback, &guid) == DS_OK) {
static const WCHAR empty[] = { 0 };
for (wod = 0; wod < devs; ++wod) {
if (IsEqualGUID( &guid, &DSOUND_renderer_guids[wod] ) ) {
err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) {
TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
"Primary Sound Driver",desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, "Primary Sound Driver", -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
if (lpDSEnumCallback(NULL, wDesc, empty, lpContext) == FALSE)
return DS_OK;
}
wod = guid.Data4[7];
if (wod < devs) {
err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) {
TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
"Primary Sound Driver",desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, "Primary Sound Driver", -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
if (lpDSEnumCallback(NULL, wDesc, empty, lpContext) == FALSE)
return DS_OK;
}
}
}
@ -374,13 +375,14 @@ HRESULT WINAPI DirectSoundEnumerateW(
for (wod = 0; wod < devs; ++wod) {
err = mmErr(waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) {
guid.Data4[7] = wod;
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
debugstr_guid(&DSOUND_renderer_guids[wod]),desc.szDesc,desc.szDrvname,lpContext);
debugstr_guid(&guid),desc.szDesc,desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
wName, sizeof(wName)/sizeof(WCHAR) );
if (lpDSEnumCallback(&DSOUND_renderer_guids[wod], wDesc, wName, lpContext) == FALSE)
if (lpDSEnumCallback(&guid, wDesc, wName, lpContext) == FALSE)
return DS_OK;
}
}
@ -452,19 +454,18 @@ DirectSoundCaptureEnumerateW(
devs = waveInGetNumDevs();
if (devs > 0) {
if (GetDeviceID(&DSDEVID_DefaultCapture, &guid) == DS_OK) {
for (wid = 0; wid < devs; ++wid) {
if (IsEqualGUID( &guid, &DSOUND_capture_guids[wid] ) ) {
err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) {
TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
"Primary Sound Capture Driver",desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, "Primary Sound Capture Driver", -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
wName, sizeof(wName)/sizeof(WCHAR) );
if (lpDSEnumCallback(NULL, wDesc, wName, lpContext) == FALSE)
return DS_OK;
}
wid = guid.Data4[7];
if (wid < devs) {
err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) {
TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
"Primary Sound Capture Driver",desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, "Primary Sound Capture Driver", -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
wName, sizeof(wName)/sizeof(WCHAR) );
if (lpDSEnumCallback(NULL, wDesc, wName, lpContext) == FALSE)
return DS_OK;
}
}
}
@ -473,13 +474,14 @@ DirectSoundCaptureEnumerateW(
for (wid = 0; wid < devs; ++wid) {
err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) {
guid.Data4[7] = wid;
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
debugstr_guid(&DSOUND_capture_guids[wid]),desc.szDesc,desc.szDrvname,lpContext);
debugstr_guid(&guid),desc.szDesc,desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
wName, sizeof(wName)/sizeof(WCHAR) );
if (lpDSEnumCallback(&DSOUND_capture_guids[wid], wDesc, wName, lpContext) == FALSE)
if (lpDSEnumCallback(&guid, wDesc, wName, lpContext) == FALSE)
return DS_OK;
}
}
@ -664,8 +666,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
for (i = 0; i < MAXWAVEDRIVERS; i++) {
DSOUND_renderer[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);
/* Increase refcount on dsound by 1 */

View File

@ -414,10 +414,9 @@ HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8);
#define DSOUND_FREQSHIFT (20)
extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS];
extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
extern GUID DSOUND_capture_guid;
extern GUID DSOUND_renderer_guid;
HRESULT mmErr(UINT err);
void setup_dsound_options(void);

View File

@ -116,7 +116,8 @@ static HRESULT DSPROPERTY_WaveDeviceMappingW(
res = waveOutGetDevCapsW(wod, &capsW, sizeof(capsW));
if (res == MMSYSERR_NOERROR) {
if (lstrcmpW(capsW.szPname, ppd->DeviceName) == 0) {
ppd->DeviceId = DSOUND_renderer_guids[wod];
ppd->DeviceId = DSOUND_renderer_guid;
ppd->DeviceId.Data4[7] = wod;
hr = DS_OK;
TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
debugstr_w(ppd->DeviceName));
@ -135,7 +136,8 @@ static HRESULT DSPROPERTY_WaveDeviceMappingW(
res = waveInGetDevCapsW(wid, &capsW, sizeof(capsW));
if (res == MMSYSERR_NOERROR) {
if (lstrcmpW(capsW.szPname, ppd->DeviceName) == 0) {
ppd->DeviceId = DSOUND_capture_guids[wid];
ppd->DeviceId = DSOUND_capture_guid;
ppd->DeviceId.Data4[7] = wid;
hr = DS_OK;
TRACE("found %s for %s\n", debugstr_guid(&ppd->DeviceId),
debugstr_w(ppd->DeviceName));
@ -220,13 +222,13 @@ static HRESULT DSPROPERTY_DescriptionW(
wodn = waveOutGetNumDevs();
widn = waveInGetNumDevs();
wid = wod = dev_guid.Data4[7];
if (!memcmp(&dev_guid, &DSOUND_renderer_guids[0], sizeof(GUID)-1)
if (!memcmp(&dev_guid, &DSOUND_renderer_guid, sizeof(GUID)-1)
&& wod < wodn)
{
ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
ppd->WaveDeviceId = wod;
}
else if (!memcmp(&dev_guid, &DSOUND_capture_guids[0], sizeof(GUID)-1)
else if (!memcmp(&dev_guid, &DSOUND_capture_guid, sizeof(GUID)-1)
&& wid < widn)
{
ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
@ -306,7 +308,7 @@ static HRESULT DSPROPERTY_EnumerateW(
wodn = waveOutGetNumDevs();
widn = waveInGetNumDevs();
data.DeviceId = DSOUND_renderer_guids[0];
data.DeviceId = DSOUND_renderer_guid;
for (i = 0; i < wodn; ++i)
{
HRESULT hr;
@ -324,7 +326,7 @@ static HRESULT DSPROPERTY_EnumerateW(
return S_OK;
}
data.DeviceId = DSOUND_capture_guids[0];
data.DeviceId = DSOUND_capture_guid;
for (i = 0; i < widn; ++i)
{
HRESULT hr;