dmstyle: COM cleanup for IDirectMusicTrack8 of DMAuditionTrack.
[wine.git] / dlls / dmstyle / auditiontrack.c
blobfa9eec88b79d0876bf2dd6f8b682593356083208
1 /* IDirectMusicAuditionTrack Implementation
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "dmstyle_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
24 static ULONG WINAPI IDirectMusicAuditionTrack_IUnknown_AddRef (LPUNKNOWN iface);
25 static ULONG WINAPI IDirectMusicAuditionTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface);
27 /*****************************************************************************
28 * IDirectMusicAuditionTrack implementation
30 typedef struct IDirectMusicAuditionTrack {
31 const IUnknownVtbl *UnknownVtbl;
32 IDirectMusicTrack8 IDirectMusicTrack8_iface;
33 const IPersistStreamVtbl *PersistStreamVtbl;
34 LONG ref;
35 DMUS_OBJECTDESC *pDesc;
36 } IDirectMusicAuditionTrack;
38 /* IDirectMusicAuditionTrack IUnknown part: */
39 static HRESULT WINAPI IDirectMusicAuditionTrack_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
40 ICOM_THIS_MULTI(IDirectMusicAuditionTrack, UnknownVtbl, iface);
41 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
43 if (IsEqualIID (riid, &IID_IUnknown)) {
44 *ppobj = &This->UnknownVtbl;
45 IDirectMusicAuditionTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
46 return S_OK;
47 } else if (IsEqualIID (riid, &IID_IDirectMusicTrack)
48 || IsEqualIID (riid, &IID_IDirectMusicTrack8)) {
49 *ppobj = &This->IDirectMusicTrack8_iface;
50 IDirectMusicTrack8_AddRef (&This->IDirectMusicTrack8_iface);
51 return S_OK;
52 } else if (IsEqualIID (riid, &IID_IPersistStream)) {
53 *ppobj = &This->PersistStreamVtbl;
54 IDirectMusicAuditionTrack_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
55 return S_OK;
58 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
59 return E_NOINTERFACE;
62 static ULONG WINAPI IDirectMusicAuditionTrack_IUnknown_AddRef (LPUNKNOWN iface) {
63 ICOM_THIS_MULTI(IDirectMusicAuditionTrack, UnknownVtbl, iface);
64 ULONG ref = InterlockedIncrement(&This->ref);
66 TRACE("(%p): AddRef from %d\n", This, ref - 1);
68 DMSTYLE_LockModule();
70 return ref;
73 static ULONG WINAPI IDirectMusicAuditionTrack_IUnknown_Release (LPUNKNOWN iface) {
74 ICOM_THIS_MULTI(IDirectMusicAuditionTrack, UnknownVtbl, iface);
75 ULONG ref = InterlockedDecrement(&This->ref);
77 TRACE("(%p): ReleaseRef to %d\n", This, ref);
79 if (ref == 0) {
80 HeapFree(GetProcessHeap(), 0, This);
83 DMSTYLE_UnlockModule();
85 return ref;
88 static const IUnknownVtbl DirectMusicAuditionTrack_Unknown_Vtbl = {
89 IDirectMusicAuditionTrack_IUnknown_QueryInterface,
90 IDirectMusicAuditionTrack_IUnknown_AddRef,
91 IDirectMusicAuditionTrack_IUnknown_Release
94 /* IDirectMusicAuditionTrack IDirectMusicTrack8 part: */
95 static inline IDirectMusicAuditionTrack *impl_from_IDirectMusicTrack8(IDirectMusicTrack8 *iface)
97 return CONTAINING_RECORD(iface, IDirectMusicAuditionTrack, IDirectMusicTrack8_iface);
100 static HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface(IDirectMusicTrack8 *iface, REFIID riid,
101 void **ppobj)
103 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
104 return IDirectMusicAuditionTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
107 static ULONG WINAPI IDirectMusicTrack8Impl_AddRef(IDirectMusicTrack8 *iface)
109 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
110 return IDirectMusicAuditionTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
113 static ULONG WINAPI IDirectMusicTrack8Impl_Release(IDirectMusicTrack8 *iface)
115 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
116 return IDirectMusicAuditionTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
119 static HRESULT WINAPI IDirectMusicTrack8Impl_Init(IDirectMusicTrack8 *iface,
120 IDirectMusicSegment *pSegment)
122 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
123 FIXME("(%p, %p): stub\n", This, pSegment);
124 return S_OK;
127 static HRESULT WINAPI IDirectMusicTrack8Impl_InitPlay(IDirectMusicTrack8 *iface,
128 IDirectMusicSegmentState *pSegmentState, IDirectMusicPerformance *pPerformance,
129 void **ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags)
131 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
132 FIXME("(%p, %p, %p, %p, %d, %d): stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
133 return S_OK;
136 static HRESULT WINAPI IDirectMusicTrack8Impl_EndPlay(IDirectMusicTrack8 *iface, void *pStateData)
138 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
139 FIXME("(%p, %p): stub\n", This, pStateData);
140 return S_OK;
143 static HRESULT WINAPI IDirectMusicTrack8Impl_Play(IDirectMusicTrack8 *iface, void *pStateData,
144 MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags,
145 IDirectMusicPerformance *pPerf, IDirectMusicSegmentState *pSegSt, DWORD dwVirtualID)
147 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
148 FIXME("(%p, %p, %d, %d, %d, %d, %p, %p, %d): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
149 return S_OK;
152 static HRESULT WINAPI IDirectMusicTrack8Impl_GetParam(IDirectMusicTrack8 *iface, REFGUID rguidType,
153 MUSIC_TIME mtTime, MUSIC_TIME *pmtNext, void *pParam)
155 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
156 FIXME("(%p, %s, %d, %p, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pmtNext, pParam);
157 return S_OK;
160 static HRESULT WINAPI IDirectMusicTrack8Impl_SetParam(IDirectMusicTrack8 *iface, REFGUID rguidType,
161 MUSIC_TIME mtTime, void *pParam)
163 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
164 FIXME("(%p, %s, %d, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pParam);
165 return S_OK;
168 static HRESULT WINAPI IDirectMusicTrack8Impl_IsParamSupported(IDirectMusicTrack8 *iface,
169 REFGUID rguidType)
171 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
173 TRACE("(%p, %s)\n", This, debugstr_dmguid(rguidType));
175 if (!rguidType)
176 return E_POINTER;
178 /* didn't find any params */
179 TRACE("param unsupported\n");
180 return DMUS_E_TYPE_UNSUPPORTED;
183 static HRESULT WINAPI IDirectMusicTrack8Impl_AddNotificationType(IDirectMusicTrack8 *iface,
184 REFGUID rguidNotificationType)
186 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
187 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
188 return S_OK;
191 static HRESULT WINAPI IDirectMusicTrack8Impl_RemoveNotificationType(IDirectMusicTrack8 *iface,
192 REFGUID rguidNotificationType)
194 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
195 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
196 return S_OK;
199 static HRESULT WINAPI IDirectMusicTrack8Impl_Clone(IDirectMusicTrack8 *iface, MUSIC_TIME mtStart,
200 MUSIC_TIME mtEnd, IDirectMusicTrack **ppTrack)
202 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
203 FIXME("(%p, %d, %d, %p): stub\n", This, mtStart, mtEnd, ppTrack);
204 return S_OK;
207 static HRESULT WINAPI IDirectMusicTrack8Impl_PlayEx(IDirectMusicTrack8 *iface, void *pStateData,
208 REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags,
209 IDirectMusicPerformance *pPerf, IDirectMusicSegmentState *pSegSt, DWORD dwVirtualID)
211 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
212 FIXME("(%p, %p, 0x%s, 0x%s, 0x%s, %d, %p, %p, %d): stub\n", This, pStateData, wine_dbgstr_longlong(rtStart),
213 wine_dbgstr_longlong(rtEnd), wine_dbgstr_longlong(rtOffset), dwFlags, pPerf, pSegSt, dwVirtualID);
214 return S_OK;
217 static HRESULT WINAPI IDirectMusicTrack8Impl_GetParamEx(IDirectMusicTrack8 *iface,
218 REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME *prtNext, void *pParam,
219 void *pStateData, DWORD dwFlags)
221 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
222 FIXME("(%p, %s, 0x%s, %p, %p, %p, %d): stub\n", This, debugstr_dmguid(rguidType),
223 wine_dbgstr_longlong(rtTime), prtNext, pParam, pStateData, dwFlags);
224 return S_OK;
227 static HRESULT WINAPI IDirectMusicTrack8Impl_SetParamEx(IDirectMusicTrack8 *iface,
228 REFGUID rguidType, REFERENCE_TIME rtTime, void *pParam, void *pStateData, DWORD dwFlags)
230 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
231 FIXME("(%p, %s, 0x%s, %p, %p, %d): stub\n", This, debugstr_dmguid(rguidType),
232 wine_dbgstr_longlong(rtTime), pParam, pStateData, dwFlags);
233 return S_OK;
236 static HRESULT WINAPI IDirectMusicTrack8Impl_Compose(IDirectMusicTrack8 *iface, IUnknown *context,
237 DWORD trackgroup, IDirectMusicTrack **track)
239 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
241 TRACE("(%p, %p, %d, %p): method not implemented\n", This, context, trackgroup, track);
242 return E_NOTIMPL;
245 static HRESULT WINAPI IDirectMusicTrack8Impl_Join(IDirectMusicTrack8 *iface,
246 IDirectMusicTrack *newtrack, MUSIC_TIME join, IUnknown *context, DWORD trackgroup,
247 IDirectMusicTrack **resulttrack)
249 IDirectMusicAuditionTrack *This = impl_from_IDirectMusicTrack8(iface);
250 TRACE("(%p, %p, %d, %p, %d, %p): stub\n", This, newtrack, join, context, trackgroup,
251 resulttrack);
252 return E_NOTIMPL;
255 static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = {
256 IDirectMusicTrack8Impl_QueryInterface,
257 IDirectMusicTrack8Impl_AddRef,
258 IDirectMusicTrack8Impl_Release,
259 IDirectMusicTrack8Impl_Init,
260 IDirectMusicTrack8Impl_InitPlay,
261 IDirectMusicTrack8Impl_EndPlay,
262 IDirectMusicTrack8Impl_Play,
263 IDirectMusicTrack8Impl_GetParam,
264 IDirectMusicTrack8Impl_SetParam,
265 IDirectMusicTrack8Impl_IsParamSupported,
266 IDirectMusicTrack8Impl_AddNotificationType,
267 IDirectMusicTrack8Impl_RemoveNotificationType,
268 IDirectMusicTrack8Impl_Clone,
269 IDirectMusicTrack8Impl_PlayEx,
270 IDirectMusicTrack8Impl_GetParamEx,
271 IDirectMusicTrack8Impl_SetParamEx,
272 IDirectMusicTrack8Impl_Compose,
273 IDirectMusicTrack8Impl_Join
276 /* IDirectMusicAuditionTrack IPersistStream part: */
277 static HRESULT WINAPI IDirectMusicAuditionTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
278 ICOM_THIS_MULTI(IDirectMusicAuditionTrack, PersistStreamVtbl, iface);
279 return IDirectMusicAuditionTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
282 static ULONG WINAPI IDirectMusicAuditionTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
283 ICOM_THIS_MULTI(IDirectMusicAuditionTrack, PersistStreamVtbl, iface);
284 return IDirectMusicAuditionTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
287 static ULONG WINAPI IDirectMusicAuditionTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
288 ICOM_THIS_MULTI(IDirectMusicAuditionTrack, PersistStreamVtbl, iface);
289 return IDirectMusicAuditionTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
292 static HRESULT WINAPI IDirectMusicAuditionTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
293 return E_NOTIMPL;
296 static HRESULT WINAPI IDirectMusicAuditionTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
297 return E_NOTIMPL;
300 static HRESULT WINAPI IDirectMusicAuditionTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
301 FIXME(": Loading not implemented yet\n");
302 return S_OK;
305 static HRESULT WINAPI IDirectMusicAuditionTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
306 return E_NOTIMPL;
309 static HRESULT WINAPI IDirectMusicAuditionTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
310 return E_NOTIMPL;
313 static const IPersistStreamVtbl DirectMusicAuditionTrack_PersistStream_Vtbl = {
314 IDirectMusicAuditionTrack_IPersistStream_QueryInterface,
315 IDirectMusicAuditionTrack_IPersistStream_AddRef,
316 IDirectMusicAuditionTrack_IPersistStream_Release,
317 IDirectMusicAuditionTrack_IPersistStream_GetClassID,
318 IDirectMusicAuditionTrack_IPersistStream_IsDirty,
319 IDirectMusicAuditionTrack_IPersistStream_Load,
320 IDirectMusicAuditionTrack_IPersistStream_Save,
321 IDirectMusicAuditionTrack_IPersistStream_GetSizeMax
324 /* for ClassFactory */
325 HRESULT WINAPI create_dmauditiontrack(REFIID lpcGUID, void **ppobj)
327 IDirectMusicAuditionTrack* track;
329 track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicAuditionTrack));
330 if (NULL == track) {
331 *ppobj = NULL;
332 return E_OUTOFMEMORY;
334 track->UnknownVtbl = &DirectMusicAuditionTrack_Unknown_Vtbl;
335 track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
336 track->PersistStreamVtbl = &DirectMusicAuditionTrack_PersistStream_Vtbl;
337 track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
338 DM_STRUCT_INIT(track->pDesc);
339 track->pDesc->dwValidData |= DMUS_OBJ_CLASS;
340 track->pDesc->guidClass = CLSID_DirectMusicAuditionTrack;
341 track->ref = 0; /* will be inited by QueryInterface */
343 return IDirectMusicAuditionTrack_IUnknown_QueryInterface ((LPUNKNOWN)&track->UnknownVtbl, lpcGUID, ppobj);