ReactOS 0.4.17-dev-923-g4c9a150
style.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2003-2004 Rok Mandeljc
3 * Copyright (C) 2003-2004 Raphael Junqueira
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include "dmstyle_private.h"
21#include "dmobject.h"
22
25
26struct style_band {
27 struct list entry;
28 IDirectMusicBand *pBand;
29};
30
32{
33 struct list entry;
36};
37
39{
40 struct list entry;
53};
54
55static void style_part_destroy(struct style_part *part)
56{
57 free(part->notes);
58 free(part->curves);
59 free(part->markers);
60 free(part->resolutions);
61 free(part->anticipations);
62 free(part);
63}
64
66{
67 struct list entry;
72 IDirectMusicBand *band;
74};
75
77{
78 struct style_part_ref *part_ref, *next;
79
80 LIST_FOR_EACH_ENTRY_SAFE(part_ref, next, &pattern->part_refs, struct style_part_ref, entry)
81 {
82 list_remove(&part_ref->entry);
83 free(part_ref);
84 }
85
88}
89
90struct style
91{
92 IDirectMusicStyle8 IDirectMusicStyle8_iface;
96 struct list patterns;
97 struct list bands;
98 struct list parts;
99};
100
101static inline struct style *impl_from_IDirectMusicStyle8(IDirectMusicStyle8 *iface)
102{
103 return CONTAINING_RECORD(iface, struct style, IDirectMusicStyle8_iface);
104}
105
106static HRESULT WINAPI style_QueryInterface(IDirectMusicStyle8 *iface, REFIID riid,
107 void **ret_iface)
108{
109 struct style *This = impl_from_IDirectMusicStyle8(iface);
110
111 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
112
113 *ret_iface = NULL;
114
115 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicStyle) ||
116 IsEqualIID(riid, &IID_IDirectMusicStyle8))
117 *ret_iface = iface;
118 else if (IsEqualIID(riid, &IID_IDirectMusicObject))
119 *ret_iface = &This->dmobj.IDirectMusicObject_iface;
121 *ret_iface = &This->dmobj.IPersistStream_iface;
122 else {
123 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
124 return E_NOINTERFACE;
125 }
126
127 IUnknown_AddRef((IUnknown*)*ret_iface);
128 return S_OK;
129}
130
131static ULONG WINAPI style_AddRef(IDirectMusicStyle8 *iface)
132{
133 struct style *This = impl_from_IDirectMusicStyle8(iface);
135
136 TRACE("(%p) ref=%ld\n", This, ref);
137
138 return ref;
139}
140
141static ULONG WINAPI style_Release(IDirectMusicStyle8 *iface)
142{
143 struct style *This = impl_from_IDirectMusicStyle8(iface);
145
146 TRACE("(%p) ref=%ld\n", This, ref);
147
148 if (!ref) {
149 struct style_band *band, *band2;
150 struct style_pattern *pattern;
151 struct style_part *part;
152 void *next;
153
154 LIST_FOR_EACH_ENTRY_SAFE(band, band2, &This->bands, struct style_band, entry) {
155 list_remove(&band->entry);
156 if (band->pBand)
158 free(band);
159 }
160
162 {
163 list_remove(&pattern->entry);
165 }
166
167 LIST_FOR_EACH_ENTRY_SAFE(part, next, &This->parts, struct style_part, entry)
168 {
169 list_remove(&part->entry);
170 style_part_destroy(part);
171 }
172
173 free(This);
174 }
175
176 return ref;
177}
178
179static HRESULT WINAPI style_GetBand(IDirectMusicStyle8 *iface, WCHAR *name,
180 IDirectMusicBand **band)
181{
182 struct style *This = impl_from_IDirectMusicStyle8(iface);
183 struct style_band *sband;
184 HRESULT hr;
185
186 TRACE("(%p, %s, %p)\n", This, debugstr_w(name), band);
187
188 if (!name)
189 return E_POINTER;
190
191 LIST_FOR_EACH_ENTRY(sband, &This->bands, struct style_band, entry) {
192 IDirectMusicObject *obj;
193
194 hr = IDirectMusicBand_QueryInterface(sband->pBand, &IID_IDirectMusicObject, (void**)&obj);
195 if (SUCCEEDED(hr)) {
197
199 if (desc.dwValidData & DMUS_OBJ_NAME && !lstrcmpW(name, desc.wszName)) {
202 *band = sband->pBand;
203 return S_OK;
204 }
205 }
206
208 }
209 }
210
211 return S_FALSE;
212}
213
214static HRESULT WINAPI style_EnumBand(IDirectMusicStyle8 *iface, DWORD dwIndex,
215 WCHAR *pwszName)
216{
217 struct style *This = impl_from_IDirectMusicStyle8(iface);
218 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
219 return S_OK;
220}
221
222static HRESULT WINAPI style_GetDefaultBand(IDirectMusicStyle8 *iface,
223 IDirectMusicBand **band)
224{
225 struct style *This = impl_from_IDirectMusicStyle8(iface);
226 FIXME("(%p, %p): stub\n", This, band);
227
228 if (!band)
229 return E_POINTER;
230
231 *band = NULL;
232
233 return S_FALSE;
234}
235
236static HRESULT WINAPI style_EnumMotif(IDirectMusicStyle8 *iface, DWORD index,
237 WCHAR *name)
238{
239 struct style *This = impl_from_IDirectMusicStyle8(iface);
240 const struct style_pattern *pattern = NULL;
241 const struct list *cursor;
242 unsigned int i = 0;
243
244 TRACE("(%p, %lu, %p)\n", This, index, name);
245
246 if (!name)
247 return E_POINTER;
248
249 /* index is zero based */
250 LIST_FOR_EACH(cursor, &This->patterns)
251 {
252 if (i == index) {
254 break;
255 }
256 i++;
257 }
258 if (!pattern)
259 return S_FALSE;
260
261 if (pattern->desc.dwValidData & DMUS_OBJ_NAME)
262 lstrcpynW(name, pattern->desc.wszName, DMUS_MAX_NAME);
263 else
264 name[0] = 0;
265
266 TRACE("returning name: %s\n", debugstr_w(name));
267 return S_OK;
268}
269
270static HRESULT WINAPI style_GetMotif(IDirectMusicStyle8 *iface, WCHAR *pwszName,
271 IDirectMusicSegment **ppSegment)
272{
273 struct style *This = impl_from_IDirectMusicStyle8(iface);
274 FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszName), ppSegment);
275 return S_FALSE;
276}
277
278static HRESULT WINAPI style_GetDefaultChordMap(IDirectMusicStyle8 *iface,
279 IDirectMusicChordMap **ppChordMap)
280{
281 struct style *This = impl_from_IDirectMusicStyle8(iface);
282 FIXME("(%p, %p): stub\n", This, ppChordMap);
283 return S_OK;
284}
285
286static HRESULT WINAPI style_EnumChordMap(IDirectMusicStyle8 *iface, DWORD dwIndex,
287 WCHAR *pwszName)
288{
289 struct style *This = impl_from_IDirectMusicStyle8(iface);
290 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
291 return S_OK;
292}
293
294static HRESULT WINAPI style_GetChordMap(IDirectMusicStyle8 *iface, WCHAR *pwszName,
295 IDirectMusicChordMap **ppChordMap)
296{
297 struct style *This = impl_from_IDirectMusicStyle8(iface);
298 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppChordMap);
299 return S_OK;
300}
301
302static HRESULT WINAPI style_GetTimeSignature(IDirectMusicStyle8 *iface,
303 DMUS_TIMESIGNATURE *pTimeSig)
304{
305 struct style *This = impl_from_IDirectMusicStyle8(iface);
306 FIXME("(%p, %p): stub\n", This, pTimeSig);
307 return S_OK;
308}
309
310static HRESULT WINAPI style_GetEmbellishmentLength(IDirectMusicStyle8 *iface,
311 DWORD dwType, DWORD dwLevel, DWORD *pdwMin, DWORD *pdwMax)
312{
313 struct style *This = impl_from_IDirectMusicStyle8(iface);
314 FIXME("(%p, %ld, %ld, %p, %p): stub\n", This, dwType, dwLevel, pdwMin, pdwMax);
315 return S_OK;
316}
317
318static HRESULT WINAPI style_GetTempo(IDirectMusicStyle8 *iface, double *pTempo)
319{
320 struct style *This = impl_from_IDirectMusicStyle8(iface);
321 FIXME("(%p, %p): stub\n", This, pTempo);
322 return S_OK;
323}
324
325static HRESULT WINAPI style_EnumPattern(IDirectMusicStyle8 *iface, DWORD dwIndex,
326 DWORD dwPatternType, WCHAR *pwszName)
327{
328 struct style *This = impl_from_IDirectMusicStyle8(iface);
329 FIXME("(%p, %ld, %ld, %p): stub\n", This, dwIndex, dwPatternType, pwszName);
330 return S_OK;
331}
332
333static const IDirectMusicStyle8Vtbl dmstyle8_vtbl = {
349};
350
353{
354 struct chunk_entry riff = {0};
355 HRESULT hr;
356
357 TRACE("(%p, %p, %p)\n", iface, stream, desc);
358
359 if (!stream || !desc)
360 return E_POINTER;
361
362 if ((hr = stream_get_chunk(stream, &riff)) != S_OK)
363 return hr;
364 if (riff.id != FOURCC_RIFF || riff.type != DMUS_FOURCC_STYLE_FORM) {
365 TRACE("loading failed: unexpected %s\n", debugstr_chunk(&riff));
368 }
369
372 if (FAILED(hr))
373 return hr;
374
375 desc->guidClass = CLSID_DirectMusicStyle;
376 desc->dwValidData |= DMUS_OBJ_CLASS;
377
379 return S_OK;
380}
381
382static const IDirectMusicObjectVtbl dmobject_vtbl = {
389};
390
391static inline struct style *impl_from_IPersistStream(IPersistStream *iface)
392{
393 return CONTAINING_RECORD(iface, struct style, dmobj.IPersistStream_iface);
394}
395
396static HRESULT load_band(IStream *pClonedStream, IDirectMusicBand **ppBand)
397{
398 HRESULT hr = E_FAIL;
399 IPersistStream* pPersistStream = NULL;
400
401 hr = CoCreateInstance (&CLSID_DirectMusicBand, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicBand, (LPVOID*) ppBand);
402 if (FAILED(hr)) {
403 ERR(": could not create object\n");
404 return hr;
405 }
406 /* acquire PersistStream interface */
407 hr = IDirectMusicBand_QueryInterface (*ppBand, &IID_IPersistStream, (LPVOID*) &pPersistStream);
408 if (FAILED(hr)) {
409 ERR(": could not acquire IPersistStream\n");
410 return hr;
411 }
412 /* load */
413 hr = IPersistStream_Load (pPersistStream, pClonedStream);
414 if (FAILED(hr)) {
415 ERR(": failed to load object\n");
416 return hr;
417 }
418
419 /* release all loading-related stuff */
420 IPersistStream_Release (pPersistStream);
421
422 return S_OK;
423}
424
426 struct list *list)
427{
428 struct chunk_entry chunk = {.parent = parent};
429 struct style_part_ref *part_ref;
431 HRESULT hr;
432
435 return hr;
436
437 if (!(part_ref = calloc(1, sizeof(*part_ref)))) return E_OUTOFMEMORY;
438 part_ref->desc = desc;
439
440 while ((hr = stream_next_chunk(stream, &chunk)) == S_OK)
441 {
442 switch (MAKE_IDTYPE(chunk.id, chunk.type))
443 {
445 hr = stream_chunk_get_data(stream, &chunk, &part_ref->header, sizeof(part_ref->header));
446 break;
447
449 /* already parsed by dmobj_parsedescriptor */
450 break;
451
452 default:
453 FIXME("Ignoring chunk %s %s\n", debugstr_fourcc(chunk.id), debugstr_fourcc(chunk.type));
454 break;
455 }
456
457 if (FAILED(hr)) break;
458 }
459
460 if (FAILED(hr)) free(part_ref);
461 else list_add_tail(list, &part_ref->entry);
462
463 return S_OK;
464}
465
467{
468 struct chunk_entry chunk = {.parent = parent};
469 struct style_part *part;
471 HRESULT hr;
472
475 return hr;
476
477 if (!(part = calloc(1, sizeof(*part)))) return E_OUTOFMEMORY;
478 part->desc = desc;
479
480 while ((hr = stream_next_chunk(stream, &chunk)) == S_OK)
481 {
482 switch (MAKE_IDTYPE(chunk.id, chunk.type))
483 {
485 hr = stream_chunk_get_data(stream, &chunk, &part->header, sizeof(part->header));
486 break;
487
489 /* already parsed by dmobj_parsedescriptor */
490 break;
491
493 hr = stream_chunk_get_array(stream, &chunk, (void **)&part->notes,
494 &part->notes_count, sizeof(*part->notes));
495 break;
496
498 hr = stream_chunk_get_array(stream, &chunk, (void **)&part->curves,
499 &part->curves_count, sizeof(*part->curves));
500 break;
501
503 hr = stream_chunk_get_array(stream, &chunk, (void **)&part->markers,
504 &part->markers_count, sizeof(*part->markers));
505 break;
506
508 hr = stream_chunk_get_array(stream, &chunk, (void **)&part->resolutions,
509 &part->resolutions_count, sizeof(*part->resolutions));
510 break;
511
514 &part->anticipations_count, sizeof(*part->anticipations));
515 break;
516
517 default:
518 FIXME("Ignoring chunk %s %s\n", debugstr_fourcc(chunk.id), debugstr_fourcc(chunk.type));
519 break;
520 }
521
522 if (FAILED(hr)) break;
523 }
524
525 if (FAILED(hr)) style_part_destroy(part);
526 else list_add_tail(&This->parts, &part->entry);
527
528 return hr;
529}
530
532{
533 struct chunk_entry chunk = {.parent = parent};
534 struct style_pattern *pattern;
536 HRESULT hr;
537
540 return hr;
541
542 if (!(pattern = calloc(1, sizeof(*pattern)))) return E_OUTOFMEMORY;
543 list_init(&pattern->part_refs);
544 pattern->desc = desc;
545
546 while ((hr = stream_next_chunk(stream, &chunk)) == S_OK)
547 {
548 switch (MAKE_IDTYPE(chunk.id, chunk.type))
549 {
551 /* already parsed by dmobj_parsedescriptor */
552 break;
553
555 hr = stream_chunk_get_data(stream, &chunk, &pattern->pattern, sizeof(pattern->pattern));
556 break;
557
559 if (chunk.size > sizeof(pattern->dwRhythm)) FIXME("Unsupported rythm chunk size\n");
560 hr = stream_read(stream, &pattern->dwRhythm, sizeof(pattern->dwRhythm));
561 break;
562
564 hr = stream_chunk_get_data(stream, &chunk, &pattern->settings, sizeof(pattern->settings));
565 break;
566
568 {
569 IPersistStream *persist;
570
571 if (pattern->band) IDirectMusicBand_Release(pattern->band);
572
573 if (FAILED(hr = CoCreateInstance(&CLSID_DirectMusicBand, NULL, CLSCTX_INPROC_SERVER,
574 &IID_IDirectMusicBand, (void **)&pattern->band)))
575 break;
576
577 if (SUCCEEDED(hr = IDirectMusicBand_QueryInterface(pattern->band, &IID_IPersistStream, (void **)&persist)))
578 {
580 hr = IPersistStream_Load(persist, stream);
581 IPersistStream_Release(persist);
582 }
583
584 break;
585 }
586
588 hr = parse_pref_list(This, stream, &chunk, &pattern->part_refs);
589 break;
590
591 default:
592 FIXME("Ignoring chunk %s %s\n", debugstr_fourcc(chunk.id), debugstr_fourcc(chunk.type));
593 break;
594 }
595
596 if (FAILED(hr)) break;
597 }
598
600 else list_add_tail(&This->patterns, &pattern->entry);
601
602 return hr;
603}
604
606{
607 HRESULT hr = E_FAIL;
608 DMUS_PRIVATE_CHUNK Chunk;
609 DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
610 LARGE_INTEGER liMove; /* used when skipping chunks */
611
612 IDirectMusicBand* pBand = NULL;
613
614 if (pChunk->fccID != DMUS_FOURCC_STYLE_FORM) {
615 ERR_(dmfile)(": %s chunk should be a STYLE form\n", debugstr_fourcc (pChunk->fccID));
616 return E_FAIL;
617 }
618
619 StreamSize = pChunk->dwSize - sizeof(FOURCC);
620 StreamCount = 0;
621
622 do {
623 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
624 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
625 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
626
627 hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk, pStm, &This->dmobj.desc);
628 if (FAILED(hr)) return hr;
629
630 if (hr == S_FALSE) {
631 switch (Chunk.fccID) {
633 TRACE_(dmfile)(": Style chunk\n");
634 IStream_Read (pStm, &This->style, sizeof(DMUS_IO_STYLE), NULL);
636 TRACE_(dmfile)(" - dblTempo: %g\n", This->style.dblTempo);
637 break;
638 }
639 case FOURCC_RIFF: {
643 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
644 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
645 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
646 ListCount[0] = 0;
647 switch (Chunk.fccID) {
648 case DMUS_FOURCC_BAND_FORM: {
649 ULARGE_INTEGER save;
650 struct style_band *pNewBand;
651
652 TRACE_(dmfile)(": BAND RIFF\n");
653
654 /* Can be application provided IStream without Clone method */
655 liMove.QuadPart = 0;
656 liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
657 IStream_Seek(pStm, liMove, STREAM_SEEK_CUR, &save);
658
659 hr = load_band(pStm, &pBand);
660 if (FAILED(hr)) {
661 ERR(": could not load track\n");
662 return hr;
663 }
664
665 if (!(pNewBand = calloc(1, sizeof(*pNewBand)))) return E_OUTOFMEMORY;
666 pNewBand->pBand = pBand;
668 list_add_tail(&This->bands, &pNewBand->entry);
669
670 IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release it as it's inserted */
671
673 liMove.QuadPart = save.QuadPart - liMove.QuadPart + ListSize[0];
674 IStream_Seek(pStm, liMove, STREAM_SEEK_SET, NULL);
675
676 break;
677 }
678 default: {
679 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
680 liMove.QuadPart = ListSize[0];
681 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
682 break;
683 }
684 }
685 break;
686 }
687 case FOURCC_LIST: {
688 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
689 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
690 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
691 ListCount[0] = 0;
692 switch (Chunk.fccID) {
693 case DMUS_FOURCC_UNFO_LIST: {
694 TRACE_(dmfile)(": UNFO list\n");
695 do {
696 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
697 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
698 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
699
700 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &This->dmobj.desc);
701 if (FAILED(hr)) return hr;
702
703 if (hr == S_FALSE) {
704 switch (Chunk.fccID) {
705 default: {
706 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
707 liMove.QuadPart = Chunk.dwSize;
708 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
709 break;
710 }
711 }
712 }
713 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
714 } while (ListCount[0] < ListSize[0]);
715 break;
716 }
718 static const LARGE_INTEGER zero = {0};
719 struct chunk_entry chunk = {FOURCC_LIST, .size = Chunk.dwSize, .type = Chunk.fccID};
720 TRACE_(dmfile)(": PART list\n");
721 IStream_Seek(pStm, zero, STREAM_SEEK_CUR, &chunk.offset);
722 chunk.offset.QuadPart -= 12;
723 hr = parse_part_list(This, pStm, &chunk);
724 if (FAILED(hr)) return hr;
725 break;
726 }
728 static const LARGE_INTEGER zero = {0};
729 struct chunk_entry chunk = {FOURCC_LIST, .size = Chunk.dwSize, .type = Chunk.fccID};
730 TRACE_(dmfile)(": PATTERN list\n");
731 IStream_Seek(pStm, zero, STREAM_SEEK_CUR, &chunk.offset);
732 chunk.offset.QuadPart -= 12;
733 hr = parse_pttn_list(This, pStm, &chunk);
734 if (FAILED(hr)) return hr;
735 break;
736 }
737 default: {
738 TRACE_(dmfile)(": unknown (skipping)\n");
739 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
740 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
741 break;
742 }
743 }
744 break;
745 }
746 default: {
747 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
748 liMove.QuadPart = Chunk.dwSize;
749 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
750 break;
751 }
752 }
753 }
754 TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
755 } while (StreamCount < StreamSize);
756
757 return S_OK;
758}
759
761{
762 struct style *This = impl_from_IPersistStream(iface);
763 DMUS_PRIVATE_CHUNK Chunk;
764 LARGE_INTEGER liMove; /* used when skipping chunks */
765 HRESULT hr;
766
767 FIXME("(%p, %p): Loading\n", This, pStm);
768
769 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
770 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
771 switch (Chunk.fccID) {
772 case FOURCC_RIFF: {
773 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
774 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
775 switch (Chunk.fccID) {
777 TRACE_(dmfile)(": Style form\n");
778 hr = parse_style_form(This, &Chunk, pStm);
779 if (FAILED(hr)) return hr;
780 break;
781 }
782 default: {
783 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
784 liMove.QuadPart = Chunk.dwSize;
785 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
786 return E_FAIL;
787 }
788 }
789 TRACE_(dmfile)(": reading finished\n");
790 break;
791 }
792 default: {
793 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
794 liMove.QuadPart = Chunk.dwSize;
795 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
796 return E_FAIL;
797 }
798 }
799
800 return S_OK;
801}
802
803static const IPersistStreamVtbl persiststream_vtbl = {
812};
813
814HRESULT create_dmstyle(REFIID lpcGUID, void **ppobj)
815{
816 struct style *obj;
817 HRESULT hr;
818
819 *ppobj = NULL;
820 if (!(obj = calloc(1, sizeof(*obj)))) return E_OUTOFMEMORY;
821 obj->IDirectMusicStyle8_iface.lpVtbl = &dmstyle8_vtbl;
822 obj->ref = 1;
823 dmobject_init(&obj->dmobj, &CLSID_DirectMusicStyle, (IUnknown *)&obj->IDirectMusicStyle8_iface);
824 obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
825 obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
826 list_init(&obj->parts);
827 list_init(&obj->bands);
828 list_init(&obj->patterns);
829
830 hr = IDirectMusicStyle8_QueryInterface(&obj->IDirectMusicStyle8_iface, lpcGUID, ppobj);
831 IDirectMusicStyle8_Release(&obj->IDirectMusicStyle8_iface);
832
833 return hr;
834}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_init(struct list_entry *head)
Definition: list.h:51
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
Definition: list.h:39
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
static HRESULT WINAPI style_EnumChordMap(IDirectMusicStyle8 *iface, DWORD dwIndex, WCHAR *pwszName)
Definition: style.c:286
static HRESULT WINAPI style_IDirectMusicObject_ParseDescriptor(IDirectMusicObject *iface, IStream *stream, DMUS_OBJECTDESC *desc)
Definition: style.c:351
static struct style * impl_from_IPersistStream(IPersistStream *iface)
Definition: style.c:391
static HRESULT WINAPI style_EnumPattern(IDirectMusicStyle8 *iface, DWORD dwIndex, DWORD dwPatternType, WCHAR *pwszName)
Definition: style.c:325
static ULONG WINAPI style_Release(IDirectMusicStyle8 *iface)
Definition: style.c:141
static HRESULT parse_part_list(struct style *This, IStream *stream, struct chunk_entry *parent)
Definition: style.c:466
static HRESULT WINAPI style_GetTimeSignature(IDirectMusicStyle8 *iface, DMUS_TIMESIGNATURE *pTimeSig)
Definition: style.c:302
static HRESULT WINAPI style_GetChordMap(IDirectMusicStyle8 *iface, WCHAR *pwszName, IDirectMusicChordMap **ppChordMap)
Definition: style.c:294
static HRESULT parse_pref_list(struct style *This, IStream *stream, struct chunk_entry *parent, struct list *list)
Definition: style.c:425
static HRESULT WINAPI style_QueryInterface(IDirectMusicStyle8 *iface, REFIID riid, void **ret_iface)
Definition: style.c:106
static void style_part_destroy(struct style_part *part)
Definition: style.c:55
static HRESULT WINAPI style_GetEmbellishmentLength(IDirectMusicStyle8 *iface, DWORD dwType, DWORD dwLevel, DWORD *pdwMin, DWORD *pdwMax)
Definition: style.c:310
static const IDirectMusicObjectVtbl dmobject_vtbl
Definition: style.c:382
static HRESULT WINAPI style_GetDefaultBand(IDirectMusicStyle8 *iface, IDirectMusicBand **band)
Definition: style.c:222
static HRESULT WINAPI style_EnumBand(IDirectMusicStyle8 *iface, DWORD dwIndex, WCHAR *pwszName)
Definition: style.c:214
static const IPersistStreamVtbl persiststream_vtbl
Definition: style.c:803
static HRESULT WINAPI style_GetDefaultChordMap(IDirectMusicStyle8 *iface, IDirectMusicChordMap **ppChordMap)
Definition: style.c:278
static HRESULT WINAPI style_EnumMotif(IDirectMusicStyle8 *iface, DWORD index, WCHAR *name)
Definition: style.c:236
static struct style * impl_from_IDirectMusicStyle8(IDirectMusicStyle8 *iface)
Definition: style.c:101
static HRESULT WINAPI style_GetTempo(IDirectMusicStyle8 *iface, double *pTempo)
Definition: style.c:318
HRESULT create_dmstyle(REFIID lpcGUID, void **ppobj)
Definition: style.c:814
static HRESULT parse_style_form(struct style *This, DMUS_PRIVATE_CHUNK *pChunk, IStream *pStm)
Definition: style.c:605
static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pStm)
Definition: style.c:760
static void style_pattern_destroy(struct style_pattern *pattern)
Definition: style.c:76
static const IDirectMusicStyle8Vtbl dmstyle8_vtbl
Definition: style.c:333
static ULONG WINAPI style_AddRef(IDirectMusicStyle8 *iface)
Definition: style.c:131
static HRESULT load_band(IStream *pClonedStream, IDirectMusicBand **ppBand)
Definition: style.c:396
static HRESULT WINAPI style_GetBand(IDirectMusicStyle8 *iface, WCHAR *name, IDirectMusicBand **band)
Definition: style.c:179
static HRESULT parse_pttn_list(struct style *This, IStream *stream, struct chunk_entry *parent)
Definition: style.c:531
static HRESULT WINAPI style_GetMotif(IDirectMusicStyle8 *iface, WCHAR *pwszName, IDirectMusicSegment **ppSegment)
Definition: style.c:270
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
#define TRACE_(x)
Definition: compat.h:76
#define WINE_DECLARE_DEBUG_CHANNEL(x)
Definition: compat.h:45
#define lstrcpynW
Definition: compat.h:738
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
DWORD FOURCC
Definition: dmdls.h:25
#define DMUS_E_CHUNKNOTFOUND
Definition: dmerror.h:66
HRESULT WINAPI dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject *iface, DMUS_OBJECTDESC *desc)
Definition: dmobject.c:503
void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk)
Definition: dmobject.c:749
HRESULT stream_chunk_get_data(IStream *stream, const struct chunk_entry *chunk, void *data, ULONG size)
Definition: dmobject.c:417
HRESULT stream_next_chunk(IStream *stream, struct chunk_entry *chunk)
Definition: dmobject.c:360
ULONG WINAPI dmobj_IPersistStream_Release(IPersistStream *iface)
Definition: dmobject.c:702
ULONG WINAPI dmobj_IDirectMusicObject_Release(IDirectMusicObject *iface)
Definition: dmobject.c:497
HRESULT dmobj_parsedescriptor(IStream *stream, const struct chunk_entry *riff, DMUS_OBJECTDESC *desc, DWORD supported)
Definition: dmobject.c:591
HRESULT WINAPI dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject *iface, REFIID riid, void **ret_iface)
Definition: dmobject.c:484
HRESULT WINAPI unimpl_IPersistStream_GetSizeMax(IPersistStream *iface, ULARGE_INTEGER *size)
Definition: dmobject.c:742
HRESULT WINAPI dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject *iface, DMUS_OBJECTDESC *desc)
Definition: dmobject.c:518
void dump_DMUS_OBJECTDESC(DMUS_OBJECTDESC *desc)
Definition: dmobject.c:222
const char * debugstr_chunk(const struct chunk_entry *chunk)
Definition: dmobject.c:279
HRESULT WINAPI dmobj_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class)
Definition: dmobject.c:708
ULONG WINAPI dmobj_IPersistStream_AddRef(IPersistStream *iface)
Definition: dmobject.c:696
const char * debugstr_dmguid(const GUID *id)
Definition: dmobject.c:36
HRESULT stream_chunk_get_array(IStream *stream, const struct chunk_entry *chunk, void **array, unsigned int *count, DWORD elem_size)
Definition: dmobject.c:378
HRESULT WINAPI dmobj_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid, void **ret_iface)
Definition: dmobject.c:689
ULONG WINAPI dmobj_IDirectMusicObject_AddRef(IDirectMusicObject *iface)
Definition: dmobject.c:491
HRESULT stream_skip_chunk(IStream *stream, const struct chunk_entry *chunk)
Definition: dmobject.c:351
HRESULT stream_get_chunk(IStream *stream, struct chunk_entry *chunk)
Definition: dmobject.c:307
HRESULT WINAPI unimpl_IPersistStream_IsDirty(IPersistStream *iface)
Definition: dmobject.c:729
HRESULT WINAPI unimpl_IPersistStream_Save(IPersistStream *iface, IStream *stream, BOOL clear_dirty)
Definition: dmobject.c:735
static HRESULT stream_reset_chunk_data(IStream *stream, const struct chunk_entry *chunk)
Definition: dmobject.h:50
#define DMUS_OBJ_NAME_INAM
Definition: dmobject.h:96
static HRESULT stream_reset_chunk_start(IStream *stream, const struct chunk_entry *chunk)
Definition: dmobject.h:61
#define MAKE_IDTYPE(id, type)
Definition: dmobject.h:33
#define IDirectMusicTrack_Release(p)
Definition: dmplugin.h:226
#define DMUS_FOURCC_STYLE_CHUNK
Definition: dmusicf.h:119
#define DMUS_FOURCC_BAND_FORM
Definition: dmusicf.h:63
#define DMUS_FOURCC_RHYTHM_CHUNK
Definition: dmusicf.h:129
#define DMUS_FOURCC_PATTERN_LIST
Definition: dmusicf.h:127
#define DMUS_FOURCC_PARTREF_LIST
Definition: dmusicf.h:130
#define DMUS_FOURCC_ANTICIPATION_CHUNK
Definition: dmusicf.h:126
#define DMUS_FOURCC_PART_LIST
Definition: dmusicf.h:120
#define DMUS_FOURCC_PARTREF_CHUNK
Definition: dmusicf.h:131
#define DMUS_FOURCC_PART_CHUNK
Definition: dmusicf.h:121
#define DMUS_FOURCC_CURVE_CHUNK
Definition: dmusicf.h:123
#define DMUS_FOURCC_STYLE_FORM
Definition: dmusicf.h:118
#define DMUS_FOURCC_UNFO_LIST
Definition: dmusicf.h:44
#define DMUS_FOURCC_PATTERN_CHUNK
Definition: dmusicf.h:128
#define DMUS_FOURCC_MOTIFSETTINGS_CHUNK
Definition: dmusicf.h:133
#define DMUS_FOURCC_RESOLUTION_CHUNK
Definition: dmusicf.h:125
#define DMUS_FOURCC_NOTE_CHUNK
Definition: dmusicf.h:122
#define DMUS_FOURCC_MARKER_CHUNK
Definition: dmusicf.h:124
#define IDirectMusicBand_AddRef(p)
Definition: dmusici.h:814
#define IDirectMusicObject_Release(p)
Definition: dmusici.h:844
#define IDirectMusicBand_QueryInterface(p, a, b)
Definition: dmusici.h:813
#define DMUS_OBJ_NAME
Definition: dmusici.h:267
#define IDirectMusicStyle8_QueryInterface(p, a, b)
Definition: dmusici.h:1555
#define IDirectMusicObject_GetDescriptor(p, a)
Definition: dmusici.h:846
#define IDirectMusicStyle8_Release(p)
Definition: dmusici.h:1557
#define DMUS_OBJ_CLASS
Definition: dmusici.h:266
#define DMUS_MAX_NAME
Definition: dmusici.h:245
#define IDirectMusicBand_Release(p)
Definition: dmusici.h:815
#define DMUS_OBJ_VERSION
Definition: dmusici.h:272
#define DMUS_OBJ_OBJECT
Definition: dmusici.h:265
HRESULT IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(DMUS_PRIVATE_CHUNK *pChunk, IStream *pStm, LPDMUS_OBJECTDESC pDesc)
Definition: dmutils.c:92
HRESULT IDirectMusicUtils_IPersistStream_ParseDescGeneric(DMUS_PRIVATE_CHUNK *pChunk, IStream *pStm, LPDMUS_OBJECTDESC pDesc)
Definition: dmutils.c:45
r parent
Definition: btrfs.c:3010
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint index
Definition: glext.h:6031
GLubyte * pattern
Definition: glext.h:7787
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
unsigned int UINT
Definition: sysinfo.c:13
const char cursor[]
Definition: icontest.c:13
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
uint32_t entry
Definition: isohybrid.c:63
#define debugstr_w
Definition: kernel32.h:32
#define FOURCC(a, b, c, d)
Definition: memtrack.h:4
#define FOURCC_RIFF
Definition: mmsystem.h:564
#define FOURCC_LIST
Definition: mmsystem.h:565
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
static int stream_read
Definition: htmldoc.c:205
#define DWORD
Definition: nt_native.h:44
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
const GUID IID_IPersistStream
Definition: proxy.cpp:13
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
static unsigned __int64 next
Definition: rand_nt.c:6
#define calloc
Definition: rosglue.h:14
#define ERR_(ch,...)
Definition: debug.h:156
static __inline const char * debugstr_fourcc(unsigned int cc)
Definition: debug.h:397
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:242
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:226
int zero
Definition: sehframes.cpp:29
#define TRACE(s)
Definition: solgame.cpp:4
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
Definition: band.c:76
Definition: dmobject.h:26
FOURCC id
Definition: dmobject.h:27
FOURCC type
Definition: dmobject.h:29
uint16_t size
Definition: btrfs_drv.h:563
uint64_t offset
Definition: btrfs_drv.h:564
Definition: name.c:39
Definition: send.c:48
Definition: parse.h:23
IDirectMusicBand * pBand
Definition: style.c:28
struct list entry
Definition: style.c:27
DMUS_OBJECTDESC desc
Definition: style.c:34
struct list entry
Definition: style.c:33
DMUS_IO_PARTREF header
Definition: style.c:35
DMUS_IO_STYLERESOLUTION * resolutions
Definition: style.c:49
DMUS_IO_STYLEMARKER * markers
Definition: style.c:47
struct list entry
Definition: style.c:40
UINT anticipations_count
Definition: style.c:52
UINT notes_count
Definition: style.c:44
DMUS_IO_STYLE_ANTICIPATION * anticipations
Definition: style.c:51
DMUS_IO_STYLECURVE * curves
Definition: style.c:45
UINT curves_count
Definition: style.c:46
UINT resolutions_count
Definition: style.c:50
DMUS_IO_STYLENOTE * notes
Definition: style.c:43
DMUS_IO_STYLEPART header
Definition: style.c:42
UINT markers_count
Definition: style.c:48
DMUS_OBJECTDESC desc
Definition: style.c:41
struct list part_refs
Definition: style.c:73
DMUS_OBJECTDESC desc
Definition: style.c:70
IDirectMusicBand * band
Definition: style.c:72
struct list entry
Definition: style.c:67
DMUS_IO_PATTERN pattern
Definition: style.c:69
DMUS_IO_MOTIFSETTINGS settings
Definition: style.c:71
DWORD dwRhythm
Definition: style.c:68
Definition: style.c:91
IDirectMusicStyle8 IDirectMusicStyle8_iface
Definition: style.c:92
struct list bands
Definition: style.c:97
struct list parts
Definition: style.c:98
LONG ref
Definition: style.c:94
struct dmobject dmobj
Definition: style.c:93
DMUS_IO_STYLE style
Definition: style.c:95
struct list patterns
Definition: style.c:96
#define LIST_ENTRY(type)
Definition: queue.h:175
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:3451
#define E_NOINTERFACE
Definition: winerror.h:3479
#define E_POINTER
Definition: winerror.h:3480