1 /* Debug and Helper Functions
3 * Copyright (C) 2004 Rok Mandeljc
4 * Copyright (C) 2004 Raphael Junqueira
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(dmfile
);
45 HRESULT
IDirectMusicUtils_IPersistStream_ParseDescGeneric (DMUS_PRIVATE_CHUNK
* pChunk
, IStream
* pStm
, LPDMUS_OBJECTDESC pDesc
) {
47 switch (pChunk
->fccID
) {
48 case DMUS_FOURCC_GUID_CHUNK
: {
49 TRACE(": GUID chunk\n");
50 pDesc
->dwValidData
|= DMUS_OBJ_OBJECT
;
51 IStream_Read (pStm
, &pDesc
->guidObject
, pChunk
->dwSize
, NULL
);
54 case DMUS_FOURCC_DATE_CHUNK
: {
55 TRACE(": file date chunk\n");
56 pDesc
->dwValidData
|= DMUS_OBJ_DATE
;
57 IStream_Read (pStm
, &pDesc
->ftDate
, pChunk
->dwSize
, NULL
);
60 case DMUS_FOURCC_NAME_CHUNK
: {
61 TRACE(": name chunk\n");
62 pDesc
->dwValidData
|= DMUS_OBJ_NAME
;
63 IStream_Read (pStm
, pDesc
->wszName
, pChunk
->dwSize
, NULL
);
66 case DMUS_FOURCC_FILE_CHUNK
: {
67 TRACE(": file name chunk\n");
68 pDesc
->dwValidData
|= DMUS_OBJ_FILENAME
;
69 IStream_Read (pStm
, pDesc
->wszFileName
, pChunk
->dwSize
, NULL
);
72 case DMUS_FOURCC_VERSION_CHUNK
: {
73 TRACE(": version chunk\n");
74 pDesc
->dwValidData
|= DMUS_OBJ_VERSION
;
75 IStream_Read (pStm
, &pDesc
->vVersion
, pChunk
->dwSize
, NULL
);
78 case DMUS_FOURCC_CATEGORY_CHUNK
: {
79 TRACE(": category chunk\n");
80 pDesc
->dwValidData
|= DMUS_OBJ_CATEGORY
;
81 IStream_Read (pStm
, pDesc
->wszCategory
, pChunk
->dwSize
, NULL
);
92 HRESULT
IDirectMusicUtils_IPersistStream_ParseUNFOGeneric (DMUS_PRIVATE_CHUNK
* pChunk
, IStream
* pStm
, LPDMUS_OBJECTDESC pDesc
) {
94 LARGE_INTEGER liMove
; /* used when skipping chunks */
97 * don't ask me why, but M$ puts INFO elements in UNFO list sometimes
98 * (though strings seem to be valid unicode)
100 switch (pChunk
->fccID
) {
102 case mmioFOURCC('I','N','A','M'):
103 case DMUS_FOURCC_UNAM_CHUNK
: {
104 TRACE(": name chunk\n");
105 pDesc
->dwValidData
|= DMUS_OBJ_NAME
;
106 IStream_Read (pStm
, pDesc
->wszName
, pChunk
->dwSize
, NULL
);
107 TRACE(" - wszName: %s\n", debugstr_w(pDesc
->wszName
));
111 case mmioFOURCC('I','A','R','T'):
112 case DMUS_FOURCC_UART_CHUNK
: {
113 TRACE(": artist chunk (ignored)\n");
114 liMove
.QuadPart
= pChunk
->dwSize
;
115 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
118 case mmioFOURCC('I','C','O','P'):
119 case DMUS_FOURCC_UCOP_CHUNK
: {
120 TRACE(": copyright chunk (ignored)\n");
121 liMove
.QuadPart
= pChunk
->dwSize
;
122 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
125 case mmioFOURCC('I','S','B','J'):
126 case DMUS_FOURCC_USBJ_CHUNK
: {
127 TRACE(": subject chunk (ignored)\n");
128 liMove
.QuadPart
= pChunk
->dwSize
;
129 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
132 case mmioFOURCC('I','C','M','T'):
133 case DMUS_FOURCC_UCMT_CHUNK
: {
134 TRACE(": comment chunk (ignored)\n");
135 liMove
.QuadPart
= pChunk
->dwSize
;
136 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
147 HRESULT
IDirectMusicUtils_IPersistStream_ParseReference (LPPERSISTSTREAM iface
, DMUS_PRIVATE_CHUNK
* pChunk
, IStream
* pStm
, IDirectMusicObject
** ppObject
) {
148 DMUS_PRIVATE_CHUNK Chunk
;
149 DWORD ListSize
[3], ListCount
[3];
150 LARGE_INTEGER liMove
; /* used when skipping chunks */
153 DMUS_IO_REFERENCE ref
;
154 DMUS_OBJECTDESC ref_desc
;
156 memset(&ref
, 0, sizeof(ref
));
157 memset(&ref_desc
, 0, sizeof(ref_desc
));
159 if (pChunk
->fccID
!= DMUS_FOURCC_REF_LIST
) {
160 ERR(": %s chunk should be a REF list\n", debugstr_fourcc (pChunk
->fccID
));
164 ListSize
[0] = pChunk
->dwSize
- sizeof(FOURCC
);
168 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
169 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
170 TRACE(": %s chunk (size = %ld)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
172 hr
= IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk
, pStm
, &ref_desc
);
173 if (FAILED(hr
)) return hr
;
176 switch (Chunk
.fccID
) {
177 case DMUS_FOURCC_REF_CHUNK
: {
178 TRACE(": Reference chunk\n");
179 if (Chunk
.dwSize
!= sizeof(DMUS_IO_REFERENCE
)) return E_FAIL
;
180 IStream_Read (pStm
, &ref
, sizeof(DMUS_IO_REFERENCE
), NULL
);
181 TRACE(" - guidClassID: %s\n", debugstr_dmguid(&ref
.guidClassID
));
182 TRACE(" - dwValidData: %lu\n", ref
.dwValidData
);
186 TRACE(": unknown chunk (irrelevant & skipping)\n");
187 liMove
.QuadPart
= Chunk
.dwSize
;
188 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
193 TRACE(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount
[0], ListSize
[0]);
194 } while (ListCount
[0] < ListSize
[0]);
196 ref_desc
.dwValidData
|= DMUS_OBJ_CLASS
;
197 ref_desc
.guidClass
= ref
.guidClassID
;
199 TRACE("** DM Reference Begin of Load ***\n");
200 TRACE("With Desc:\n");
201 dump_DMUS_OBJECTDESC(&ref_desc
);
204 LPDIRECTMUSICGETLOADER pGetLoader
= NULL
;
205 LPDIRECTMUSICLOADER pLoader
= NULL
;
207 IStream_QueryInterface (pStm
, &IID_IDirectMusicGetLoader
, (LPVOID
*)&pGetLoader
);
208 IDirectMusicGetLoader_GetLoader (pGetLoader
, &pLoader
);
209 IDirectMusicGetLoader_Release (pGetLoader
);
211 hr
= IDirectMusicLoader_GetObject (pLoader
, &ref_desc
, &IID_IDirectMusicObject
, (LPVOID
*)ppObject
);
212 IDirectMusicLoader_Release (pLoader
); /* release loader */
214 TRACE("** DM Reference End of Load ***\n");