dmstyle: Use the generic DirectMusicObject implementation for DMStyle.

This commit is contained in:
Michael Stefaniuc 2015-06-10 23:48:15 +02:00 committed by Alexandre Julliard
parent b8149561ec
commit 3ebf41cc42
4 changed files with 281 additions and 131 deletions

View File

@ -5,6 +5,7 @@ C_SRCS = \
auditiontrack.c \ auditiontrack.c \
chordtrack.c \ chordtrack.c \
commandtrack.c \ commandtrack.c \
dmobject.c \
dmstyle_main.c \ dmstyle_main.c \
dmutils.c \ dmutils.c \
motiftrack.c \ motiftrack.c \

185
dlls/dmstyle/dmobject.c Normal file
View File

@ -0,0 +1,185 @@
/*
* Base IDirectMusicObject Implementation
* Keep in sync with the master in dlls/dmusic/dmobject.c
*
* Copyright (C) 2003-2004 Rok Mandeljc
* Copyright (C) 2014 Michael Stefaniuc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "objbase.h"
#include "dmusici.h"
#include "dmobject.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmobj);
/* Generic IDirectMusicObject methods */
static inline struct dmobject *impl_from_IDirectMusicObject(IDirectMusicObject *iface)
{
return CONTAINING_RECORD(iface, struct dmobject, IDirectMusicObject_iface);
}
HRESULT WINAPI dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject *iface, REFIID riid,
void **ret_iface)
{
struct dmobject *This = impl_from_IDirectMusicObject(iface);
return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
}
ULONG WINAPI dmobj_IDirectMusicObject_AddRef(IDirectMusicObject *iface)
{
struct dmobject *This = impl_from_IDirectMusicObject(iface);
return IUnknown_AddRef(This->outer_unk);
}
ULONG WINAPI dmobj_IDirectMusicObject_Release(IDirectMusicObject *iface)
{
struct dmobject *This = impl_from_IDirectMusicObject(iface);
return IUnknown_Release(This->outer_unk);
}
HRESULT WINAPI dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject *iface,
DMUS_OBJECTDESC *desc)
{
struct dmobject *This = impl_from_IDirectMusicObject(iface);
TRACE("(%p/%p)->(%p)\n", iface, This, desc);
if (!desc)
return E_POINTER;
memcpy(desc, &This->desc, This->desc.dwSize);
return S_OK;
}
HRESULT WINAPI dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject *iface,
DMUS_OBJECTDESC *desc)
{
struct dmobject *This = impl_from_IDirectMusicObject(iface);
HRESULT ret = S_OK;
TRACE("(%p, %p)\n", iface, desc);
if (!desc)
return E_POINTER;
/* Immutable property */
if (desc->dwValidData & DMUS_OBJ_CLASS)
{
desc->dwValidData &= ~DMUS_OBJ_CLASS;
ret = S_FALSE;
}
/* Set only valid fields */
if (desc->dwValidData & DMUS_OBJ_OBJECT)
This->desc.guidObject = desc->guidObject;
if (desc->dwValidData & DMUS_OBJ_NAME)
lstrcpynW(This->desc.wszName, desc->wszName, DMUS_MAX_NAME);
if (desc->dwValidData & DMUS_OBJ_CATEGORY)
lstrcpynW(This->desc.wszCategory, desc->wszCategory, DMUS_MAX_CATEGORY);
if (desc->dwValidData & DMUS_OBJ_FILENAME)
lstrcpynW(This->desc.wszFileName, desc->wszFileName, DMUS_MAX_FILENAME);
if (desc->dwValidData & DMUS_OBJ_VERSION)
This->desc.vVersion = desc->vVersion;
if (desc->dwValidData & DMUS_OBJ_DATE)
This->desc.ftDate = desc->ftDate;
if (desc->dwValidData & DMUS_OBJ_MEMORY) {
This->desc.llMemLength = desc->llMemLength;
memcpy(This->desc.pbMemData, desc->pbMemData, desc->llMemLength);
}
if (desc->dwValidData & DMUS_OBJ_STREAM)
IStream_Clone(desc->pStream, &This->desc.pStream);
This->desc.dwValidData |= desc->dwValidData;
return ret;
}
/* Generic IPersistStream methods */
static inline struct dmobject *impl_from_IPersistStream(IPersistStream *iface)
{
return CONTAINING_RECORD(iface, struct dmobject, IPersistStream_iface);
}
HRESULT WINAPI dmobj_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid,
void **ret_iface)
{
struct dmobject *This = impl_from_IPersistStream(iface);
return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
}
ULONG WINAPI dmobj_IPersistStream_AddRef(IPersistStream *iface)
{
struct dmobject *This = impl_from_IPersistStream(iface);
return IUnknown_AddRef(This->outer_unk);
}
ULONG WINAPI dmobj_IPersistStream_Release(IPersistStream *iface)
{
struct dmobject *This = impl_from_IPersistStream(iface);
return IUnknown_Release(This->outer_unk);
}
HRESULT WINAPI dmobj_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class)
{
struct dmobject *This = impl_from_IPersistStream(iface);
TRACE("(%p, %p)\n", This, class);
if (!class)
return E_POINTER;
*class = This->desc.guidClass;
return S_OK;
}
/* IPersistStream methods not implemented in native */
HRESULT WINAPI unimpl_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class)
{
TRACE("(%p, %p): method not implemented\n", iface, class);
return E_NOTIMPL;
}
HRESULT WINAPI unimpl_IPersistStream_IsDirty(IPersistStream *iface)
{
TRACE("(%p): method not implemented, always returning S_FALSE\n", iface);
return S_FALSE;
}
HRESULT WINAPI unimpl_IPersistStream_Save(IPersistStream *iface, IStream *stream,
BOOL clear_dirty)
{
TRACE("(%p, %p, %d): method not implemented\n", iface, stream, clear_dirty);
return E_NOTIMPL;
}
HRESULT WINAPI unimpl_IPersistStream_GetSizeMax(IPersistStream *iface, ULARGE_INTEGER *size)
{
TRACE("(%p, %p): method not implemented\n", iface, size);
return E_NOTIMPL;
}
void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk)
{
dmobj->outer_unk = outer_unk;
dmobj->desc.dwSize = sizeof(dmobj->desc);
dmobj->desc.dwValidData = DMUS_OBJ_CLASS;
dmobj->desc.guidClass = *class;
}

55
dlls/dmstyle/dmobject.h Normal file
View File

@ -0,0 +1,55 @@
/*
* Base IDirectMusicObject Implementation
* Keep in sync with the master in dlls/dmusic/dmobject.h
*
* Copyright (C) 2014 Michael Stefaniuc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
struct dmobject {
IDirectMusicObject IDirectMusicObject_iface;
IPersistStream IPersistStream_iface;
IUnknown *outer_unk;
DMUS_OBJECTDESC desc;
};
void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk) DECLSPEC_HIDDEN;
/* Generic IDirectMusicObject methods */
HRESULT WINAPI dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject *iface, REFIID riid,
void **ret_iface) DECLSPEC_HIDDEN;
ULONG WINAPI dmobj_IDirectMusicObject_AddRef(IDirectMusicObject *iface) DECLSPEC_HIDDEN;
ULONG WINAPI dmobj_IDirectMusicObject_Release(IDirectMusicObject *iface) DECLSPEC_HIDDEN;
HRESULT WINAPI dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject *iface,
DMUS_OBJECTDESC *desc) DECLSPEC_HIDDEN;
HRESULT WINAPI dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject *iface,
DMUS_OBJECTDESC *desc) DECLSPEC_HIDDEN;
/* Generic IPersistStream methods */
HRESULT WINAPI dmobj_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid,
void **ret_iface) DECLSPEC_HIDDEN;
ULONG WINAPI dmobj_IPersistStream_AddRef(IPersistStream *iface) DECLSPEC_HIDDEN;
ULONG WINAPI dmobj_IPersistStream_Release(IPersistStream *iface) DECLSPEC_HIDDEN;
HRESULT WINAPI dmobj_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class) DECLSPEC_HIDDEN;
/* IPersistStream methods not implemented in native */
HRESULT WINAPI unimpl_IPersistStream_GetClassID(IPersistStream *iface,
CLSID *class) DECLSPEC_HIDDEN;
HRESULT WINAPI unimpl_IPersistStream_IsDirty(IPersistStream *iface) DECLSPEC_HIDDEN;
HRESULT WINAPI unimpl_IPersistStream_Save(IPersistStream *iface, IStream *stream,
BOOL clear_dirty) DECLSPEC_HIDDEN;
HRESULT WINAPI unimpl_IPersistStream_GetSizeMax(IPersistStream *iface,
ULARGE_INTEGER *size) DECLSPEC_HIDDEN;

View File

@ -19,6 +19,7 @@
*/ */
#include "dmstyle_private.h" #include "dmstyle_private.h"
#include "dmobject.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmstyle); WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
WINE_DECLARE_DEBUG_CHANNEL(dmfile); WINE_DECLARE_DEBUG_CHANNEL(dmfile);
@ -28,10 +29,8 @@ WINE_DECLARE_DEBUG_CHANNEL(dmfile);
*/ */
typedef struct IDirectMusicStyle8Impl { typedef struct IDirectMusicStyle8Impl {
IDirectMusicStyle8 IDirectMusicStyle8_iface; IDirectMusicStyle8 IDirectMusicStyle8_iface;
const IDirectMusicObjectVtbl *ObjectVtbl; struct dmobject dmobj;
const IPersistStreamVtbl *PersistStreamVtbl;
LONG ref; LONG ref;
DMUS_OBJECTDESC *pDesc;
DMUS_IO_STYLE style; DMUS_IO_STYLE style;
struct list Motifs; struct list Motifs;
struct list Bands; struct list Bands;
@ -56,9 +55,9 @@ static HRESULT WINAPI IDirectMusicStyle8Impl_QueryInterface(IDirectMusicStyle8 *
IsEqualIID(riid, &IID_IDirectMusicStyle8)) IsEqualIID(riid, &IID_IDirectMusicStyle8))
*ret_iface = iface; *ret_iface = iface;
else if (IsEqualIID(riid, &IID_IDirectMusicObject)) else if (IsEqualIID(riid, &IID_IDirectMusicObject))
*ret_iface = &This->ObjectVtbl; *ret_iface = &This->dmobj.IDirectMusicObject_iface;
else if (IsEqualIID(riid, &IID_IPersistStream)) else if (IsEqualIID(riid, &IID_IPersistStream))
*ret_iface = &This->PersistStreamVtbl; *ret_iface = &This->dmobj.IPersistStream_iface;
else { else {
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface); WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
return E_NOINTERFACE; return E_NOINTERFACE;
@ -86,7 +85,6 @@ static ULONG WINAPI IDirectMusicStyle8Impl_Release(IDirectMusicStyle8 *iface)
TRACE("(%p) ref=%d\n", This, ref); TRACE("(%p) ref=%d\n", This, ref);
if (!ref) { if (!ref) {
HeapFree(GetProcessHeap(), 0, This->pDesc);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
DMSTYLE_UnlockModule(); DMSTYLE_UnlockModule();
} }
@ -209,65 +207,15 @@ static const IDirectMusicStyle8Vtbl dmstyle8_vtbl = {
}; };
/* IDirectMusicStyle8Impl IDirectMusicObject part: */ /* IDirectMusicStyle8Impl IDirectMusicObject part: */
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) { static inline IDirectMusicStyle8Impl *impl_from_IDirectMusicObject(IDirectMusicObject *iface)
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface); {
return IDirectMusicStyle8_QueryInterface(&This->IDirectMusicStyle8_iface, riid, ppobj); return CONTAINING_RECORD(iface, IDirectMusicStyle8Impl, dmobj.IDirectMusicObject_iface);
} }
static ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) { static HRESULT WINAPI IDirectMusicObjectImpl_ParseDescriptor(IDirectMusicObject *iface,
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface); IStream *pStream, DMUS_OBJECTDESC *pDesc)
return IDirectMusicStyle8_AddRef(&This->IDirectMusicStyle8_iface); {
} IDirectMusicStyle8Impl *This = impl_from_IDirectMusicObject(iface);
static ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
return IDirectMusicStyle8_Release(&This->IDirectMusicStyle8_iface);
}
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
TRACE("(%p, %p)\n", This, pDesc);
/* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
return S_OK;
}
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc));
/* According to MSDN, we should copy only given values, not whole struct */
if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
This->pDesc->guidObject = pDesc->guidObject;
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
This->pDesc->guidClass = pDesc->guidClass;
if (pDesc->dwValidData & DMUS_OBJ_NAME)
lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
This->pDesc->vVersion = pDesc->vVersion;
if (pDesc->dwValidData & DMUS_OBJ_DATE)
This->pDesc->ftDate = pDesc->ftDate;
if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
This->pDesc->llMemLength = pDesc->llMemLength;
memcpy (This->pDesc->pbMemData, pDesc->pbMemData, pDesc->llMemLength);
}
if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
/* according to MSDN, we copy the stream */
IStream_Clone (pDesc->pStream, &This->pDesc->pStream);
}
/* add new flags */
This->pDesc->dwValidData |= pDesc->dwValidData;
return S_OK;
}
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
DMUS_PRIVATE_CHUNK Chunk; DMUS_PRIVATE_CHUNK Chunk;
DWORD StreamSize, StreamCount, ListSize[1], ListCount[1]; DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
LARGE_INTEGER liMove; /* used when skipping chunks */ LARGE_INTEGER liMove; /* used when skipping chunks */
@ -414,42 +362,19 @@ static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_ParseDescriptor
return S_OK; return S_OK;
} }
static const IDirectMusicObjectVtbl DirectMusicStyle8_Object_Vtbl = { static const IDirectMusicObjectVtbl dmobject_vtbl = {
IDirectMusicStyle8Impl_IDirectMusicObject_QueryInterface, dmobj_IDirectMusicObject_QueryInterface,
IDirectMusicStyle8Impl_IDirectMusicObject_AddRef, dmobj_IDirectMusicObject_AddRef,
IDirectMusicStyle8Impl_IDirectMusicObject_Release, dmobj_IDirectMusicObject_Release,
IDirectMusicStyle8Impl_IDirectMusicObject_GetDescriptor, dmobj_IDirectMusicObject_GetDescriptor,
IDirectMusicStyle8Impl_IDirectMusicObject_SetDescriptor, dmobj_IDirectMusicObject_SetDescriptor,
IDirectMusicStyle8Impl_IDirectMusicObject_ParseDescriptor IDirectMusicObjectImpl_ParseDescriptor
}; };
/* IDirectMusicStyle8Impl IPersistStream part: */ /* IDirectMusicStyle8Impl IPersistStream part: */
static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) { static inline IDirectMusicStyle8Impl *impl_from_IPersistStream(IPersistStream *iface)
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface); {
return IDirectMusicStyle8_QueryInterface(&This->IDirectMusicStyle8_iface, riid, ppobj); return CONTAINING_RECORD(iface, IDirectMusicStyle8Impl, dmobj.IPersistStream_iface);
}
static ULONG WINAPI IDirectMusicStyle8Impl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
return IDirectMusicStyle8_AddRef(&This->IDirectMusicStyle8_iface);
}
static ULONG WINAPI IDirectMusicStyle8Impl_IPersistStream_Release (LPPERSISTSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
return IDirectMusicStyle8_Release(&This->IDirectMusicStyle8_iface);
}
static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
TRACE("(%p, %p)\n", This, pClassID);
*pClassID = CLSID_DirectMusicStyle;
return S_OK;
}
static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
FIXME("(%p): stub, always S_FALSE\n", This);
return S_FALSE;
} }
static HRESULT load_band(IStream *pClonedStream, IDirectMusicBand **ppBand) static HRESULT load_band(IStream *pClonedStream, IDirectMusicBand **ppBand)
@ -893,8 +818,8 @@ static HRESULT parse_style_form(IDirectMusicStyle8Impl *This, DMUS_PRIVATE_CHUNK
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL); IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize; StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize); TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk, pStm, This->pDesc); hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk, pStm, &This->dmobj.desc);
if (FAILED(hr)) return hr; if (FAILED(hr)) return hr;
if (hr == S_FALSE) { if (hr == S_FALSE) {
@ -972,8 +897,8 @@ static HRESULT parse_style_form(IDirectMusicStyle8Impl *This, DMUS_PRIVATE_CHUNK
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL); IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize; ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize); TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, This->pDesc); hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &This->dmobj.desc);
if (FAILED(hr)) return hr; if (FAILED(hr)) return hr;
if (hr == S_FALSE) { if (hr == S_FALSE) {
@ -1025,9 +950,9 @@ static HRESULT parse_style_form(IDirectMusicStyle8Impl *This, DMUS_PRIVATE_CHUNK
return S_OK; return S_OK;
} }
static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) { static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pStm)
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface); {
IDirectMusicStyle8Impl *This = impl_from_IPersistStream(iface);
DMUS_PRIVATE_CHUNK Chunk; DMUS_PRIVATE_CHUNK Chunk;
LARGE_INTEGER liMove; /* used when skipping chunks */ LARGE_INTEGER liMove; /* used when skipping chunks */
HRESULT hr; HRESULT hr;
@ -1068,28 +993,15 @@ static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Load (LPPERSISTSTREA
return S_OK; return S_OK;
} }
static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) { static const IPersistStreamVtbl persiststream_vtbl = {
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface); dmobj_IPersistStream_QueryInterface,
FIXME("(%p): Saving not implemented yet\n", This); dmobj_IPersistStream_AddRef,
return E_NOTIMPL; dmobj_IPersistStream_Release,
} dmobj_IPersistStream_GetClassID,
unimpl_IPersistStream_IsDirty,
static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) { IPersistStreamImpl_Load,
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface); unimpl_IPersistStream_Save,
FIXME("(%p, %p): stub\n", This, pcbSize); unimpl_IPersistStream_GetSizeMax
return E_NOTIMPL;
}
static const IPersistStreamVtbl DirectMusicStyle8_PersistStream_Vtbl = {
IDirectMusicStyle8Impl_IPersistStream_QueryInterface,
IDirectMusicStyle8Impl_IPersistStream_AddRef,
IDirectMusicStyle8Impl_IPersistStream_Release,
IDirectMusicStyle8Impl_IPersistStream_GetClassID,
IDirectMusicStyle8Impl_IPersistStream_IsDirty,
IDirectMusicStyle8Impl_IPersistStream_Load,
IDirectMusicStyle8Impl_IPersistStream_Save,
IDirectMusicStyle8Impl_IPersistStream_GetSizeMax
}; };
/* for ClassFactory */ /* for ClassFactory */
@ -1104,13 +1016,10 @@ HRESULT WINAPI create_dmstyle(REFIID lpcGUID, void **ppobj)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
obj->IDirectMusicStyle8_iface.lpVtbl = &dmstyle8_vtbl; obj->IDirectMusicStyle8_iface.lpVtbl = &dmstyle8_vtbl;
obj->ObjectVtbl = &DirectMusicStyle8_Object_Vtbl;
obj->PersistStreamVtbl = &DirectMusicStyle8_PersistStream_Vtbl;
obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
DM_STRUCT_INIT(obj->pDesc);
obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
obj->pDesc->guidClass = CLSID_DirectMusicStyle;
obj->ref = 1; obj->ref = 1;
dmobject_init(&obj->dmobj, &CLSID_DirectMusicStyle, (IUnknown *)&obj->IDirectMusicStyle8_iface);
obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
list_init (&obj->Bands); list_init (&obj->Bands);
list_init (&obj->Motifs); list_init (&obj->Motifs);