Fixes support for older versions of direct sound.

Adds support for deleting notification array.
Minor debug and white space cleanups.
oldstable
Robert Reif 2004-04-19 02:58:45 +00:00 committed by Alexandre Julliard
parent eb80f29350
commit dbb03ec6dc
4 changed files with 66 additions and 13 deletions

View File

@ -100,7 +100,7 @@ static HRESULT WINAPI IDirectSoundNotifyImpl_SetNotificationPositions(
ICOM_THIS(IDirectSoundNotifyImpl,iface);
TRACE("(%p,0x%08lx,%p)\n",This,howmuch,notify);
if (notify == NULL) {
if (howmuch > 0 && notify == NULL) {
WARN("invalid parameter: notify == NULL\n");
return DSERR_INVALIDPARAM;
}
@ -118,7 +118,7 @@ static HRESULT WINAPI IDirectSoundNotifyImpl_SetNotificationPositions(
if (hres != DS_OK)
WARN("IDsDriverNotify_SetNotificationPositions failed\n");
return hres;
} else {
} else if (howmuch > 0) {
/* Make an internal copy of the caller-supplied array.
* Replace the existing copy if one is already present. */
if (This->dsb->notifies)
@ -134,7 +134,13 @@ static HRESULT WINAPI IDirectSoundNotifyImpl_SetNotificationPositions(
}
memcpy(This->dsb->notifies, notify, howmuch * sizeof(DSBPOSITIONNOTIFY));
This->dsb->nrofnotifies = howmuch;
}
} else {
if (This->dsb->notifies) {
HeapFree(GetProcessHeap(), 0, This->dsb->notifies);
This->dsb->notifies = NULL;
}
This->dsb->nrofnotifies = 0;
}
return S_OK;
}

View File

@ -667,7 +667,8 @@ DSOUND_CreateDirectSoundCaptureBuffer(
return DSERR_INVALIDPARAM;
}
if ( (lpcDSCBufferDesc->dwSize < sizeof(DSCBUFFERDESC)) ||
if ( ((lpcDSCBufferDesc->dwSize != sizeof(DSCBUFFERDESC)) &&
(lpcDSCBufferDesc->dwSize != sizeof(DSCBUFFERDESC1))) ||
(lpcDSCBufferDesc->dwBufferBytes == 0) ||
(lpcDSCBufferDesc->lpwfxFormat == NULL) ) {
WARN("invalid lpcDSCBufferDesc\n");
@ -823,6 +824,8 @@ static ULONG WINAPI IDirectSoundCaptureNotifyImpl_Release(LPDIRECTSOUNDNOTIFY if
ref = InterlockedDecrement(&(This->ref));
if (ref == 0) {
if (This->dscb->hwnotify)
IDsDriverNotify_Release(This->dscb->hwnotify);
This->dscb->notify=NULL;
IDirectSoundCaptureBuffer_Release((LPDIRECTSOUNDCAPTUREBUFFER)This->dscb);
HeapFree(GetProcessHeap(),0,This);
@ -839,7 +842,7 @@ static HRESULT WINAPI IDirectSoundCaptureNotifyImpl_SetNotificationPositions(
ICOM_THIS(IDirectSoundCaptureNotifyImpl,iface);
TRACE("(%p,0x%08lx,%p)\n",This,howmuch,notify);
if (notify == NULL) {
if (howmuch > 0 && notify == NULL) {
WARN("invalid parameter: notify == NULL\n");
return DSERR_INVALIDPARAM;
}
@ -857,7 +860,7 @@ static HRESULT WINAPI IDirectSoundCaptureNotifyImpl_SetNotificationPositions(
if (hres != DS_OK)
WARN("IDsDriverNotify_SetNotificationPositions failed\n");
return hres;
} else {
} else if (howmuch > 0) {
/* Make an internal copy of the caller-supplied array.
* Replace the existing copy if one is already present. */
if (This->dscb->notifies)
@ -873,6 +876,12 @@ static HRESULT WINAPI IDirectSoundCaptureNotifyImpl_SetNotificationPositions(
}
memcpy(This->dscb->notifies, notify, howmuch * sizeof(DSBPOSITIONNOTIFY));
This->dscb->nrofnotifies = howmuch;
} else {
if (This->dscb->notifies) {
HeapFree(GetProcessHeap(), 0, This->dscb->notifies);
This->dscb->notifies = NULL;
}
This->dscb->nrofnotifies = 0;
}
return S_OK;
@ -1361,6 +1370,11 @@ IDirectSoundCaptureBufferImpl_Start(
ipDSC->nrofpwaves*sizeof(WAVEHDR));
for (c = 0; c < ipDSC->nrofpwaves; c++) {
if (This->notifies[c].dwOffset == DSBPN_OFFSETSTOP) {
TRACE("got DSBPN_OFFSETSTOP\n");
ipDSC->nrofpwaves = c;
break;
}
if (c == 0) {
ipDSC->pwave[0].lpData = ipDSC->buffer;
ipDSC->pwave[0].dwBufferLength =
@ -1379,6 +1393,7 @@ IDirectSoundCaptureBufferImpl_Start(
err = mmErr(waveInPrepareHeader(ipDSC->hwi,
&(ipDSC->pwave[c]),sizeof(WAVEHDR)));
if (err != DS_OK) {
WARN("waveInPrepareHeader failed\n");
while (c--)
waveInUnprepareHeader(ipDSC->hwi,
&(ipDSC->pwave[c]),sizeof(WAVEHDR));
@ -1388,6 +1403,7 @@ IDirectSoundCaptureBufferImpl_Start(
err = mmErr(waveInAddBuffer(ipDSC->hwi,
&(ipDSC->pwave[c]), sizeof(WAVEHDR)));
if (err != DS_OK) {
WARN("waveInAddBuffer failed\n");
while (c--)
waveInUnprepareHeader(ipDSC->hwi,
&(ipDSC->pwave[c]),sizeof(WAVEHDR));
@ -1423,6 +1439,7 @@ IDirectSoundCaptureBufferImpl_Start(
err = mmErr(waveInAddBuffer(ipDSC->hwi,
&(ipDSC->pwave[0]), sizeof(WAVEHDR)));
if (err != DS_OK) {
WARN("waveInAddBuffer failed\n");
waveInUnprepareHeader(ipDSC->hwi,
&(ipDSC->pwave[0]),sizeof(WAVEHDR));
}
@ -1435,6 +1452,8 @@ IDirectSoundCaptureBufferImpl_Start(
if (err == DS_OK) {
/* start filling the first buffer */
err = mmErr(waveInStart(ipDSC->hwi));
if (err != DS_OK)
WARN("waveInStart failed\n");
}
}

View File

@ -475,7 +475,11 @@ static HRESULT WINAPI IDirectSoundImpl_SetCooperativeLevel(
LPDIRECTSOUND8 iface,HWND hwnd,DWORD level
) {
ICOM_THIS(IDirectSoundImpl,iface);
TRACE("(%p,%08lx,%ld)\n",This,(DWORD)hwnd,level);
TRACE("(%p,%08lx,%ld(%s))\n",This,(DWORD)hwnd,level,
level == DSSCL_NORMAL ? "DSSCL_NORMAL" :
level == DSSCL_PRIORITY ? "DSSCL_PRIORITY" :
level == DSSCL_EXCLUSIVE ? "DSSCL_EXCLUSIVE" :
level == DSSCL_WRITEPRIMARY ? "DSSCL_WRITEPRIMARY" : "Unknown");
if (level==DSSCL_PRIORITY || level==DSSCL_EXCLUSIVE) {
FIXME("level=%s not fully supported\n",
@ -506,6 +510,11 @@ static HRESULT WINAPI IDirectSoundImpl_CreateSoundBuffer(
return DSERR_INVALIDPARAM;
}
if (dsbd->dwSize != sizeof(DSBUFFERDESC) && dsbd->dwSize != sizeof(DSBUFFERDESC1)) {
WARN("invalid parameter: dsbd\n");
return DSERR_INVALIDPARAM;
}
if (ppdsb == NULL) {
WARN("invalid parameter: ppdsb == NULL\n");
return DSERR_INVALIDPARAM;

View File

@ -266,6 +266,16 @@ enum
DSFXR_SENDLOOP
};
typedef struct _DSBUFFERDESC1
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwBufferBytes;
DWORD dwReserved;
LPWAVEFORMATEX lpwfxFormat;
} DSBUFFERDESC1,*LPDSBUFFERDESC1;
typedef const DSBUFFERDESC1 *LPCDSBUFFERDESC1;
typedef struct _DSBUFFERDESC
{
DWORD dwSize;
@ -314,13 +324,22 @@ typedef struct _DSCEFFECTDESC
DWORD dwReserved2;
} DSCEFFECTDESC, *LPDSCEFFECTDESC;
typedef const DSCEFFECTDESC *LPCDSCEFFECTDESC;
#define DSCFX_LOCHARDWARE 0x00000001
#define DSCFX_LOCSOFTWARE 0x00000002
#define DSCFXR_LOCHARDWARE 0x00000010
#define DSCFXR_LOCSOFTWARE 0x00000020
typedef struct _DSCBUFFERDESC1
{
DWORD dwSize;
DWORD dwFlags;
DWORD dwBufferBytes;
DWORD dwReserved;
LPWAVEFORMATEX lpwfxFormat;
} DSCBUFFERDESC1, *LPDSCBUFFERDESC1;
typedef struct _DSCBUFFERDESC
{
DWORD dwSize;
@ -390,9 +409,9 @@ extern HRESULT WINAPI DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW, LPVOID);
extern HRESULT WINAPI DirectSoundCreate8(LPCGUID lpGUID,LPDIRECTSOUND8 *ppDS8,LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DirectSoundCaptureCreate8(LPCGUID lpGUID, LPDIRECTSOUNDCAPTURE *ppDSC8, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevice, LPCGUID pcGuidRenderDevice,
LPCDSCBUFFERDESC pcDSCBufferDesc, LPCDSBUFFERDESC pcDSBufferDesc, HWND hWnd, DWORD dwLevel,
LPDIRECTSOUNDFULLDUPLEX *ppDSFD, LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8, LPDIRECTSOUNDBUFFER8 *ppDSBuffer8, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevice, LPCGUID pcGuidRenderDevice,
LPCDSCBUFFERDESC pcDSCBufferDesc, LPCDSBUFFERDESC pcDSBufferDesc, HWND hWnd, DWORD dwLevel,
LPDIRECTSOUNDFULLDUPLEX *ppDSFD, LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8, LPDIRECTSOUNDBUFFER8 *ppDSBuffer8, LPUNKNOWN pUnkOuter);
#define DirectSoundFullDuplexCreate8 DirectSoundFullDuplexCreate
extern HRESULT WINAPI GetDeviceID(LPCGUID lpGuidSrc, LPGUID lpGuidDest);