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