From ace56c62a36003f080b5d036043424dafad37a22 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Mon, 25 Mar 2002 20:52:17 +0000 Subject: [PATCH] Dsound will now try as many devices as are available when trying to open a waveOut device in DirectSoundCreate(). --- dlls/dsound/dsound_main.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c index 3ba4aca8fc5..de8aca187d5 100644 --- a/dlls/dsound/dsound_main.c +++ b/dlls/dsound/dsound_main.c @@ -1175,6 +1175,9 @@ static HRESULT DSOUND_PrimaryPlay(IDirectSoundBufferImpl *dsb) static HRESULT DSOUND_PrimaryStop(IDirectSoundBufferImpl *dsb) { HRESULT err = DS_OK; + + TRACE("\n"); + if (dsb->hwbuf) { err = IDsDriverBuffer_Stop(dsb->hwbuf); if (err == DSERR_BUFFERLOST) { @@ -3525,8 +3528,8 @@ HRESULT WINAPI DirectSoundCreate(REFGUID lpGUID,LPDIRECTSOUND *ppDS,IUnknown *pU if (!wodn) return DSERR_NODRIVER; /* FIXME: How do we find the GUID of an audio device? */ - /* Well, just use the first available device for now... */ - wod = 0; + wod = 0; /* start at the first audio device */ + /* Get output device caps */ waveOutGetDevCapsA(wod, &wcaps, sizeof(wcaps)); /* DRV_QUERYDSOUNDIFACE is a "Wine extension" to get the DSound interface */ @@ -3570,11 +3573,26 @@ HRESULT WINAPI DirectSoundCreate(REFGUID lpGUID,LPDIRECTSOUND *ppDS,IUnknown *pU /* If the driver requests being opened through MMSYSTEM * (which is recommended by the DDK), it is supposed to happen * before the DirectSound interface is opened */ - if ((*ippDS)->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN) { + if ((*ippDS)->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN) + { /* FIXME: is this right? */ - err = mmErr(waveOutOpen(&((*ippDS)->hwo), (*ippDS)->drvdesc.dnDevNode, &((*ippDS)->wfx), - (DWORD)DSOUND_callback, (DWORD)(*ippDS), - CALLBACK_FUNCTION | WAVE_DIRECTSOUND)); + + (*ippDS)->drvdesc.dnDevNode = 0; + err = DSERR_ALLOCATED; + + /* if this device is busy try the next one */ + while((err == DSERR_ALLOCATED) && + ((*ippDS)->drvdesc.dnDevNode < wodn)) + { + err = mmErr(waveOutOpen(&((*ippDS)->hwo), + (*ippDS)->drvdesc.dnDevNode, &((*ippDS)->wfx), + (DWORD)DSOUND_callback, (DWORD)(*ippDS), + CALLBACK_FUNCTION | WAVE_DIRECTSOUND)); + (*ippDS)->drvdesc.dnDevNode++; /* next wave device */ + } + + (*ippDS)->drvdesc.dnDevNode--; /* take away last increment */ + } if (drv && (err == DS_OK)) -- 2.11.4.GIT