Commit b79f81ad authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

dmband: Use the generic IPersistStream implementation from dmobject.

parent 1093fa28
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#include "dmband_private.h" #include "dmband_private.h"
#include "dmobject.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmband); WINE_DEFAULT_DEBUG_CHANNEL(dmband);
WINE_DECLARE_DEBUG_CHANNEL(dmfile); WINE_DECLARE_DEBUG_CHANNEL(dmfile);
...@@ -27,9 +28,8 @@ WINE_DECLARE_DEBUG_CHANNEL(dmfile); ...@@ -27,9 +28,8 @@ WINE_DECLARE_DEBUG_CHANNEL(dmfile);
*/ */
typedef struct IDirectMusicBandTrack { typedef struct IDirectMusicBandTrack {
IDirectMusicTrack8 IDirectMusicTrack8_iface; IDirectMusicTrack8 IDirectMusicTrack8_iface;
const IPersistStreamVtbl *PersistStreamVtbl; struct dmobject dmobj; /* IPersistStream only */
LONG ref; LONG ref;
DMUS_OBJECTDESC *pDesc;
DMUS_IO_BAND_TRACK_HEADER header; DMUS_IO_BAND_TRACK_HEADER header;
struct list Bands; struct list Bands;
} IDirectMusicBandTrack; } IDirectMusicBandTrack;
...@@ -51,7 +51,7 @@ static HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface(IDirectMusicTrack8 * ...@@ -51,7 +51,7 @@ static HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface(IDirectMusicTrack8 *
IsEqualIID(riid, &IID_IDirectMusicTrack8)) IsEqualIID(riid, &IID_IDirectMusicTrack8))
*ret_iface = iface; *ret_iface = 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;
...@@ -278,34 +278,6 @@ static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = { ...@@ -278,34 +278,6 @@ static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = {
}; };
/* IDirectMusicBandTrack IPersistStream part: */ /* IDirectMusicBandTrack IPersistStream part: */
static HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
return IDirectMusicTrack8_QueryInterface(&This->IDirectMusicTrack8_iface, riid, ppobj);
}
static ULONG WINAPI IDirectMusicBandTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
return IDirectMusicTrack8_AddRef(&This->IDirectMusicTrack8_iface);
}
static ULONG WINAPI IDirectMusicBandTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
return IDirectMusicTrack8_Release(&This->IDirectMusicTrack8_iface);
}
static HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
TRACE("(%p, %p)\n", This, pClassID);
*pClassID = CLSID_DirectMusicBandTrack;
return S_OK;
}
static HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
FIXME("(%p): stub, always S_FALSE\n", This);
return S_FALSE;
}
static HRESULT load_band(IDirectMusicBandTrack *This, IStream *pClonedStream, static HRESULT load_band(IDirectMusicBandTrack *This, IStream *pClonedStream,
IDirectMusicBand **ppBand, DMUS_PRIVATE_BAND_ITEM_HEADER *pHeader) IDirectMusicBand **ppBand, DMUS_PRIVATE_BAND_ITEM_HEADER *pHeader)
{ {
...@@ -494,7 +466,7 @@ static HRESULT parse_bandtrack_form(IDirectMusicBandTrack *This, DMUS_PRIVATE_CH ...@@ -494,7 +466,7 @@ static HRESULT parse_bandtrack_form(IDirectMusicBandTrack *This, DMUS_PRIVATE_CH
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) {
...@@ -517,8 +489,8 @@ static HRESULT parse_bandtrack_form(IDirectMusicBandTrack *This, DMUS_PRIVATE_CH ...@@ -517,8 +489,8 @@ static HRESULT parse_bandtrack_form(IDirectMusicBandTrack *This, DMUS_PRIVATE_CH
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) {
...@@ -564,10 +536,14 @@ static HRESULT parse_bandtrack_form(IDirectMusicBandTrack *This, DMUS_PRIVATE_CH ...@@ -564,10 +536,14 @@ static HRESULT parse_bandtrack_form(IDirectMusicBandTrack *This, DMUS_PRIVATE_CH
return S_OK; return S_OK;
} }
static inline IDirectMusicBandTrack *impl_from_IPersistStream(IPersistStream *iface)
{
return CONTAINING_RECORD(iface, IDirectMusicBandTrack, dmobj.IPersistStream_iface);
}
static HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) { static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pStm)
ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface); {
IDirectMusicBandTrack *This = impl_from_IPersistStream(iface);
DMUS_PRIVATE_CHUNK Chunk; DMUS_PRIVATE_CHUNK Chunk;
LARGE_INTEGER liMove; LARGE_INTEGER liMove;
HRESULT hr; HRESULT hr;
...@@ -608,27 +584,15 @@ static HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_Load (LPPERSISTSTREAM ...@@ -608,27 +584,15 @@ static HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_Load (LPPERSISTSTREAM
return S_OK; return S_OK;
} }
static HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) { static const IPersistStreamVtbl persiststream_vtbl = {
ICOM_THIS_MULTI(IDirectMusicBandTrack, 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 IDirectMusicBandTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) { IPersistStreamImpl_Load,
ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface); unimpl_IPersistStream_Save,
FIXME("(%p, %p): stub\n", This, pcbSize); unimpl_IPersistStream_GetSizeMax
return E_NOTIMPL;
}
static const IPersistStreamVtbl DirectMusicBandTrack_PerststStream_Vtbl = {
IDirectMusicBandTrack_IPersistStream_QueryInterface,
IDirectMusicBandTrack_IPersistStream_AddRef,
IDirectMusicBandTrack_IPersistStream_Release,
IDirectMusicBandTrack_IPersistStream_GetClassID,
IDirectMusicBandTrack_IPersistStream_IsDirty,
IDirectMusicBandTrack_IPersistStream_Load,
IDirectMusicBandTrack_IPersistStream_Save,
IDirectMusicBandTrack_IPersistStream_GetSizeMax
}; };
/* for ClassFactory */ /* for ClassFactory */
...@@ -643,12 +607,10 @@ HRESULT WINAPI create_dmbandtrack(REFIID lpcGUID, void **ppobj) ...@@ -643,12 +607,10 @@ HRESULT WINAPI create_dmbandtrack(REFIID lpcGUID, void **ppobj)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl; track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
track->PersistStreamVtbl = &DirectMusicBandTrack_PerststStream_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_DirectMusicBandTrack;
track->ref = 1; track->ref = 1;
dmobject_init(&track->dmobj, &CLSID_DirectMusicBandTrack,
(IUnknown *)&track->IDirectMusicTrack8_iface);
track->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
list_init (&track->Bands); list_init (&track->Bands);
DMBAND_LockModule(); DMBAND_LockModule();
......
...@@ -27,8 +27,6 @@ typedef struct _DMUS_PRIVATE_CHUNK { ...@@ -27,8 +27,6 @@ typedef struct _DMUS_PRIVATE_CHUNK {
DWORD dwSize; /* size of the chunk */ DWORD dwSize; /* size of the chunk */
} DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_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 * Parsing utilities
*/ */
...@@ -51,12 +49,6 @@ typedef struct { ...@@ -51,12 +49,6 @@ typedef struct {
} guid_info; } guid_info;
/* used for initialising structs */ /* used for initialising structs */
#define DM_STRUCT_INIT(x) \
do { \
memset((x), 0, sizeof(*(x))); \
(x)->dwSize = sizeof(*x); \
} while (0)
#define FE(x) { x, #x } #define FE(x) { x, #x }
#define GE(x) { &x, #x } #define GE(x) { &x, #x }
......
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