dmusic: COM cleanup of IDirectMusicDownload.

This commit is contained in:
Christian Costa 2013-01-09 10:22:55 +01:00 committed by Alexandre Julliard
parent ba6932459a
commit 1c77528a89
2 changed files with 66 additions and 52 deletions

View File

@ -148,11 +148,11 @@ struct IDirectMusicDownloadedInstrumentImpl {
* IDirectMusicDownloadImpl implementation structure * IDirectMusicDownloadImpl implementation structure
*/ */
struct IDirectMusicDownloadImpl { struct IDirectMusicDownloadImpl {
/* IUnknown fields */ /* IUnknown fields */
const IDirectMusicDownloadVtbl *lpVtbl; IDirectMusicDownload IDirectMusicDownload_iface;
LONG ref; LONG ref;
/* IDirectMusicDownloadImpl fields */ /* IDirectMusicDownloadImpl fields */
}; };
/***************************************************************************** /*****************************************************************************

View File

@ -1,4 +1,5 @@
/* IDirectMusicDownload Implementation /*
* IDirectMusicDownload Implementation
* *
* Copyright (C) 2003-2004 Rok Mandeljc * Copyright (C) 2003-2004 Rok Mandeljc
* *
@ -21,72 +22,85 @@
WINE_DEFAULT_DEBUG_CHANNEL(dmusic); WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
static inline IDirectMusicDownloadImpl* impl_from_IDirectMusicDownload(IDirectMusicDownload *iface)
{
return CONTAINING_RECORD(iface, IDirectMusicDownloadImpl, IDirectMusicDownload_iface);
}
/* IDirectMusicDownloadImpl IUnknown part: */ /* IDirectMusicDownloadImpl IUnknown part: */
static HRESULT WINAPI IDirectMusicDownloadImpl_QueryInterface (LPDIRECTMUSICDOWNLOAD iface, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI IDirectMusicDownloadImpl_QueryInterface(IDirectMusicDownload *iface, REFIID riid, void **ret_iface)
IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface; {
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj); TRACE("(%p, %s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
if (IsEqualIID (riid, &IID_IUnknown) if (IsEqualIID(riid, &IID_IUnknown) ||
|| IsEqualIID (riid, &IID_IDirectMusicDownload)) { IsEqualIID(riid, &IID_IDirectMusicDownload))
IUnknown_AddRef(iface); {
*ppobj = This; IDirectMusicDownload_AddRef(iface);
return S_OK; *ret_iface = iface;
} return S_OK;
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj); }
return E_NOINTERFACE;
*ret_iface = NULL;
WARN("(%p, %s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
return E_NOINTERFACE;
} }
static ULONG WINAPI IDirectMusicDownloadImpl_AddRef (LPDIRECTMUSICDOWNLOAD iface) { static ULONG WINAPI IDirectMusicDownloadImpl_AddRef(IDirectMusicDownload *iface)
IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface; {
ULONG refCount = InterlockedIncrement(&This->ref); IDirectMusicDownloadImpl *This = impl_from_IDirectMusicDownload(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before=%u)\n", This, refCount - 1); TRACE("(%p)->(): new ref = %u\n", iface, ref);
DMUSIC_LockModule(); DMUSIC_LockModule();
return refCount; return ref;
} }
static ULONG WINAPI IDirectMusicDownloadImpl_Release (LPDIRECTMUSICDOWNLOAD iface) { static ULONG WINAPI IDirectMusicDownloadImpl_Release(IDirectMusicDownload *iface)
IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface; {
ULONG refCount = InterlockedDecrement(&This->ref); IDirectMusicDownloadImpl *This = impl_from_IDirectMusicDownload(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%u)\n", This, refCount + 1); TRACE("(%p)->(): new ref = %u\n", iface, ref);
if (!refCount) { if (!ref)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
}
DMUSIC_UnlockModule(); DMUSIC_UnlockModule();
return refCount; return ref;
} }
/* IDirectMusicDownloadImpl IDirectMusicDownload part: */ /* IDirectMusicDownloadImpl IDirectMusicDownload part: */
static HRESULT WINAPI IDirectMusicDownloadImpl_GetBuffer (LPDIRECTMUSICDOWNLOAD iface, void** ppvBuffer, DWORD* pdwSize) { static HRESULT WINAPI IDirectMusicDownloadImpl_GetBuffer(IDirectMusicDownload *iface, void **buffer, DWORD *size)
IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface; {
FIXME("(%p, %p, %p): stub\n", This, ppvBuffer, pdwSize); FIXME("(%p, %p, %p): stub\n", iface, buffer, size);
return S_OK;
return S_OK;
} }
static const IDirectMusicDownloadVtbl DirectMusicDownload_Vtbl = { static const IDirectMusicDownloadVtbl DirectMusicDownload_Vtbl = {
IDirectMusicDownloadImpl_QueryInterface, IDirectMusicDownloadImpl_QueryInterface,
IDirectMusicDownloadImpl_AddRef, IDirectMusicDownloadImpl_AddRef,
IDirectMusicDownloadImpl_Release, IDirectMusicDownloadImpl_Release,
IDirectMusicDownloadImpl_GetBuffer IDirectMusicDownloadImpl_GetBuffer
}; };
/* for ClassFactory */ /* for ClassFactory */
HRESULT DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) { HRESULT DMUSIC_CreateDirectMusicDownloadImpl(const GUID *guid, void **ret_iface, IUnknown *unk_outer)
IDirectMusicDownloadImpl* dmdl; {
IDirectMusicDownloadImpl *download;
dmdl = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicDownloadImpl));
if (NULL == dmdl) { download = HeapAlloc(GetProcessHeap(), 0, sizeof(*download));
*ppobj = NULL; if (!download)
return E_OUTOFMEMORY; {
} *ret_iface = NULL;
dmdl->lpVtbl = &DirectMusicDownload_Vtbl; return E_OUTOFMEMORY;
dmdl->ref = 0; /* will be inited by QueryInterface */ }
return IDirectMusicDownloadImpl_QueryInterface ((LPDIRECTMUSICDOWNLOAD)dmdl, lpcGUID, ppobj); download->IDirectMusicDownload_iface.lpVtbl = &DirectMusicDownload_Vtbl;
download->ref = 1;
return S_OK;
} }