2 * Base IDirectMusicObject Implementation
4 * Copyright (C) 2003-2004 Rok Mandeljc
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 "dmusic_private.h"
24 /* Generic IDirectMusicObject methods */
25 static inline struct dmobject
*impl_from_IDirectMusicObject(IDirectMusicObject
*iface
)
27 return CONTAINING_RECORD(iface
, struct dmobject
, IDirectMusicObject_iface
);
30 HRESULT WINAPI
dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject
*iface
, REFIID riid
,
33 struct dmobject
*This
= impl_from_IDirectMusicObject(iface
);
34 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ret_iface
);
37 ULONG WINAPI
dmobj_IDirectMusicObject_AddRef(IDirectMusicObject
*iface
)
39 struct dmobject
*This
= impl_from_IDirectMusicObject(iface
);
40 return IUnknown_AddRef(This
->outer_unk
);
43 ULONG WINAPI
dmobj_IDirectMusicObject_Release(IDirectMusicObject
*iface
)
45 struct dmobject
*This
= impl_from_IDirectMusicObject(iface
);
46 return IUnknown_Release(This
->outer_unk
);
49 HRESULT WINAPI
dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject
*iface
,
50 DMUS_OBJECTDESC
*desc
)
52 struct dmobject
*This
= impl_from_IDirectMusicObject(iface
);
54 TRACE("(%p/%p)->(%p)\n", iface
, This
, desc
);
59 memcpy(desc
, &This
->desc
, This
->desc
.dwSize
);
64 HRESULT WINAPI
dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject
*iface
,
65 DMUS_OBJECTDESC
*desc
)
67 struct dmobject
*This
= impl_from_IDirectMusicObject(iface
);
70 TRACE("(%p, %p)\n", iface
, desc
);
75 /* Immutable property */
76 if (desc
->dwValidData
& DMUS_OBJ_CLASS
)
78 desc
->dwValidData
&= ~DMUS_OBJ_CLASS
;
81 /* Set only valid fields */
82 if (desc
->dwValidData
& DMUS_OBJ_OBJECT
)
83 This
->desc
.guidObject
= desc
->guidObject
;
84 if (desc
->dwValidData
& DMUS_OBJ_NAME
)
85 lstrcpynW(This
->desc
.wszName
, desc
->wszName
, DMUS_MAX_NAME
);
86 if (desc
->dwValidData
& DMUS_OBJ_CATEGORY
)
87 lstrcpynW(This
->desc
.wszCategory
, desc
->wszCategory
, DMUS_MAX_CATEGORY
);
88 if (desc
->dwValidData
& DMUS_OBJ_FILENAME
)
89 lstrcpynW(This
->desc
.wszFileName
, desc
->wszFileName
, DMUS_MAX_FILENAME
);
90 if (desc
->dwValidData
& DMUS_OBJ_VERSION
)
91 This
->desc
.vVersion
= desc
->vVersion
;
92 if (desc
->dwValidData
& DMUS_OBJ_DATE
)
93 This
->desc
.ftDate
= desc
->ftDate
;
94 if (desc
->dwValidData
& DMUS_OBJ_MEMORY
) {
95 This
->desc
.llMemLength
= desc
->llMemLength
;
96 memcpy(This
->desc
.pbMemData
, desc
->pbMemData
, desc
->llMemLength
);
98 if (desc
->dwValidData
& DMUS_OBJ_STREAM
)
99 IStream_Clone(desc
->pStream
, &This
->desc
.pStream
);
101 This
->desc
.dwValidData
|= desc
->dwValidData
;
106 /* Generic IPersistStream methods */
107 static inline struct dmobject
*impl_from_IPersistStream(IPersistStream
*iface
)
109 return CONTAINING_RECORD(iface
, struct dmobject
, IPersistStream_iface
);
112 HRESULT WINAPI
dmobj_IPersistStream_QueryInterface(IPersistStream
*iface
, REFIID riid
,
115 struct dmobject
*This
= impl_from_IPersistStream(iface
);
116 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ret_iface
);
119 ULONG WINAPI
dmobj_IPersistStream_AddRef(IPersistStream
*iface
)
121 struct dmobject
*This
= impl_from_IPersistStream(iface
);
122 return IUnknown_AddRef(This
->outer_unk
);
125 ULONG WINAPI
dmobj_IPersistStream_Release(IPersistStream
*iface
)
127 struct dmobject
*This
= impl_from_IPersistStream(iface
);
128 return IUnknown_Release(This
->outer_unk
);
131 /* IPersistStream methods not implemented in native */
132 HRESULT WINAPI
unimpl_IPersistStream_GetClassID(IPersistStream
*iface
, CLSID
*class)
134 TRACE("(%p, %p): method not implemented\n", iface
, class);
138 HRESULT WINAPI
unimpl_IPersistStream_IsDirty(IPersistStream
*iface
)
140 TRACE("(%p): method not implemented, always returning S_FALSE\n", iface
);
144 HRESULT WINAPI
unimpl_IPersistStream_Save(IPersistStream
*iface
, IStream
*stream
,
147 TRACE("(%p, %p, %d): method not implemented\n", iface
, stream
, clear_dirty
);
151 HRESULT WINAPI
unimpl_IPersistStream_GetSizeMax(IPersistStream
*iface
, ULARGE_INTEGER
*size
)
153 TRACE("(%p, %p): method not implemented\n", iface
, size
);
158 void dmobject_init(struct dmobject
*dmobj
, const GUID
*class, IUnknown
*outer_unk
)
160 dmobj
->outer_unk
= outer_unk
;
161 dmobj
->desc
.dwSize
= sizeof(dmobj
->desc
);
162 dmobj
->desc
.dwValidData
= DMUS_OBJ_CLASS
;
163 dmobj
->desc
.guidClass
= *class;