2 * Base IDirectMusicObject Implementation
3 * Keep in sync with the master in dlls/dmusic/dmobject.h
5 * Copyright (C) 2014 Michael Stefaniuc
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.
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.
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
22 #include "wine/debug.h"
24 /* RIFF stream parsing */
29 FOURCC type
; /* valid only for LIST and RIFF chunks */
30 ULARGE_INTEGER offset
; /* chunk offset from start of stream */
31 const struct chunk_entry
*parent
; /* enclosing RIFF or LIST chunk */
34 HRESULT
stream_get_chunk(IStream
*stream
, struct chunk_entry
*chunk
) DECLSPEC_HIDDEN
;
35 HRESULT
stream_next_chunk(IStream
*stream
, struct chunk_entry
*chunk
) DECLSPEC_HIDDEN
;
36 HRESULT
stream_skip_chunk(IStream
*stream
, struct chunk_entry
*chunk
) DECLSPEC_HIDDEN
;
38 HRESULT
stream_chunk_get_data(IStream
*stream
, const struct chunk_entry
*chunk
, void *data
,
39 ULONG size
) DECLSPEC_HIDDEN
;
40 HRESULT
stream_chunk_get_wstr(IStream
*stream
, const struct chunk_entry
*chunk
, WCHAR
*str
,
41 ULONG size
) DECLSPEC_HIDDEN
;
43 static inline HRESULT
stream_reset_chunk_data(IStream
*stream
, const struct chunk_entry
*chunk
)
47 offset
.QuadPart
= chunk
->offset
.QuadPart
+ sizeof(FOURCC
) + sizeof(DWORD
);
48 if (chunk
->id
== FOURCC_RIFF
|| chunk
->id
== FOURCC_LIST
)
49 offset
.QuadPart
+= sizeof(FOURCC
);
51 return IStream_Seek(stream
, offset
, STREAM_SEEK_SET
, NULL
);
54 static inline HRESULT
stream_reset_chunk_start(IStream
*stream
, const struct chunk_entry
*chunk
)
58 offset
.QuadPart
= chunk
->offset
.QuadPart
;
60 return IStream_Seek(stream
, offset
, STREAM_SEEK_SET
, NULL
);
63 const char *debugstr_chunk(const struct chunk_entry
*chunk
) DECLSPEC_HIDDEN
;
66 /* IDirectMusicObject base object */
68 IDirectMusicObject IDirectMusicObject_iface
;
69 IPersistStream IPersistStream_iface
;
74 void dmobject_init(struct dmobject
*dmobj
, const GUID
*class, IUnknown
*outer_unk
) DECLSPEC_HIDDEN
;
76 /* Generic IDirectMusicObject methods */
77 HRESULT WINAPI
dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject
*iface
, REFIID riid
,
78 void **ret_iface
) DECLSPEC_HIDDEN
;
79 ULONG WINAPI
dmobj_IDirectMusicObject_AddRef(IDirectMusicObject
*iface
) DECLSPEC_HIDDEN
;
80 ULONG WINAPI
dmobj_IDirectMusicObject_Release(IDirectMusicObject
*iface
) DECLSPEC_HIDDEN
;
81 HRESULT WINAPI
dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject
*iface
,
82 DMUS_OBJECTDESC
*desc
) DECLSPEC_HIDDEN
;
83 HRESULT WINAPI
dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject
*iface
,
84 DMUS_OBJECTDESC
*desc
) DECLSPEC_HIDDEN
;
86 /* Helper for IDirectMusicObject::ParseDescriptor */
87 HRESULT
dmobj_parsedescriptor(IStream
*stream
, const struct chunk_entry
*riff
,
88 DMUS_OBJECTDESC
*desc
, DWORD supported
) DECLSPEC_HIDDEN
;
89 /* Additional supported flags for dmobj_parsedescriptor.
90 DMUS_OBJ_NAME is 'UNAM' chunk in UNFO list */
91 #define DMUS_OBJ_NAME_INAM 0x1000 /* 'INAM' chunk in UNFO list */
92 #define DMUS_OBJ_NAME_INFO 0x2000 /* 'INAM' chunk in INFO list */
94 /* Generic IPersistStream methods */
95 HRESULT WINAPI
dmobj_IPersistStream_QueryInterface(IPersistStream
*iface
, REFIID riid
,
96 void **ret_iface
) DECLSPEC_HIDDEN
;
97 ULONG WINAPI
dmobj_IPersistStream_AddRef(IPersistStream
*iface
) DECLSPEC_HIDDEN
;
98 ULONG WINAPI
dmobj_IPersistStream_Release(IPersistStream
*iface
) DECLSPEC_HIDDEN
;
99 HRESULT WINAPI
dmobj_IPersistStream_GetClassID(IPersistStream
*iface
, CLSID
*class) DECLSPEC_HIDDEN
;
101 /* IPersistStream methods not implemented in native */
102 HRESULT WINAPI
unimpl_IPersistStream_GetClassID(IPersistStream
*iface
,
103 CLSID
*class) DECLSPEC_HIDDEN
;
104 HRESULT WINAPI
unimpl_IPersistStream_IsDirty(IPersistStream
*iface
) DECLSPEC_HIDDEN
;
105 HRESULT WINAPI
unimpl_IPersistStream_Save(IPersistStream
*iface
, IStream
*stream
,
106 BOOL clear_dirty
) DECLSPEC_HIDDEN
;
107 HRESULT WINAPI
unimpl_IPersistStream_GetSizeMax(IPersistStream
*iface
,
108 ULARGE_INTEGER
*size
) DECLSPEC_HIDDEN
;