dmstyle: Use the generic IPersistStream for DMStyleTrack.

This commit is contained in:
Michael Stefaniuc 2015-07-01 09:27:38 +02:00 committed by Alexandre Julliard
parent f143c16bb8
commit 2026a21525
2 changed files with 23 additions and 63 deletions

View File

@ -27,8 +27,6 @@ typedef struct _DMUS_PRIVATE_CHUNK {
DWORD dwSize; /* size of the chunk */
} DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_CHUNK;
#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
/**
* Parsing utilities
*/

View File

@ -18,6 +18,7 @@
*/
#include "dmstyle_private.h"
#include "dmobject.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
WINE_DECLARE_DEBUG_CHANNEL(dmfile);
@ -27,9 +28,8 @@ WINE_DECLARE_DEBUG_CHANNEL(dmfile);
*/
typedef struct IDirectMusicStyleTrack {
IDirectMusicTrack8 IDirectMusicTrack8_iface;
const IPersistStreamVtbl *PersistStreamVtbl;
struct dmobject dmobj; /* IPersistStream only */
LONG ref;
DMUS_OBJECTDESC *pDesc;
struct list Items;
} IDirectMusicStyleTrack;
@ -52,7 +52,7 @@ static HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface(IDirectMusicTrack8 *
IsEqualIID(riid, &IID_IDirectMusicTrack8))
*ret_iface = iface;
else if (IsEqualIID(riid, &IID_IPersistStream))
*ret_iface = &This->PersistStreamVtbl;
*ret_iface = &This->dmobj.IPersistStream_iface;
else {
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
return E_NOINTERFACE;
@ -250,35 +250,6 @@ static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = {
IDirectMusicTrack8Impl_Join
};
/* IDirectMusicStyleTrack IPersistStream part: */
static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
return IDirectMusicTrack8_QueryInterface(&This->IDirectMusicTrack8_iface, riid, ppobj);
}
static ULONG WINAPI IDirectMusicStyleTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
return IDirectMusicTrack8_AddRef(&This->IDirectMusicTrack8_iface);
}
static ULONG WINAPI IDirectMusicStyleTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
return IDirectMusicTrack8_Release(&This->IDirectMusicTrack8_iface);
}
static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
TRACE("(%p, %p)\n", This, pClassID);
*pClassID = CLSID_DirectMusicStyleTrack;
return S_OK;
}
static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
FIXME("(%p): stub, always S_FALSE\n", This);
return S_FALSE;
}
static HRESULT parse_style_ref(IDirectMusicStyleTrack *This, DMUS_PRIVATE_CHUNK *pChunk,
IStream *pStm)
{
@ -326,7 +297,7 @@ static HRESULT parse_style_ref(IDirectMusicStyleTrack *This, DMUS_PRIVATE_CHUNK
*/
case DMUS_FOURCC_REF_LIST: {
FIXME_(dmfile)(": DMRF (DM References) list, not yet handled\n");
hr = IDirectMusicUtils_IPersistStream_ParseReference((IPersistStream*)&This->PersistStreamVtbl,
hr = IDirectMusicUtils_IPersistStream_ParseReference(&This->dmobj.IPersistStream_iface,
&Chunk, pStm, &pObject);
if (FAILED(hr)) {
ERR(": could not load Reference\n");
@ -418,9 +389,14 @@ static HRESULT parse_styletrack_list(IDirectMusicStyleTrack *This, DMUS_PRIVATE_
return S_OK;
}
static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
static inline IDirectMusicStyleTrack *impl_from_IPersistStream(IPersistStream *iface)
{
return CONTAINING_RECORD(iface, IDirectMusicStyleTrack, dmobj.IPersistStream_iface);
}
static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pStm)
{
IDirectMusicStyleTrack *This = impl_from_IPersistStream(iface);
DMUS_PRIVATE_CHUNK Chunk;
LARGE_INTEGER liMove;
HRESULT hr;
@ -461,27 +437,15 @@ static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_Load (LPPERSISTSTREA
return S_OK;
}
static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
FIXME("(%p): Saving not implemented yet\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
FIXME("(%p, %p): stub\n", This, pcbSize);
return E_NOTIMPL;
}
static const IPersistStreamVtbl DirectMusicStyleTrack_PersistStream_Vtbl = {
IDirectMusicStyleTrack_IPersistStream_QueryInterface,
IDirectMusicStyleTrack_IPersistStream_AddRef,
IDirectMusicStyleTrack_IPersistStream_Release,
IDirectMusicStyleTrack_IPersistStream_GetClassID,
IDirectMusicStyleTrack_IPersistStream_IsDirty,
IDirectMusicStyleTrack_IPersistStream_Load,
IDirectMusicStyleTrack_IPersistStream_Save,
IDirectMusicStyleTrack_IPersistStream_GetSizeMax
static const IPersistStreamVtbl persiststream_vtbl = {
dmobj_IPersistStream_QueryInterface,
dmobj_IPersistStream_AddRef,
dmobj_IPersistStream_Release,
dmobj_IPersistStream_GetClassID,
unimpl_IPersistStream_IsDirty,
IPersistStreamImpl_Load,
unimpl_IPersistStream_Save,
unimpl_IPersistStream_GetSizeMax
};
/* for ClassFactory */
@ -496,12 +460,10 @@ HRESULT WINAPI create_dmstyletrack(REFIID lpcGUID, void **ppobj)
return E_OUTOFMEMORY;
}
track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
track->PersistStreamVtbl = &DirectMusicStyleTrack_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_DirectMusicStyleTrack;
track->ref = 1;
dmobject_init(&track->dmobj, &CLSID_DirectMusicStyleTrack,
(IUnknown *)&track->IDirectMusicTrack8_iface);
track->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
list_init (&track->Items);
DMSTYLE_LockModule();