d3d10core: Implement d3d10_device_OMGetRenderTargets().
[wine.git] / dlls / dmusic / dmobject.c
blob4afd5b923a21739e43539e1404212c2efd9166c1
1 /*
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 #define COBJMACROS
23 #include "objbase.h"
24 #include "dmusici.h"
25 #include "dmobject.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(dmobj);
30 /* Generic IDirectMusicObject methods */
31 static inline struct dmobject *impl_from_IDirectMusicObject(IDirectMusicObject *iface)
33 return CONTAINING_RECORD(iface, struct dmobject, IDirectMusicObject_iface);
36 HRESULT WINAPI dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject *iface, REFIID riid,
37 void **ret_iface)
39 struct dmobject *This = impl_from_IDirectMusicObject(iface);
40 return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
43 ULONG WINAPI dmobj_IDirectMusicObject_AddRef(IDirectMusicObject *iface)
45 struct dmobject *This = impl_from_IDirectMusicObject(iface);
46 return IUnknown_AddRef(This->outer_unk);
49 ULONG WINAPI dmobj_IDirectMusicObject_Release(IDirectMusicObject *iface)
51 struct dmobject *This = impl_from_IDirectMusicObject(iface);
52 return IUnknown_Release(This->outer_unk);
55 HRESULT WINAPI dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject *iface,
56 DMUS_OBJECTDESC *desc)
58 struct dmobject *This = impl_from_IDirectMusicObject(iface);
60 TRACE("(%p/%p)->(%p)\n", iface, This, desc);
62 if (!desc)
63 return E_POINTER;
65 memcpy(desc, &This->desc, This->desc.dwSize);
67 return S_OK;
70 HRESULT WINAPI dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject *iface,
71 DMUS_OBJECTDESC *desc)
73 struct dmobject *This = impl_from_IDirectMusicObject(iface);
74 HRESULT ret = S_OK;
76 TRACE("(%p, %p)\n", iface, desc);
78 if (!desc)
79 return E_POINTER;
81 /* Immutable property */
82 if (desc->dwValidData & DMUS_OBJ_CLASS)
84 desc->dwValidData &= ~DMUS_OBJ_CLASS;
85 ret = S_FALSE;
87 /* Set only valid fields */
88 if (desc->dwValidData & DMUS_OBJ_OBJECT)
89 This->desc.guidObject = desc->guidObject;
90 if (desc->dwValidData & DMUS_OBJ_NAME)
91 lstrcpynW(This->desc.wszName, desc->wszName, DMUS_MAX_NAME);
92 if (desc->dwValidData & DMUS_OBJ_CATEGORY)
93 lstrcpynW(This->desc.wszCategory, desc->wszCategory, DMUS_MAX_CATEGORY);
94 if (desc->dwValidData & DMUS_OBJ_FILENAME)
95 lstrcpynW(This->desc.wszFileName, desc->wszFileName, DMUS_MAX_FILENAME);
96 if (desc->dwValidData & DMUS_OBJ_VERSION)
97 This->desc.vVersion = desc->vVersion;
98 if (desc->dwValidData & DMUS_OBJ_DATE)
99 This->desc.ftDate = desc->ftDate;
100 if (desc->dwValidData & DMUS_OBJ_MEMORY) {
101 This->desc.llMemLength = desc->llMemLength;
102 memcpy(This->desc.pbMemData, desc->pbMemData, desc->llMemLength);
104 if (desc->dwValidData & DMUS_OBJ_STREAM)
105 IStream_Clone(desc->pStream, &This->desc.pStream);
107 This->desc.dwValidData |= desc->dwValidData;
109 return ret;
112 /* Generic IPersistStream methods */
113 static inline struct dmobject *impl_from_IPersistStream(IPersistStream *iface)
115 return CONTAINING_RECORD(iface, struct dmobject, IPersistStream_iface);
118 HRESULT WINAPI dmobj_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid,
119 void **ret_iface)
121 struct dmobject *This = impl_from_IPersistStream(iface);
122 return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
125 ULONG WINAPI dmobj_IPersistStream_AddRef(IPersistStream *iface)
127 struct dmobject *This = impl_from_IPersistStream(iface);
128 return IUnknown_AddRef(This->outer_unk);
131 ULONG WINAPI dmobj_IPersistStream_Release(IPersistStream *iface)
133 struct dmobject *This = impl_from_IPersistStream(iface);
134 return IUnknown_Release(This->outer_unk);
137 /* IPersistStream methods not implemented in native */
138 HRESULT WINAPI unimpl_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class)
140 TRACE("(%p, %p): method not implemented\n", iface, class);
141 return E_NOTIMPL;
144 HRESULT WINAPI unimpl_IPersistStream_IsDirty(IPersistStream *iface)
146 TRACE("(%p): method not implemented, always returning S_FALSE\n", iface);
147 return S_FALSE;
150 HRESULT WINAPI unimpl_IPersistStream_Save(IPersistStream *iface, IStream *stream,
151 BOOL clear_dirty)
153 TRACE("(%p, %p, %d): method not implemented\n", iface, stream, clear_dirty);
154 return E_NOTIMPL;
157 HRESULT WINAPI unimpl_IPersistStream_GetSizeMax(IPersistStream *iface, ULARGE_INTEGER *size)
159 TRACE("(%p, %p): method not implemented\n", iface, size);
160 return E_NOTIMPL;
164 void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk)
166 dmobj->outer_unk = outer_unk;
167 dmobj->desc.dwSize = sizeof(dmobj->desc);
168 dmobj->desc.dwValidData = DMUS_OBJ_CLASS;
169 dmobj->desc.guidClass = *class;