dmime: Remove the extraneous IUnknown from DMSysExTrack.
Also lock/unlock the module only on creation/destruction of the object.
This commit is contained in:
parent
9a47a46a95
commit
b9360bd999
|
@ -25,68 +25,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmime);
|
|||
* IDirectMusicSysExTrack implementation
|
||||
*/
|
||||
typedef struct IDirectMusicSysExTrack {
|
||||
const IUnknownVtbl *UnknownVtbl;
|
||||
IDirectMusicTrack8 IDirectMusicTrack8_iface;
|
||||
const IPersistStreamVtbl *PersistStreamVtbl;
|
||||
LONG ref;
|
||||
DMUS_OBJECTDESC *pDesc;
|
||||
} IDirectMusicSysExTrack;
|
||||
|
||||
/* IDirectMusicSysExTrack IUnknown part: */
|
||||
static HRESULT WINAPI IDirectMusicSysExTrack_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
|
||||
ICOM_THIS_MULTI(IDirectMusicSysExTrack, UnknownVtbl, iface);
|
||||
TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppobj);
|
||||
|
||||
if (IsEqualIID (riid, &IID_IUnknown)) {
|
||||
*ppobj = &This->UnknownVtbl;
|
||||
IUnknown_AddRef(iface);
|
||||
return S_OK;
|
||||
} else if (IsEqualIID (riid, &IID_IDirectMusicTrack)
|
||||
|| IsEqualIID (riid, &IID_IDirectMusicTrack8)) {
|
||||
*ppobj = &This->IDirectMusicTrack8_iface;
|
||||
IUnknown_AddRef(iface);
|
||||
return S_OK;
|
||||
} else if (IsEqualIID (riid, &IID_IPersistStream)) {
|
||||
*ppobj = &This->PersistStreamVtbl;
|
||||
IUnknown_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
WARN("(%p, %s, %p): not found\n", This, debugstr_guid(riid), ppobj);
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI IDirectMusicSysExTrack_IUnknown_AddRef (LPUNKNOWN iface) {
|
||||
ICOM_THIS_MULTI(IDirectMusicSysExTrack, UnknownVtbl, iface);
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
|
||||
TRACE("(%p): AddRef from %d\n", This, ref - 1);
|
||||
|
||||
DMIME_LockModule();
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
static ULONG WINAPI IDirectMusicSysExTrack_IUnknown_Release (LPUNKNOWN iface) {
|
||||
ICOM_THIS_MULTI(IDirectMusicSysExTrack, UnknownVtbl, iface);
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
TRACE("(%p): ReleaseRef to %d\n", This, ref);
|
||||
|
||||
if (ref == 0) {
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
DMIME_UnlockModule();
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
static const IUnknownVtbl DirectMusicSysExTrack_Unknown_Vtbl = {
|
||||
IDirectMusicSysExTrack_IUnknown_QueryInterface,
|
||||
IDirectMusicSysExTrack_IUnknown_AddRef,
|
||||
IDirectMusicSysExTrack_IUnknown_Release
|
||||
};
|
||||
|
||||
/* IDirectMusicSysExTrack IDirectMusicTrack8 part: */
|
||||
static inline IDirectMusicSysExTrack *impl_from_IDirectMusicTrack8(IDirectMusicTrack8 *iface)
|
||||
{
|
||||
|
@ -94,22 +38,51 @@ static inline IDirectMusicSysExTrack *impl_from_IDirectMusicTrack8(IDirectMusicT
|
|||
}
|
||||
|
||||
static HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface(IDirectMusicTrack8 *iface, REFIID riid,
|
||||
void **ppobj)
|
||||
void **ret_iface)
|
||||
{
|
||||
IDirectMusicSysExTrack *This = impl_from_IDirectMusicTrack8(iface);
|
||||
return 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)
|
||||
{
|
||||
IDirectMusicSysExTrack *This = impl_from_IDirectMusicTrack8(iface);
|
||||
return 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)
|
||||
{
|
||||
IDirectMusicSysExTrack *This = impl_from_IDirectMusicTrack8(iface);
|
||||
return IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
||||
LONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
TRACE("(%p) ref=%d\n", This, ref);
|
||||
|
||||
if (!ref) {
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
DMIME_UnlockModule();
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDirectMusicTrack8Impl_Init(IDirectMusicTrack8 *iface,
|
||||
|
@ -272,17 +245,17 @@ static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = {
|
|||
/* IDirectMusicSysExTrack IPersistStream part: */
|
||||
static HRESULT WINAPI IDirectMusicSysExTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
|
||||
ICOM_THIS_MULTI(IDirectMusicSysExTrack, PersistStreamVtbl, iface);
|
||||
return IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
|
||||
return IDirectMusicTrack8_QueryInterface(&This->IDirectMusicTrack8_iface, riid, ppobj);
|
||||
}
|
||||
|
||||
static ULONG WINAPI IDirectMusicSysExTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
|
||||
ICOM_THIS_MULTI(IDirectMusicSysExTrack, PersistStreamVtbl, iface);
|
||||
return IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
||||
return IDirectMusicTrack8_AddRef(&This->IDirectMusicTrack8_iface);
|
||||
}
|
||||
|
||||
static ULONG WINAPI IDirectMusicSysExTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
|
||||
ICOM_THIS_MULTI(IDirectMusicSysExTrack, PersistStreamVtbl, iface);
|
||||
return IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
||||
return IDirectMusicTrack8_Release(&This->IDirectMusicTrack8_iface);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDirectMusicSysExTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
|
||||
|
@ -320,21 +293,25 @@ static const IPersistStreamVtbl DirectMusicSysExTrack_PersistStream_Vtbl = {
|
|||
/* for ClassFactory */
|
||||
HRESULT WINAPI create_dmsysextrack(REFIID lpcGUID, void **ppobj)
|
||||
{
|
||||
IDirectMusicSysExTrack* track;
|
||||
|
||||
track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSysExTrack));
|
||||
if (NULL == track) {
|
||||
*ppobj = NULL;
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
track->UnknownVtbl = &DirectMusicSysExTrack_Unknown_Vtbl;
|
||||
IDirectMusicSysExTrack *track;
|
||||
HRESULT hr;
|
||||
|
||||
track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
|
||||
if (!track) {
|
||||
*ppobj = NULL;
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
|
||||
track->PersistStreamVtbl = &DirectMusicSysExTrack_PersistStream_Vtbl;
|
||||
track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
|
||||
DM_STRUCT_INIT(track->pDesc);
|
||||
track->pDesc->dwValidData |= DMUS_OBJ_CLASS;
|
||||
track->pDesc->guidClass = CLSID_DirectMusicSysExTrack;
|
||||
track->ref = 0; /* will be inited by QueryInterface */
|
||||
track->ref = 1;
|
||||
|
||||
return IDirectMusicSysExTrack_IUnknown_QueryInterface ((LPUNKNOWN)&track->UnknownVtbl, lpcGUID, ppobj);
|
||||
DMIME_LockModule();
|
||||
hr = IDirectMusicTrack8_QueryInterface(&track->IDirectMusicTrack8_iface, lpcGUID, ppobj);
|
||||
IDirectMusicTrack8_Release(&track->IDirectMusicTrack8_iface);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue