Commit 03c75b9c authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

dmusic: COM cleanup of IDirectMusicInstrument and get rid of separated IUnknown interface.

parent 8ed11d8b
...@@ -142,7 +142,7 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_EnumInst ...@@ -142,7 +142,7 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_EnumInst
LIST_FOR_EACH (listEntry, &This->Instruments) { LIST_FOR_EACH (listEntry, &This->Instruments) {
tmpEntry = LIST_ENTRY(listEntry, DMUS_PRIVATE_INSTRUMENTENTRY, entry); tmpEntry = LIST_ENTRY(listEntry, DMUS_PRIVATE_INSTRUMENTENTRY, entry);
if (r == dwIndex) { if (r == dwIndex) {
ICOM_NAME_MULTI (IDirectMusicInstrumentImpl, InstrumentVtbl, tmpEntry->pInstrument, pInstrument); IDirectMusicInstrumentImpl *pInstrument = impl_from_IDirectMusicInstrument(tmpEntry->pInstrument);
IDirectMusicInstrument_GetPatch (tmpEntry->pInstrument, pdwPatch); IDirectMusicInstrument_GetPatch (tmpEntry->pInstrument, pdwPatch);
if (pwszName) { if (pwszName) {
dwLen = min(strlenW(pInstrument->wszName),dwNameLen-1); dwLen = min(strlenW(pInstrument->wszName),dwNameLen-1);
...@@ -606,7 +606,7 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load (LPPERSISTS ...@@ -606,7 +606,7 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load (LPPERSISTS
TRACE_(dmfile)(": instrument list\n"); TRACE_(dmfile)(": instrument list\n");
DMUSIC_CreateDirectMusicInstrumentImpl (&IID_IDirectMusicInstrument, (LPVOID*)&pNewInstrument->pInstrument, NULL); /* only way to create this one... even M$ does it discretely */ DMUSIC_CreateDirectMusicInstrumentImpl (&IID_IDirectMusicInstrument, (LPVOID*)&pNewInstrument->pInstrument, NULL); /* only way to create this one... even M$ does it discretely */
{ {
ICOM_NAME_MULTI (IDirectMusicInstrumentImpl, InstrumentVtbl, pNewInstrument->pInstrument, pInstrument); IDirectMusicInstrumentImpl *pInstrument = impl_from_IDirectMusicInstrument(pNewInstrument->pInstrument);
liMove.QuadPart = 0; liMove.QuadPart = 0;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, &dlibInstrumentPosition); IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, &dlibInstrumentPosition);
pInstrument->liInstrumentPosition.QuadPart = dlibInstrumentPosition.QuadPart - (2*sizeof(FOURCC) + sizeof(DWORD)); /* store offset, it'll be needed later */ pInstrument->liInstrumentPosition.QuadPart = dlibInstrumentPosition.QuadPart - (2*sizeof(FOURCC) + sizeof(DWORD)); /* store offset, it'll be needed later */
......
...@@ -214,8 +214,7 @@ struct IDirectMusicCollectionImpl { ...@@ -214,8 +214,7 @@ struct IDirectMusicCollectionImpl {
*/ */
struct IDirectMusicInstrumentImpl { struct IDirectMusicInstrumentImpl {
/* IUnknown fields */ /* IUnknown fields */
const IUnknownVtbl *UnknownVtbl; IDirectMusicInstrument IDirectMusicInstrument_iface;
const IDirectMusicInstrumentVtbl *InstrumentVtbl;
LONG ref; LONG ref;
/* IDirectMusicInstrumentImpl fields */ /* IDirectMusicInstrumentImpl fields */
...@@ -226,6 +225,11 @@ struct IDirectMusicInstrumentImpl { ...@@ -226,6 +225,11 @@ struct IDirectMusicInstrumentImpl {
/* instrument data */ /* instrument data */
}; };
static inline IDirectMusicInstrumentImpl *impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
{
return CONTAINING_RECORD(iface, IDirectMusicInstrumentImpl, IDirectMusicInstrument_iface);
}
/* custom :) */ /* custom :) */
extern HRESULT IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm) DECLSPEC_HIDDEN; extern HRESULT IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm) DECLSPEC_HIDDEN;
......
/* IDirectMusicInstrument Implementation /*
* IDirectMusicInstrument Implementation
* *
* Copyright (C) 2003-2004 Rok Mandeljc * Copyright (C) 2003-2004 Rok Mandeljc
* *
...@@ -21,41 +22,42 @@ ...@@ -21,41 +22,42 @@
WINE_DEFAULT_DEBUG_CHANNEL(dmusic); WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
static const GUID IID_IDirectMusicInstrumentPRIVATE = {0xbcb20080,0xa40c,0x11d1,{0x86,0xbc,0x00,0xc0,0x4f,0xbf,0x8f,0xef}}; static const GUID IID_IDirectMusicInstrumentPRIVATE = { 0xbcb20080, 0xa40c, 0x11d1, { 0x86, 0xbc, 0x00, 0xc0, 0x4f, 0xbf, 0x8f, 0xef } };
static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_AddRef (LPUNKNOWN iface);
static ULONG WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef (LPDIRECTMUSICINSTRUMENT iface);
/* IDirectMusicInstrument IUnknown part: */ /* IDirectMusicInstrument IUnknown part: */
static HRESULT WINAPI IDirectMusicInstrumentImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI IDirectMusicInstrumentImpl_QueryInterface(LPDIRECTMUSICINSTRUMENT iface, REFIID riid, LPVOID *ret_iface)
ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, UnknownVtbl, 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) ||
*ppobj = &This->UnknownVtbl; IsEqualIID(riid, &IID_IDirectMusicInstrument))
IDirectMusicInstrumentImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl); {
return S_OK; *ret_iface = iface;
} else if (IsEqualIID (riid, &IID_IDirectMusicInstrument)) { IDirectMusicInstrument_AddRef(iface);
*ppobj = &This->InstrumentVtbl; return S_OK;
IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef ((LPDIRECTMUSICINSTRUMENT)&This->InstrumentVtbl); }
return S_OK; else if (IsEqualIID(riid, &IID_IDirectMusicInstrumentPRIVATE))
} else if (IsEqualIID (riid, &IID_IDirectMusicInstrumentPRIVATE)) { {
/* it seems to me that this interface is only basic IUnknown, without any /* it seems to me that this interface is only basic IUnknown, without any
other inherited functions... *sigh* this is the worst scenario, since it means * other inherited functions... *sigh* this is the worst scenario, since it means
that whoever calls it knows the layout of original implementation table and therefore * that whoever calls it knows the layout of original implementation table and therefore
tries to get data by direct access... expect crashes */ * tries to get data by direct access... expect crashes
FIXME("*sigh*... requested private/unspecified interface\n"); */
*ppobj = &This->UnknownVtbl; FIXME("*sigh*... requested private/unspecified interface\n");
IDirectMusicInstrumentImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
return S_OK; *ret_iface = iface;
} IDirectMusicInstrument_AddRef(iface);
return S_OK;
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj); }
return E_NOINTERFACE;
WARN("(%p)->(%s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
return E_NOINTERFACE;
} }
static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_AddRef (LPUNKNOWN iface) { static ULONG WINAPI IDirectMusicInstrumentImpl_AddRef(LPDIRECTMUSICINSTRUMENT iface)
ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, UnknownVtbl, iface); {
IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
ULONG refCount = InterlockedIncrement(&This->ref); ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before=%u)\n", This, refCount - 1); TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
...@@ -65,8 +67,9 @@ static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_AddRef (LPUNKNOWN iface) ...@@ -65,8 +67,9 @@ static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_AddRef (LPUNKNOWN iface)
return refCount; return refCount;
} }
static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_Release (LPUNKNOWN iface) { static ULONG WINAPI IDirectMusicInstrumentImpl_Release(LPDIRECTMUSICINSTRUMENT iface)
ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, UnknownVtbl, iface); {
IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
ULONG refCount = InterlockedDecrement(&This->ref); ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%u)\n", This, refCount + 1); TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
...@@ -80,48 +83,36 @@ static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_Release (LPUNKNOWN iface ...@@ -80,48 +83,36 @@ static ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_Release (LPUNKNOWN iface
return refCount; return refCount;
} }
static const IUnknownVtbl DirectMusicInstrument_Unknown_Vtbl = {
IDirectMusicInstrumentImpl_IUnknown_QueryInterface,
IDirectMusicInstrumentImpl_IUnknown_AddRef,
IDirectMusicInstrumentImpl_IUnknown_Release
};
/* IDirectMusicInstrumentImpl IDirectMusicInstrument part: */ /* IDirectMusicInstrumentImpl IDirectMusicInstrument part: */
static HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_QueryInterface (LPDIRECTMUSICINSTRUMENT iface, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI IDirectMusicInstrumentImpl_GetPatch(LPDIRECTMUSICINSTRUMENT iface, DWORD* pdwPatch)
ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface); {
return IDirectMusicInstrumentImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj); IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
}
static ULONG WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef (LPDIRECTMUSICINSTRUMENT iface) { TRACE("(%p)->(%p)\n", This, pdwPatch);
ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
return IDirectMusicInstrumentImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
}
static ULONG WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_Release (LPDIRECTMUSICINSTRUMENT iface) { *pdwPatch = MIDILOCALE2Patch(&This->pHeader->Locale);
ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
return IDirectMusicInstrumentImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
}
static HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_GetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD* pdwPatch) { return S_OK;
ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface);
TRACE("(%p, %p)\n", This, pdwPatch);
*pdwPatch = MIDILOCALE2Patch(&This->pHeader->Locale);
return S_OK;
} }
static HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_SetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch) { static HRESULT WINAPI IDirectMusicInstrumentImpl_SetPatch(LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch)
ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface); {
TRACE("(%p, %d): stub\n", This, dwPatch); IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
Patch2MIDILOCALE(dwPatch, &This->pHeader->Locale);
return S_OK; TRACE("(%p)->(%d): stub\n", This, dwPatch);
Patch2MIDILOCALE(dwPatch, &This->pHeader->Locale);
return S_OK;
} }
static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Instrument_Vtbl = { static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Vtbl =
IDirectMusicInstrumentImpl_IDirectMusicInstrument_QueryInterface, {
IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef, IDirectMusicInstrumentImpl_QueryInterface,
IDirectMusicInstrumentImpl_IDirectMusicInstrument_Release, IDirectMusicInstrumentImpl_AddRef,
IDirectMusicInstrumentImpl_IDirectMusicInstrument_GetPatch, IDirectMusicInstrumentImpl_Release,
IDirectMusicInstrumentImpl_IDirectMusicInstrument_SetPatch IDirectMusicInstrumentImpl_GetPatch,
IDirectMusicInstrumentImpl_SetPatch
}; };
/* for ClassFactory */ /* for ClassFactory */
...@@ -133,11 +124,10 @@ HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, ...@@ -133,11 +124,10 @@ HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj,
*ppobj = NULL; *ppobj = NULL;
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
dminst->UnknownVtbl = &DirectMusicInstrument_Unknown_Vtbl; dminst->IDirectMusicInstrument_iface.lpVtbl = &DirectMusicInstrument_Vtbl;
dminst->InstrumentVtbl = &DirectMusicInstrument_Instrument_Vtbl;
dminst->ref = 0; /* will be inited by QueryInterface */ dminst->ref = 0; /* will be inited by QueryInterface */
return IDirectMusicInstrumentImpl_IUnknown_QueryInterface ((LPUNKNOWN)&dminst->UnknownVtbl, lpcGUID, ppobj); return IDirectMusicInstrument_QueryInterface(&dminst->IDirectMusicInstrument_iface, lpcGUID, ppobj);
} }
static HRESULT read_from_stream(IStream *stream, void *data, ULONG size) static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)
...@@ -238,9 +228,9 @@ static HRESULT load_instrument(IDirectMusicInstrumentImpl *This, IStream *stream ...@@ -238,9 +228,9 @@ static HRESULT load_instrument(IDirectMusicInstrumentImpl *This, IStream *stream
/* aux. function that completely loads instrument; my tests indicate that it's /* aux. function that completely loads instrument; my tests indicate that it's
called somewhere around IDirectMusicCollection_GetInstrument */ called somewhere around IDirectMusicCollection_GetInstrument */
HRESULT IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM stream) HRESULT IDirectMusicInstrumentImpl_Custom_Load(LPDIRECTMUSICINSTRUMENT iface, LPSTREAM stream)
{ {
ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, InstrumentVtbl, iface); IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
LARGE_INTEGER move; LARGE_INTEGER move;
FOURCC fourcc; FOURCC fourcc;
DWORD bytes; DWORD bytes;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment