Properly implement DllCanUnloadNow ref counting.
This commit is contained in:
parent
475a81a818
commit
e8cafa5799
|
@ -41,6 +41,8 @@ ULONG WINAPI IDirectMusicBufferImpl_AddRef (LPDIRECTMUSICBUFFER iface) {
|
||||||
|
|
||||||
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
||||||
|
|
||||||
|
DMUSIC_LockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +55,9 @@ ULONG WINAPI IDirectMusicBufferImpl_Release (LPDIRECTMUSICBUFFER iface) {
|
||||||
if (!refCount) {
|
if (!refCount) {
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,8 @@ ULONG WINAPI IReferenceClockImpl_AddRef (IReferenceClock *iface) {
|
||||||
|
|
||||||
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
||||||
|
|
||||||
|
DMUSIC_LockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +56,9 @@ ULONG WINAPI IReferenceClockImpl_Release (IReferenceClock *iface) {
|
||||||
if (!refCount) {
|
if (!refCount) {
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,8 @@ ULONG WINAPI IDirectMusicCollectionImpl_IUnknown_AddRef (LPUNKNOWN iface) {
|
||||||
|
|
||||||
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
||||||
|
|
||||||
|
DMUSIC_LockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +72,9 @@ ULONG WINAPI IDirectMusicCollectionImpl_IUnknown_Release (LPUNKNOWN iface) {
|
||||||
if (!refCount) {
|
if (!refCount) {
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,8 @@ ULONG WINAPI IDirectMusic8Impl_AddRef (LPDIRECTMUSIC8 iface) {
|
||||||
|
|
||||||
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
||||||
|
|
||||||
|
DMUSIC_LockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +58,9 @@ ULONG WINAPI IDirectMusic8Impl_Release (LPDIRECTMUSIC8 iface) {
|
||||||
if (!refCount) {
|
if (!refCount) {
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,41 +23,48 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
|
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
|
||||||
|
|
||||||
|
LONG DMUSIC_refCount = 0;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* IUnknown fields */
|
|
||||||
IClassFactoryVtbl *lpVtbl;
|
IClassFactoryVtbl *lpVtbl;
|
||||||
DWORD ref;
|
|
||||||
} IClassFactoryImpl;
|
} IClassFactoryImpl;
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* DirectMusic ClassFactory
|
* DirectMusic ClassFactory
|
||||||
*/
|
*/
|
||||||
static HRESULT WINAPI DirectMusicCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
|
static HRESULT WINAPI DirectMusicCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
|
||||||
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
|
||||||
FIXME("(%p, %s, %p): stub\n",This,debugstr_dmguid(riid),ppobj);
|
|
||||||
|
if (ppobj == NULL) return E_POINTER;
|
||||||
|
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI DirectMusicCF_AddRef(LPCLASSFACTORY iface) {
|
static ULONG WINAPI DirectMusicCF_AddRef(LPCLASSFACTORY iface) {
|
||||||
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
DMUSIC_LockModule();
|
||||||
return InterlockedIncrement(&This->ref);
|
|
||||||
|
return 2; /* non-heap based object */
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI DirectMusicCF_Release(LPCLASSFACTORY iface) {
|
static ULONG WINAPI DirectMusicCF_Release(LPCLASSFACTORY iface) {
|
||||||
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
DMUSIC_UnlockModule();
|
||||||
/* static class, won't be freed */
|
|
||||||
return InterlockedDecrement(&This->ref);
|
return 1; /* non-heap based object */
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI DirectMusicCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
|
static HRESULT WINAPI DirectMusicCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
|
||||||
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
|
||||||
TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
|
|
||||||
return DMUSIC_CreateDirectMusicImpl (riid, (LPVOID*) ppobj, pOuter);
|
return DMUSIC_CreateDirectMusicImpl (riid, (LPVOID*) ppobj, pOuter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI DirectMusicCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
|
static HRESULT WINAPI DirectMusicCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
|
||||||
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
TRACE("(%d)\n", dolock);
|
||||||
FIXME("(%p, %d): stub\n", This, dolock);
|
|
||||||
|
if (dolock)
|
||||||
|
DMUSIC_LockModule();
|
||||||
|
else
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,37 +76,44 @@ static IClassFactoryVtbl DirectMusicCF_Vtbl = {
|
||||||
DirectMusicCF_LockServer
|
DirectMusicCF_LockServer
|
||||||
};
|
};
|
||||||
|
|
||||||
static IClassFactoryImpl DirectMusic_CF = {&DirectMusicCF_Vtbl, 1 };
|
static IClassFactoryImpl DirectMusic_CF = {&DirectMusicCF_Vtbl};
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* DirectMusicCollection ClassFactory
|
* DirectMusicCollection ClassFactory
|
||||||
*/
|
*/
|
||||||
static HRESULT WINAPI CollectionCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
|
static HRESULT WINAPI CollectionCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
|
||||||
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
|
||||||
FIXME("(%p, %s, %p): stub\n",This,debugstr_dmguid(riid),ppobj);
|
|
||||||
|
if (ppobj == NULL) return E_POINTER;
|
||||||
|
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI CollectionCF_AddRef(LPCLASSFACTORY iface) {
|
static ULONG WINAPI CollectionCF_AddRef(LPCLASSFACTORY iface) {
|
||||||
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
DMUSIC_LockModule();
|
||||||
return InterlockedIncrement(&This->ref);
|
|
||||||
|
return 2; /* non-heap based object */
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI CollectionCF_Release(LPCLASSFACTORY iface) {
|
static ULONG WINAPI CollectionCF_Release(LPCLASSFACTORY iface) {
|
||||||
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
DMUSIC_UnlockModule();
|
||||||
/* static class, won't be freed */
|
|
||||||
return InterlockedDecrement(&This->ref);
|
return 1; /* non-heap based object */
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI CollectionCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
|
static HRESULT WINAPI CollectionCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
|
||||||
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
|
||||||
TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
|
|
||||||
return DMUSIC_CreateDirectMusicCollectionImpl (riid, ppobj, pOuter);
|
return DMUSIC_CreateDirectMusicCollectionImpl (riid, ppobj, pOuter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI CollectionCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
|
static HRESULT WINAPI CollectionCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
|
||||||
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
TRACE("(%d)\n", dolock);
|
||||||
FIXME("(%p, %d): stub\n", This, dolock);
|
|
||||||
|
if (dolock)
|
||||||
|
DMUSIC_LockModule();
|
||||||
|
else
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +125,7 @@ static IClassFactoryVtbl CollectionCF_Vtbl = {
|
||||||
CollectionCF_LockServer
|
CollectionCF_LockServer
|
||||||
};
|
};
|
||||||
|
|
||||||
static IClassFactoryImpl Collection_CF = {&CollectionCF_Vtbl, 1 };
|
static IClassFactoryImpl Collection_CF = {&CollectionCF_Vtbl};
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* DllMain
|
* DllMain
|
||||||
|
@ -136,8 +150,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI DMUSIC_DllCanUnloadNow(void) {
|
HRESULT WINAPI DMUSIC_DllCanUnloadNow(void) {
|
||||||
FIXME("(void): stub\n");
|
return DMUSIC_refCount != 0 ? S_FALSE : S_OK;
|
||||||
return S_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -402,6 +402,12 @@ extern HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_SetPatch
|
||||||
/* custom :) */
|
/* custom :) */
|
||||||
extern HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm);
|
extern HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm);
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Dll lifetime tracking declaration for dmusic.dll
|
||||||
|
*/
|
||||||
|
extern LONG DMUSIC_refCount;
|
||||||
|
static inline void DMUSIC_LockModule() { InterlockedIncrement( &DMUSIC_refCount ); }
|
||||||
|
static inline void DMUSIC_UnlockModule() { InterlockedDecrement( &DMUSIC_refCount ); }
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Helper Functions
|
* Helper Functions
|
||||||
|
|
|
@ -42,6 +42,8 @@ ULONG WINAPI IDirectMusicDownloadImpl_AddRef (LPDIRECTMUSICDOWNLOAD iface) {
|
||||||
|
|
||||||
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
||||||
|
|
||||||
|
DMUSIC_LockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +56,9 @@ ULONG WINAPI IDirectMusicDownloadImpl_Release (LPDIRECTMUSICDOWNLOAD iface) {
|
||||||
if (!refCount) {
|
if (!refCount) {
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,8 @@ ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_AddRef (LPDIRECTMUSICDOWNLOADE
|
||||||
|
|
||||||
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
||||||
|
|
||||||
|
DMUSIC_LockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +56,9 @@ ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_Release (LPDIRECTMUSICDOWNLOAD
|
||||||
if (!refCount) {
|
if (!refCount) {
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,8 @@ ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_AddRef (LPUNKNOWN iface) {
|
||||||
|
|
||||||
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
||||||
|
|
||||||
|
DMUSIC_LockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +72,9 @@ ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_Release (LPUNKNOWN iface) {
|
||||||
if (!refCount) {
|
if (!refCount) {
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ ULONG WINAPI IDirectMusicPortImpl_AddRef (LPDIRECTMUSICPORT iface) {
|
||||||
|
|
||||||
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
||||||
|
|
||||||
|
DMUSIC_LockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +55,9 @@ ULONG WINAPI IDirectMusicPortImpl_Release (LPDIRECTMUSICPORT iface) {
|
||||||
if (!refCount) {
|
if (!refCount) {
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ ULONG WINAPI IDirectMusicPortDownloadImpl_AddRef (LPDIRECTMUSICPORTDOWNLOAD ifac
|
||||||
|
|
||||||
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
||||||
|
|
||||||
|
DMUSIC_LockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +55,9 @@ ULONG WINAPI IDirectMusicPortDownloadImpl_Release (LPDIRECTMUSICPORTDOWNLOAD ifa
|
||||||
if (!refCount) {
|
if (!refCount) {
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,8 @@ ULONG WINAPI IDirectMusicThruImpl_AddRef (LPDIRECTMUSICTHRU iface) {
|
||||||
|
|
||||||
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
||||||
|
|
||||||
|
DMUSIC_LockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +56,9 @@ ULONG WINAPI IDirectMusicThruImpl_Release (LPDIRECTMUSICTHRU iface) {
|
||||||
if (!refCount) {
|
if (!refCount) {
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DMUSIC_UnlockModule();
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue