Properly implement DllCanUnloadNow ref counting.

This commit is contained in:
James Hawkins 2005-01-24 19:33:23 +00:00 committed by Alexandre Julliard
parent eae60bedd5
commit 1fd9425088
9 changed files with 206 additions and 101 deletions

View File

@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicAuditionTrack_IUnknown_AddRef (LPUNKNOWN iface) {
TRACE("(%p): AddRef from %ld\n", This, ref - 1); TRACE("(%p): AddRef from %ld\n", This, ref - 1);
DMSTYLE_LockModule();
return ref; return ref;
} }
@ -67,6 +69,9 @@ ULONG WINAPI IDirectMusicAuditionTrack_IUnknown_Release (LPUNKNOWN iface) {
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
DMSTYLE_UnlockModule();
return ref; return ref;
} }

View File

@ -56,6 +56,8 @@ ULONG WINAPI IDirectMusicChordTrack_IUnknown_AddRef (LPUNKNOWN iface) {
TRACE("(%p): AddRef from %ld\n", This, ref - 1); TRACE("(%p): AddRef from %ld\n", This, ref - 1);
DMSTYLE_LockModule();
return ref; return ref;
} }
@ -68,6 +70,9 @@ ULONG WINAPI IDirectMusicChordTrack_IUnknown_Release (LPUNKNOWN iface) {
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
DMSTYLE_UnlockModule();
return ref; return ref;
} }

View File

@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicCommandTrack_IUnknown_AddRef (LPUNKNOWN iface) {
TRACE("(%p): AddRef from %ld\n", This, ref - 1); TRACE("(%p): AddRef from %ld\n", This, ref - 1);
DMSTYLE_LockModule();
return ref; return ref;
} }
@ -67,6 +69,9 @@ ULONG WINAPI IDirectMusicCommandTrack_IUnknown_Release (LPUNKNOWN iface) {
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
DMSTYLE_UnlockModule();
return ref; return ref;
} }

View File

@ -21,43 +21,52 @@
WINE_DEFAULT_DEBUG_CHANNEL(dmstyle); WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
LONG DMSTYLE_refCount = 0;
typedef struct { typedef struct {
/* IUnknown fields */
IClassFactoryVtbl *lpVtbl; IClassFactoryVtbl *lpVtbl;
DWORD ref;
} IClassFactoryImpl; } IClassFactoryImpl;
/****************************************************************** /******************************************************************
* DirectMusicSection ClassFactory * DirectMusicSection ClassFactory
*/ */
static HRESULT WINAPI SectionCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { static HRESULT WINAPI SectionCF_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 SectionCF_AddRef(LPCLASSFACTORY iface) { static ULONG WINAPI SectionCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_LockModule();
return InterlockedIncrement(&This->ref);
return 2; /* non-heap based object */
} }
static ULONG WINAPI SectionCF_Release(LPCLASSFACTORY iface) { static ULONG WINAPI SectionCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_UnlockModule();
/* static class, won't be freed */
return InterlockedDecrement(&This->ref); return 1; /* non-heap based object */
} }
static HRESULT WINAPI SectionCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI SectionCF_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);
/* nothing here yet */ /* nothing here yet */
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj); WARN("(%s, %p): not found\n", debugstr_dmguid(riid), ppobj);
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static HRESULT WINAPI SectionCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { static HRESULT WINAPI SectionCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; TRACE("(%d)\n", dolock);
FIXME("(%p, %d): stub\n", This, dolock);
if (dolock)
DMSTYLE_LockModule();
else
DMSTYLE_UnlockModule();
return S_OK; return S_OK;
} }
@ -69,37 +78,45 @@ static IClassFactoryVtbl SectionCF_Vtbl = {
SectionCF_LockServer SectionCF_LockServer
}; };
static IClassFactoryImpl Section_CF = {&SectionCF_Vtbl, 1 }; static IClassFactoryImpl Section_CF = {&SectionCF_Vtbl};
/****************************************************************** /******************************************************************
* DirectMusicStyle ClassFactory * DirectMusicStyle ClassFactory
*/ */
static HRESULT WINAPI StyleCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { static HRESULT WINAPI StyleCF_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 StyleCF_AddRef(LPCLASSFACTORY iface) { static ULONG WINAPI StyleCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_LockModule();
return InterlockedIncrement(&This->ref);
return 2; /* non-heap based object */
} }
static ULONG WINAPI StyleCF_Release(LPCLASSFACTORY iface) { static ULONG WINAPI StyleCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_UnlockModule();
/* static class, won't be freed */
return InterlockedDecrement(&This->ref); return 1; /* non-heap based object */
} }
static HRESULT WINAPI StyleCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI StyleCF_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_CreateDirectMusicStyleImpl (riid, ppobj, pOuter); return DMUSIC_CreateDirectMusicStyleImpl (riid, ppobj, pOuter);
} }
static HRESULT WINAPI StyleCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { static HRESULT WINAPI StyleCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; TRACE("(%d)\n", dolock);
FIXME("(%p, %d): stub\n", This, dolock);
if (dolock)
DMSTYLE_LockModule();
else
DMSTYLE_UnlockModule();
return S_OK; return S_OK;
} }
@ -111,37 +128,45 @@ static IClassFactoryVtbl StyleCF_Vtbl = {
StyleCF_LockServer StyleCF_LockServer
}; };
static IClassFactoryImpl Style_CF = {&StyleCF_Vtbl, 1 }; static IClassFactoryImpl Style_CF = {&StyleCF_Vtbl};
/****************************************************************** /******************************************************************
* DirectMusicChordTrack ClassFactory * DirectMusicChordTrack ClassFactory
*/ */
static HRESULT WINAPI ChordTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { static HRESULT WINAPI ChordTrackCF_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 ChordTrackCF_AddRef(LPCLASSFACTORY iface) { static ULONG WINAPI ChordTrackCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_LockModule();
return InterlockedIncrement(&This->ref);
return 2; /* non-heap based object */
} }
static ULONG WINAPI ChordTrackCF_Release(LPCLASSFACTORY iface) { static ULONG WINAPI ChordTrackCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_UnlockModule();
/* static class, won't be freed */
return InterlockedDecrement(&This->ref); return 1; /* non-heap based object */
} }
static HRESULT WINAPI ChordTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI ChordTrackCF_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_CreateDirectMusicChordTrack (riid, ppobj, pOuter); return DMUSIC_CreateDirectMusicChordTrack (riid, ppobj, pOuter);
} }
static HRESULT WINAPI ChordTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { static HRESULT WINAPI ChordTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; TRACE("(%d)\n", dolock);
FIXME("(%p, %d): stub\n", This, dolock);
if (dolock)
DMSTYLE_LockModule();
else
DMSTYLE_UnlockModule();
return S_OK; return S_OK;
} }
@ -153,37 +178,45 @@ static IClassFactoryVtbl ChordTrackCF_Vtbl = {
ChordTrackCF_LockServer ChordTrackCF_LockServer
}; };
static IClassFactoryImpl ChordTrack_CF = {&ChordTrackCF_Vtbl, 1 }; static IClassFactoryImpl ChordTrack_CF = {&ChordTrackCF_Vtbl};
/****************************************************************** /******************************************************************
* DirectMusicCommandTrack ClassFactory * DirectMusicCommandTrack ClassFactory
*/ */
static HRESULT WINAPI CommandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { static HRESULT WINAPI CommandTrackCF_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 CommandTrackCF_AddRef(LPCLASSFACTORY iface) { static ULONG WINAPI CommandTrackCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_LockModule();
return InterlockedIncrement(&This->ref);
return 2; /* non-heap based object */
} }
static ULONG WINAPI CommandTrackCF_Release(LPCLASSFACTORY iface) { static ULONG WINAPI CommandTrackCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_UnlockModule();
/* static class, won't be freed */
return InterlockedDecrement(&This->ref); return 1; /* non-heap based object */
} }
static HRESULT WINAPI CommandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI CommandTrackCF_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_CreateDirectMusicCommandTrack (riid, ppobj, pOuter); return DMUSIC_CreateDirectMusicCommandTrack (riid, ppobj, pOuter);
} }
static HRESULT WINAPI CommandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { static HRESULT WINAPI CommandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; TRACE("(%d)\n", dolock);
FIXME("(%p, %d): stub\n", This, dolock);
if (dolock)
DMSTYLE_LockModule();
else
DMSTYLE_UnlockModule();
return S_OK; return S_OK;
} }
@ -195,37 +228,45 @@ static IClassFactoryVtbl CommandTrackCF_Vtbl = {
CommandTrackCF_LockServer CommandTrackCF_LockServer
}; };
static IClassFactoryImpl CommandTrack_CF = {&CommandTrackCF_Vtbl, 1 }; static IClassFactoryImpl CommandTrack_CF = {&CommandTrackCF_Vtbl};
/****************************************************************** /******************************************************************
* DirectMusicStyleTrack ClassFactory * DirectMusicStyleTrack ClassFactory
*/ */
static HRESULT WINAPI StyleTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { static HRESULT WINAPI StyleTrackCF_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 StyleTrackCF_AddRef(LPCLASSFACTORY iface) { static ULONG WINAPI StyleTrackCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_LockModule();
return InterlockedIncrement(&This->ref);
return 2; /* non-heap based object */
} }
static ULONG WINAPI StyleTrackCF_Release(LPCLASSFACTORY iface) { static ULONG WINAPI StyleTrackCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_UnlockModule();
/* static class, won't be freed */
return InterlockedDecrement(&This->ref); return 1; /* non-heap based object */
} }
static HRESULT WINAPI StyleTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI StyleTrackCF_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_CreateDirectMusicStyleTrack (riid, ppobj, pOuter); return DMUSIC_CreateDirectMusicStyleTrack (riid, ppobj, pOuter);
} }
static HRESULT WINAPI StyleTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { static HRESULT WINAPI StyleTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; TRACE("(%d)\n", dolock);
FIXME("(%p, %d): stub\n", This, dolock);
if (dolock)
DMSTYLE_LockModule();
else
DMSTYLE_UnlockModule();
return S_OK; return S_OK;
} }
@ -237,37 +278,45 @@ static IClassFactoryVtbl StyleTrackCF_Vtbl = {
StyleTrackCF_LockServer StyleTrackCF_LockServer
}; };
static IClassFactoryImpl StyleTrack_CF = {&StyleTrackCF_Vtbl, 1 }; static IClassFactoryImpl StyleTrack_CF = {&StyleTrackCF_Vtbl};
/****************************************************************** /******************************************************************
* DirectMusicMotifTrack ClassFactory * DirectMusicMotifTrack ClassFactory
*/ */
static HRESULT WINAPI MotifTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { static HRESULT WINAPI MotifTrackCF_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 MotifTrackCF_AddRef(LPCLASSFACTORY iface) { static ULONG WINAPI MotifTrackCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_LockModule();
return InterlockedIncrement(&This->ref);
return 2; /* non-heap based object */
} }
static ULONG WINAPI MotifTrackCF_Release(LPCLASSFACTORY iface) { static ULONG WINAPI MotifTrackCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_UnlockModule();
/* static class, won't be freed */
return InterlockedDecrement(&This->ref); return 1; /* non-heap based object */
} }
static HRESULT WINAPI MotifTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI MotifTrackCF_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_CreateDirectMusicMotifTrack (riid, ppobj, pOuter); return DMUSIC_CreateDirectMusicMotifTrack (riid, ppobj, pOuter);
} }
static HRESULT WINAPI MotifTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { static HRESULT WINAPI MotifTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; TRACE("(%d)\n", dolock);
FIXME("(%p, %d): stub\n", This, dolock);
if (dolock)
DMSTYLE_LockModule();
else
DMSTYLE_UnlockModule();
return S_OK; return S_OK;
} }
@ -279,37 +328,45 @@ static IClassFactoryVtbl MotifTrackCF_Vtbl = {
MotifTrackCF_LockServer MotifTrackCF_LockServer
}; };
static IClassFactoryImpl MotifTrack_CF = {&MotifTrackCF_Vtbl, 1 }; static IClassFactoryImpl MotifTrack_CF = {&MotifTrackCF_Vtbl};
/****************************************************************** /******************************************************************
* DirectMusicAuditionTrack ClassFactory * DirectMusicAuditionTrack ClassFactory
*/ */
static HRESULT WINAPI AuditionTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { static HRESULT WINAPI AuditionTrackCF_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 AuditionTrackCF_AddRef(LPCLASSFACTORY iface) { static ULONG WINAPI AuditionTrackCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_LockModule();
return InterlockedIncrement(&This->ref);
return 2; /* non-heap based object */
} }
static ULONG WINAPI AuditionTrackCF_Release(LPCLASSFACTORY iface) { static ULONG WINAPI AuditionTrackCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_UnlockModule();
/* static class, won't be freed */
return InterlockedDecrement(&This->ref); return 1; /* non-heap based object */
} }
static HRESULT WINAPI AuditionTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI AuditionTrackCF_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_CreateDirectMusicAuditionTrack (riid, ppobj, pOuter); return DMUSIC_CreateDirectMusicAuditionTrack (riid, ppobj, pOuter);
} }
static HRESULT WINAPI AuditionTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { static HRESULT WINAPI AuditionTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; TRACE("(%d)\n", dolock);
FIXME("(%p, %d): stub\n", This, dolock);
if (dolock)
DMSTYLE_LockModule();
else
DMSTYLE_UnlockModule();
return S_OK; return S_OK;
} }
@ -321,37 +378,45 @@ static IClassFactoryVtbl AuditionTrackCF_Vtbl = {
AuditionTrackCF_LockServer AuditionTrackCF_LockServer
}; };
static IClassFactoryImpl AuditionTrack_CF = {&AuditionTrackCF_Vtbl, 1 }; static IClassFactoryImpl AuditionTrack_CF = {&AuditionTrackCF_Vtbl};
/****************************************************************** /******************************************************************
* DirectMusicMuteTrack ClassFactory * DirectMusicMuteTrack ClassFactory
*/ */
static HRESULT WINAPI MuteTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { static HRESULT WINAPI MuteTrackCF_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 MuteTrackCF_AddRef(LPCLASSFACTORY iface) { static ULONG WINAPI MuteTrackCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_LockModule();
return InterlockedIncrement(&This->ref);
return 2; /* non-heap based object */
} }
static ULONG WINAPI MuteTrackCF_Release(LPCLASSFACTORY iface) { static ULONG WINAPI MuteTrackCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; DMSTYLE_UnlockModule();
/* static class, won't be freed */
return InterlockedDecrement(&This->ref); return 1; /* non-heap based object */
} }
static HRESULT WINAPI MuteTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI MuteTrackCF_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_CreateDirectMusicMuteTrack (riid, ppobj, pOuter); return DMUSIC_CreateDirectMusicMuteTrack (riid, ppobj, pOuter);
} }
static HRESULT WINAPI MuteTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { static HRESULT WINAPI MuteTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; TRACE("(%d)\n", dolock);
FIXME("(%p, %d): stub\n", This, dolock);
if (dolock)
DMSTYLE_LockModule();
else
DMSTYLE_UnlockModule();
return S_OK; return S_OK;
} }
@ -363,7 +428,7 @@ static IClassFactoryVtbl MuteTrackCF_Vtbl = {
MuteTrackCF_LockServer MuteTrackCF_LockServer
}; };
static IClassFactoryImpl MuteTrack_CF = {&MuteTrackCF_Vtbl, 1 }; static IClassFactoryImpl MuteTrack_CF = {&MuteTrackCF_Vtbl};
/****************************************************************** /******************************************************************
* DllMain * DllMain
@ -388,8 +453,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
* *
*/ */
HRESULT WINAPI DMSTYLE_DllCanUnloadNow(void) { HRESULT WINAPI DMSTYLE_DllCanUnloadNow(void) {
FIXME("(void): stub\n"); return DMSTYLE_refCount != 0 ? S_FALSE : S_OK;
return S_FALSE;
} }

View File

@ -539,6 +539,12 @@ extern HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_Load (LPPERSISTSTREA
extern HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty); extern HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty);
extern HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize); extern HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize);
/**********************************************************************
* Dll lifetime tracking declaration for dmstyle.dll
*/
extern LONG DMSTYLE_refCount;
static inline void DMSTYLE_LockModule() { InterlockedIncrement( &DMSTYLE_refCount ); }
static inline void DMSTYLE_UnlockModule() { InterlockedDecrement( &DMSTYLE_refCount ); }
/***************************************************************************** /*****************************************************************************
* Misc. * Misc.

View File

@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicMotifTrack_IUnknown_AddRef (LPUNKNOWN iface) {
TRACE("(%p): AddRef from %ld\n", This, ref - 1); TRACE("(%p): AddRef from %ld\n", This, ref - 1);
DMSTYLE_LockModule();
return ref; return ref;
} }
@ -67,6 +69,9 @@ ULONG WINAPI IDirectMusicMotifTrack_IUnknown_Release (LPUNKNOWN iface) {
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
DMSTYLE_UnlockModule();
return ref; return ref;
} }

View File

@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicMuteTrack_IUnknown_AddRef (LPUNKNOWN iface) {
TRACE("(%p): AddRef from %ld\n", This, ref - 1); TRACE("(%p): AddRef from %ld\n", This, ref - 1);
DMSTYLE_LockModule();
return ref; return ref;
} }
@ -67,6 +69,9 @@ ULONG WINAPI IDirectMusicMuteTrack_IUnknown_Release (LPUNKNOWN iface) {
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
DMSTYLE_UnlockModule();
return ref; return ref;
} }

View File

@ -63,6 +63,8 @@ ULONG WINAPI IDirectMusicStyle8Impl_IUnknown_AddRef (LPUNKNOWN iface) {
TRACE("(%p): AddRef from %ld\n", This, ref - 1); TRACE("(%p): AddRef from %ld\n", This, ref - 1);
DMSTYLE_LockModule();
return ref; return ref;
} }
@ -75,6 +77,9 @@ ULONG WINAPI IDirectMusicStyle8Impl_IUnknown_Release (LPUNKNOWN iface) {
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
DMSTYLE_UnlockModule();
return ref; return ref;
} }

View File

@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicStyleTrack_IUnknown_AddRef (LPUNKNOWN iface) {
TRACE("(%p): AddRef from %ld\n", This, ref - 1); TRACE("(%p): AddRef from %ld\n", This, ref - 1);
DMSTYLE_LockModule();
return ref; return ref;
} }
@ -67,6 +69,9 @@ ULONG WINAPI IDirectMusicStyleTrack_IUnknown_Release (LPUNKNOWN iface) {
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
DMSTYLE_UnlockModule();
return ref; return ref;
} }