ReactOS 0.4.15-dev-5666-gc548b97
dmobject.h File Reference
#include "wine/debug.h"
Include dependency graph for dmobject.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  chunk_entry
 
struct  dmobject
 

Macros

#define DMUS_OBJ_NAME_INAM   0x1000 /* 'INAM' chunk in UNFO list */
 
#define DMUS_OBJ_NAME_INFO   0x2000 /* 'INAM' chunk in INFO list */
 

Functions

HRESULT stream_get_chunk (IStream *stream, struct chunk_entry *chunk) DECLSPEC_HIDDEN
 
HRESULT stream_next_chunk (IStream *stream, struct chunk_entry *chunk) DECLSPEC_HIDDEN
 
HRESULT stream_skip_chunk (IStream *stream, struct chunk_entry *chunk) DECLSPEC_HIDDEN
 
HRESULT stream_chunk_get_data (IStream *stream, const struct chunk_entry *chunk, void *data, ULONG size) DECLSPEC_HIDDEN
 
HRESULT stream_chunk_get_wstr (IStream *stream, const struct chunk_entry *chunk, WCHAR *str, ULONG size) DECLSPEC_HIDDEN
 
static HRESULT stream_reset_chunk_data (IStream *stream, const struct chunk_entry *chunk)
 
static HRESULT stream_reset_chunk_start (IStream *stream, const struct chunk_entry *chunk)
 
const chardebugstr_chunk (const struct chunk_entry *chunk) DECLSPEC_HIDDEN
 
void dmobject_init (struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk) DECLSPEC_HIDDEN
 
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
 
HRESULT dmobj_parsedescriptor (IStream *stream, const struct chunk_entry *riff, DMUS_OBJECTDESC *desc, DWORD supported) DECLSPEC_HIDDEN
 
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
 
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
 

Macro Definition Documentation

◆ DMUS_OBJ_NAME_INAM

#define DMUS_OBJ_NAME_INAM   0x1000 /* 'INAM' chunk in UNFO list */

Definition at line 93 of file dmobject.h.

◆ DMUS_OBJ_NAME_INFO

#define DMUS_OBJ_NAME_INFO   0x2000 /* 'INAM' chunk in INFO list */

Definition at line 94 of file dmobject.h.

Function Documentation

◆ debugstr_chunk()

const char * debugstr_chunk ( const struct chunk_entry chunk)

Definition at line 48 of file dmobject.c.

49{
50 const char *type = "";
51
52 if (!chunk)
53 return "(null)";
54 if (chunk->id == FOURCC_RIFF || chunk->id == FOURCC_LIST)
55 type = wine_dbg_sprintf("type %s, ", debugstr_fourcc(chunk->type));
56 return wine_dbg_sprintf("%s chunk, %ssize %u", debugstr_fourcc(chunk->id), type, chunk->size);
57}
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296
static const char * debugstr_fourcc(DWORD fourcc)
Definition: dmobject.c:40
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FOURCC_RIFF
Definition: mmsystem.h:564
#define FOURCC_LIST
Definition: mmsystem.h:565
uint16_t size
Definition: btrfs_drv.h:563

Referenced by col_IDirectMusicObject_ParseDescriptor(), dmobj_parsedescriptor(), and stream_get_chunk().

◆ dmobj_IDirectMusicObject_AddRef()

ULONG WINAPI dmobj_IDirectMusicObject_AddRef ( IDirectMusicObject *  iface)

Definition at line 188 of file dmobject.c.

189{
191 return IUnknown_AddRef(This->outer_unk);
192}
static struct dmobject * impl_from_IDirectMusicObject(IDirectMusicObject *iface)
Definition: dmobject.c:176

◆ dmobj_IDirectMusicObject_GetDescriptor()

HRESULT WINAPI dmobj_IDirectMusicObject_GetDescriptor ( IDirectMusicObject *  iface,
DMUS_OBJECTDESC desc 
)

Definition at line 200 of file dmobject.c.

202{
204
205 TRACE("(%p/%p)->(%p)\n", iface, This, desc);
206
207 if (!desc)
208 return E_POINTER;
209
210 memcpy(desc, &This->desc, This->desc.dwSize);
211
212 return S_OK;
213}
#define S_OK
Definition: intsafe.h:52
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const WCHAR desc[]
Definition: protectdata.c:36
#define TRACE(s)
Definition: solgame.cpp:4
#define E_POINTER
Definition: winerror.h:2365

◆ dmobj_IDirectMusicObject_QueryInterface()

HRESULT WINAPI dmobj_IDirectMusicObject_QueryInterface ( IDirectMusicObject *  iface,
REFIID  riid,
void **  ret_iface 
)

Definition at line 181 of file dmobject.c.

183{
185 return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
186}
REFIID riid
Definition: atlbase.h:39

◆ dmobj_IDirectMusicObject_Release()

ULONG WINAPI dmobj_IDirectMusicObject_Release ( IDirectMusicObject *  iface)

Definition at line 194 of file dmobject.c.

195{
197 return IUnknown_Release(This->outer_unk);
198}

◆ dmobj_IDirectMusicObject_SetDescriptor()

HRESULT WINAPI dmobj_IDirectMusicObject_SetDescriptor ( IDirectMusicObject *  iface,
DMUS_OBJECTDESC desc 
)

Definition at line 215 of file dmobject.c.

217{
219 HRESULT ret = S_OK;
220
221 TRACE("(%p, %p)\n", iface, desc);
222
223 if (!desc)
224 return E_POINTER;
225
226 /* Immutable property */
227 if (desc->dwValidData & DMUS_OBJ_CLASS)
228 {
229 desc->dwValidData &= ~DMUS_OBJ_CLASS;
230 ret = S_FALSE;
231 }
232 /* Set only valid fields */
233 if (desc->dwValidData & DMUS_OBJ_OBJECT)
234 This->desc.guidObject = desc->guidObject;
235 if (desc->dwValidData & DMUS_OBJ_NAME)
236 lstrcpynW(This->desc.wszName, desc->wszName, DMUS_MAX_NAME);
237 if (desc->dwValidData & DMUS_OBJ_CATEGORY)
238 lstrcpynW(This->desc.wszCategory, desc->wszCategory, DMUS_MAX_CATEGORY);
239 if (desc->dwValidData & DMUS_OBJ_FILENAME)
240 lstrcpynW(This->desc.wszFileName, desc->wszFileName, DMUS_MAX_FILENAME);
241 if (desc->dwValidData & DMUS_OBJ_VERSION)
242 This->desc.vVersion = desc->vVersion;
243 if (desc->dwValidData & DMUS_OBJ_DATE)
244 This->desc.ftDate = desc->ftDate;
245 if (desc->dwValidData & DMUS_OBJ_MEMORY) {
246 This->desc.llMemLength = desc->llMemLength;
247 memcpy(This->desc.pbMemData, desc->pbMemData, desc->llMemLength);
248 }
249 if (desc->dwValidData & DMUS_OBJ_STREAM)
250 IStream_Clone(desc->pStream, &This->desc.pStream);
251
252 This->desc.dwValidData |= desc->dwValidData;
253
254 return ret;
255}
#define lstrcpynW
Definition: compat.h:738
#define DMUS_OBJ_DATE
Definition: dmusici.h:273
#define DMUS_MAX_CATEGORY
Definition: dmusici.h:246
#define DMUS_OBJ_MEMORY
Definition: dmusici.h:275
#define DMUS_OBJ_NAME
Definition: dmusici.h:267
#define DMUS_OBJ_STREAM
Definition: dmusici.h:276
#define DMUS_OBJ_FILENAME
Definition: dmusici.h:269
#define DMUS_OBJ_CLASS
Definition: dmusici.h:266
#define DMUS_MAX_NAME
Definition: dmusici.h:245
#define DMUS_MAX_FILENAME
Definition: dmusici.h:247
#define DMUS_OBJ_VERSION
Definition: dmusici.h:272
#define DMUS_OBJ_CATEGORY
Definition: dmusici.h:268
#define DMUS_OBJ_OBJECT
Definition: dmusici.h:265
int ret
#define S_FALSE
Definition: winerror.h:2357

◆ dmobj_IPersistStream_AddRef()

ULONG WINAPI dmobj_IPersistStream_AddRef ( IPersistStream iface)

Definition at line 354 of file dmobject.c.

355{
356 struct dmobject *This = impl_from_IPersistStream(iface);
357 return IUnknown_AddRef(This->outer_unk);
358}
static struct dmobject * impl_from_IPersistStream(IPersistStream *iface)
Definition: dmobject.c:342

◆ dmobj_IPersistStream_GetClassID()

HRESULT WINAPI dmobj_IPersistStream_GetClassID ( IPersistStream iface,
CLSID class 
)

Definition at line 366 of file dmobject.c.

367{
368 struct dmobject *This = impl_from_IPersistStream(iface);
369
370 TRACE("(%p, %p)\n", This, class);
371
372 if (!class)
373 return E_POINTER;
374
375 *class = This->desc.guidClass;
376
377 return S_OK;
378}

◆ dmobj_IPersistStream_QueryInterface()

HRESULT WINAPI dmobj_IPersistStream_QueryInterface ( IPersistStream iface,
REFIID  riid,
void **  ret_iface 
)

Definition at line 347 of file dmobject.c.

349{
350 struct dmobject *This = impl_from_IPersistStream(iface);
351 return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
352}

◆ dmobj_IPersistStream_Release()

ULONG WINAPI dmobj_IPersistStream_Release ( IPersistStream iface)

Definition at line 360 of file dmobject.c.

361{
362 struct dmobject *This = impl_from_IPersistStream(iface);
363 return IUnknown_Release(This->outer_unk);
364}

◆ dmobj_parsedescriptor()

HRESULT dmobj_parsedescriptor ( IStream stream,
const struct chunk_entry riff,
DMUS_OBJECTDESC desc,
DWORD  supported 
)

Definition at line 296 of file dmobject.c.

298{
299#ifndef __REACTOS__
300 struct chunk_entry chunk = {.parent = riff};
301#else
302 struct chunk_entry chunk = { 0, 0, 0, {{0}}, riff };
303#endif
304 HRESULT hr;
305
306 TRACE("Looking for %#x in %p: %s\n", supported, stream, debugstr_chunk(riff));
307
308 desc->dwValidData = 0;
309 desc->dwSize = sizeof(*desc);
310
311 while ((hr = stream_next_chunk(stream, &chunk)) == S_OK) {
312 switch (chunk.id) {
314 if ((supported & DMUS_OBJ_OBJECT) && stream_chunk_get_data(stream, &chunk,
315 &desc->guidObject, sizeof(desc->guidObject)) == S_OK)
316 desc->dwValidData |= DMUS_OBJ_OBJECT;
317 break;
320 desc->wszCategory, sizeof(desc->wszCategory)) == S_OK)
321 desc->dwValidData |= DMUS_OBJ_CATEGORY;
322 break;
324 if ((supported & DMUS_OBJ_VERSION) && stream_chunk_get_data(stream, &chunk,
325 &desc->vVersion, sizeof(desc->vVersion)) == S_OK)
326 desc->dwValidData |= DMUS_OBJ_VERSION;
327 break;
328 case FOURCC_LIST:
329 if (chunk.type == DMUS_FOURCC_UNFO_LIST && (supported & DMUS_OBJ_NAME))
331 else if (chunk.type == DMUS_FOURCC_INFO_LIST && (supported & DMUS_OBJ_NAME_INFO))
333 break;
334 }
335 }
336 TRACE("Found %#x\n", desc->dwValidData);
337
338 return hr;
339}
HRESULT stream_chunk_get_data(IStream *stream, const struct chunk_entry *chunk, void *data, ULONG size)
Definition: dmobject.c:143
HRESULT stream_next_chunk(IStream *stream, struct chunk_entry *chunk)
Definition: dmobject.c:130
static void info_get_name(IStream *stream, const struct chunk_entry *info, DMUS_OBJECTDESC *desc)
Definition: dmobject.c:258
static void unfo_get_name(IStream *stream, const struct chunk_entry *unfo, DMUS_OBJECTDESC *desc, BOOL inam)
Definition: dmobject.c:281
HRESULT stream_chunk_get_wstr(IStream *stream, const struct chunk_entry *chunk, WCHAR *str, ULONG size)
Definition: dmobject.c:155
const char * debugstr_chunk(const struct chunk_entry *chunk)
Definition: dmobject.c:48
#define DMUS_OBJ_NAME_INAM
Definition: dmobject.h:93
#define DMUS_OBJ_NAME_INFO
Definition: dmobject.h:94
#define DMUS_FOURCC_GUID_CHUNK
Definition: dmusicf.h:42
#define DMUS_FOURCC_VERSION_CHUNK
Definition: dmusicf.h:51
#define DMUS_FOURCC_INFO_LIST
Definition: dmusicf.h:43
#define DMUS_FOURCC_UNFO_LIST
Definition: dmusicf.h:44
#define DMUS_FOURCC_CATEGORY_CHUNK
Definition: dmusicf.h:50
HRESULT hr
Definition: shlfolder.c:183
Definition: dmobject.h:28
Definition: parse.h:23

Referenced by col_IDirectMusicObject_ParseDescriptor().

◆ dmobject_init()

void dmobject_init ( struct dmobject dmobj,
const GUID class,
IUnknown outer_unk 
)

Definition at line 407 of file dmobject.c.

408{
409 dmobj->outer_unk = outer_unk;
410 dmobj->desc.dwSize = sizeof(dmobj->desc);
412 dmobj->desc.guidClass = *class;
413}
DWORD dwValidData
Definition: dmusici.h:743
DMUS_OBJECTDESC desc
Definition: dmobject.h:73
IUnknown * outer_unk
Definition: dmobject.h:72

Referenced by DMUSIC_CreateDirectMusicCollectionImpl().

◆ stream_chunk_get_data()

HRESULT stream_chunk_get_data ( IStream stream,
const struct chunk_entry chunk,
void data,
ULONG  size 
)

Definition at line 143 of file dmobject.c.

145{
146 if (chunk->size != size) {
147 WARN_(dmfile)("Chunk %s (size %u, offset %s) doesn't contains the expected data size %u\n",
150 return E_FAIL;
151 }
152 return stream_read(stream, data, size);
153}
#define E_FAIL
Definition: ddrawi.h:102
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
static int stream_read
Definition: htmldoc.c:205
#define WARN_(ch,...)
Definition: debug.h:157
uint64_t offset
Definition: btrfs_drv.h:564

Referenced by dmobj_parsedescriptor().

◆ stream_chunk_get_wstr()

HRESULT stream_chunk_get_wstr ( IStream stream,
const struct chunk_entry chunk,
WCHAR str,
ULONG  size 
)

Definition at line 155 of file dmobject.c.

157{
158 ULONG len;
159 HRESULT hr;
160
161 hr = IStream_Read(stream, str, min(chunk->size, size), &len);
162 if (FAILED(hr))
163 return hr;
164
165 /* Don't assume the string is properly zero terminated */
166 str[min(len, size - 1)] = 0;
167
168 if (len < chunk->size)
169 return S_FALSE;
170 return S_OK;
171}
GLenum GLsizei len
Definition: glext.h:6722
#define FAILED(hr)
Definition: intsafe.h:51
unsigned int ULONG
Definition: retypes.h:1
#define min(a, b)
Definition: monoChain.cc:55
const WCHAR * str

Referenced by dmobj_parsedescriptor(), and unfo_get_name().

◆ stream_get_chunk()

HRESULT stream_get_chunk ( IStream stream,
struct chunk_entry chunk 
)

Definition at line 76 of file dmobject.c.

77{
78 static const LARGE_INTEGER zero;
79 ULONGLONG ck_end = 0, p_end = 0;
80 HRESULT hr;
81
82 hr = IStream_Seek(stream, zero, STREAM_SEEK_CUR, &chunk->offset);
83 if (FAILED(hr))
84 return hr;
85 assert(!(chunk->offset.QuadPart & 1));
86 if (chunk->parent) {
87 p_end = chunk->parent->offset.QuadPart + CHUNK_HDR_SIZE + ((chunk->parent->size + 1) & ~1);
88 if (chunk->offset.QuadPart == p_end)
89 return S_FALSE;
90 ck_end = chunk->offset.QuadPart + CHUNK_HDR_SIZE;
91 if (ck_end > p_end) {
92 WARN_(dmfile)("No space for sub-chunk header in parent chunk: ends at offset %s > %s\n",
94 return E_FAIL;
95 }
96 }
97
99 if (hr != S_OK)
100 return hr;
101 if (chunk->parent) {
102 ck_end += (chunk->size + 1) & ~1;
103 if (ck_end > p_end) {
104 WARN_(dmfile)("No space for sub-chunk data in parent chunk: ends at offset %s > %s\n",
106 return E_FAIL;
107 }
108 }
109
110 if (chunk->id == FOURCC_LIST || chunk->id == FOURCC_RIFF) {
111 hr = stream_read(stream, &chunk->type, sizeof(FOURCC));
112 if (hr != S_OK)
113 return hr != S_FALSE ? hr : E_FAIL;
114 }
115
116 TRACE_(dmfile)("Returning %s\n", debugstr_chunk(chunk));
117
118 return S_OK;
119}
#define TRACE_(x)
Definition: compat.h:76
#define assert(x)
Definition: debug.h:53
DWORD FOURCC
Definition: dmdls.h:25
#define CHUNK_HDR_SIZE
Definition: dmobject.c:37
int zero
Definition: sehframes.cpp:29
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by col_IDirectMusicObject_ParseDescriptor(), and stream_next_chunk().

◆ stream_next_chunk()

HRESULT stream_next_chunk ( IStream stream,
struct chunk_entry chunk 
)

Definition at line 130 of file dmobject.c.

131{
132 HRESULT hr;
133
134 if (chunk->id) {
136 if (FAILED(hr))
137 return hr;
138 }
139
141}
HRESULT stream_skip_chunk(IStream *stream, struct chunk_entry *chunk)
Definition: dmobject.c:121
HRESULT stream_get_chunk(IStream *stream, struct chunk_entry *chunk)
Definition: dmobject.c:76

Referenced by dmobj_parsedescriptor(), info_get_name(), and unfo_get_name().

◆ stream_reset_chunk_data()

static HRESULT stream_reset_chunk_data ( IStream stream,
const struct chunk_entry chunk 
)
inlinestatic

Definition at line 45 of file dmobject.h.

46{
48
49 offset.QuadPart = chunk->offset.QuadPart + sizeof(FOURCC) + sizeof(DWORD);
50 if (chunk->id == FOURCC_RIFF || chunk->id == FOURCC_LIST)
51 offset.QuadPart += sizeof(FOURCC);
52
53 return IStream_Seek(stream, offset, STREAM_SEEK_SET, NULL);
54}
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
GLintptr offset
Definition: glext.h:5920
#define FOURCC(a, b, c, d)
Definition: memtrack.h:4

◆ stream_reset_chunk_start()

static HRESULT stream_reset_chunk_start ( IStream stream,
const struct chunk_entry chunk 
)
inlinestatic

Definition at line 56 of file dmobject.h.

57{
59
60 offset.QuadPart = chunk->offset.QuadPart;
61
62 return IStream_Seek(stream, offset, STREAM_SEEK_SET, NULL);
63}

◆ stream_skip_chunk()

HRESULT stream_skip_chunk ( IStream stream,
struct chunk_entry chunk 
)

Definition at line 121 of file dmobject.c.

122{
124
125 end.QuadPart = (chunk->offset.QuadPart + CHUNK_HDR_SIZE + chunk->size + 1) & ~(ULONGLONG)1;
126
127 return IStream_Seek(stream, end, STREAM_SEEK_SET, NULL);
128}
GLuint GLuint end
Definition: gl.h:1545

Referenced by col_IDirectMusicObject_ParseDescriptor(), and stream_next_chunk().

◆ unimpl_IPersistStream_GetClassID()

HRESULT WINAPI unimpl_IPersistStream_GetClassID ( IPersistStream iface,
CLSID class 
)

Definition at line 381 of file dmobject.c.

382{
383 TRACE("(%p, %p): method not implemented\n", iface, class);
384 return E_NOTIMPL;
385}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ unimpl_IPersistStream_GetSizeMax()

HRESULT WINAPI unimpl_IPersistStream_GetSizeMax ( IPersistStream iface,
ULARGE_INTEGER size 
)

Definition at line 400 of file dmobject.c.

401{
402 TRACE("(%p, %p): method not implemented\n", iface, size);
403 return E_NOTIMPL;
404}

◆ unimpl_IPersistStream_IsDirty()

HRESULT WINAPI unimpl_IPersistStream_IsDirty ( IPersistStream iface)

Definition at line 387 of file dmobject.c.

388{
389 TRACE("(%p): method not implemented, always returning S_FALSE\n", iface);
390 return S_FALSE;
391}

◆ unimpl_IPersistStream_Save()

HRESULT WINAPI unimpl_IPersistStream_Save ( IPersistStream iface,
IStream stream,
BOOL  clear_dirty 
)

Definition at line 393 of file dmobject.c.

395{
396 TRACE("(%p, %p, %d): method not implemented\n", iface, stream, clear_dirty);
397 return E_NOTIMPL;
398}