d3dx9/tests: Use true spherical light values and relax expectations.
[wine.git] / dlls / dmime / dmobject.c
blobcabb6f74db983979b9edf1f2504dcd2806f0218b
1 /*
2 * Base IDirectMusicObject Implementation
3 * Keep in sync with the master in dlls/dmusic/dmobject.c
5 * Copyright (C) 2003-2004 Rok Mandeljc
6 * Copyright (C) 2014 Michael Stefaniuc
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define COBJMACROS
24 #include "objbase.h"
25 #include "dmusici.h"
26 #include "dmobject.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(dmobj);
31 /* Generic IDirectMusicObject methods */
32 static inline struct dmobject *impl_from_IDirectMusicObject(IDirectMusicObject *iface)
34 return CONTAINING_RECORD(iface, struct dmobject, IDirectMusicObject_iface);
37 HRESULT WINAPI dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject *iface, REFIID riid,
38 void **ret_iface)
40 struct dmobject *This = impl_from_IDirectMusicObject(iface);
41 return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
44 ULONG WINAPI dmobj_IDirectMusicObject_AddRef(IDirectMusicObject *iface)
46 struct dmobject *This = impl_from_IDirectMusicObject(iface);
47 return IUnknown_AddRef(This->outer_unk);
50 ULONG WINAPI dmobj_IDirectMusicObject_Release(IDirectMusicObject *iface)
52 struct dmobject *This = impl_from_IDirectMusicObject(iface);
53 return IUnknown_Release(This->outer_unk);
56 HRESULT WINAPI dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject *iface,
57 DMUS_OBJECTDESC *desc)
59 struct dmobject *This = impl_from_IDirectMusicObject(iface);
61 TRACE("(%p/%p)->(%p)\n", iface, This, desc);
63 if (!desc)
64 return E_POINTER;
66 memcpy(desc, &This->desc, This->desc.dwSize);
68 return S_OK;
71 HRESULT WINAPI dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject *iface,
72 DMUS_OBJECTDESC *desc)
74 struct dmobject *This = impl_from_IDirectMusicObject(iface);
75 HRESULT ret = S_OK;
77 TRACE("(%p, %p)\n", iface, desc);
79 if (!desc)
80 return E_POINTER;
82 /* Immutable property */
83 if (desc->dwValidData & DMUS_OBJ_CLASS)
85 desc->dwValidData &= ~DMUS_OBJ_CLASS;
86 ret = S_FALSE;
88 /* Set only valid fields */
89 if (desc->dwValidData & DMUS_OBJ_OBJECT)
90 This->desc.guidObject = desc->guidObject;
91 if (desc->dwValidData & DMUS_OBJ_NAME)
92 lstrcpynW(This->desc.wszName, desc->wszName, DMUS_MAX_NAME);
93 if (desc->dwValidData & DMUS_OBJ_CATEGORY)
94 lstrcpynW(This->desc.wszCategory, desc->wszCategory, DMUS_MAX_CATEGORY);
95 if (desc->dwValidData & DMUS_OBJ_FILENAME)
96 lstrcpynW(This->desc.wszFileName, desc->wszFileName, DMUS_MAX_FILENAME);
97 if (desc->dwValidData & DMUS_OBJ_VERSION)
98 This->desc.vVersion = desc->vVersion;
99 if (desc->dwValidData & DMUS_OBJ_DATE)
100 This->desc.ftDate = desc->ftDate;
101 if (desc->dwValidData & DMUS_OBJ_MEMORY) {
102 This->desc.llMemLength = desc->llMemLength;
103 memcpy(This->desc.pbMemData, desc->pbMemData, desc->llMemLength);
105 if (desc->dwValidData & DMUS_OBJ_STREAM)
106 IStream_Clone(desc->pStream, &This->desc.pStream);
108 This->desc.dwValidData |= desc->dwValidData;
110 return ret;
113 /* Generic IPersistStream methods */
114 static inline struct dmobject *impl_from_IPersistStream(IPersistStream *iface)
116 return CONTAINING_RECORD(iface, struct dmobject, IPersistStream_iface);
119 HRESULT WINAPI dmobj_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid,
120 void **ret_iface)
122 struct dmobject *This = impl_from_IPersistStream(iface);
123 return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
126 ULONG WINAPI dmobj_IPersistStream_AddRef(IPersistStream *iface)
128 struct dmobject *This = impl_from_IPersistStream(iface);
129 return IUnknown_AddRef(This->outer_unk);
132 ULONG WINAPI dmobj_IPersistStream_Release(IPersistStream *iface)
134 struct dmobject *This = impl_from_IPersistStream(iface);
135 return IUnknown_Release(This->outer_unk);
138 HRESULT WINAPI dmobj_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class)
140 struct dmobject *This = impl_from_IPersistStream(iface);
142 TRACE("(%p, %p)\n", This, class);
144 if (!class)
145 return E_POINTER;
147 *class = This->desc.guidClass;
149 return S_OK;
152 /* IPersistStream methods not implemented in native */
153 HRESULT WINAPI unimpl_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class)
155 TRACE("(%p, %p): method not implemented\n", iface, class);
156 return E_NOTIMPL;
159 HRESULT WINAPI unimpl_IPersistStream_IsDirty(IPersistStream *iface)
161 TRACE("(%p): method not implemented, always returning S_FALSE\n", iface);
162 return S_FALSE;
165 HRESULT WINAPI unimpl_IPersistStream_Save(IPersistStream *iface, IStream *stream,
166 BOOL clear_dirty)
168 TRACE("(%p, %p, %d): method not implemented\n", iface, stream, clear_dirty);
169 return E_NOTIMPL;
172 HRESULT WINAPI unimpl_IPersistStream_GetSizeMax(IPersistStream *iface, ULARGE_INTEGER *size)
174 TRACE("(%p, %p): method not implemented\n", iface, size);
175 return E_NOTIMPL;
179 void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk)
181 dmobj->outer_unk = outer_unk;
182 dmobj->desc.dwSize = sizeof(dmobj->desc);
183 dmobj->desc.dwValidData = DMUS_OBJ_CLASS;
184 dmobj->desc.guidClass = *class;