dmloader: COM cleanup for IDirectMusicContainer.
This commit is contained in:
parent
8a15ea1190
commit
9ab1cfb5e0
|
@ -27,14 +27,24 @@ WINE_DECLARE_DEBUG_CHANNEL(dmdump);
|
||||||
#define DMUS_MAX_NAME_SIZE DMUS_MAX_NAME*sizeof(WCHAR)
|
#define DMUS_MAX_NAME_SIZE DMUS_MAX_NAME*sizeof(WCHAR)
|
||||||
#define DMUS_MAX_FILENAME_SIZE DMUS_MAX_FILENAME*sizeof(WCHAR)
|
#define DMUS_MAX_FILENAME_SIZE DMUS_MAX_FILENAME*sizeof(WCHAR)
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicContainerImpl_IDirectMusicContainer_AddRef (LPDIRECTMUSICCONTAINER iface);
|
|
||||||
static ULONG WINAPI IDirectMusicContainerImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface);
|
|
||||||
static ULONG WINAPI IDirectMusicContainerImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface);
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* IDirectMusicContainerImpl implementation
|
* IDirectMusicContainerImpl implementation
|
||||||
*/
|
*/
|
||||||
/* IUnknown/IDirectMusicContainer part: */
|
typedef struct IDirectMusicContainerImpl {
|
||||||
|
IDirectMusicContainer IDirectMusicContainer_iface;
|
||||||
|
const IDirectMusicObjectVtbl *ObjectVtbl;
|
||||||
|
const IPersistStreamVtbl *PersistStreamVtbl;
|
||||||
|
LONG ref;
|
||||||
|
IStream *pStream;
|
||||||
|
DMUS_IO_CONTAINER_HEADER Header; /* header */
|
||||||
|
struct list *pContainedObjects; /* data */
|
||||||
|
DMUS_OBJECTDESC Desc;
|
||||||
|
} IDirectMusicContainerImpl;
|
||||||
|
|
||||||
|
static inline IDirectMusicContainerImpl *impl_from_IDirectMusicContainer(IDirectMusicContainer *iface)
|
||||||
|
{
|
||||||
|
return CONTAINING_RECORD(iface, IDirectMusicContainerImpl, IDirectMusicContainer_iface);
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT destroy_dmcontainer(IDirectMusicContainerImpl *This)
|
static HRESULT destroy_dmcontainer(IDirectMusicContainerImpl *This)
|
||||||
{
|
{
|
||||||
|
@ -72,52 +82,59 @@ static HRESULT destroy_dmcontainer(IDirectMusicContainerImpl *This)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface (LPDIRECTMUSICCONTAINER iface, REFIID riid, LPVOID *ppobj) {
|
static HRESULT WINAPI IDirectMusicContainerImpl_QueryInterface(IDirectMusicContainer *iface, REFIID riid, void **ret_iface)
|
||||||
ICOM_THIS_MULTI(IDirectMusicContainerImpl, ContainerVtbl, iface);
|
{
|
||||||
|
IDirectMusicContainerImpl *This = impl_from_IDirectMusicContainer(iface);
|
||||||
|
|
||||||
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
|
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
|
||||||
if (IsEqualIID (riid, &IID_IUnknown) ||
|
|
||||||
IsEqualIID (riid, &IID_IDirectMusicContainer)) {
|
|
||||||
*ppobj = &This->ContainerVtbl;
|
|
||||||
IDirectMusicContainerImpl_IDirectMusicContainer_AddRef ((LPDIRECTMUSICCONTAINER)&This->ContainerVtbl);
|
|
||||||
return S_OK;
|
|
||||||
} else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
|
|
||||||
*ppobj = &This->ObjectVtbl;
|
|
||||||
IDirectMusicContainerImpl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl);
|
|
||||||
return S_OK;
|
|
||||||
} else if (IsEqualIID (riid, &IID_IPersistStream)) {
|
|
||||||
*ppobj = &This->PersistStreamVtbl;
|
|
||||||
IDirectMusicContainerImpl_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
WARN(": not found\n");
|
if (IsEqualIID (riid, &IID_IUnknown) || IsEqualIID (riid, &IID_IDirectMusicContainer))
|
||||||
return E_NOINTERFACE;
|
*ret_iface = &This->IDirectMusicContainer_iface;
|
||||||
|
else if (IsEqualIID (riid, &IID_IDirectMusicObject))
|
||||||
|
*ret_iface = &This->ObjectVtbl;
|
||||||
|
else if (IsEqualIID (riid, &IID_IPersistStream))
|
||||||
|
*ret_iface = &This->PersistStreamVtbl;
|
||||||
|
else {
|
||||||
|
WARN("Unknown interface %s\n", debugstr_dmguid(riid));
|
||||||
|
*ret_iface = NULL;
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
IUnknown_AddRef((IUnknown*)*ret_iface);
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicContainerImpl_IDirectMusicContainer_AddRef (LPDIRECTMUSICCONTAINER iface) {
|
static ULONG WINAPI IDirectMusicContainerImpl_AddRef(IDirectMusicContainer *iface)
|
||||||
ICOM_THIS_MULTI(IDirectMusicContainerImpl, ContainerVtbl, iface);
|
{
|
||||||
TRACE("(%p): AddRef from %d\n", This, This->dwRef);
|
IDirectMusicContainerImpl *This = impl_from_IDirectMusicContainer(iface);
|
||||||
return InterlockedIncrement (&This->dwRef);
|
LONG ref = InterlockedIncrement(&This->ref);
|
||||||
|
|
||||||
|
TRACE("(%p) ref=%d\n", This, ref);
|
||||||
|
|
||||||
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicContainerImpl_IDirectMusicContainer_Release (LPDIRECTMUSICCONTAINER iface) {
|
static ULONG WINAPI IDirectMusicContainerImpl_Release(IDirectMusicContainer *iface)
|
||||||
ICOM_THIS_MULTI(IDirectMusicContainerImpl, ContainerVtbl, iface);
|
{
|
||||||
|
IDirectMusicContainerImpl *This = impl_from_IDirectMusicContainer(iface);
|
||||||
|
LONG ref = InterlockedDecrement(&This->ref);
|
||||||
|
|
||||||
DWORD dwRef = InterlockedDecrement (&This->dwRef);
|
TRACE("(%p) ref=%d\n", This, ref);
|
||||||
TRACE("(%p): ReleaseRef to %d\n", This, dwRef);
|
|
||||||
if (dwRef == 0) {
|
|
||||||
if (This->pStream)
|
|
||||||
destroy_dmcontainer(This);
|
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
|
||||||
unlock_module();
|
|
||||||
}
|
|
||||||
|
|
||||||
return dwRef;
|
if (!ref) {
|
||||||
|
if (This->pStream)
|
||||||
|
destroy_dmcontainer(This);
|
||||||
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
|
unlock_module();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicContainer_EnumObject (LPDIRECTMUSICCONTAINER iface, REFGUID rguidClass, DWORD dwIndex, LPDMUS_OBJECTDESC pDesc, WCHAR* pwszAlias) {
|
static HRESULT WINAPI IDirectMusicContainerImpl_EnumObject(IDirectMusicContainer *iface,
|
||||||
ICOM_THIS_MULTI(IDirectMusicContainerImpl, ContainerVtbl, iface);
|
REFGUID rguidClass, DWORD dwIndex, DMUS_OBJECTDESC *pDesc, WCHAR *pwszAlias)
|
||||||
|
{
|
||||||
|
IDirectMusicContainerImpl *This = impl_from_IDirectMusicContainer(iface);
|
||||||
struct list *pEntry;
|
struct list *pEntry;
|
||||||
LPWINE_CONTAINER_ENTRY pContainedObject;
|
LPWINE_CONTAINER_ENTRY pContainedObject;
|
||||||
DWORD dwCount = 0;
|
DWORD dwCount = 0;
|
||||||
|
@ -155,27 +172,27 @@ static HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicContainer_EnumObject
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const IDirectMusicContainerVtbl DirectMusicContainer_Container_Vtbl = {
|
static const IDirectMusicContainerVtbl dmcontainer_vtbl = {
|
||||||
IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface,
|
IDirectMusicContainerImpl_QueryInterface,
|
||||||
IDirectMusicContainerImpl_IDirectMusicContainer_AddRef,
|
IDirectMusicContainerImpl_AddRef,
|
||||||
IDirectMusicContainerImpl_IDirectMusicContainer_Release,
|
IDirectMusicContainerImpl_Release,
|
||||||
IDirectMusicContainerImpl_IDirectMusicContainer_EnumObject
|
IDirectMusicContainerImpl_EnumObject
|
||||||
};
|
};
|
||||||
|
|
||||||
/* IDirectMusicObject part: */
|
/* IDirectMusicObject part: */
|
||||||
static HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
|
static HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
|
||||||
ICOM_THIS_MULTI(IDirectMusicContainerImpl, ObjectVtbl, iface);
|
ICOM_THIS_MULTI(IDirectMusicContainerImpl, ObjectVtbl, iface);
|
||||||
return IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface ((LPDIRECTMUSICCONTAINER)&This->ContainerVtbl, riid, ppobj);
|
return IDirectMusicContainerImpl_QueryInterface(&This->IDirectMusicContainer_iface, riid, ppobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicContainerImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
|
static ULONG WINAPI IDirectMusicContainerImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
|
||||||
ICOM_THIS_MULTI(IDirectMusicContainerImpl, ObjectVtbl, iface);
|
ICOM_THIS_MULTI(IDirectMusicContainerImpl, ObjectVtbl, iface);
|
||||||
return IDirectMusicContainerImpl_IDirectMusicContainer_AddRef ((LPDIRECTMUSICCONTAINER)&This->ContainerVtbl);
|
return IDirectMusicContainer_AddRef(&This->IDirectMusicContainer_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicContainerImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
|
static ULONG WINAPI IDirectMusicContainerImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
|
||||||
ICOM_THIS_MULTI(IDirectMusicContainerImpl, ObjectVtbl, iface);
|
ICOM_THIS_MULTI(IDirectMusicContainerImpl, ObjectVtbl, iface);
|
||||||
return IDirectMusicContainerImpl_IDirectMusicContainer_Release ((LPDIRECTMUSICCONTAINER)&This->ContainerVtbl);
|
return IDirectMusicContainerImpl_Release(&This->IDirectMusicContainer_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
|
static HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
|
||||||
|
@ -439,17 +456,17 @@ static const IDirectMusicObjectVtbl DirectMusicContainer_Object_Vtbl = {
|
||||||
/* IPersistStream part: */
|
/* IPersistStream part: */
|
||||||
static HRESULT WINAPI IDirectMusicContainerImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
|
static HRESULT WINAPI IDirectMusicContainerImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
|
||||||
ICOM_THIS_MULTI(IDirectMusicContainerImpl, PersistStreamVtbl, iface);
|
ICOM_THIS_MULTI(IDirectMusicContainerImpl, PersistStreamVtbl, iface);
|
||||||
return IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface ((LPDIRECTMUSICCONTAINER)&This->ContainerVtbl, riid, ppobj);
|
return IDirectMusicContainerImpl_QueryInterface(&This->IDirectMusicContainer_iface, riid, ppobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicContainerImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
|
static ULONG WINAPI IDirectMusicContainerImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
|
||||||
ICOM_THIS_MULTI(IDirectMusicContainerImpl, PersistStreamVtbl, iface);
|
ICOM_THIS_MULTI(IDirectMusicContainerImpl, PersistStreamVtbl, iface);
|
||||||
return IDirectMusicContainerImpl_IDirectMusicContainer_AddRef ((LPDIRECTMUSICCONTAINER)&This->ContainerVtbl);
|
return IDirectMusicContainer_AddRef(&This->IDirectMusicContainer_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI IDirectMusicContainerImpl_IPersistStream_Release (LPPERSISTSTREAM iface) {
|
static ULONG WINAPI IDirectMusicContainerImpl_IPersistStream_Release (LPPERSISTSTREAM iface) {
|
||||||
ICOM_THIS_MULTI(IDirectMusicContainerImpl, PersistStreamVtbl, iface);
|
ICOM_THIS_MULTI(IDirectMusicContainerImpl, PersistStreamVtbl, iface);
|
||||||
return IDirectMusicContainerImpl_IDirectMusicContainer_Release ((LPDIRECTMUSICCONTAINER)&This->ContainerVtbl);
|
return IDirectMusicContainerImpl_Release(&This->IDirectMusicContainer_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirectMusicContainerImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
|
static HRESULT WINAPI IDirectMusicContainerImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
|
||||||
|
@ -913,20 +930,24 @@ static const IPersistStreamVtbl DirectMusicContainer_PersistStream_Vtbl = {
|
||||||
HRESULT WINAPI create_dmcontainer(REFIID lpcGUID, void **ppobj)
|
HRESULT WINAPI create_dmcontainer(REFIID lpcGUID, void **ppobj)
|
||||||
{
|
{
|
||||||
IDirectMusicContainerImpl* obj;
|
IDirectMusicContainerImpl* obj;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerImpl));
|
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerImpl));
|
||||||
if (NULL == obj) {
|
if (NULL == obj) {
|
||||||
*ppobj = NULL;
|
*ppobj = NULL;
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
obj->ContainerVtbl = &DirectMusicContainer_Container_Vtbl;
|
obj->IDirectMusicContainer_iface.lpVtbl = &dmcontainer_vtbl;
|
||||||
obj->ObjectVtbl = &DirectMusicContainer_Object_Vtbl;
|
obj->ObjectVtbl = &DirectMusicContainer_Object_Vtbl;
|
||||||
obj->PersistStreamVtbl = &DirectMusicContainer_PersistStream_Vtbl;
|
obj->PersistStreamVtbl = &DirectMusicContainer_PersistStream_Vtbl;
|
||||||
obj->dwRef = 0; /* will be inited by QueryInterface */
|
obj->ref = 1;
|
||||||
obj->pContainedObjects = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(struct list));
|
obj->pContainedObjects = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(struct list));
|
||||||
list_init (obj->pContainedObjects);
|
list_init (obj->pContainedObjects);
|
||||||
|
|
||||||
lock_module();
|
lock_module();
|
||||||
|
|
||||||
return IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface ((LPDIRECTMUSICCONTAINER)&obj->ContainerVtbl, lpcGUID, ppobj);
|
hr = IDirectMusicContainer_QueryInterface(&obj->IDirectMusicContainer_iface, lpcGUID, ppobj);
|
||||||
|
IDirectMusicContainer_Release(&obj->IDirectMusicContainer_iface);
|
||||||
|
|
||||||
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,6 @@ typedef struct IDirectMusicLoaderCF IDirectMusicLoaderCF;
|
||||||
typedef struct IDirectMusicContainerCF IDirectMusicContainerCF;
|
typedef struct IDirectMusicContainerCF IDirectMusicContainerCF;
|
||||||
|
|
||||||
typedef struct IDirectMusicLoaderImpl IDirectMusicLoaderImpl;
|
typedef struct IDirectMusicLoaderImpl IDirectMusicLoaderImpl;
|
||||||
typedef struct IDirectMusicContainerImpl IDirectMusicContainerImpl;
|
|
||||||
|
|
||||||
typedef struct IDirectMusicLoaderFileStream IDirectMusicLoaderFileStream;
|
typedef struct IDirectMusicLoaderFileStream IDirectMusicLoaderFileStream;
|
||||||
typedef struct IDirectMusicLoaderResourceStream IDirectMusicLoaderResourceStream;
|
typedef struct IDirectMusicLoaderResourceStream IDirectMusicLoaderResourceStream;
|
||||||
|
@ -109,26 +108,6 @@ typedef struct _WINE_CONTAINER_ENTRY {
|
||||||
LPDIRECTMUSICOBJECT pObject; /* needed when releasing from loader's cache on container release */
|
LPDIRECTMUSICOBJECT pObject; /* needed when releasing from loader's cache on container release */
|
||||||
} WINE_CONTAINER_ENTRY, *LPWINE_CONTAINER_ENTRY;
|
} WINE_CONTAINER_ENTRY, *LPWINE_CONTAINER_ENTRY;
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* IDirectMusicContainerImpl implementation structure
|
|
||||||
*/
|
|
||||||
struct IDirectMusicContainerImpl {
|
|
||||||
/* VTABLEs */
|
|
||||||
const IDirectMusicContainerVtbl *ContainerVtbl;
|
|
||||||
const IDirectMusicObjectVtbl *ObjectVtbl;
|
|
||||||
const IPersistStreamVtbl *PersistStreamVtbl;
|
|
||||||
/* reference counter */
|
|
||||||
LONG dwRef;
|
|
||||||
/* stream */
|
|
||||||
LPSTREAM pStream;
|
|
||||||
/* header */
|
|
||||||
DMUS_IO_CONTAINER_HEADER Header;
|
|
||||||
/* data */
|
|
||||||
struct list *pContainedObjects;
|
|
||||||
/* descriptor */
|
|
||||||
DMUS_OBJECTDESC Desc;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* IDirectMusicLoaderFileStream implementation structure
|
* IDirectMusicLoaderFileStream implementation structure
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue