ReactOS  0.4.14-dev-1112-g2b067d6
collection.c File Reference
#include "dmusic_private.h"
#include "dmobject.h"
Include dependency graph for collection.c:

Go to the source code of this file.

Classes

struct  IDirectMusicCollectionImpl
 

Typedefs

typedef struct IDirectMusicCollectionImpl IDirectMusicCollectionImpl
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dmusic)
 
 WINE_DECLARE_DEBUG_CHANNEL (dmfile)
 
static IDirectMusicCollectionImplimpl_from_IDirectMusicCollection (IDirectMusicCollection *iface)
 
static struct dmobjectimpl_from_IDirectMusicObject (IDirectMusicObject *iface)
 
static IDirectMusicCollectionImplimpl_from_IPersistStream (IPersistStream *iface)
 
static HRESULT WINAPI IDirectMusicCollectionImpl_QueryInterface (IDirectMusicCollection *iface, REFIID riid, void **ret_iface)
 
static ULONG WINAPI IDirectMusicCollectionImpl_AddRef (IDirectMusicCollection *iface)
 
static ULONG WINAPI IDirectMusicCollectionImpl_Release (IDirectMusicCollection *iface)
 
static HRESULT WINAPI IDirectMusicCollectionImpl_GetInstrument (IDirectMusicCollection *iface, DWORD patch, IDirectMusicInstrument **instrument)
 
static HRESULT WINAPI IDirectMusicCollectionImpl_EnumInstrument (IDirectMusicCollection *iface, DWORD index, DWORD *patch, LPWSTR name, DWORD name_length)
 
static HRESULT WINAPI col_IDirectMusicObject_ParseDescriptor (IDirectMusicObject *iface, IStream *stream, DMUS_OBJECTDESC *desc)
 
static HRESULT WINAPI IPersistStreamImpl_Load (IPersistStream *iface, IStream *stream)
 
HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter)
 

Variables

static const IDirectMusicCollectionVtbl DirectMusicCollection_Collection_Vtbl
 
static const IDirectMusicObjectVtbl dmobject_vtbl
 
static const IPersistStreamVtbl persiststream_vtbl
 

Typedef Documentation

◆ IDirectMusicCollectionImpl

Function Documentation

◆ col_IDirectMusicObject_ParseDescriptor()

static HRESULT WINAPI col_IDirectMusicObject_ParseDescriptor ( IDirectMusicObject *  iface,
IStream stream,
DMUS_OBJECTDESC desc 
)
static

Definition at line 179 of file collection.c.

181 {
182  struct chunk_entry riff = {0};
183  HRESULT hr;
184 
185  TRACE("(%p, %p, %p)\n", iface, stream, desc);
186 
187  if (!stream || !desc)
188  return E_POINTER;
189 
190  if ((hr = stream_get_chunk(stream, &riff)) != S_OK)
191  return hr;
192  if (riff.id != FOURCC_RIFF || riff.type != FOURCC_DLS) {
193  TRACE("loading failed: unexpected %s\n", debugstr_chunk(&riff));
194  stream_skip_chunk(stream, &riff);
195  return DMUS_E_NOTADLSCOL;
196  }
197 
199  if (FAILED(hr))
200  return hr;
201 
202  desc->guidClass = CLSID_DirectMusicCollection;
203  desc->dwValidData |= DMUS_OBJ_CLASS;
204 
205  TRACE("returning descriptor:\n");
207  return S_OK;
208 }
HRESULT dmobj_parsedescriptor(IStream *stream, const struct chunk_entry *riff, DMUS_OBJECTDESC *desc, DWORD supported)
Definition: dmobject.c:296
HRESULT hr
Definition: shlfolder.c:183
void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc)
Definition: dmusic_main.c:459
#define FOURCC_DLS
Definition: dls1.h:33
FOURCC id
Definition: dmobject.h:29
FOURCC type
Definition: dmobject.h:31
#define DMUS_E_NOTADLSCOL
Definition: dmerror.h:60
static const WCHAR desc[]
Definition: protectdata.c:36
const char * debugstr_chunk(const struct chunk_entry *chunk)
Definition: dmobject.c:48
#define TRACE(s)
Definition: solgame.cpp:4
#define DMUS_OBJ_NAME_INFO
Definition: dmobject.h:94
LONG HRESULT
Definition: typedefs.h:78
Definition: dmobject.h:28
#define FOURCC_RIFF
Definition: mmsystem.h:564
Definition: parse.h:22
#define S_OK
Definition: intsafe.h:59
HRESULT stream_skip_chunk(IStream *stream, struct chunk_entry *chunk)
Definition: dmobject.c:121
#define DMUS_OBJ_VERSION
Definition: dmusici.h:272
#define E_POINTER
Definition: winerror.h:2365
#define DMUS_OBJ_CLASS
Definition: dmusici.h:266
HRESULT stream_get_chunk(IStream *stream, struct chunk_entry *chunk)
Definition: dmobject.c:76

◆ DMUSIC_CreateDirectMusicCollectionImpl()

HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl ( LPCGUID  lpcGUID,
LPVOID ppobj,
LPUNKNOWN  pUnkOuter 
)

Definition at line 530 of file collection.c.

531 {
533  HRESULT hr;
534 
535  *ppobj = NULL;
536  if (pUnkOuter)
537  return CLASS_E_NOAGGREGATION;
538 
540  if (!obj)
541  return E_OUTOFMEMORY;
542 
543  obj->IDirectMusicCollection_iface.lpVtbl = &DirectMusicCollection_Collection_Vtbl;
544  obj->ref = 1;
545  dmobject_init(&obj->dmobj, &CLSID_DirectMusicCollection,
546  (IUnknown*)&obj->IDirectMusicCollection_iface);
547  obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
548  obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
549 
550  list_init (&obj->Instruments);
551 
553  hr = IDirectMusicCollection_QueryInterface(&obj->IDirectMusicCollection_iface, lpcGUID, ppobj);
554  IDirectMusicCollection_Release(&obj->IDirectMusicCollection_iface);
555 
556  return hr;
557 }
HRESULT hr
Definition: shlfolder.c:183
static const IDirectMusicCollectionVtbl DirectMusicCollection_Collection_Vtbl
Definition: collection.c:170
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
#define IDirectMusicCollection_QueryInterface(p, a, b)
Definition: dmusicc.h:575
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
static void DMUSIC_LockModule(void)
void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk)
Definition: dmobject.c:407
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:78
#define IDirectMusicCollection_Release(p)
Definition: dmusicc.h:577
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
static const IPersistStreamVtbl persiststream_vtbl
Definition: collection.c:518
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
static const IDirectMusicObjectVtbl dmobject_vtbl
Definition: collection.c:210

◆ IDirectMusicCollectionImpl_AddRef()

static ULONG WINAPI IDirectMusicCollectionImpl_AddRef ( IDirectMusicCollection *  iface)
static

Definition at line 88 of file collection.c.

89 {
92 
93  TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref);
94 
95  return ref;
96 }
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
static IDirectMusicCollectionImpl * impl_from_IDirectMusicCollection(IDirectMusicCollection *iface)
Definition: collection.c:47
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ IDirectMusicCollectionImpl_EnumInstrument()

static HRESULT WINAPI IDirectMusicCollectionImpl_EnumInstrument ( IDirectMusicCollection *  iface,
DWORD  index,
DWORD patch,
LPWSTR  name,
DWORD  name_length 
)
static

Definition at line 141 of file collection.c.

143 {
145  DWORD i = 0;
146  DMUS_PRIVATE_INSTRUMENTENTRY *inst_entry;
147  struct list *list_entry;
148  DWORD length;
149 
150  TRACE("(%p/%p)->(%d, %p, %p, %d)\n", iface, This, index, patch, name, name_length);
151 
152  LIST_FOR_EACH(list_entry, &This->Instruments) {
154  if (i == index) {
156  IDirectMusicInstrument_GetPatch(inst_entry->pInstrument, patch);
157  if (name) {
158  length = min(lstrlenW(instrument->wszName), name_length - 1);
159  memcpy(name, instrument->wszName, length * sizeof(WCHAR));
160  name[length] = '\0';
161  }
162  return S_OK;
163  }
164  i++;
165  }
166 
167  return S_FALSE;
168 }
#define IDirectMusicInstrument_GetPatch(p, a)
Definition: dmusicc.h:528
static IDirectMusicInstrumentImpl * impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
#define lstrlenW
Definition: compat.h:415
#define list_entry(ptr, type, member)
Definition: list.h:185
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define S_FALSE
Definition: winerror.h:2357
IDirectMusicInstrument * pInstrument
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
static IDirectMusicCollectionImpl * impl_from_IDirectMusicCollection(IDirectMusicCollection *iface)
Definition: collection.c:47
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: _list.h:228
#define S_OK
Definition: intsafe.h:59
#define min(a, b)
Definition: monoChain.cc:55
Definition: list.h:27
Definition: name.c:38
#define LIST_ENTRY(type)
Definition: queue.h:175
WCHAR wszName[DMUS_MAX_NAME]

◆ IDirectMusicCollectionImpl_GetInstrument()

static HRESULT WINAPI IDirectMusicCollectionImpl_GetInstrument ( IDirectMusicCollection *  iface,
DWORD  patch,
IDirectMusicInstrument **  instrument 
)
static

Definition at line 114 of file collection.c.

116 {
118  DMUS_PRIVATE_INSTRUMENTENTRY *inst_entry;
119  struct list *list_entry;
120  DWORD inst_patch;
121 
122  TRACE("(%p/%p)->(%u, %p)\n", iface, This, patch, instrument);
123 
124  LIST_FOR_EACH(list_entry, &This->Instruments) {
126  IDirectMusicInstrument_GetPatch(inst_entry->pInstrument, &inst_patch);
127  if (patch == inst_patch) {
128  *instrument = inst_entry->pInstrument;
131  TRACE(": returning instrument %p\n", *instrument);
132  return S_OK;
133  }
134  }
135 
136  TRACE(": instrument not found\n");
137 
138  return DMUS_E_INVALIDPATCH;
139 }
#define IDirectMusicInstrument_GetPatch(p, a)
Definition: dmusicc.h:528
#define DMUS_E_INVALIDPATCH
Definition: dmerror.h:64
#define list_entry(ptr, type, member)
Definition: list.h:185
IDirectMusicInstrument * pInstrument
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
#define TRACE(s)
Definition: solgame.cpp:4
static IDirectMusicCollectionImpl * impl_from_IDirectMusicCollection(IDirectMusicCollection *iface)
Definition: collection.c:47
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDirectMusicInstrument_AddRef(p)
Definition: dmusicc.h:525
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
#define S_OK
Definition: intsafe.h:59
Definition: list.h:27
#define LIST_ENTRY(type)
Definition: queue.h:175
HRESULT IDirectMusicInstrumentImpl_CustomLoad(IDirectMusicInstrument *iface, IStream *stream) DECLSPEC_HIDDEN
Definition: instrument.c:291

◆ IDirectMusicCollectionImpl_QueryInterface()

static HRESULT WINAPI IDirectMusicCollectionImpl_QueryInterface ( IDirectMusicCollection *  iface,
REFIID  riid,
void **  ret_iface 
)
static

Definition at line 63 of file collection.c.

65 {
67 
68  TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_dmguid(riid), ret_iface);
69 
70  *ret_iface = NULL;
71 
72  if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicCollection))
73  *ret_iface = iface;
74  else if (IsEqualIID(riid, &IID_IDirectMusicObject))
75  *ret_iface = &This->dmobj.IDirectMusicObject_iface;
77  *ret_iface = &This->dmobj.IPersistStream_iface;
78  else
79  {
80  WARN("(%p/%p)->(%s, %p): not found\n", iface, This, debugstr_dmguid(riid), ret_iface);
81  return E_NOINTERFACE;
82  }
83 
84  IUnknown_AddRef((IUnknown*)*ret_iface);
85  return S_OK;
86 }
#define E_NOINTERFACE
Definition: winerror.h:2364
const char * debugstr_dmguid(const GUID *id)
Definition: dmusic_main.c:237
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static IDirectMusicCollectionImpl * impl_from_IDirectMusicCollection(IDirectMusicCollection *iface)
Definition: collection.c:47
const GUID IID_IUnknown
const GUID IID_IPersistStream
Definition: proxy.cpp:13
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ IDirectMusicCollectionImpl_Release()

static ULONG WINAPI IDirectMusicCollectionImpl_Release ( IDirectMusicCollection *  iface)
static

Definition at line 98 of file collection.c.

99 {
102 
103  TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref);
104 
105  if (!ref) {
108  }
109 
110  return ref;
111 }
Definition: send.c:47
static void DMUSIC_UnlockModule(void)
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
static IDirectMusicCollectionImpl * impl_from_IDirectMusicCollection(IDirectMusicCollection *iface)
Definition: collection.c:47
#define GetProcessHeap()
Definition: compat.h:403
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ impl_from_IDirectMusicCollection()

static IDirectMusicCollectionImpl* impl_from_IDirectMusicCollection ( IDirectMusicCollection *  iface)
inlinestatic

Definition at line 47 of file collection.c.

48 {
49  return CONTAINING_RECORD(iface, IDirectMusicCollectionImpl, IDirectMusicCollection_iface);
50 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by IDirectMusicCollectionImpl_AddRef(), IDirectMusicCollectionImpl_EnumInstrument(), IDirectMusicCollectionImpl_GetInstrument(), IDirectMusicCollectionImpl_QueryInterface(), and IDirectMusicCollectionImpl_Release().

◆ impl_from_IDirectMusicObject()

static struct dmobject* impl_from_IDirectMusicObject ( IDirectMusicObject *  iface)
inlinestatic

Definition at line 52 of file collection.c.

53 {
54  return CONTAINING_RECORD(iface, struct dmobject, IDirectMusicObject_iface);
55 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

◆ impl_from_IPersistStream()

static IDirectMusicCollectionImpl* impl_from_IPersistStream ( IPersistStream iface)
inlinestatic

Definition at line 57 of file collection.c.

58 {
59  return CONTAINING_RECORD(iface, IDirectMusicCollectionImpl, dmobj.IPersistStream_iface);
60 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by IPersistStreamImpl_Load().

◆ IPersistStreamImpl_Load()

static HRESULT WINAPI IPersistStreamImpl_Load ( IPersistStream iface,
IStream stream 
)
static

Definition at line 220 of file collection.c.

222 {
225  DWORD StreamSize, StreamCount, ListSize[2], ListCount[2];
226  LARGE_INTEGER liMove; /* used when skipping chunks */
227  ULARGE_INTEGER dlibCollectionPosition, dlibInstrumentPosition, dlibWavePoolPosition;
228 
229  IStream_AddRef(stream); /* add count for later references */
230  liMove.QuadPart = 0;
231  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, &dlibCollectionPosition); /* store offset, in case it'll be needed later */
232  This->liCollectionPosition.QuadPart = dlibCollectionPosition.QuadPart;
233  This->pStm = stream;
234 
235  IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
236  TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
237 
238  if (chunk.fccID != FOURCC_RIFF) {
239  TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
240  liMove.QuadPart = chunk.dwSize;
241  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
242  return E_FAIL;
243  }
244 
245  IStream_Read(stream, &chunk.fccID, sizeof(FOURCC), NULL);
246  TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunk.fccID));
247  StreamSize = chunk.dwSize - sizeof(FOURCC);
248  StreamCount = 0;
249 
250  if (chunk.fccID != FOURCC_DLS) {
251  TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
252  liMove.QuadPart = StreamSize;
253  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
254  return E_FAIL;
255  }
256 
257  TRACE_(dmfile)(": collection form\n");
258  do {
259  IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
260  StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
261  TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
262  switch (chunk.fccID) {
263  case FOURCC_COLH: {
264  TRACE_(dmfile)(": collection header chunk\n");
265  This->pHeader = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, chunk.dwSize);
266  IStream_Read(stream, This->pHeader, chunk.dwSize, NULL);
267  break;
268  }
269  case FOURCC_DLID: {
270  TRACE_(dmfile)(": DLID (GUID) chunk\n");
271  This->dmobj.desc.dwValidData |= DMUS_OBJ_OBJECT;
272  IStream_Read(stream, &This->dmobj.desc.guidObject, chunk.dwSize, NULL);
273  break;
274  }
275  case FOURCC_VERS: {
276  TRACE_(dmfile)(": version chunk\n");
277  This->dmobj.desc.dwValidData |= DMUS_OBJ_VERSION;
278  IStream_Read(stream, &This->dmobj.desc.vVersion, chunk.dwSize, NULL);
279  break;
280  }
281  case FOURCC_PTBL: {
282  TRACE_(dmfile)(": pool table chunk\n");
283  This->pPoolTable = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(POOLTABLE));
284  IStream_Read(stream, This->pPoolTable, sizeof(POOLTABLE), NULL);
285  chunk.dwSize -= sizeof(POOLTABLE);
286  This->pPoolCues = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pPoolTable->cCues * sizeof(POOLCUE));
287  IStream_Read(stream, This->pPoolCues, chunk.dwSize, NULL);
288  break;
289  }
290  case FOURCC_LIST: {
291  IStream_Read(stream, &chunk.fccID, sizeof(FOURCC), NULL);
292  TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunk.fccID));
293  ListSize[0] = chunk.dwSize - sizeof(FOURCC);
294  ListCount[0] = 0;
295  switch (chunk.fccID) {
296  case DMUS_FOURCC_INFO_LIST: {
297  TRACE_(dmfile)(": INFO list\n");
298  do {
299  IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
300  ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
301  TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
302  switch (chunk.fccID) {
303  case mmioFOURCC('I','N','A','M'): {
305  TRACE_(dmfile)(": name chunk\n");
306  This->dmobj.desc.dwValidData |= DMUS_OBJ_NAME;
307  IStream_Read(stream, szName, chunk.dwSize, NULL);
308  MultiByteToWideChar(CP_ACP, 0, szName, -1, This->dmobj.desc.wszName, DMUS_MAX_NAME);
309  if (even_or_odd(chunk.dwSize)) {
310  ListCount[0]++;
311  liMove.QuadPart = 1;
312  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
313  }
314  break;
315  }
316  case mmioFOURCC('I','A','R','T'): {
317  TRACE_(dmfile)(": artist chunk (ignored)\n");
318  if (even_or_odd(chunk.dwSize)) {
319  ListCount[0]++;
320  chunk.dwSize++;
321  }
322  liMove.QuadPart = chunk.dwSize;
323  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
324  break;
325  }
326  case mmioFOURCC('I','C','O','P'): {
327  TRACE_(dmfile)(": copyright chunk\n");
328  This->szCopyright = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, chunk.dwSize);
329  IStream_Read(stream, This->szCopyright, chunk.dwSize, NULL);
330  if (even_or_odd(chunk.dwSize)) {
331  ListCount[0]++;
332  liMove.QuadPart = 1;
333  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
334  }
335  break;
336  }
337  case mmioFOURCC('I','S','B','J'): {
338  TRACE_(dmfile)(": subject chunk (ignored)\n");
339  if (even_or_odd(chunk.dwSize)) {
340  ListCount[0]++;
341  chunk.dwSize++;
342  }
343  liMove.QuadPart = chunk.dwSize;
344  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
345  break;
346  }
347  case mmioFOURCC('I','C','M','T'): {
348  TRACE_(dmfile)(": comment chunk (ignored)\n");
349  if (even_or_odd(chunk.dwSize)) {
350  ListCount[0]++;
351  chunk.dwSize++;
352  }
353  liMove.QuadPart = chunk.dwSize;
354  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
355  break;
356  }
357  default: {
358  TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
359  if (even_or_odd(chunk.dwSize)) {
360  ListCount[0]++;
361  chunk.dwSize++;
362  }
363  liMove.QuadPart = chunk.dwSize;
364  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
365  break;
366  }
367  }
368  TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
369  } while (ListCount[0] < ListSize[0]);
370  break;
371  }
372  case FOURCC_WVPL: {
373  TRACE_(dmfile)(": wave pool list (mark & skip)\n");
374  liMove.QuadPart = 0;
375  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, &dlibWavePoolPosition); /* store position */
376  This->liWavePoolTablePosition.QuadPart = dlibWavePoolPosition.QuadPart;
377  liMove.QuadPart = chunk.dwSize - sizeof(FOURCC);
378  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
379  break;
380  }
381  case FOURCC_LINS: {
382  TRACE_(dmfile)(": instruments list\n");
383  do {
384  IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
385  ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
386  TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
387  switch (chunk.fccID) {
388  case FOURCC_LIST: {
389  IStream_Read(stream, &chunk.fccID, sizeof(FOURCC), NULL);
390  TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunk.fccID));
391  ListSize[1] = chunk.dwSize - sizeof(FOURCC);
392  ListCount[1] = 0;
393  switch (chunk.fccID) {
394  case FOURCC_INS: {
396  TRACE_(dmfile)(": instrument list\n");
397  /* Only way to create this one... even M$ does it discretely */
398  DMUSIC_CreateDirectMusicInstrumentImpl(&IID_IDirectMusicInstrument, (void**)&new_instrument->pInstrument, NULL);
399  {
401  /* Store offset and length, they will be needed when loading the instrument */
402  liMove.QuadPart = 0;
403  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, &dlibInstrumentPosition);
404  instrument->liInstrumentPosition.QuadPart = dlibInstrumentPosition.QuadPart;
405  instrument->length = ListSize[1];
406  do {
407  IStream_Read(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD), NULL);
408  ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + chunk.dwSize;
409  TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc(chunk.fccID), chunk.dwSize);
410  switch (chunk.fccID) {
411  case FOURCC_INSH: {
412  TRACE_(dmfile)(": instrument header chunk\n");
413  IStream_Read(stream, &instrument->header, chunk.dwSize, NULL);
414  break;
415  }
416  case FOURCC_DLID: {
417  TRACE_(dmfile)(": DLID (GUID) chunk\n");
418  IStream_Read(stream, &instrument->id, chunk.dwSize, NULL);
419  break;
420  }
421  case FOURCC_LIST: {
422  IStream_Read(stream, &chunk.fccID, sizeof(FOURCC), NULL);
423  TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunk.fccID));
424  switch (chunk.fccID) {
425  default: {
426  TRACE_(dmfile)(": unknown (skipping)\n");
427  liMove.QuadPart = chunk.dwSize - sizeof(FOURCC);
428  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
429  break;
430  }
431  }
432  break;
433  }
434  default: {
435  TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
436  liMove.QuadPart = chunk.dwSize;
437  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
438  break;
439  }
440  }
441  TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
442  } while (ListCount[1] < ListSize[1]);
443  /* DEBUG: dumps whole instrument object tree: */
444  if (TRACE_ON(dmusic)) {
445  TRACE("*** IDirectMusicInstrument (%p) ***\n", instrument);
446  if (!IsEqualGUID(&instrument->id, &GUID_NULL))
447  TRACE(" - GUID = %s\n", debugstr_dmguid(&instrument->id));
448  TRACE(" - Instrument header:\n");
449  TRACE(" - cRegions: %d\n", instrument->header.cRegions);
450  TRACE(" - Locale:\n");
451  TRACE(" - ulBank: %d\n", instrument->header.Locale.ulBank);
452  TRACE(" - ulInstrument: %d\n", instrument->header.Locale.ulInstrument);
453  TRACE(" => dwPatch: %d\n", MIDILOCALE2Patch(&instrument->header.Locale));
454  }
455  list_add_tail(&This->Instruments, &new_instrument->entry);
456  }
457  break;
458  }
459  }
460  break;
461  }
462  default: {
463  TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
464  liMove.QuadPart = chunk.dwSize;
465  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
466  break;
467  }
468  }
469  TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
470  } while (ListCount[0] < ListSize[0]);
471  break;
472  }
473  default: {
474  TRACE_(dmfile)(": unknown (skipping)\n");
475  liMove.QuadPart = chunk.dwSize - sizeof(FOURCC);
476  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
477  break;
478  }
479  }
480  break;
481  }
482  default: {
483  TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
484  liMove.QuadPart = chunk.dwSize;
485  IStream_Seek(stream, liMove, STREAM_SEEK_CUR, NULL);
486  break;
487  }
488  }
489  TRACE_(dmfile)(": StreamCount = %d < StreamSize = %d\n", StreamCount, StreamSize);
490  } while (StreamCount < StreamSize);
491 
492  TRACE_(dmfile)(": reading finished\n");
493 
494 
495  /* DEBUG: dumps whole collection object tree: */
496  if (TRACE_ON(dmusic)) {
497  int r = 0;
499  struct list *listEntry;
500 
501  TRACE("*** IDirectMusicCollection (%p) ***\n", &This->IDirectMusicCollection_iface);
502  dump_DMUS_OBJECTDESC(&This->dmobj.desc);
503 
504  TRACE(" - Collection header:\n");
505  TRACE(" - cInstruments: %d\n", This->pHeader->cInstruments);
506  TRACE(" - Instruments:\n");
507 
508  LIST_FOR_EACH(listEntry, &This->Instruments) {
509  tmpEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_INSTRUMENTENTRY, entry );
510  TRACE(" - Instrument[%i]: %p\n", r, tmpEntry->pInstrument);
511  r++;
512  }
513  }
514 
515  return S_OK;
516 }
Definition: dls1.h:106
LARGE_INTEGER liInstrumentPosition
DWORD MIDILOCALE2Patch(const MIDILOCALE *pLocale)
Definition: dmusic_main.c:195
static IDirectMusicInstrumentImpl * impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc)
Definition: dmusic_main.c:459
const char * debugstr_dmguid(const GUID *id)
Definition: dmusic_main.c:237
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define CP_ACP
Definition: compat.h:99
char CHAR
Definition: xmlstorage.h:175
#define DMUS_OBJ_NAME
Definition: dmusici.h:267
#define FOURCC_LINS
Definition: dls1.h:40
#define FOURCC_DLS
Definition: dls1.h:33
#define FOURCC_VERS
Definition: dls1.h:50
#define FOURCC_COLH
Definition: dls1.h:35
#define E_FAIL
Definition: ddrawi.h:102
static IDirectMusicCollectionImpl * impl_from_IPersistStream(IPersistStream *iface)
Definition: collection.c:57
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FOURCC_DLID
Definition: dls1.h:34
static const char * debugstr_fourcc(DWORD fourcc)
Definition: parsing.c:85
IDirectMusicInstrument * pInstrument
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
smooth NULL
Definition: ftsmooth.c:416
HRESULT DMUSIC_CreateDirectMusicInstrumentImpl(LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN
Definition: instrument.c:123
ULONG ulInstrument
Definition: dls1.h:97
#define FOURCC_WVPL
Definition: dls1.h:36
ULONG ulBank
Definition: dls1.h:96
#define TRACE_(x)
Definition: compat.h:66
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
#define FOURCC_LIST
Definition: mmsystem.h:565
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DMUS_OBJ_OBJECT
Definition: dmusici.h:265
MIDILOCALE Locale
Definition: dls1.h:103
struct _POOLTABLE POOLTABLE
#define FOURCC_RIFF
Definition: mmsystem.h:564
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
#define FOURCC_INS
Definition: dls1.h:41
#define mmioFOURCC(c0, c1, c2, c3)
Definition: mmsystem.h:38
uint32_t entry
Definition: isohybrid.c:63
#define GUID_NULL
Definition: ks.h:106
Definition: _list.h:228
int even_or_odd(DWORD number)
Definition: dmusic_main.c:214
DWORD FOURCC
Definition: dmdls.h:25
#define S_OK
Definition: intsafe.h:59
#define FOURCC_PTBL
Definition: dls1.h:37
#define DMUS_FOURCC_INFO_LIST
Definition: dmusicf.h:43
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MultiByteToWideChar
Definition: compat.h:100
static const WCHAR szName[]
Definition: msipriv.h:1194
#define FOURCC(a, b, c, d)
Definition: memtrack.h:4
#define DMUS_OBJ_VERSION
Definition: dmusici.h:272
#define LIST_ENTRY(type)
Definition: queue.h:175
struct list entry
#define TRACE_ON(x)
Definition: compat.h:65
#define DMUS_MAX_NAME
Definition: dmusici.h:245
ULONG cRegions
Definition: dls1.h:102
LONGLONG QuadPart
Definition: typedefs.h:113
#define FOURCC_INSH
Definition: dls1.h:42

◆ WINE_DECLARE_DEBUG_CHANNEL()

WINE_DECLARE_DEBUG_CHANNEL ( dmfile  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dmusic  )

Variable Documentation

◆ DirectMusicCollection_Collection_Vtbl

const IDirectMusicCollectionVtbl DirectMusicCollection_Collection_Vtbl
static
Initial value:
= {
}
static HRESULT WINAPI IDirectMusicCollectionImpl_GetInstrument(IDirectMusicCollection *iface, DWORD patch, IDirectMusicInstrument **instrument)
Definition: collection.c:114
static HRESULT WINAPI IDirectMusicCollectionImpl_EnumInstrument(IDirectMusicCollection *iface, DWORD index, DWORD *patch, LPWSTR name, DWORD name_length)
Definition: collection.c:141
static ULONG WINAPI IDirectMusicCollectionImpl_AddRef(IDirectMusicCollection *iface)
Definition: collection.c:88
static ULONG WINAPI IDirectMusicCollectionImpl_Release(IDirectMusicCollection *iface)
Definition: collection.c:98
static HRESULT WINAPI IDirectMusicCollectionImpl_QueryInterface(IDirectMusicCollection *iface, REFIID riid, void **ret_iface)
Definition: collection.c:63

Definition at line 170 of file collection.c.

Referenced by DMUSIC_CreateDirectMusicCollectionImpl().

◆ dmobject_vtbl

const IDirectMusicObjectVtbl dmobject_vtbl
static
Initial value:
= {
}
HRESULT WINAPI dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject *iface, DMUS_OBJECTDESC *desc)
Definition: dmobject.c:215
ULONG WINAPI dmobj_IDirectMusicObject_Release(IDirectMusicObject *iface)
Definition: dmobject.c:194
static HRESULT WINAPI col_IDirectMusicObject_ParseDescriptor(IDirectMusicObject *iface, IStream *stream, DMUS_OBJECTDESC *desc)
Definition: collection.c:179
ULONG WINAPI dmobj_IDirectMusicObject_AddRef(IDirectMusicObject *iface)
Definition: dmobject.c:188
HRESULT WINAPI dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject *iface, DMUS_OBJECTDESC *desc)
Definition: dmobject.c:200
HRESULT WINAPI dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject *iface, REFIID riid, void **ret_iface)
Definition: dmobject.c:181

Definition at line 210 of file collection.c.

Referenced by DMUSIC_CreateDirectMusicCollectionImpl().

◆ persiststream_vtbl

const IPersistStreamVtbl persiststream_vtbl
static
Initial value:
= {
}
HRESULT WINAPI unimpl_IPersistStream_IsDirty(IPersistStream *iface)
Definition: dmobject.c:387
HRESULT WINAPI dmobj_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid, void **ret_iface)
Definition: dmobject.c:347
static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *stream)
Definition: collection.c:220
HRESULT WINAPI unimpl_IPersistStream_Save(IPersistStream *iface, IStream *stream, BOOL clear_dirty)
Definition: dmobject.c:393
ULONG WINAPI dmobj_IPersistStream_Release(IPersistStream *iface)
Definition: dmobject.c:360
HRESULT WINAPI unimpl_IPersistStream_GetSizeMax(IPersistStream *iface, ULARGE_INTEGER *size)
Definition: dmobject.c:400
ULONG WINAPI dmobj_IPersistStream_AddRef(IPersistStream *iface)
Definition: dmobject.c:354
HRESULT WINAPI unimpl_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class)
Definition: dmobject.c:381

Definition at line 518 of file collection.c.

Referenced by DMUSIC_CreateDirectMusicCollectionImpl().