dsound: Add an object refcount for DirectSoundFullDuplex.
This commit is contained in:
parent
023a19d931
commit
6692f97e01
|
@ -43,8 +43,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound);
|
||||||
typedef struct IDirectSoundFullDuplexImpl
|
typedef struct IDirectSoundFullDuplexImpl
|
||||||
{
|
{
|
||||||
IDirectSoundFullDuplex IDirectSoundFullDuplex_iface;
|
IDirectSoundFullDuplex IDirectSoundFullDuplex_iface;
|
||||||
LONG ref;
|
LONG ref, numIfaces;
|
||||||
|
|
||||||
/* IDirectSoundFullDuplexImpl fields */
|
/* IDirectSoundFullDuplexImpl fields */
|
||||||
IDirectSound8 *renderer_device;
|
IDirectSound8 *renderer_device;
|
||||||
IDirectSoundCapture *capture_device;
|
IDirectSoundCapture *capture_device;
|
||||||
|
@ -72,6 +71,16 @@ typedef struct IDirectSoundFullDuplex_IDirectSoundCapture {
|
||||||
IDirectSoundFullDuplexImpl *pdsfd;
|
IDirectSoundFullDuplexImpl *pdsfd;
|
||||||
} IDirectSoundFullDuplex_IDirectSoundCapture;
|
} IDirectSoundFullDuplex_IDirectSoundCapture;
|
||||||
|
|
||||||
|
static void fullduplex_destroy(IDirectSoundFullDuplexImpl *This)
|
||||||
|
{
|
||||||
|
if (This->capture_device)
|
||||||
|
IDirectSoundCapture_Release(This->capture_device);
|
||||||
|
if (This->renderer_device)
|
||||||
|
IDirectSound_Release(This->renderer_device);
|
||||||
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
|
TRACE("(%p) released\n", This);
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* IUnknown
|
* IUnknown
|
||||||
*/
|
*/
|
||||||
|
@ -449,7 +458,11 @@ static ULONG WINAPI IDirectSoundFullDuplexImpl_AddRef(IDirectSoundFullDuplex *if
|
||||||
{
|
{
|
||||||
IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface);
|
IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface);
|
||||||
ULONG ref = InterlockedIncrement(&(This->ref));
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
||||||
TRACE("(%p) ref was %d\n", This, ref - 1);
|
|
||||||
|
TRACE("(%p) ref=%d\n", This, ref);
|
||||||
|
|
||||||
|
if(ref == 1)
|
||||||
|
InterlockedIncrement(&This->numIfaces);
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,16 +529,11 @@ static ULONG WINAPI IDirectSoundFullDuplexImpl_Release(IDirectSoundFullDuplex *i
|
||||||
{
|
{
|
||||||
IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface);
|
IDirectSoundFullDuplexImpl *This = impl_from_IDirectSoundFullDuplex(iface);
|
||||||
ULONG ref = InterlockedDecrement(&(This->ref));
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
||||||
TRACE("(%p) ref was %d\n", This, ref - 1);
|
|
||||||
|
|
||||||
if (!ref) {
|
TRACE("(%p) ref=%d\n", This, ref);
|
||||||
if (This->capture_device)
|
|
||||||
IDirectSoundCapture_Release(This->capture_device);
|
if (!ref && !InterlockedDecrement(&This->numIfaces))
|
||||||
if (This->renderer_device)
|
fullduplex_destroy(This);
|
||||||
IDirectSound_Release(This->renderer_device);
|
|
||||||
HeapFree( GetProcessHeap(), 0, This );
|
|
||||||
TRACE("(%p) released\n", This);
|
|
||||||
}
|
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,6 +642,7 @@ HRESULT DSOUND_FullDuplexCreate(REFIID riid, void **ppv)
|
||||||
|
|
||||||
obj->IDirectSoundFullDuplex_iface.lpVtbl = &dsfd_vtbl;
|
obj->IDirectSoundFullDuplex_iface.lpVtbl = &dsfd_vtbl;
|
||||||
obj->ref = 1;
|
obj->ref = 1;
|
||||||
|
obj->numIfaces = 1;
|
||||||
|
|
||||||
hr = IUnknown_QueryInterface((IUnknown*)obj, riid, ppv);
|
hr = IUnknown_QueryInterface((IUnknown*)obj, riid, ppv);
|
||||||
IUnknown_Release((IUnknown*)obj);
|
IUnknown_Release((IUnknown*)obj);
|
||||||
|
|
Loading…
Reference in New Issue