From 1727eb485e4f1109b9a9084e0a561f2f60bdc132 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Wed, 2 Feb 2005 09:31:06 +0000 Subject: [PATCH] Properly implement DllCanUnloadNow ref counting. --- dlls/dmime/audiopath.c | 6 + dlls/dmime/dmime_main.c | 454 ++++++++++++++++++++------------- dlls/dmime/dmime_private.h | 6 + dlls/dmime/graph.c | 6 + dlls/dmime/lyricstrack.c | 6 + dlls/dmime/markertrack.c | 6 + dlls/dmime/paramcontroltrack.c | 6 + dlls/dmime/patterntrack.c | 6 + dlls/dmime/performance.c | 6 + dlls/dmime/segment.c | 6 + dlls/dmime/segmentstate.c | 6 + dlls/dmime/segtriggertrack.c | 6 + dlls/dmime/seqtrack.c | 6 + dlls/dmime/sysextrack.c | 6 + dlls/dmime/tempotrack.c | 6 + dlls/dmime/timesigtrack.c | 6 + dlls/dmime/tool.c | 6 + dlls/dmime/wavetrack.c | 6 + 18 files changed, 384 insertions(+), 172 deletions(-) diff --git a/dlls/dmime/audiopath.c b/dlls/dmime/audiopath.c index 591fdb240d4..49580c44d5a 100644 --- a/dlls/dmime/audiopath.c +++ b/dlls/dmime/audiopath.c @@ -58,6 +58,8 @@ ULONG WINAPI IDirectMusicAudioPathImpl_IUnknown_AddRef (LPUNKNOWN iface) { TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -65,12 +67,16 @@ ULONG WINAPI IDirectMusicAudioPathImpl_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, UnknownVtbl, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { if (This->pDSBuffer) { IDirectSoundBuffer8_Release(This->pDSBuffer); } HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/dmime_main.c b/dlls/dmime/dmime_main.c index 7c3fb3cb802..1cd28a4f000 100644 --- a/dlls/dmime/dmime_main.c +++ b/dlls/dmime/dmime_main.c @@ -23,41 +23,49 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmime); WINE_DECLARE_DEBUG_CHANNEL(dmfile); +LONG DMIME_refCount = 0; + typedef struct { - /* IUnknown fields */ IClassFactoryVtbl *lpVtbl; - DWORD ref; } IClassFactoryImpl; /****************************************************************** * DirectMusicPerformance ClassFactory */ static HRESULT WINAPI PerformanceCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI PerformanceCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI PerformanceCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI PerformanceCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicPerformanceImpl (riid, ppobj, pOuter); } static HRESULT WINAPI PerformanceCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -69,37 +77,45 @@ static IClassFactoryVtbl PerformanceCF_Vtbl = { PerformanceCF_LockServer }; -static IClassFactoryImpl Performance_CF = {&PerformanceCF_Vtbl, 1 }; +static IClassFactoryImpl Performance_CF = {&PerformanceCF_Vtbl}; /****************************************************************** * DirectMusicSegment ClassFactory */ static HRESULT WINAPI SegmentCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI SegmentCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI SegmentCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI SegmentCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicSegmentImpl (riid, ppobj, pOuter); } static HRESULT WINAPI SegmentCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -111,37 +127,45 @@ static IClassFactoryVtbl SegmentCF_Vtbl = { SegmentCF_LockServer }; -static IClassFactoryImpl Segment_CF = {&SegmentCF_Vtbl, 1 }; +static IClassFactoryImpl Segment_CF = {&SegmentCF_Vtbl}; /****************************************************************** * DirectMusicSegmentState ClassFactory */ static HRESULT WINAPI SegmentStateCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI SegmentStateCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based objects */ } static ULONG WINAPI SegmentStateCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI SegmentStateCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicSegmentStateImpl (riid, ppobj, pOuter); } static HRESULT WINAPI SegmentStateCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -153,37 +177,45 @@ static IClassFactoryVtbl SegmentStateCF_Vtbl = { SegmentStateCF_LockServer }; -static IClassFactoryImpl SegmentState_CF = {&SegmentStateCF_Vtbl, 1 }; +static IClassFactoryImpl SegmentState_CF = {&SegmentStateCF_Vtbl}; /****************************************************************** * DirectMusicGraph ClassFactory */ static HRESULT WINAPI GraphCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI GraphCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI GraphCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI GraphCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicGraphImpl (riid, ppobj, pOuter); } static HRESULT WINAPI GraphCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -195,37 +227,45 @@ static IClassFactoryVtbl GraphCF_Vtbl = { GraphCF_LockServer }; -static IClassFactoryImpl Graph_CF = {&GraphCF_Vtbl, 1 }; +static IClassFactoryImpl Graph_CF = {&GraphCF_Vtbl}; /****************************************************************** * DirectMusicTempoTrack ClassFactory */ static HRESULT WINAPI TempoTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI TempoTrackCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI TempoTrackCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI TempoTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicTempoTrack (riid, ppobj, pOuter); } static HRESULT WINAPI TempoTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -237,37 +277,45 @@ static IClassFactoryVtbl TempoTrackCF_Vtbl = { TempoTrackCF_LockServer }; -static IClassFactoryImpl TempoTrack_CF = {&TempoTrackCF_Vtbl, 1 }; +static IClassFactoryImpl TempoTrack_CF = {&TempoTrackCF_Vtbl}; /****************************************************************** * DirectMusicSeqTrack ClassFactory */ static HRESULT WINAPI SeqTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI SeqTrackCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI SeqTrackCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI SeqTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicSeqTrack (riid, ppobj, pOuter); } static HRESULT WINAPI SeqTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -279,37 +327,44 @@ static IClassFactoryVtbl SeqTrackCF_Vtbl = { SeqTrackCF_LockServer }; -static IClassFactoryImpl SeqTrack_CF = {&SeqTrackCF_Vtbl, 1 }; +static IClassFactoryImpl SeqTrack_CF = {&SeqTrackCF_Vtbl}; /****************************************************************** * DirectMusicSysExTrack ClassFactory */ static HRESULT WINAPI SysExTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI SysExTrackCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI SysExTrackCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI SysExTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); return DMUSIC_CreateDirectMusicSysExTrack (riid, ppobj, pOuter); } static HRESULT WINAPI SysExTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -321,37 +376,45 @@ static IClassFactoryVtbl SysExTrackCF_Vtbl = { SysExTrackCF_LockServer }; -static IClassFactoryImpl SysExTrack_CF = {&SysExTrackCF_Vtbl, 1 }; +static IClassFactoryImpl SysExTrack_CF = {&SysExTrackCF_Vtbl}; /****************************************************************** * DirectMusicTimeSigTrack ClassFactory */ static HRESULT WINAPI TimeSigTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI TimeSigTrackCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI TimeSigTrackCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI TimeSigTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicTimeSigTrack (riid, ppobj, pOuter); } static HRESULT WINAPI TimeSigTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -363,37 +426,45 @@ static IClassFactoryVtbl TimeSigTrackCF_Vtbl = { TimeSigTrackCF_LockServer }; -static IClassFactoryImpl TimeSigTrack_CF = {&TimeSigTrackCF_Vtbl, 1 }; +static IClassFactoryImpl TimeSigTrack_CF = {&TimeSigTrackCF_Vtbl}; /****************************************************************** * DirectMusicParamControlTrack ClassFactory */ static HRESULT WINAPI ParamControlTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI ParamControlTrackCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI ParamControlTrackCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI ParamControlTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicParamControlTrack (riid, ppobj, pOuter); } static HRESULT WINAPI ParamControlTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -405,37 +476,45 @@ static IClassFactoryVtbl ParamControlTrackCF_Vtbl = { ParamControlTrackCF_LockServer }; -static IClassFactoryImpl ParamControlTrack_CF = {&ParamControlTrackCF_Vtbl, 1 }; +static IClassFactoryImpl ParamControlTrack_CF = {&ParamControlTrackCF_Vtbl}; /****************************************************************** * DirectMusicMarkerTrack ClassFactory */ static HRESULT WINAPI MarkerTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI MarkerTrackCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI MarkerTrackCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI MarkerTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicMarkerTrack (riid, ppobj, pOuter); } static HRESULT WINAPI MarkerTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -447,37 +526,45 @@ static IClassFactoryVtbl MarkerTrackCF_Vtbl = { MarkerTrackCF_LockServer }; -static IClassFactoryImpl MarkerTrack_CF = {&MarkerTrackCF_Vtbl, 1 }; +static IClassFactoryImpl MarkerTrack_CF = {&MarkerTrackCF_Vtbl}; /****************************************************************** * DirectMusicLyricsTrack ClassFactory */ static HRESULT WINAPI LyricsTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI LyricsTrackCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI LyricsTrackCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI LyricsTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicLyricsTrack (riid, ppobj, pOuter); } static HRESULT WINAPI LyricsTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -489,38 +576,46 @@ static IClassFactoryVtbl LyricsTrackCF_Vtbl = { LyricsTrackCF_LockServer }; -static IClassFactoryImpl LyricsTrack_CF = {&LyricsTrackCF_Vtbl, 1 }; +static IClassFactoryImpl LyricsTrack_CF = {&LyricsTrackCF_Vtbl}; /****************************************************************** * DirectMusicSegTriggerTrack ClassFactory */ static HRESULT WINAPI SegTriggerTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI SegTriggerTrackCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI SegTriggerTrackCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI SegTriggerTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicSegTriggerTrack (riid, ppobj, pOuter); } static HRESULT WINAPI SegTriggerTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -532,37 +627,45 @@ static IClassFactoryVtbl SegTriggerTrackCF_Vtbl = { SegTriggerTrackCF_LockServer }; -static IClassFactoryImpl SegTriggerTrack_CF = {&SegTriggerTrackCF_Vtbl, 1 }; +static IClassFactoryImpl SegTriggerTrack_CF = {&SegTriggerTrackCF_Vtbl}; /****************************************************************** * DirectMusicAudioPath ClassFactory */ static HRESULT WINAPI AudioPathCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI AudioPathCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI AudioPathCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI AudioPathCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicAudioPathImpl (riid, ppobj, pOuter); } static HRESULT WINAPI AudioPathCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -574,37 +677,45 @@ static IClassFactoryVtbl AudioPathCF_Vtbl = { AudioPathCF_LockServer }; -static IClassFactoryImpl AudioPath_CF = {&AudioPathCF_Vtbl, 1 }; +static IClassFactoryImpl AudioPath_CF = {&AudioPathCF_Vtbl}; /****************************************************************** * DirectMusicWaveTrack ClassFactory */ static HRESULT WINAPI WaveTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %s, %p): stub\n", This, debugstr_dmguid(riid), ppobj); + FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); + + if (ppobj == NULL) return E_POINTER; + return E_NOINTERFACE; } static ULONG WINAPI WaveTrackCF_AddRef(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return InterlockedIncrement(&This->ref); + DMIME_LockModule(); + + return 2; /* non-heap based object */ } static ULONG WINAPI WaveTrackCF_Release(LPCLASSFACTORY iface) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - /* static class, won't be freed */ - return InterlockedDecrement(&This->ref); + DMIME_UnlockModule(); + + return 1; /* non-heap based object */ } static HRESULT WINAPI WaveTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj); + TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj); + return DMUSIC_CreateDirectMusicWaveTrack (riid, ppobj, pOuter); } static HRESULT WINAPI WaveTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p, %d): stub\n", This, dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + DMIME_LockModule(); + else + DMIME_UnlockModule(); + return S_OK; } @@ -616,7 +727,7 @@ static IClassFactoryVtbl WaveTrackCF_Vtbl = { WaveTrackCF_LockServer }; -static IClassFactoryImpl WaveTrack_CF = {&WaveTrackCF_Vtbl, 1 }; +static IClassFactoryImpl WaveTrack_CF = {&WaveTrackCF_Vtbl}; /****************************************************************** * DllMain @@ -642,8 +753,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { * */ HRESULT WINAPI DMIME_DllCanUnloadNow(void) { - FIXME("(void): stub\n"); - return S_FALSE; + return DMIME_refCount != 0 ? S_FALSE : S_OK; } diff --git a/dlls/dmime/dmime_private.h b/dlls/dmime/dmime_private.h index 0043cddb9bf..bf18504495a 100644 --- a/dlls/dmime/dmime_private.h +++ b/dlls/dmime/dmime_private.h @@ -949,6 +949,12 @@ extern HRESULT WINAPI IDirectMusicWaveTrack_IPersistStream_Load (LPPERSISTSTREAM extern HRESULT WINAPI IDirectMusicWaveTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty); extern HRESULT WINAPI IDirectMusicWaveTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize); +/********************************************************************** + * Dll lifetime tracking declaration for dmime.dll + */ +extern LONG DMIME_refCount; +static inline void DMIME_LockModule() { InterlockedIncrement( &DMIME_refCount ); } +static inline void DMIME_UnlockModule() { InterlockedDecrement( &DMIME_refCount ); } /***************************************************************************** * Misc. diff --git a/dlls/dmime/graph.c b/dlls/dmime/graph.c index 8b5f74841c3..e3b59c1b313 100644 --- a/dlls/dmime/graph.c +++ b/dlls/dmime/graph.c @@ -58,6 +58,8 @@ ULONG WINAPI IDirectMusicGraphImpl_IUnknown_AddRef (LPUNKNOWN iface) { TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -65,9 +67,13 @@ ULONG WINAPI IDirectMusicGraphImpl_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicGraphImpl, UnknownVtbl, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/lyricstrack.c b/dlls/dmime/lyricstrack.c index 8e52798067d..1846eaf55a8 100644 --- a/dlls/dmime/lyricstrack.c +++ b/dlls/dmime/lyricstrack.c @@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicLyricsTrack_IUnknown_AddRef (LPUNKNOWN iface) { TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -62,9 +64,13 @@ ULONG WINAPI IDirectMusicLyricsTrack_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicLyricsTrack, UnknownVtbl, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/markertrack.c b/dlls/dmime/markertrack.c index d51ca177f04..f8030aa6641 100644 --- a/dlls/dmime/markertrack.c +++ b/dlls/dmime/markertrack.c @@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicMarkerTrack_IUnknown_AddRef (LPUNKNOWN iface) { TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -62,9 +64,13 @@ ULONG WINAPI IDirectMusicMarkerTrack_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicMarkerTrack, UnknownVtbl, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/paramcontroltrack.c b/dlls/dmime/paramcontroltrack.c index 9563b9aa03c..33bd4f3f60d 100644 --- a/dlls/dmime/paramcontroltrack.c +++ b/dlls/dmime/paramcontroltrack.c @@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicParamControlTrack_IUnknown_AddRef (LPUNKNOWN iface) { TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -62,9 +64,13 @@ ULONG WINAPI IDirectMusicParamControlTrack_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicParamControlTrack, UnknownVtbl, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/patterntrack.c b/dlls/dmime/patterntrack.c index 8032999a824..4322e745136 100644 --- a/dlls/dmime/patterntrack.c +++ b/dlls/dmime/patterntrack.c @@ -43,6 +43,8 @@ ULONG WINAPI IDirectMusicPatternTrackImpl_AddRef (LPDIRECTMUSICPATTERNTRACK ifac TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -50,9 +52,13 @@ ULONG WINAPI IDirectMusicPatternTrackImpl_Release (LPDIRECTMUSICPATTERNTRACK ifa IDirectMusicPatternTrackImpl *This = (IDirectMusicPatternTrackImpl *)iface; ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c index 95a8406b8dd..1efb69f568b 100644 --- a/dlls/dmime/performance.c +++ b/dlls/dmime/performance.c @@ -186,6 +186,8 @@ ULONG WINAPI IDirectMusicPerformance8Impl_AddRef (LPDIRECTMUSICPERFORMANCE8 ifac TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -193,10 +195,14 @@ ULONG WINAPI IDirectMusicPerformance8Impl_Release (LPDIRECTMUSICPERFORMANCE8 ifa IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface; ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { DeleteCriticalSection(&This->safe); HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/segment.c b/dlls/dmime/segment.c index 3a3df8edeee..b3d46901761 100644 --- a/dlls/dmime/segment.c +++ b/dlls/dmime/segment.c @@ -61,6 +61,8 @@ ULONG WINAPI IDirectMusicSegment8Impl_IUnknown_AddRef (LPUNKNOWN iface) { TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -68,9 +70,13 @@ ULONG WINAPI IDirectMusicSegment8Impl_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicSegment8Impl, UnknownVtbl, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/segmentstate.c b/dlls/dmime/segmentstate.c index 39b0527d4ed..18c036cb4b5 100644 --- a/dlls/dmime/segmentstate.c +++ b/dlls/dmime/segmentstate.c @@ -43,6 +43,8 @@ ULONG WINAPI IDirectMusicSegmentState8Impl_AddRef (LPDIRECTMUSICSEGMENTSTATE8 if TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -50,9 +52,13 @@ ULONG WINAPI IDirectMusicSegmentState8Impl_Release (LPDIRECTMUSICSEGMENTSTATE8 i IDirectMusicSegmentState8Impl *This = (IDirectMusicSegmentState8Impl *)iface; ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/segtriggertrack.c b/dlls/dmime/segtriggertrack.c index ea118314f1c..f6b5823089e 100644 --- a/dlls/dmime/segtriggertrack.c +++ b/dlls/dmime/segtriggertrack.c @@ -56,6 +56,8 @@ ULONG WINAPI IDirectMusicSegTriggerTrack_IUnknown_AddRef (LPUNKNOWN iface) { TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -63,9 +65,13 @@ ULONG WINAPI IDirectMusicSegTriggerTrack_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, UnknownVtbl, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/seqtrack.c b/dlls/dmime/seqtrack.c index 7e229180fb3..21f78c8e805 100644 --- a/dlls/dmime/seqtrack.c +++ b/dlls/dmime/seqtrack.c @@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicSeqTrack_IUnknown_AddRef (LPUNKNOWN iface) { TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -62,9 +64,13 @@ ULONG WINAPI IDirectMusicSeqTrack_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicSeqTrack, UnknownVtbl, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/sysextrack.c b/dlls/dmime/sysextrack.c index c90fa9e2583..e0a72b3b5b7 100644 --- a/dlls/dmime/sysextrack.c +++ b/dlls/dmime/sysextrack.c @@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicSysExTrack_IUnknown_AddRef (LPUNKNOWN iface) { TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -62,9 +64,13 @@ ULONG WINAPI IDirectMusicSysExTrack_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicSysExTrack, UnknownVtbl, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/tempotrack.c b/dlls/dmime/tempotrack.c index 3359dbfb6d7..f894dac4017 100644 --- a/dlls/dmime/tempotrack.c +++ b/dlls/dmime/tempotrack.c @@ -56,6 +56,8 @@ ULONG WINAPI IDirectMusicTempoTrack_IUnknown_AddRef (LPUNKNOWN iface) { TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -63,9 +65,13 @@ ULONG WINAPI IDirectMusicTempoTrack_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicTempoTrack, UnknownVtbl, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/timesigtrack.c b/dlls/dmime/timesigtrack.c index bb0266d8012..a88665a301e 100644 --- a/dlls/dmime/timesigtrack.c +++ b/dlls/dmime/timesigtrack.c @@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicTimeSigTrack_IUnknown_AddRef (LPUNKNOWN iface) { TRACE("(%p): AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -62,9 +64,13 @@ ULONG WINAPI IDirectMusicTimeSigTrack_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicTimeSigTrack, UnknownVtbl, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p): ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/tool.c b/dlls/dmime/tool.c index 8fc4268da48..1277f2d536d 100644 --- a/dlls/dmime/tool.c +++ b/dlls/dmime/tool.c @@ -42,6 +42,8 @@ ULONG WINAPI IDirectMusicTool8Impl_AddRef (LPDIRECTMUSICTOOL8 iface) { TRACE("(%p) : AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -49,9 +51,13 @@ ULONG WINAPI IDirectMusicTool8Impl_Release (LPDIRECTMUSICTOOL8 iface) { IDirectMusicTool8Impl *This = (IDirectMusicTool8Impl *)iface; ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) : ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; } diff --git a/dlls/dmime/wavetrack.c b/dlls/dmime/wavetrack.c index 77b141c17e8..829ee350882 100644 --- a/dlls/dmime/wavetrack.c +++ b/dlls/dmime/wavetrack.c @@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicWaveTrack_IUnknown_AddRef (LPUNKNOWN iface) { TRACE("(%p) : AddRef from %ld\n", This, ref - 1); + DMIME_LockModule(); + return ref; } @@ -62,9 +64,13 @@ ULONG WINAPI IDirectMusicWaveTrack_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicWaveTrack, UnknownVtbl, iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) : ReleaseRef to %ld\n", This, ref); + if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); } + + DMIME_UnlockModule(); + return ref; }