dmstyle: Remove the extraneous IUnknown from DMMuteTrack.
Also lock/unlock the module only on creation/destruction of the object.
This commit is contained in:
parent
c0b7fe8027
commit
43c9f3a0bc
|
@ -21,76 +21,16 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
|
WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicMuteTrack_IUnknown_AddRef (LPUNKNOWN iface);
|
|
||||||
static ULONG WINAPI IDirectMusicMuteTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface);
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* IDirectMusicMuteTrack implementation
|
* IDirectMusicMuteTrack implementation
|
||||||
*/
|
*/
|
||||||
typedef struct IDirectMusicMuteTrack {
|
typedef struct IDirectMusicMuteTrack {
|
||||||
const IUnknownVtbl *UnknownVtbl;
|
|
||||||
IDirectMusicTrack8 IDirectMusicTrack8_iface;
|
IDirectMusicTrack8 IDirectMusicTrack8_iface;
|
||||||
const IPersistStreamVtbl *PersistStreamVtbl;
|
const IPersistStreamVtbl *PersistStreamVtbl;
|
||||||
LONG ref;
|
LONG ref;
|
||||||
DMUS_OBJECTDESC *pDesc;
|
DMUS_OBJECTDESC *pDesc;
|
||||||
} IDirectMusicMuteTrack;
|
} IDirectMusicMuteTrack;
|
||||||
|
|
||||||
/* IDirectMusicMuteTrack IUnknown part: */
|
|
||||||
static HRESULT WINAPI IDirectMusicMuteTrack_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
|
|
||||||
ICOM_THIS_MULTI(IDirectMusicMuteTrack, UnknownVtbl, iface);
|
|
||||||
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
|
|
||||||
|
|
||||||
if (IsEqualIID (riid, &IID_IUnknown)) {
|
|
||||||
*ppobj = &This->UnknownVtbl;
|
|
||||||
IDirectMusicMuteTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
|
||||||
return S_OK;
|
|
||||||
} else if (IsEqualIID (riid, &IID_IDirectMusicTrack)
|
|
||||||
|| IsEqualIID (riid, &IID_IDirectMusicTrack8)) {
|
|
||||||
*ppobj = &This->IDirectMusicTrack8_iface;
|
|
||||||
IDirectMusicTrack8_AddRef (&This->IDirectMusicTrack8_iface);
|
|
||||||
return S_OK;
|
|
||||||
} else if (IsEqualIID (riid, &IID_IPersistStream)) {
|
|
||||||
*ppobj = &This->PersistStreamVtbl;
|
|
||||||
IDirectMusicMuteTrack_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
|
|
||||||
return E_NOINTERFACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicMuteTrack_IUnknown_AddRef (LPUNKNOWN iface) {
|
|
||||||
ICOM_THIS_MULTI(IDirectMusicMuteTrack, UnknownVtbl, iface);
|
|
||||||
ULONG ref = InterlockedIncrement(&This->ref);
|
|
||||||
|
|
||||||
TRACE("(%p): AddRef from %d\n", This, ref - 1);
|
|
||||||
|
|
||||||
DMSTYLE_LockModule();
|
|
||||||
|
|
||||||
return ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicMuteTrack_IUnknown_Release (LPUNKNOWN iface) {
|
|
||||||
ICOM_THIS_MULTI(IDirectMusicMuteTrack, UnknownVtbl, iface);
|
|
||||||
ULONG ref = InterlockedDecrement(&This->ref);
|
|
||||||
|
|
||||||
TRACE("(%p): ReleaseRef to %d\n", This, ref);
|
|
||||||
|
|
||||||
if (ref == 0) {
|
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
|
||||||
}
|
|
||||||
|
|
||||||
DMSTYLE_UnlockModule();
|
|
||||||
|
|
||||||
return ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const IUnknownVtbl DirectMusicMuteTrack_Unknown_Vtbl = {
|
|
||||||
IDirectMusicMuteTrack_IUnknown_QueryInterface,
|
|
||||||
IDirectMusicMuteTrack_IUnknown_AddRef,
|
|
||||||
IDirectMusicMuteTrack_IUnknown_Release
|
|
||||||
};
|
|
||||||
|
|
||||||
/* IDirectMusicMuteTrack IDirectMusicTrack8 part: */
|
/* IDirectMusicMuteTrack IDirectMusicTrack8 part: */
|
||||||
static inline IDirectMusicMuteTrack *impl_from_IDirectMusicTrack8(IDirectMusicTrack8 *iface)
|
static inline IDirectMusicMuteTrack *impl_from_IDirectMusicTrack8(IDirectMusicTrack8 *iface)
|
||||||
{
|
{
|
||||||
|
@ -98,22 +38,51 @@ static inline IDirectMusicMuteTrack *impl_from_IDirectMusicTrack8(IDirectMusicTr
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface(IDirectMusicTrack8 *iface, REFIID riid,
|
static HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface(IDirectMusicTrack8 *iface, REFIID riid,
|
||||||
void **ppobj)
|
void **ret_iface)
|
||||||
{
|
{
|
||||||
IDirectMusicMuteTrack *This = impl_from_IDirectMusicTrack8(iface);
|
IDirectMusicMuteTrack *This = impl_from_IDirectMusicTrack8(iface);
|
||||||
return IDirectMusicMuteTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
|
|
||||||
|
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
|
||||||
|
|
||||||
|
*ret_iface = NULL;
|
||||||
|
|
||||||
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicTrack) ||
|
||||||
|
IsEqualIID(riid, &IID_IDirectMusicTrack8))
|
||||||
|
*ret_iface = iface;
|
||||||
|
else if (IsEqualIID(riid, &IID_IPersistStream))
|
||||||
|
*ret_iface = &This->PersistStreamVtbl;
|
||||||
|
else {
|
||||||
|
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
IUnknown_AddRef((IUnknown*)*ret_iface);
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicTrack8Impl_AddRef(IDirectMusicTrack8 *iface)
|
static ULONG WINAPI IDirectMusicTrack8Impl_AddRef(IDirectMusicTrack8 *iface)
|
||||||
{
|
{
|
||||||
IDirectMusicMuteTrack *This = impl_from_IDirectMusicTrack8(iface);
|
IDirectMusicMuteTrack *This = impl_from_IDirectMusicTrack8(iface);
|
||||||
return IDirectMusicMuteTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
LONG ref = InterlockedIncrement(&This->ref);
|
||||||
|
|
||||||
|
TRACE("(%p) ref=%d\n", This, ref);
|
||||||
|
|
||||||
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicTrack8Impl_Release(IDirectMusicTrack8 *iface)
|
static ULONG WINAPI IDirectMusicTrack8Impl_Release(IDirectMusicTrack8 *iface)
|
||||||
{
|
{
|
||||||
IDirectMusicMuteTrack *This = impl_from_IDirectMusicTrack8(iface);
|
IDirectMusicMuteTrack *This = impl_from_IDirectMusicTrack8(iface);
|
||||||
return IDirectMusicMuteTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
LONG ref = InterlockedDecrement(&This->ref);
|
||||||
|
|
||||||
|
TRACE("(%p) ref=%d\n", This, ref);
|
||||||
|
|
||||||
|
if (!ref) {
|
||||||
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
|
DMSTYLE_UnlockModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirectMusicTrack8Impl_Init(IDirectMusicTrack8 *iface,
|
static HRESULT WINAPI IDirectMusicTrack8Impl_Init(IDirectMusicTrack8 *iface,
|
||||||
|
@ -281,17 +250,17 @@ static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = {
|
||||||
/* IDirectMusicMuteTrack IPersistStream part: */
|
/* IDirectMusicMuteTrack IPersistStream part: */
|
||||||
static HRESULT WINAPI IDirectMusicMuteTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
|
static HRESULT WINAPI IDirectMusicMuteTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
|
||||||
ICOM_THIS_MULTI(IDirectMusicMuteTrack, PersistStreamVtbl, iface);
|
ICOM_THIS_MULTI(IDirectMusicMuteTrack, PersistStreamVtbl, iface);
|
||||||
return IDirectMusicMuteTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
|
return IDirectMusicTrack8_QueryInterface(&This->IDirectMusicTrack8_iface, riid, ppobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicMuteTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
|
static ULONG WINAPI IDirectMusicMuteTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
|
||||||
ICOM_THIS_MULTI(IDirectMusicMuteTrack, PersistStreamVtbl, iface);
|
ICOM_THIS_MULTI(IDirectMusicMuteTrack, PersistStreamVtbl, iface);
|
||||||
return IDirectMusicMuteTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
return IDirectMusicTrack8_AddRef(&This->IDirectMusicTrack8_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicMuteTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
|
static ULONG WINAPI IDirectMusicMuteTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
|
||||||
ICOM_THIS_MULTI(IDirectMusicMuteTrack, PersistStreamVtbl, iface);
|
ICOM_THIS_MULTI(IDirectMusicMuteTrack, PersistStreamVtbl, iface);
|
||||||
return IDirectMusicMuteTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
return IDirectMusicTrack8_Release(&This->IDirectMusicTrack8_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirectMusicMuteTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
|
static HRESULT WINAPI IDirectMusicMuteTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
|
||||||
|
@ -329,21 +298,25 @@ static const IPersistStreamVtbl DirectMusicMuteTrack_PersistStream_Vtbl = {
|
||||||
/* for ClassFactory */
|
/* for ClassFactory */
|
||||||
HRESULT WINAPI create_dmmutetrack(REFIID lpcGUID, void **ppobj)
|
HRESULT WINAPI create_dmmutetrack(REFIID lpcGUID, void **ppobj)
|
||||||
{
|
{
|
||||||
IDirectMusicMuteTrack* track;
|
IDirectMusicMuteTrack *track;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicMuteTrack));
|
track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
|
||||||
if (NULL == track) {
|
if (!track) {
|
||||||
*ppobj = NULL;
|
*ppobj = NULL;
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
track->UnknownVtbl = &DirectMusicMuteTrack_Unknown_Vtbl;
|
|
||||||
track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
|
track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
|
||||||
track->PersistStreamVtbl = &DirectMusicMuteTrack_PersistStream_Vtbl;
|
track->PersistStreamVtbl = &DirectMusicMuteTrack_PersistStream_Vtbl;
|
||||||
track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
|
track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
|
||||||
DM_STRUCT_INIT(track->pDesc);
|
DM_STRUCT_INIT(track->pDesc);
|
||||||
track->pDesc->dwValidData |= DMUS_OBJ_CLASS;
|
track->pDesc->dwValidData |= DMUS_OBJ_CLASS;
|
||||||
track->pDesc->guidClass = CLSID_DirectMusicMuteTrack;
|
track->pDesc->guidClass = CLSID_DirectMusicMuteTrack;
|
||||||
track->ref = 0; /* will be inited by QueryInterface */
|
track->ref = 1;
|
||||||
|
|
||||||
return IDirectMusicMuteTrack_IUnknown_QueryInterface ((LPUNKNOWN)&track->UnknownVtbl, lpcGUID, ppobj);
|
DMSTYLE_LockModule();
|
||||||
|
hr = IDirectMusicTrack8_QueryInterface(&track->IDirectMusicTrack8_iface, lpcGUID, ppobj);
|
||||||
|
IDirectMusicTrack8_Release(&track->IDirectMusicTrack8_iface);
|
||||||
|
|
||||||
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue