From 5c8fb168938831f8eb158ee5c605a55f52a9347c Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Sat, 4 Jun 2005 09:38:14 +0000 Subject: [PATCH] Finish DirectSoundCapture/DirectSoundCapture8 split. Add tests to verify split. --- dlls/dsound/capture.c | 662 +++++++++++++++++++++++++++---------------- dlls/dsound/dsound.spec | 2 +- dlls/dsound/dsound_main.c | 1 + dlls/dsound/dsound_private.h | 21 +- dlls/dsound/propset.c | 6 +- include/dsound.h | 2 +- 6 files changed, 446 insertions(+), 248 deletions(-) diff --git a/dlls/dsound/capture.c b/dlls/dsound/capture.c index 15cc0feb1bf..31e8f10db4c 100644 --- a/dlls/dsound/capture.c +++ b/dlls/dsound/capture.c @@ -21,6 +21,8 @@ /* * TODO: * Implement FX support. + * Implement both IDirectSoundCaptureBuffer and IDirectSoundCaptureBuffer8 + * Make DirectSoundCaptureCreate and DirectSoundCaptureCreate8 behave differently */ #include @@ -56,7 +58,7 @@ static HRESULT DSOUND_CreateDirectSoundCaptureBuffer( static const IDirectSoundCaptureVtbl dscvt; static const IDirectSoundCaptureBuffer8Vtbl dscbvt; -static IDirectSoundCaptureImpl* dsound_capture = NULL; +DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS]; static const char * captureStateString[] = { "STATE_STOPPED", @@ -65,6 +67,76 @@ static const char * captureStateString[] = { "STATE_STOPPING" }; +HRESULT WINAPI IDirectSoundCaptureImpl_Create( + LPDIRECTSOUNDCAPTURE8 * ppDSC) +{ + IDirectSoundCaptureImpl *pDSC; + TRACE("(%p)\n", ppDSC); + + /* Allocate memory */ + pDSC = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectSoundCaptureImpl)); + if (pDSC == NULL) { + WARN("out of memory\n"); + *ppDSC = NULL; + return DSERR_OUTOFMEMORY; + } + + pDSC->lpVtbl = &dscvt; + pDSC->ref = 0; + pDSC->device = NULL; + + *ppDSC = (LPDIRECTSOUNDCAPTURE8)pDSC; + + return DS_OK; +} + +HRESULT WINAPI DSOUND_CaptureCreate( + + LPDIRECTSOUNDCAPTURE *ppDSC, + IUnknown *pUnkOuter) +{ + LPDIRECTSOUNDCAPTURE pDSC; + HRESULT hr; + TRACE("(%p,%p)\n",ppDSC,pUnkOuter); + + /* Get dsound configuration */ + setup_dsound_options(); + + hr = IDirectSoundCaptureImpl_Create(&pDSC); + if (hr == DS_OK) { + IDirectSoundCapture_AddRef(pDSC); + *ppDSC = pDSC; + } else { + WARN("IDirectSoundCaptureImpl_Create failed\n"); + *ppDSC = 0; + } + + return hr; +} + +HRESULT WINAPI DSOUND_CaptureCreate8( + LPDIRECTSOUNDCAPTURE8 *ppDSC8, + IUnknown *pUnkOuter) +{ + LPDIRECTSOUNDCAPTURE8 pDSC8; + HRESULT hr; + TRACE("(%p,%p)\n",ppDSC8,pUnkOuter); + + /* Get dsound configuration */ + setup_dsound_options(); + + hr = IDirectSoundCaptureImpl_Create(&pDSC8); + if (hr == DS_OK) { + IDirectSoundCapture_AddRef(pDSC8); + *ppDSC8 = pDSC8; + } else { + WARN("IDirectSoundCaptureImpl_Create failed\n"); + *ppDSC8 = 0; + } + + return hr; +} + /*************************************************************************** * DirectSoundCaptureCreate [DSOUND.6] * @@ -87,57 +159,119 @@ static const char * captureStateString[] = { * * DSERR_ALLOCATED is returned for sound devices that do not support full duplex. */ -HRESULT WINAPI -DirectSoundCaptureCreate8( +HRESULT WINAPI DirectSoundCaptureCreate( LPCGUID lpcGUID, - LPDIRECTSOUNDCAPTURE* lplpDSC, - LPUNKNOWN pUnkOuter ) + LPDIRECTSOUNDCAPTURE *ppDSC, + LPUNKNOWN pUnkOuter) { - IDirectSoundCaptureImpl** ippDSC=(IDirectSoundCaptureImpl**)lplpDSC; - TRACE("(%s,%p,%p)\n", debugstr_guid(lpcGUID), lplpDSC, pUnkOuter); + HRESULT hr; + LPDIRECTSOUNDCAPTURE pDSC; + TRACE("(%s,%p,%p)\n", debugstr_guid(lpcGUID), ppDSC, pUnkOuter); + + if (ppDSC == NULL) { + WARN("invalid parameter: ppDSC == NULL\n"); + return DSERR_INVALIDPARAM; + } - if ( pUnkOuter ) { + if (pUnkOuter) { WARN("invalid parameter: pUnkOuter != NULL\n"); + *ppDSC = NULL; return DSERR_NOAGGREGATION; } - if ( !lplpDSC ) { - WARN("invalid parameter: lplpDSC == NULL\n"); + hr = DSOUND_CaptureCreate(&pDSC, (IUnknown *)pUnkOuter); + if (hr == DS_OK) { + hr = IDirectSoundCapture_Initialize(pDSC, lpcGUID); + if (hr != DS_OK) { + IDirectSoundCapture_Release(pDSC); + pDSC = 0; + } + } + + *ppDSC = pDSC; + + return hr; +} + +/*************************************************************************** + * DirectSoundCaptureCreate8 [DSOUND.12] + * + * Create and initialize a DirectSoundCapture interface. + * + * PARAMS + * lpcGUID [I] Address of the GUID that identifies the sound capture device. + * lplpDSC [O] Address of a variable to receive the interface pointer. + * pUnkOuter [I] Must be NULL. + * + * RETURNS + * Success: DS_OK + * Failure: DSERR_NOAGGREGATION, DSERR_ALLOCATED, DSERR_INVALIDPARAM, + * DSERR_OUTOFMEMORY + * + * NOTES + * lpcGUID must be one of the values returned from DirectSoundCaptureEnumerate + * or NULL for the default device or DSDEVID_DefaultCapture or + * DSDEVID_DefaultVoiceCapture. + * + * DSERR_ALLOCATED is returned for sound devices that do not support full duplex. + */ +HRESULT WINAPI DirectSoundCaptureCreate8( + LPCGUID lpcGUID, + LPDIRECTSOUNDCAPTURE8 *ppDSC8, + LPUNKNOWN pUnkOuter) +{ + HRESULT hr; + LPDIRECTSOUNDCAPTURE8 pDSC8; + TRACE("(%s,%p,%p)\n", debugstr_guid(lpcGUID), ppDSC8, pUnkOuter); + + if (ppDSC8 == NULL) { + WARN("invalid parameter: ppDSC8 == NULL\n"); return DSERR_INVALIDPARAM; } - /* Default device? */ - if ( !lpcGUID || IsEqualGUID(lpcGUID, &GUID_NULL) ) - lpcGUID = &DSDEVID_DefaultCapture; + if (pUnkOuter) { + WARN("invalid parameter: pUnkOuter != NULL\n"); + *ppDSC8 = NULL; + return DSERR_NOAGGREGATION; + } + + hr = DSOUND_CaptureCreate8(&pDSC8, (IUnknown *)pUnkOuter); + if (hr == DS_OK) { + hr = IDirectSoundCapture_Initialize(pDSC8, lpcGUID); + if (hr != DS_OK) { + IDirectSoundCapture_Release(pDSC8); + pDSC8 = 0; + } + } + + *ppDSC8 = pDSC8; - *ippDSC = HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, sizeof(IDirectSoundCaptureImpl)); + return hr; +} + +static HRESULT DirectSoundCaptureDevice_Create( + DirectSoundCaptureDevice ** ppDevice) +{ + DirectSoundCaptureDevice * device; + TRACE("(%p)\n", ppDevice); + + /* Allocate memory */ + device = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DirectSoundCaptureDevice)); - if (*ippDSC == NULL) { + if (device == NULL) { WARN("out of memory\n"); return DSERR_OUTOFMEMORY; - } else { - IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)*ippDSC; + } - This->ref = 1; - This->state = STATE_STOPPED; + device->ref = 1; + device->state = STATE_STOPPED; - InitializeCriticalSection( &(This->lock) ); - This->lock.DebugInfo->Spare[1] = (DWORD)"DSCAPTURE_lock"; + InitializeCriticalSection( &(device->lock) ); + device->lock.DebugInfo->Spare[1] = (DWORD)"DSCAPTURE_lock"; - This->lpVtbl = &dscvt; - dsound_capture = This; + *ppDevice = device; - if (GetDeviceID(lpcGUID, &This->guid) == DS_OK) { - HRESULT hres; - hres = IDirectSoundCaptureImpl_Initialize( (LPDIRECTSOUNDCAPTURE)This, &This->guid); - if (hres != DS_OK) - WARN("IDirectSoundCaptureImpl_Initialize failed\n"); - return hres; - } - } - WARN("invalid GUID: %s\n", debugstr_guid(lpcGUID)); - return DSERR_INVALIDPARAM; + return DS_OK; } /*************************************************************************** @@ -278,7 +412,7 @@ DSOUND_capture_callback( DWORD dw1, DWORD dw2 ) { - IDirectSoundCaptureImpl* This = (IDirectSoundCaptureImpl*)dwUser; + DirectSoundCaptureDevice * This = (DirectSoundCaptureDevice*)dwUser; TRACE("(%p,%08x(%s),%08lx,%08lx,%08lx) entering at %ld\n",hwi,msg, msg == MM_WIM_OPEN ? "MM_WIM_OPEN" : msg == MM_WIM_CLOSE ? "MM_WIM_CLOSE" : msg == MM_WIM_DATA ? "MM_WIM_DATA" : "UNKNOWN",dwUser,dw1,dw2,GetTickCount()); @@ -323,7 +457,7 @@ IDirectSoundCaptureImpl_QueryInterface( REFIID riid, LPVOID* ppobj ) { - IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface; + DirectSoundCaptureDevice *This = ((IDirectSoundCaptureImpl *)iface)->device; TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj ); if (ppobj == NULL) { @@ -354,6 +488,36 @@ IDirectSoundCaptureImpl_AddRef( LPDIRECTSOUNDCAPTURE iface ) return ref; } +static ULONG DirectSoundCaptureDevice_Release( + DirectSoundCaptureDevice * device) +{ + ULONG ref; + + TRACE("(%p) ref was %lu\n", device, device->ref); + + device->ref--; + ref=device->ref; + if (device->ref == 0) { + TRACE("deleting object\n"); + if (device->capture_buffer) + IDirectSoundCaptureBufferImpl_Release( + (LPDIRECTSOUNDCAPTUREBUFFER8) device->capture_buffer); + + if (device->driver) { + IDsCaptureDriver_Close(device->driver); + IDsCaptureDriver_Release(device->driver); + } + + HeapFree(GetProcessHeap(), 0, device->pwfx); + device->lock.DebugInfo->Spare[1] = 0; + DeleteCriticalSection( &(device->lock) ); + DSOUND_capture[device->drvdesc.dnDevNode] = NULL; + HeapFree(GetProcessHeap(), 0, device); + TRACE("(%p) released\n", device); + } + return ref; +} + static ULONG WINAPI IDirectSoundCaptureImpl_Release( LPDIRECTSOUNDCAPTURE iface ) { @@ -362,21 +526,10 @@ IDirectSoundCaptureImpl_Release( LPDIRECTSOUNDCAPTURE iface ) TRACE("(%p) ref was %ld\n", This, ref + 1); if (!ref) { - TRACE("deleting object\n"); - if (This->capture_buffer) - IDirectSoundCaptureBufferImpl_Release( - (LPDIRECTSOUNDCAPTUREBUFFER8) This->capture_buffer); - - if (This->driver) { - IDsCaptureDriver_Close(This->driver); - IDsCaptureDriver_Release(This->driver); - } + if (This->device) + DirectSoundCaptureDevice_Release(This->device); - HeapFree(GetProcessHeap(), 0, This->pwfx); - This->lock.DebugInfo->Spare[1] = 0; - DeleteCriticalSection( &(This->lock) ); HeapFree( GetProcessHeap(), 0, This ); - dsound_capture = NULL; TRACE("(%p) released\n", This); } return ref; @@ -392,7 +545,7 @@ IDirectSoundCaptureImpl_CreateCaptureBuffer( HRESULT hr; IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface; - TRACE( "(%p,%p,%p,%p)\n",This,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk ); + TRACE( "(%p,%p,%p,%p)\n",iface,lpcDSCBufferDesc,lplpDSCaptureBuffer,pUnk); if (This == NULL) { WARN("invalid parameter: This == NULL\n"); @@ -415,12 +568,12 @@ IDirectSoundCaptureImpl_CreateCaptureBuffer( } /* FIXME: We can only have one buffer so what do we do here? */ - if (This->capture_buffer) { + if (This->device->capture_buffer) { WARN("lnvalid parameter: already has buffer\n"); return DSERR_INVALIDPARAM; /* DSERR_GENERIC ? */ } - hr = DSOUND_CreateDirectSoundCaptureBuffer( This, lpcDSCBufferDesc, + hr = DSOUND_CreateDirectSoundCaptureBuffer(This, lpcDSCBufferDesc, (LPVOID*)lplpDSCaptureBuffer ); if (hr != DS_OK) @@ -448,14 +601,14 @@ IDirectSoundCaptureImpl_GetCaps( return DSERR_INVALIDPARAM; } - if ( !(This->initialized) ) { + if ( !(This->device) ) { WARN("not initialized\n"); return DSERR_UNINITIALIZED; } - lpDSCCaps->dwFlags = This->drvcaps.dwFlags; - lpDSCCaps->dwFormats = This->drvcaps.dwFormats; - lpDSCCaps->dwChannels = This->drvcaps.dwChannels; + lpDSCCaps->dwFlags = This->device->drvcaps.dwFlags; + lpDSCCaps->dwFormats = This->device->drvcaps.dwFormats; + lpDSCCaps->dwChannels = This->device->drvcaps.dwChannels; TRACE("(flags=0x%08lx,format=0x%08lx,channels=%ld)\n",lpDSCCaps->dwFlags, lpDSCCaps->dwFormats, lpDSCCaps->dwChannels); @@ -470,7 +623,10 @@ IDirectSoundCaptureImpl_Initialize( { HRESULT err = DSERR_INVALIDPARAM; unsigned wid, widn; + BOOLEAN found = FALSE; + GUID devGUID; IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface; + DirectSoundCaptureDevice *device = This->device; TRACE("(%p)\n", This); if (!This) { @@ -478,35 +634,54 @@ IDirectSoundCaptureImpl_Initialize( return DSERR_INVALIDPARAM; } - if (This->initialized) { + if (device != NULL) { WARN("already initialized\n"); return DSERR_ALREADYINITIALIZED; } - widn = waveInGetNumDevs(); + /* Default device? */ + if ( !lpcGUID || IsEqualGUID(lpcGUID, &GUID_NULL) ) + lpcGUID = &DSDEVID_DefaultCapture; + if (GetDeviceID(lpcGUID, &devGUID) != DS_OK) { + WARN("invalid parameter: lpcGUID\n"); + return DSERR_INVALIDPARAM; + } + + widn = waveInGetNumDevs(); if (!widn) { WARN("no audio devices found\n"); return DSERR_NODRIVER; } - /* Get dsound configuration */ - setup_dsound_options(); - /* enumerate WINMM audio devices and find the one we want */ for (wid=0; widdevice = device; + device->guid = devGUID; - err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&(This->driver),0)); + err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&(This->device->driver),0)); if ( (err != DS_OK) && (err != DSERR_UNSUPPORTED) ) { WARN("waveInMessage failed; err=%lx\n",err); return err; @@ -515,12 +690,12 @@ IDirectSoundCaptureImpl_Initialize( /* Disable the direct sound driver to force emulation if requested. */ if (ds_hw_accel == DS_HW_ACCEL_EMULATION) - This->driver = NULL; + This->device->driver = NULL; /* Get driver description */ - if (This->driver) { + if (This->device->driver) { TRACE("using DirectSound driver\n"); - err = IDsCaptureDriver_GetDriverDesc(This->driver, &(This->drvdesc)); + err = IDsCaptureDriver_GetDriverDesc(This->device->driver, &(This->device->drvdesc)); if (err != DS_OK) { WARN("IDsCaptureDriver_GetDriverDesc failed\n"); return err; @@ -528,39 +703,39 @@ IDirectSoundCaptureImpl_Initialize( } else { TRACE("using WINMM\n"); /* if no DirectSound interface available, use WINMM API instead */ - This->drvdesc.dwFlags = DSDDESC_DOMMSYSTEMOPEN | + This->device->drvdesc.dwFlags = DSDDESC_DOMMSYSTEMOPEN | DSDDESC_DOMMSYSTEMSETFORMAT; } - This->drvdesc.dnDevNode = wid; + This->device->drvdesc.dnDevNode = wid; /* open the DirectSound driver if available */ - if (This->driver && (err == DS_OK)) - err = IDsCaptureDriver_Open(This->driver); + if (This->device->driver && (err == DS_OK)) + err = IDsCaptureDriver_Open(This->device->driver); if (err == DS_OK) { - This->initialized = TRUE; + This->device = device; /* the driver is now open, so it's now allowed to call GetCaps */ - if (This->driver) { - This->drvcaps.dwSize = sizeof(This->drvcaps); - err = IDsCaptureDriver_GetCaps(This->driver,&(This->drvcaps)); + if (This->device->driver) { + This->device->drvcaps.dwSize = sizeof(This->device->drvcaps); + err = IDsCaptureDriver_GetCaps(This->device->driver,&(This->device->drvcaps)); if (err != DS_OK) { WARN("IDsCaptureDriver_GetCaps failed\n"); return err; } } else /*if (This->hwi)*/ { WAVEINCAPSA wic; - err = mmErr(waveInGetDevCapsA((UINT)This->drvdesc.dnDevNode, &wic, sizeof(wic))); + err = mmErr(waveInGetDevCapsA((UINT)This->device->drvdesc.dnDevNode, &wic, sizeof(wic))); if (err == DS_OK) { - This->drvcaps.dwFlags = 0; - lstrcpynA(This->drvdesc.szDrvname, wic.szPname, - sizeof(This->drvdesc.szDrvname)); + This->device->drvcaps.dwFlags = 0; + lstrcpynA(This->device->drvdesc.szDrvname, wic.szPname, + sizeof(This->device->drvdesc.szDrvname)); - This->drvcaps.dwFlags |= DSCCAPS_EMULDRIVER; - This->drvcaps.dwFormats = wic.dwFormats; - This->drvcaps.dwChannels = wic.wChannels; + This->device->drvcaps.dwFlags |= DSCCAPS_EMULDRIVER; + This->device->drvcaps.dwFormats = wic.dwFormats; + This->device->drvcaps.dwChannels = wic.wChannels; } } } @@ -614,7 +789,7 @@ DSOUND_CreateDirectSoundCaptureBuffer( return DSERR_INVALIDPARAM; } - if ( !ipDSC->initialized ) { + if ( !ipDSC->device) { WARN("not initialized\n"); *ppobj = NULL; return DSERR_UNINITIALIZED; @@ -630,12 +805,12 @@ DSOUND_CreateDirectSoundCaptureBuffer( wfex->wBitsPerSample, wfex->cbSize); if (wfex->wFormatTag == WAVE_FORMAT_PCM) { - ipDSC->pwfx = HeapAlloc(GetProcessHeap(),0,sizeof(WAVEFORMATEX)); - CopyMemory(ipDSC->pwfx, wfex, sizeof(WAVEFORMATEX)); - ipDSC->pwfx->cbSize = 0; + ipDSC->device->pwfx = HeapAlloc(GetProcessHeap(),0,sizeof(WAVEFORMATEX)); + CopyMemory(ipDSC->device->pwfx, wfex, sizeof(WAVEFORMATEX)); + ipDSC->device->pwfx->cbSize = 0; } else { - ipDSC->pwfx = HeapAlloc(GetProcessHeap(),0,sizeof(WAVEFORMATEX)+wfex->cbSize); - CopyMemory(ipDSC->pwfx, wfex, sizeof(WAVEFORMATEX)+wfex->cbSize); + ipDSC->device->pwfx = HeapAlloc(GetProcessHeap(),0,sizeof(WAVEFORMATEX)+wfex->cbSize); + CopyMemory(ipDSC->device->pwfx, wfex, sizeof(WAVEFORMATEX)+wfex->cbSize); } } else { WARN("lpcDSCBufferDesc->lpwfxFormat == 0\n"); @@ -658,7 +833,7 @@ DSOUND_CreateDirectSoundCaptureBuffer( This->ref = 1; This->dsound = ipDSC; - This->dsound->capture_buffer = This; + This->dsound->device->capture_buffer = This; This->notify = NULL; This->nrofnotifies = 0; This->hwnotify = NULL; @@ -669,7 +844,7 @@ DSOUND_CreateDirectSoundCaptureBuffer( CopyMemory(This->pdscbd, lpcDSCBufferDesc, lpcDSCBufferDesc->dwSize); else { WARN("no memory\n"); - This->dsound->capture_buffer = 0; + This->dsound->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); *ppobj = NULL; return DSERR_OUTOFMEMORY; @@ -677,16 +852,16 @@ DSOUND_CreateDirectSoundCaptureBuffer( This->lpVtbl = &dscbvt; - if (ipDSC->driver) { - if (This->dsound->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN) + if (ipDSC->device->driver) { + if (This->dsound->device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN) FIXME("DSDDESC_DOMMSYSTEMOPEN not supported\n"); - if (This->dsound->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) { + if (This->dsound->device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) { /* allocate buffer from system memory */ buflen = lpcDSCBufferDesc->dwBufferBytes; - TRACE("desired buflen=%ld, old buffer=%p\n", buflen, ipDSC->buffer); - if (ipDSC->buffer) - newbuf = HeapReAlloc(GetProcessHeap(),0,ipDSC->buffer,buflen); + TRACE("desired buflen=%ld, old buffer=%p\n", buflen, ipDSC->device->buffer); + if (ipDSC->device->buffer) + newbuf = HeapReAlloc(GetProcessHeap(),0,ipDSC->device->buffer,buflen); else newbuf = HeapAlloc(GetProcessHeap(),0,buflen); @@ -695,22 +870,22 @@ DSOUND_CreateDirectSoundCaptureBuffer( err = DSERR_OUTOFMEMORY; /* but the old buffer might still exist and must be re-prepared */ } else { - ipDSC->buffer = newbuf; - ipDSC->buflen = buflen; + ipDSC->device->buffer = newbuf; + ipDSC->device->buflen = buflen; } } else { /* let driver allocate memory */ - ipDSC->buflen = lpcDSCBufferDesc->dwBufferBytes; + ipDSC->device->buflen = lpcDSCBufferDesc->dwBufferBytes; /* FIXME: */ - HeapFree( GetProcessHeap(), 0, ipDSC->buffer); - ipDSC->buffer = NULL; + HeapFree( GetProcessHeap(), 0, ipDSC->device->buffer); + ipDSC->device->buffer = NULL; } - err = IDsCaptureDriver_CreateCaptureBuffer(ipDSC->driver, - ipDSC->pwfx,0,0,&(ipDSC->buflen),&(ipDSC->buffer),(LPVOID*)&(ipDSC->hwbuf)); + err = IDsCaptureDriver_CreateCaptureBuffer(ipDSC->device->driver, + ipDSC->device->pwfx,0,0,&(ipDSC->device->buflen),&(ipDSC->device->buffer),(LPVOID*)&(ipDSC->device->hwbuf)); if (err != DS_OK) { WARN("IDsCaptureDriver_CreateCaptureBuffer failed\n"); - This->dsound->capture_buffer = 0; + This->dsound->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); *ppobj = NULL; return err; @@ -719,21 +894,21 @@ DSOUND_CreateDirectSoundCaptureBuffer( DWORD flags = CALLBACK_FUNCTION; if (ds_hw_accel != DS_HW_ACCEL_EMULATION) flags |= WAVE_DIRECTSOUND; - err = mmErr(waveInOpen(&(ipDSC->hwi), - ipDSC->drvdesc.dnDevNode, ipDSC->pwfx, - (DWORD)DSOUND_capture_callback, (DWORD)ipDSC, flags)); + err = mmErr(waveInOpen(&(ipDSC->device->hwi), + ipDSC->device->drvdesc.dnDevNode, ipDSC->device->pwfx, + (DWORD)DSOUND_capture_callback, (DWORD)ipDSC->device, flags)); if (err != DS_OK) { WARN("waveInOpen failed\n"); - This->dsound->capture_buffer = 0; + This->dsound->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); *ppobj = NULL; return err; } buflen = lpcDSCBufferDesc->dwBufferBytes; - TRACE("desired buflen=%ld, old buffer=%p\n", buflen, ipDSC->buffer); - if (ipDSC->buffer) - newbuf = HeapReAlloc(GetProcessHeap(),0,ipDSC->buffer,buflen); + TRACE("desired buflen=%ld, old buffer=%p\n", buflen, ipDSC->device->buffer); + if (ipDSC->device->buffer) + newbuf = HeapReAlloc(GetProcessHeap(),0,ipDSC->device->buffer,buflen); else newbuf = HeapAlloc(GetProcessHeap(),0,buflen); if (newbuf == NULL) { @@ -741,8 +916,8 @@ DSOUND_CreateDirectSoundCaptureBuffer( err = DSERR_OUTOFMEMORY; /* but the old buffer might still exist and must be re-prepared */ } else { - ipDSC->buffer = newbuf; - ipDSC->buflen = buflen; + ipDSC->device->buffer = newbuf; + ipDSC->device->buflen = buflen; } } } @@ -902,8 +1077,8 @@ IDirectSoundCaptureBufferImpl_QueryInterface( if (!This->notify) hres = IDirectSoundCaptureNotifyImpl_Create(This, &This->notify); if (This->notify) { - if (This->dsound->hwbuf) { - hres = IDsCaptureDriverBuffer_QueryInterface(This->dsound->hwbuf, + if (This->dsound->device->hwbuf) { + hres = IDsCaptureDriverBuffer_QueryInterface(This->dsound->device->hwbuf, &IID_IDsDriverNotify, (LPVOID*)&(This->hwnotify)); if (hres != DS_OK) { WARN("IDsCaptureDriverBuffer_QueryInterface failed\n"); @@ -950,25 +1125,25 @@ IDirectSoundCaptureBufferImpl_Release( LPDIRECTSOUNDCAPTUREBUFFER8 iface ) if (!ref) { TRACE("deleting object\n"); - if (This->dsound->state == STATE_CAPTURING) - This->dsound->state = STATE_STOPPING; + if (This->dsound->device->state == STATE_CAPTURING) + This->dsound->device->state = STATE_STOPPING; HeapFree(GetProcessHeap(),0, This->pdscbd); - if (This->dsound->hwi) { - waveInReset(This->dsound->hwi); - waveInClose(This->dsound->hwi); - HeapFree(GetProcessHeap(),0, This->dsound->pwave); - This->dsound->pwave = 0; - This->dsound->hwi = 0; + if (This->dsound->device->hwi) { + waveInReset(This->dsound->device->hwi); + waveInClose(This->dsound->device->hwi); + HeapFree(GetProcessHeap(),0, This->dsound->device->pwave); + This->dsound->device->pwave = 0; + This->dsound->device->hwi = 0; } - if (This->dsound->hwbuf) - IDsCaptureDriverBuffer_Release(This->dsound->hwbuf); + if (This->dsound->device->hwbuf) + IDsCaptureDriverBuffer_Release(This->dsound->device->hwbuf); /* remove from IDirectSoundCaptureImpl */ if (This->dsound) - This->dsound->capture_buffer = NULL; + This->dsound->device->capture_buffer = NULL; else ERR("does not reference dsound\n"); @@ -1040,33 +1215,33 @@ IDirectSoundCaptureBufferImpl_GetCurrentPosition( return DSERR_INVALIDPARAM; } - if (This->dsound->driver) { - hres = IDsCaptureDriverBuffer_GetPosition(This->dsound->hwbuf, lpdwCapturePosition, lpdwReadPosition ); + if (This->dsound->device->driver) { + hres = IDsCaptureDriverBuffer_GetPosition(This->dsound->device->hwbuf, lpdwCapturePosition, lpdwReadPosition ); if (hres != DS_OK) WARN("IDsCaptureDriverBuffer_GetPosition failed\n"); - } else if (This->dsound->hwi) { - EnterCriticalSection(&(This->dsound->lock)); - TRACE("old This->dsound->state=%s\n",captureStateString[This->dsound->state]); + } else if (This->dsound->device->hwi) { + EnterCriticalSection(&(This->dsound->device->lock)); + TRACE("old This->dsound->device->state=%s\n",captureStateString[This->dsound->device->state]); if (lpdwCapturePosition) { MMTIME mtime; mtime.wType = TIME_BYTES; - waveInGetPosition(This->dsound->hwi, &mtime, sizeof(mtime)); - TRACE("mtime.u.cb=%ld,This->dsound->buflen=%ld\n", mtime.u.cb, - This->dsound->buflen); - mtime.u.cb = mtime.u.cb % This->dsound->buflen; + waveInGetPosition(This->dsound->device->hwi, &mtime, sizeof(mtime)); + TRACE("mtime.u.cb=%ld,This->dsound->device->buflen=%ld\n", mtime.u.cb, + This->dsound->device->buflen); + mtime.u.cb = mtime.u.cb % This->dsound->device->buflen; *lpdwCapturePosition = mtime.u.cb; } if (lpdwReadPosition) { - if (This->dsound->state == STATE_STARTING) { + if (This->dsound->device->state == STATE_STARTING) { if (lpdwCapturePosition) - This->dsound->read_position = *lpdwCapturePosition; - This->dsound->state = STATE_CAPTURING; + This->dsound->device->read_position = *lpdwCapturePosition; + This->dsound->device->state = STATE_CAPTURING; } - *lpdwReadPosition = This->dsound->read_position; + *lpdwReadPosition = This->dsound->device->read_position; } - TRACE("new This->dsound->state=%s\n",captureStateString[This->dsound->state]); - LeaveCriticalSection(&(This->dsound->lock)); + TRACE("new This->dsound->device->state=%s\n",captureStateString[This->dsound->device->state]); + LeaveCriticalSection(&(This->dsound->device->lock)); if (lpdwCapturePosition) TRACE("*lpdwCapturePosition=%ld\n",*lpdwCapturePosition); if (lpdwReadPosition) TRACE("*lpdwReadPosition=%ld\n",*lpdwReadPosition); } else { @@ -1100,16 +1275,16 @@ IDirectSoundCaptureBufferImpl_GetFormat( return DSERR_INVALIDPARAM; } - if (dwSizeAllocated > (sizeof(WAVEFORMATEX) + This->dsound->pwfx->cbSize)) - dwSizeAllocated = sizeof(WAVEFORMATEX) + This->dsound->pwfx->cbSize; + if (dwSizeAllocated > (sizeof(WAVEFORMATEX) + This->dsound->device->pwfx->cbSize)) + dwSizeAllocated = sizeof(WAVEFORMATEX) + This->dsound->device->pwfx->cbSize; if (lpwfxFormat) { /* NULL is valid (just want size) */ - CopyMemory(lpwfxFormat, This->dsound->pwfx, dwSizeAllocated); + CopyMemory(lpwfxFormat, This->dsound->device->pwfx, dwSizeAllocated); if (lpdwSizeWritten) *lpdwSizeWritten = dwSizeAllocated; } else { if (lpdwSizeWritten) - *lpdwSizeWritten = sizeof(WAVEFORMATEX) + This->dsound->pwfx->cbSize; + *lpdwSizeWritten = sizeof(WAVEFORMATEX) + This->dsound->device->pwfx->cbSize; else { TRACE("invalid parameter: lpdwSizeWritten = NULL\n"); hres = DSERR_INVALIDPARAM; @@ -1144,19 +1319,19 @@ IDirectSoundCaptureBufferImpl_GetStatus( } *lpdwStatus = 0; - EnterCriticalSection(&(This->dsound->lock)); + EnterCriticalSection(&(This->dsound->device->lock)); TRACE("old This->dsound->state=%s, old lpdwStatus=%08lx\n", - captureStateString[This->dsound->state],*lpdwStatus); - if ((This->dsound->state == STATE_STARTING) || - (This->dsound->state == STATE_CAPTURING)) { + captureStateString[This->dsound->device->state],*lpdwStatus); + if ((This->dsound->device->state == STATE_STARTING) || + (This->dsound->device->state == STATE_CAPTURING)) { *lpdwStatus |= DSCBSTATUS_CAPTURING; if (This->flags & DSCBSTART_LOOPING) *lpdwStatus |= DSCBSTATUS_LOOPING; } TRACE("new This->dsound->state=%s, new lpdwStatus=%08lx\n", - captureStateString[This->dsound->state],*lpdwStatus); - LeaveCriticalSection(&(This->dsound->lock)); + captureStateString[This->dsound->device->state],*lpdwStatus); + LeaveCriticalSection(&(This->dsound->device->lock)); TRACE("status=%lx\n", *lpdwStatus); TRACE("returning DS_OK\n"); @@ -1213,21 +1388,21 @@ IDirectSoundCaptureBufferImpl_Lock( return DSERR_INVALIDPARAM; } - EnterCriticalSection(&(This->dsound->lock)); + EnterCriticalSection(&(This->dsound->device->lock)); - if (This->dsound->driver) { - hres = IDsCaptureDriverBuffer_Lock(This->dsound->hwbuf, lplpvAudioPtr1, + if (This->dsound->device->driver) { + hres = IDsCaptureDriverBuffer_Lock(This->dsound->device->hwbuf, lplpvAudioPtr1, lpdwAudioBytes1, lplpvAudioPtr2, lpdwAudioBytes2, dwReadCusor, dwReadBytes, dwFlags); if (hres != DS_OK) WARN("IDsCaptureDriverBuffer_Lock failed\n"); - } else if (This->dsound->hwi) { - *lplpvAudioPtr1 = This->dsound->buffer + dwReadCusor; - if ( (dwReadCusor + dwReadBytes) > This->dsound->buflen) { - *lpdwAudioBytes1 = This->dsound->buflen - dwReadCusor; + } else if (This->dsound->device->hwi) { + *lplpvAudioPtr1 = This->dsound->device->buffer + dwReadCusor; + if ( (dwReadCusor + dwReadBytes) > This->dsound->device->buflen) { + *lpdwAudioBytes1 = This->dsound->device->buflen - dwReadCusor; if (lplpvAudioPtr2) - *lplpvAudioPtr2 = This->dsound->buffer; + *lplpvAudioPtr2 = This->dsound->device->buffer; if (lpdwAudioBytes2) *lpdwAudioBytes2 = dwReadBytes - *lpdwAudioBytes1; } else { @@ -1242,7 +1417,7 @@ IDirectSoundCaptureBufferImpl_Lock( hres = DSERR_INVALIDCALL; /* DSERR_NODRIVER ? */ } - LeaveCriticalSection(&(This->dsound->lock)); + LeaveCriticalSection(&(This->dsound->device->lock)); TRACE("returning %08lx\n", hres); return hres; @@ -1267,136 +1442,136 @@ IDirectSoundCaptureBufferImpl_Start( return DSERR_INVALIDPARAM; } - if ( (This->dsound->driver == 0) && (This->dsound->hwi == 0) ) { + if ( (This->dsound->device->driver == 0) && (This->dsound->device->hwi == 0) ) { WARN("no driver\n"); return DSERR_NODRIVER; } - EnterCriticalSection(&(This->dsound->lock)); + EnterCriticalSection(&(This->dsound->device->lock)); This->flags = dwFlags; - TRACE("old This->dsound->state=%s\n",captureStateString[This->dsound->state]); - if (This->dsound->state == STATE_STOPPED) - This->dsound->state = STATE_STARTING; - else if (This->dsound->state == STATE_STOPPING) - This->dsound->state = STATE_CAPTURING; - TRACE("new This->dsound->state=%s\n",captureStateString[This->dsound->state]); + TRACE("old This->dsound->state=%s\n",captureStateString[This->dsound->device->state]); + if (This->dsound->device->state == STATE_STOPPED) + This->dsound->device->state = STATE_STARTING; + else if (This->dsound->device->state == STATE_STOPPING) + This->dsound->device->state = STATE_CAPTURING; + TRACE("new This->dsound->device->state=%s\n",captureStateString[This->dsound->device->state]); - LeaveCriticalSection(&(This->dsound->lock)); + LeaveCriticalSection(&(This->dsound->device->lock)); - if (This->dsound->driver) { - hres = IDsCaptureDriverBuffer_Start(This->dsound->hwbuf, dwFlags); + if (This->dsound->device->driver) { + hres = IDsCaptureDriverBuffer_Start(This->dsound->device->hwbuf, dwFlags); if (hres != DS_OK) WARN("IDsCaptureDriverBuffer_Start failed\n"); - } else if (This->dsound->hwi) { + } else if (This->dsound->device->hwi) { IDirectSoundCaptureImpl* ipDSC = This->dsound; - if (ipDSC->buffer) { + if (ipDSC->device->buffer) { if (This->nrofnotifies) { int c; - ipDSC->nrofpwaves = This->nrofnotifies; + ipDSC->device->nrofpwaves = This->nrofnotifies; TRACE("nrofnotifies=%d\n", This->nrofnotifies); /* prepare headers */ - if (ipDSC->pwave) - ipDSC->pwave = HeapReAlloc(GetProcessHeap(),0,ipDSC->pwave, - ipDSC->nrofpwaves*sizeof(WAVEHDR)); + if (ipDSC->device->pwave) + ipDSC->device->pwave = HeapReAlloc(GetProcessHeap(),0,ipDSC->device->pwave, + ipDSC->device->nrofpwaves*sizeof(WAVEHDR)); else - ipDSC->pwave = HeapAlloc(GetProcessHeap(),0, - ipDSC->nrofpwaves*sizeof(WAVEHDR)); + ipDSC->device->pwave = HeapAlloc(GetProcessHeap(),0, + ipDSC->device->nrofpwaves*sizeof(WAVEHDR)); - for (c = 0; c < ipDSC->nrofpwaves; c++) { + for (c = 0; c < ipDSC->device->nrofpwaves; c++) { if (This->notifies[c].dwOffset == DSBPN_OFFSETSTOP) { TRACE("got DSBPN_OFFSETSTOP\n"); - ipDSC->nrofpwaves = c; + ipDSC->device->nrofpwaves = c; break; } if (c == 0) { - ipDSC->pwave[0].lpData = ipDSC->buffer; - ipDSC->pwave[0].dwBufferLength = + ipDSC->device->pwave[0].lpData = ipDSC->device->buffer; + ipDSC->device->pwave[0].dwBufferLength = This->notifies[0].dwOffset + 1; } else { - ipDSC->pwave[c].lpData = ipDSC->buffer + + ipDSC->device->pwave[c].lpData = ipDSC->device->buffer + This->notifies[c-1].dwOffset + 1; - ipDSC->pwave[c].dwBufferLength = + ipDSC->device->pwave[c].dwBufferLength = This->notifies[c].dwOffset - This->notifies[c-1].dwOffset; } - ipDSC->pwave[c].dwBytesRecorded = 0; - ipDSC->pwave[c].dwUser = (DWORD)ipDSC; - ipDSC->pwave[c].dwFlags = 0; - ipDSC->pwave[c].dwLoops = 0; - hres = mmErr(waveInPrepareHeader(ipDSC->hwi, - &(ipDSC->pwave[c]),sizeof(WAVEHDR))); + ipDSC->device->pwave[c].dwBytesRecorded = 0; + ipDSC->device->pwave[c].dwUser = (DWORD)ipDSC; + ipDSC->device->pwave[c].dwFlags = 0; + ipDSC->device->pwave[c].dwLoops = 0; + hres = mmErr(waveInPrepareHeader(ipDSC->device->hwi, + &(ipDSC->device->pwave[c]),sizeof(WAVEHDR))); if (hres != DS_OK) { WARN("waveInPrepareHeader failed\n"); while (c--) - waveInUnprepareHeader(ipDSC->hwi, - &(ipDSC->pwave[c]),sizeof(WAVEHDR)); + waveInUnprepareHeader(ipDSC->device->hwi, + &(ipDSC->device->pwave[c]),sizeof(WAVEHDR)); break; } - hres = mmErr(waveInAddBuffer(ipDSC->hwi, - &(ipDSC->pwave[c]), sizeof(WAVEHDR))); + hres = mmErr(waveInAddBuffer(ipDSC->device->hwi, + &(ipDSC->device->pwave[c]), sizeof(WAVEHDR))); if (hres != DS_OK) { WARN("waveInAddBuffer failed\n"); while (c--) - waveInUnprepareHeader(ipDSC->hwi, - &(ipDSC->pwave[c]),sizeof(WAVEHDR)); + waveInUnprepareHeader(ipDSC->device->hwi, + &(ipDSC->device->pwave[c]),sizeof(WAVEHDR)); break; } } - FillMemory(ipDSC->buffer, ipDSC->buflen, - (ipDSC->pwfx->wBitsPerSample == 8) ? 128 : 0); + FillMemory(ipDSC->device->buffer, ipDSC->device->buflen, + (ipDSC->device->pwfx->wBitsPerSample == 8) ? 128 : 0); } else { TRACE("no notifiers specified\n"); /* no notifiers specified so just create a single default header */ - ipDSC->nrofpwaves = 1; - if (ipDSC->pwave) - ipDSC->pwave = HeapReAlloc(GetProcessHeap(),0,ipDSC->pwave,sizeof(WAVEHDR)); + ipDSC->device->nrofpwaves = 1; + if (ipDSC->device->pwave) + ipDSC->device->pwave = HeapReAlloc(GetProcessHeap(),0,ipDSC->device->pwave,sizeof(WAVEHDR)); else - ipDSC->pwave = HeapAlloc(GetProcessHeap(),0,sizeof(WAVEHDR)); + ipDSC->device->pwave = HeapAlloc(GetProcessHeap(),0,sizeof(WAVEHDR)); - ipDSC->pwave[0].lpData = ipDSC->buffer; - ipDSC->pwave[0].dwBufferLength = ipDSC->buflen; - ipDSC->pwave[0].dwBytesRecorded = 0; - ipDSC->pwave[0].dwUser = (DWORD)ipDSC; - ipDSC->pwave[0].dwFlags = 0; - ipDSC->pwave[0].dwLoops = 0; + ipDSC->device->pwave[0].lpData = ipDSC->device->buffer; + ipDSC->device->pwave[0].dwBufferLength = ipDSC->device->buflen; + ipDSC->device->pwave[0].dwBytesRecorded = 0; + ipDSC->device->pwave[0].dwUser = (DWORD)ipDSC; + ipDSC->device->pwave[0].dwFlags = 0; + ipDSC->device->pwave[0].dwLoops = 0; - hres = mmErr(waveInPrepareHeader(ipDSC->hwi, - &(ipDSC->pwave[0]),sizeof(WAVEHDR))); + hres = mmErr(waveInPrepareHeader(ipDSC->device->hwi, + &(ipDSC->device->pwave[0]),sizeof(WAVEHDR))); if (hres != DS_OK) { WARN("waveInPrepareHeader failed\n"); - waveInUnprepareHeader(ipDSC->hwi, - &(ipDSC->pwave[0]),sizeof(WAVEHDR)); + waveInUnprepareHeader(ipDSC->device->hwi, + &(ipDSC->device->pwave[0]),sizeof(WAVEHDR)); } - hres = mmErr(waveInAddBuffer(ipDSC->hwi, - &(ipDSC->pwave[0]), sizeof(WAVEHDR))); + hres = mmErr(waveInAddBuffer(ipDSC->device->hwi, + &(ipDSC->device->pwave[0]), sizeof(WAVEHDR))); if (hres != DS_OK) { WARN("waveInAddBuffer failed\n"); - waveInUnprepareHeader(ipDSC->hwi, - &(ipDSC->pwave[0]),sizeof(WAVEHDR)); + waveInUnprepareHeader(ipDSC->device->hwi, + &(ipDSC->device->pwave[0]),sizeof(WAVEHDR)); } } } - ipDSC->index = 0; - ipDSC->read_position = 0; + ipDSC->device->index = 0; + ipDSC->device->read_position = 0; if (hres == DS_OK) { /* start filling the first buffer */ - hres = mmErr(waveInStart(ipDSC->hwi)); + hres = mmErr(waveInStart(ipDSC->device->hwi)); if (hres != DS_OK) WARN("waveInStart failed\n"); } if (hres != DS_OK) { WARN("calling waveInClose because of error\n"); - waveInClose(This->dsound->hwi); - This->dsound->hwi = 0; + waveInClose(This->dsound->device->hwi); + This->dsound->device->hwi = 0; } } else { WARN("no driver\n"); @@ -1424,23 +1599,23 @@ IDirectSoundCaptureBufferImpl_Stop( LPDIRECTSOUNDCAPTUREBUFFER8 iface ) return DSERR_INVALIDPARAM; } - EnterCriticalSection(&(This->dsound->lock)); + EnterCriticalSection(&(This->dsound->device->lock)); - TRACE("old This->dsound->state=%s\n",captureStateString[This->dsound->state]); - if (This->dsound->state == STATE_CAPTURING) - This->dsound->state = STATE_STOPPING; - else if (This->dsound->state == STATE_STARTING) - This->dsound->state = STATE_STOPPED; - TRACE("new This->dsound->state=%s\n",captureStateString[This->dsound->state]); + TRACE("old This->dsound->state=%s\n",captureStateString[This->dsound->device->state]); + if (This->dsound->device->state == STATE_CAPTURING) + This->dsound->device->state = STATE_STOPPING; + else if (This->dsound->device->state == STATE_STARTING) + This->dsound->device->state = STATE_STOPPED; + TRACE("new This->dsound->device->state=%s\n",captureStateString[This->dsound->device->state]); - LeaveCriticalSection(&(This->dsound->lock)); + LeaveCriticalSection(&(This->dsound->device->lock)); - if (This->dsound->driver) { - hres = IDsCaptureDriverBuffer_Stop(This->dsound->hwbuf); + if (This->dsound->device->driver) { + hres = IDsCaptureDriverBuffer_Stop(This->dsound->device->hwbuf); if (hres != DS_OK) WARN("IDsCaptureDriverBuffer_Stop() failed\n"); - } else if (This->dsound->hwi) { - hres = mmErr(waveInReset(This->dsound->hwi)); + } else if (This->dsound->device->hwi) { + hres = mmErr(waveInReset(This->dsound->device->hwi)); if (hres != DS_OK) WARN("waveInReset() failed\n"); } else { @@ -1475,14 +1650,14 @@ IDirectSoundCaptureBufferImpl_Unlock( return DSERR_INVALIDPARAM; } - if (This->dsound->driver) { - hres = IDsCaptureDriverBuffer_Unlock(This->dsound->hwbuf, lpvAudioPtr1, + if (This->dsound->device->driver) { + hres = IDsCaptureDriverBuffer_Unlock(This->dsound->device->hwbuf, lpvAudioPtr1, dwAudioBytes1, lpvAudioPtr2, dwAudioBytes2); if (hres != DS_OK) WARN("IDsCaptureDriverBuffer_Unlock failed\n"); - } else if (This->dsound->hwi) { - This->dsound->read_position = (This->dsound->read_position + - (dwAudioBytes1 + dwAudioBytes2)) % This->dsound->buflen; + } else if (This->dsound->device->hwi) { + This->dsound->device->read_position = (This->dsound->device->read_position + + (dwAudioBytes1 + dwAudioBytes2)) % This->dsound->device->buflen; } else { WARN("invalid call\n"); hres = DSERR_INVALIDCALL; @@ -1595,8 +1770,11 @@ DSCCF_CreateInstance( *ppobj = NULL; + if ( IsEqualGUID( &IID_IDirectSoundCapture, riid ) ) + return DSOUND_CaptureCreate((LPDIRECTSOUNDCAPTURE*)ppobj,pOuter); + if ( IsEqualGUID( &IID_IDirectSoundCapture8, riid ) ) - return DirectSoundCaptureCreate8(0,(LPDIRECTSOUNDCAPTURE8*)ppobj,pOuter); + return DSOUND_CaptureCreate8((LPDIRECTSOUNDCAPTURE8*)ppobj,pOuter); WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj); return E_NOINTERFACE; diff --git a/dlls/dsound/dsound.spec b/dlls/dsound/dsound.spec index c870a282ec6..e4878a81692 100644 --- a/dlls/dsound/dsound.spec +++ b/dlls/dsound/dsound.spec @@ -1,7 +1,7 @@ 1 stdcall DirectSoundCreate(ptr ptr ptr) 2 stdcall DirectSoundEnumerateA(ptr ptr) 3 stdcall DirectSoundEnumerateW(ptr ptr) -6 stdcall DirectSoundCaptureCreate(ptr ptr ptr) DirectSoundCaptureCreate8 +6 stdcall DirectSoundCaptureCreate(ptr ptr ptr) 7 stdcall DirectSoundCaptureEnumerateA(ptr ptr) 8 stdcall DirectSoundCaptureEnumerateW(ptr ptr) 9 stdcall GetDeviceID(ptr ptr) diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c index d67aa9bfd67..182d36661c5 100644 --- a/dlls/dsound/dsound_main.c +++ b/dlls/dsound/dsound_main.c @@ -665,6 +665,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) TRACE("DLL_PROCESS_ATTACH\n"); 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); } diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h index a107ce34b51..2a3c9261690 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h @@ -64,6 +64,7 @@ typedef struct PrimaryBufferImpl PrimaryBufferImpl; typedef struct SecondaryBufferImpl SecondaryBufferImpl; typedef struct IClassFactoryImpl IClassFactoryImpl; typedef struct DirectSoundDevice DirectSoundDevice; +typedef struct DirectSoundCaptureDevice DirectSoundCaptureDevice; /***************************************************************************** * IDirectSound implementation structure @@ -280,9 +281,14 @@ struct IDirectSoundCaptureImpl const IDirectSoundCaptureVtbl *lpVtbl; DWORD ref; + DirectSoundCaptureDevice *device; +}; + +struct DirectSoundCaptureDevice +{ /* IDirectSoundCaptureImpl fields */ GUID guid; - BOOL initialized; + DWORD ref; /* DirectSound driver stuff */ PIDSCDRIVER driver; @@ -308,6 +314,17 @@ struct IDirectSoundCaptureImpl CRITICAL_SECTION lock; }; +HRESULT WINAPI IDirectSoundCaptureImpl_Create( + LPDIRECTSOUNDCAPTURE8 * ppds); + +HRESULT WINAPI DSOUND_CaptureCreate( + LPDIRECTSOUNDCAPTURE *ppDSC, + IUnknown *pUnkOuter); + +HRESULT WINAPI DSOUND_CaptureCreate8( + LPDIRECTSOUNDCAPTURE8 *ppDSC8, + IUnknown *pUnkOuter); + /***************************************************************************** * IDirectSoundCaptureBuffer implementation structure */ @@ -498,6 +515,8 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb); extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS]; extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS]; + +extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS]; extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS]; extern HRESULT mmErr(UINT err); diff --git a/dlls/dsound/propset.c b/dlls/dsound/propset.c index 774a1ea37d0..83f3be16294 100644 --- a/dlls/dsound/propset.c +++ b/dlls/dsound/propset.c @@ -688,7 +688,7 @@ static HRESULT WINAPI DSPROPERTY_DescriptionA( if (err == DS_OK && drv) ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD; else - WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n"); + WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n"); break; } else { WARN("no memory\n"); @@ -784,7 +784,7 @@ static HRESULT WINAPI DSPROPERTY_DescriptionA( if (err == DS_OK && drv) ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD; else - WARN("waveOutMessage(DRV_QUERYDSOUNDIFACE) failed\n"); + WARN("waveInMessage(DRV_QUERYDSOUNDIFACE) failed\n"); found = TRUE; break; } else { @@ -1508,7 +1508,7 @@ HRESULT WINAPI IKsPrivatePropertySetImpl_Create( IKsPrivatePropertySetImpl *iks; iks = HeapAlloc(GetProcessHeap(),0,sizeof(*iks)); - iks->ref = 0; + iks->ref = 1; iks->lpVtbl = &ikspvt; *piks = iks; diff --git a/include/dsound.h b/include/dsound.h index 9087f77edd9..ca643e3c235 100644 --- a/include/dsound.h +++ b/include/dsound.h @@ -401,7 +401,7 @@ extern HRESULT WINAPI DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA, LPVOID); 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 DirectSoundCaptureCreate8(LPCGUID lpGUID, LPDIRECTSOUNDCAPTURE8 *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); -- 2.11.4.GIT