Commit b970aeb4 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

Cleanup reference counting.

parent 6df12bb3
......@@ -70,12 +70,10 @@ static HRESULT WINAPI IDirectSoundNotifyImpl_QueryInterface(
static ULONG WINAPI IDirectSoundNotifyImpl_AddRef(LPDIRECTSOUNDNOTIFY iface) {
IDirectSoundNotifyImpl *This = (IDirectSoundNotifyImpl *)iface;
DWORD ref;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
ref = InterlockedIncrement(&(This->ref));
return ref;
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI IDirectSoundNotifyImpl_Release(LPDIRECTSOUNDNOTIFY iface) {
......
......@@ -373,19 +373,9 @@ IDirectSoundCaptureImpl_QueryInterface(
static ULONG WINAPI
IDirectSoundCaptureImpl_AddRef( LPDIRECTSOUNDCAPTURE iface )
{
ULONG uRef;
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
EnterCriticalSection( &(This->lock) );
uRef = ++(This->ref);
if (This->driver)
IDsCaptureDriver_AddRef(This->driver);
LeaveCriticalSection( &(This->lock) );
return uRef;
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI
......@@ -395,12 +385,7 @@ IDirectSoundCaptureImpl_Release( LPDIRECTSOUNDCAPTURE iface )
IDirectSoundCaptureImpl *This = (IDirectSoundCaptureImpl *)iface;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
EnterCriticalSection( &(This->lock) );
uRef = --(This->ref);
LeaveCriticalSection( &(This->lock) );
uRef = InterlockedDecrement(&(This->ref));
if ( uRef == 0 ) {
TRACE("deleting object\n");
if (This->capture_buffer)
......@@ -788,12 +773,8 @@ static HRESULT WINAPI IDirectSoundCaptureNotifyImpl_QueryInterface(
static ULONG WINAPI IDirectSoundCaptureNotifyImpl_AddRef(LPDIRECTSOUNDNOTIFY iface)
{
IDirectSoundCaptureNotifyImpl *This = (IDirectSoundCaptureNotifyImpl *)iface;
DWORD ref;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
ref = InterlockedIncrement(&(This->ref));
return ref;
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI IDirectSoundCaptureNotifyImpl_Release(LPDIRECTSOUNDNOTIFY iface)
......@@ -958,19 +939,9 @@ IDirectSoundCaptureBufferImpl_QueryInterface(
static ULONG WINAPI
IDirectSoundCaptureBufferImpl_AddRef( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
{
ULONG uRef;
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
assert(This->dsound);
EnterCriticalSection( &(This->dsound->lock) );
uRef = ++(This->ref);
LeaveCriticalSection( &(This->dsound->lock) );
return uRef;
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI
......@@ -980,14 +951,7 @@ IDirectSoundCaptureBufferImpl_Release( LPDIRECTSOUNDCAPTUREBUFFER8 iface )
IDirectSoundCaptureBufferImpl *This = (IDirectSoundCaptureBufferImpl *)iface;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
assert(This->dsound);
EnterCriticalSection( &(This->dsound->lock) );
uRef = --(This->ref);
LeaveCriticalSection( &(This->dsound->lock) );
uRef = InterlockedDecrement(&(This->ref));
if ( uRef == 0 ) {
TRACE("deleting object\n");
if (This->dsound->state == STATE_CAPTURING)
......@@ -1613,7 +1577,7 @@ DSCCF_AddRef(LPCLASSFACTORY iface)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
TRACE("(%p) ref was %ld\n", This, This->ref);
return ++(This->ref);
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI
......@@ -1622,7 +1586,7 @@ DSCCF_Release(LPCLASSFACTORY iface)
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
/* static class, won't be freed */
TRACE("(%p) ref was %ld\n", This, This->ref);
return --(This->ref);
return InterlockedDecrement(&(This->ref));
}
static HRESULT WINAPI
......@@ -1761,17 +1725,9 @@ IDirectSoundFullDuplexImpl_QueryInterface(
static ULONG WINAPI
IDirectSoundFullDuplexImpl_AddRef( LPDIRECTSOUNDFULLDUPLEX iface )
{
ULONG uRef;
IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
EnterCriticalSection( &(This->lock) );
uRef = ++(This->ref);
LeaveCriticalSection( &(This->lock) );
return uRef;
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI
......@@ -1781,12 +1737,7 @@ IDirectSoundFullDuplexImpl_Release( LPDIRECTSOUNDFULLDUPLEX iface )
IDirectSoundFullDuplexImpl *This = (IDirectSoundFullDuplexImpl *)iface;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
EnterCriticalSection( &(This->lock) );
uRef = --(This->ref);
LeaveCriticalSection( &(This->lock) );
uRef = InterlockedDecrement(&(This->ref));
if ( uRef == 0 ) {
This->lock.DebugInfo->Spare[1] = 0;
DeleteCriticalSection( &(This->lock) );
......@@ -1849,7 +1800,7 @@ DSFDCF_AddRef(LPCLASSFACTORY iface)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
TRACE("(%p) ref was %ld\n", This, This->ref);
return ++(This->ref);
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI
......@@ -1858,7 +1809,7 @@ DSFDCF_Release(LPCLASSFACTORY iface)
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
/* static class, won't be freed */
TRACE("(%p) ref was %ld\n", This, This->ref);
return --(This->ref);
return InterlockedDecrement(&(This->ref));
}
static HRESULT WINAPI
......
......@@ -249,7 +249,7 @@ static ULONG WINAPI IDirectSoundImpl_AddRef(
IDirectSoundImpl *This = (IDirectSoundImpl *)iface;
TRACE("(%p) ref was %ld, thread is %04lx\n", This, This->ref, GetCurrentThreadId());
return InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI IDirectSoundImpl_Release(
......@@ -260,7 +260,7 @@ static ULONG WINAPI IDirectSoundImpl_Release(
TRACE("(%p) ref was %ld, thread is %04lx\n",
This, This->ref, GetCurrentThreadId());
ref = InterlockedDecrement(&This->ref);
ref = InterlockedDecrement(&(This->ref));
if (ref == 0) {
HRESULT hres;
INT i;
......@@ -985,7 +985,7 @@ static ULONG WINAPI IDirectSound_IUnknown_AddRef(
{
IDirectSound_IUnknown *This = (IDirectSound_IUnknown *)iface;
TRACE("(%p) ref was %ld, thread is %04lx\n", This, This->ref, GetCurrentThreadId());
return InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI IDirectSound_IUnknown_Release(
......@@ -994,7 +994,7 @@ static ULONG WINAPI IDirectSound_IUnknown_Release(
IDirectSound_IUnknown *This = (IDirectSound_IUnknown *)iface;
ULONG ulReturn;
TRACE("(%p) ref was %ld, thread is %04lx\n", This, This->ref, GetCurrentThreadId());
ulReturn = InterlockedDecrement(&This->ref);
ulReturn = InterlockedDecrement(&(This->ref));
if (ulReturn == 0) {
IDirectSoundImpl_Release(This->pds);
HeapFree(GetProcessHeap(),0,This);
......@@ -1063,7 +1063,7 @@ static ULONG WINAPI IDirectSound_IDirectSound_AddRef(
{
IDirectSound_IDirectSound *This = (IDirectSound_IDirectSound *)iface;
TRACE("(%p) ref was %ld, thread is %04lx\n", This, This->ref, GetCurrentThreadId());
return InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI IDirectSound_IDirectSound_Release(
......@@ -1224,7 +1224,7 @@ static ULONG WINAPI IDirectSound8_IUnknown_AddRef(
{
IDirectSound_IUnknown *This = (IDirectSound_IUnknown *)iface;
TRACE("(%p) ref was %ld, thread is %04lx\n", This, This->ref, GetCurrentThreadId());
return InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI IDirectSound8_IUnknown_Release(
......@@ -1233,7 +1233,7 @@ static ULONG WINAPI IDirectSound8_IUnknown_Release(
IDirectSound_IUnknown *This = (IDirectSound_IUnknown *)iface;
ULONG ulReturn;
TRACE("(%p) ref was %ld, thread is %04lx\n", This, This->ref, GetCurrentThreadId());
ulReturn = InterlockedDecrement(&This->ref);
ulReturn = InterlockedDecrement(&(This->ref));
if (ulReturn == 0) {
IDirectSoundImpl_Release(This->pds);
HeapFree(GetProcessHeap(),0,This);
......@@ -1302,7 +1302,7 @@ static ULONG WINAPI IDirectSound8_IDirectSound_AddRef(
{
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
TRACE("(%p) ref was %ld, thread is %04lx\n", This, This->ref, GetCurrentThreadId());
return InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI IDirectSound8_IDirectSound_Release(
......@@ -1311,7 +1311,7 @@ static ULONG WINAPI IDirectSound8_IDirectSound_Release(
IDirectSound8_IDirectSound *This = (IDirectSound8_IDirectSound *)iface;
ULONG ulReturn;
TRACE("(%p) ref was %ld, thread is %04lx\n", This, This->ref, GetCurrentThreadId());
ulReturn = InterlockedDecrement(&This->ref);
ulReturn = InterlockedDecrement(&(This->ref));
if (ulReturn == 0) {
IDirectSoundImpl_Release(This->pds);
HeapFree(GetProcessHeap(),0,This);
......@@ -1463,7 +1463,7 @@ static ULONG WINAPI IDirectSound8_IDirectSound8_AddRef(
{
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
TRACE("(%p) ref was %ld, thread is %04lx\n", This, This->ref, GetCurrentThreadId());
return InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI IDirectSound8_IDirectSound8_Release(
......@@ -1472,7 +1472,7 @@ static ULONG WINAPI IDirectSound8_IDirectSound8_Release(
IDirectSound8_IDirectSound8 *This = (IDirectSound8_IDirectSound8 *)iface;
ULONG ulReturn;
TRACE("(%p) ref was %ld, thread is %04lx\n", This, This->ref, GetCurrentThreadId());
ulReturn = InterlockedDecrement(&This->ref);
ulReturn = InterlockedDecrement(&(This->ref));
if (ulReturn == 0) {
IDirectSoundImpl_Release(This->pds);
HeapFree(GetProcessHeap(),0,This);
......
......@@ -448,14 +448,14 @@ static ULONG WINAPI
DSCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
TRACE("(%p) ref was %ld\n", This, This->ref);
return ++(This->ref);
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
/* static class, won't be freed */
TRACE("(%p) ref was %ld\n", This, This->ref);
return --(This->ref);
return InterlockedDecrement(&(This->ref));
}
static HRESULT WINAPI DSCF_CreateInstance(
......@@ -513,7 +513,7 @@ static ULONG WINAPI
DSPCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
TRACE("(%p) ref was %ld\n", This, This->ref);
return ++(This->ref);
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI
......@@ -521,7 +521,7 @@ DSPCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
/* static class, won't be freed */
TRACE("(%p) ref was %ld\n", This, This->ref);
return --(This->ref);
return InterlockedDecrement(&(This->ref));
}
static HRESULT WINAPI
......
......@@ -580,12 +580,8 @@ static HRESULT WINAPI PrimaryBufferImpl_Stop(LPDIRECTSOUNDBUFFER8 iface)
static DWORD WINAPI PrimaryBufferImpl_AddRef(LPDIRECTSOUNDBUFFER8 iface) {
PrimaryBufferImpl *This = (PrimaryBufferImpl *)iface;
DWORD ref;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
ref = InterlockedIncrement(&(This->ref));
return ref;
return InterlockedIncrement(&(This->ref));
}
static DWORD WINAPI PrimaryBufferImpl_Release(LPDIRECTSOUNDBUFFER8 iface) {
......
......@@ -74,11 +74,8 @@ static HRESULT WINAPI IKsBufferPropertySetImpl_QueryInterface(
static ULONG WINAPI IKsBufferPropertySetImpl_AddRef(LPKSPROPERTYSET iface)
{
IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
ULONG ulReturn;
TRACE("(%p) ref was %ld\n", This, This->ref);
ulReturn = InterlockedIncrement(&(This->ref));
return ulReturn;
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI IKsBufferPropertySetImpl_Release(LPKSPROPERTYSET iface)
......@@ -87,7 +84,7 @@ static ULONG WINAPI IKsBufferPropertySetImpl_Release(LPKSPROPERTYSET iface)
ULONG ulReturn;
TRACE("(%p) ref was %ld\n", This, This->ref);
ulReturn = InterlockedDecrement(&This->ref);
ulReturn = InterlockedDecrement(&(This->ref));
if (!ulReturn) {
This->dsb->iks = 0;
IDirectSoundBuffer_Release((LPDIRECTSOUND3DBUFFER)This->dsb);
......@@ -249,11 +246,9 @@ static HRESULT WINAPI IKsPrivatePropertySetImpl_QueryInterface(
static ULONG WINAPI IKsPrivatePropertySetImpl_AddRef(LPKSPROPERTYSET iface)
{
IKsPrivatePropertySetImpl *This = (IKsPrivatePropertySetImpl *)iface;
ULONG ulReturn;
TRACE("(%p) ref was %ld\n", This, This->ref);
ulReturn = InterlockedIncrement(&This->ref);
return ulReturn;
return InterlockedIncrement(&(This->ref));
}
static ULONG WINAPI IKsPrivatePropertySetImpl_Release(LPKSPROPERTYSET iface)
......@@ -262,7 +257,11 @@ static ULONG WINAPI IKsPrivatePropertySetImpl_Release(LPKSPROPERTYSET iface)
ULONG ulReturn;
TRACE("(%p) ref was %ld\n", This, This->ref);
ulReturn = InterlockedDecrement(&This->ref);
ulReturn = InterlockedDecrement(&(This->ref));
if (ulReturn == 0) {
HeapFree(GetProcessHeap(),0,This);
TRACE("(%p) released\n",This);
}
return ulReturn;
}
......
......@@ -382,7 +382,7 @@ static ULONG WINAPI IDirectSound3DBufferImpl_AddRef(LPDIRECTSOUND3DBUFFER iface)
ULONG ref;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
ref = InterlockedIncrement(&This->ref);
ref = InterlockedIncrement(&(This->ref));
if (!ref) {
FIXME("thread-safety alert! AddRef-ing with a zero refcount!\n");
}
......@@ -395,7 +395,7 @@ static ULONG WINAPI IDirectSound3DBufferImpl_Release(LPDIRECTSOUND3DBUFFER iface
ULONG ulReturn;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
ulReturn = InterlockedDecrement(&This->ref);
ulReturn = InterlockedDecrement(&(This->ref));
if (!ulReturn) {
This->dsb->ds3db = NULL;
IDirectSoundBuffer_Release((LPDIRECTSOUNDBUFFER8)This->dsb);
......@@ -825,7 +825,7 @@ static ULONG WINAPI IDirectSound3DListenerImpl_AddRef(LPDIRECTSOUND3DLISTENER if
ULONG ref;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
ref = InterlockedIncrement(&This->ref);
ref = InterlockedIncrement(&(This->ref));
if (!ref) {
FIXME("thread-safety alert! AddRef-ing with a zero refcount!\n");
......@@ -840,7 +840,7 @@ static ULONG WINAPI IDirectSound3DListenerImpl_Release(LPDIRECTSOUND3DLISTENER i
ULONG ulReturn;
TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
ulReturn = InterlockedDecrement(&This->ref);
ulReturn = InterlockedDecrement(&(This->ref));
/* Free all resources */
if( ulReturn == 0 ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment