1 /* 2 * Base IDirectMusicObject Implementation 3 * Keep in sync with the master in dlls/dmusic/dmobject.h 4 * 5 * Copyright (C) 2014 Michael Stefaniuc 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 */ 21 22 #pragma once 23 24 #include "wine/debug.h" 25 26 /* RIFF stream parsing */ 27 struct chunk_entry; 28 struct chunk_entry { 29 FOURCC id; 30 DWORD size; 31 FOURCC type; /* valid only for LIST and RIFF chunks */ 32 ULARGE_INTEGER offset; /* chunk offset from start of stream */ 33 const struct chunk_entry *parent; /* enclosing RIFF or LIST chunk */ 34 }; 35 36 HRESULT stream_get_chunk(IStream *stream, struct chunk_entry *chunk) DECLSPEC_HIDDEN; 37 HRESULT stream_next_chunk(IStream *stream, struct chunk_entry *chunk) DECLSPEC_HIDDEN; 38 HRESULT stream_skip_chunk(IStream *stream, struct chunk_entry *chunk) DECLSPEC_HIDDEN; 39 40 HRESULT stream_chunk_get_data(IStream *stream, const struct chunk_entry *chunk, void *data, 41 ULONG size) DECLSPEC_HIDDEN; 42 HRESULT stream_chunk_get_wstr(IStream *stream, const struct chunk_entry *chunk, WCHAR *str, 43 ULONG size) DECLSPEC_HIDDEN; 44 45 static inline HRESULT stream_reset_chunk_data(IStream *stream, const struct chunk_entry *chunk) 46 { 47 LARGE_INTEGER offset; 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 } 55 56 static inline HRESULT stream_reset_chunk_start(IStream *stream, const struct chunk_entry *chunk) 57 { 58 LARGE_INTEGER offset; 59 60 offset.QuadPart = chunk->offset.QuadPart; 61 62 return IStream_Seek(stream, offset, STREAM_SEEK_SET, NULL); 63 } 64 65 const char *debugstr_chunk(const struct chunk_entry *chunk) DECLSPEC_HIDDEN; 66 67 68 /* IDirectMusicObject base object */ 69 struct dmobject { 70 IDirectMusicObject IDirectMusicObject_iface; 71 IPersistStream IPersistStream_iface; 72 IUnknown *outer_unk; 73 DMUS_OBJECTDESC desc; 74 }; 75 76 void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk) DECLSPEC_HIDDEN; 77 78 /* Generic IDirectMusicObject methods */ 79 HRESULT WINAPI dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject *iface, REFIID riid, 80 void **ret_iface) DECLSPEC_HIDDEN; 81 ULONG WINAPI dmobj_IDirectMusicObject_AddRef(IDirectMusicObject *iface) DECLSPEC_HIDDEN; 82 ULONG WINAPI dmobj_IDirectMusicObject_Release(IDirectMusicObject *iface) DECLSPEC_HIDDEN; 83 HRESULT WINAPI dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject *iface, 84 DMUS_OBJECTDESC *desc) DECLSPEC_HIDDEN; 85 HRESULT WINAPI dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject *iface, 86 DMUS_OBJECTDESC *desc) DECLSPEC_HIDDEN; 87 88 /* Helper for IDirectMusicObject::ParseDescriptor */ 89 HRESULT dmobj_parsedescriptor(IStream *stream, const struct chunk_entry *riff, 90 DMUS_OBJECTDESC *desc, DWORD supported) DECLSPEC_HIDDEN; 91 /* Additional supported flags for dmobj_parsedescriptor. 92 DMUS_OBJ_NAME is 'UNAM' chunk in UNFO list */ 93 #define DMUS_OBJ_NAME_INAM 0x1000 /* 'INAM' chunk in UNFO list */ 94 #define DMUS_OBJ_NAME_INFO 0x2000 /* 'INAM' chunk in INFO list */ 95 96 /* Generic IPersistStream methods */ 97 HRESULT WINAPI dmobj_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid, 98 void **ret_iface) DECLSPEC_HIDDEN; 99 ULONG WINAPI dmobj_IPersistStream_AddRef(IPersistStream *iface) DECLSPEC_HIDDEN; 100 ULONG WINAPI dmobj_IPersistStream_Release(IPersistStream *iface) DECLSPEC_HIDDEN; 101 HRESULT WINAPI dmobj_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class) DECLSPEC_HIDDEN; 102 103 /* IPersistStream methods not implemented in native */ 104 HRESULT WINAPI unimpl_IPersistStream_GetClassID(IPersistStream *iface, 105 CLSID *class) DECLSPEC_HIDDEN; 106 HRESULT WINAPI unimpl_IPersistStream_IsDirty(IPersistStream *iface) DECLSPEC_HIDDEN; 107 HRESULT WINAPI unimpl_IPersistStream_Save(IPersistStream *iface, IStream *stream, 108 BOOL clear_dirty) DECLSPEC_HIDDEN; 109 HRESULT WINAPI unimpl_IPersistStream_GetSizeMax(IPersistStream *iface, 110 ULARGE_INTEGER *size) DECLSPEC_HIDDEN; 111