dmime: Remove the extraneous IUnknown from DMTimeSigTrack.
[wine.git] / dlls / dmime / timesigtrack.c
blobb56f4de5f8f8c3691fb7ea5ce15cf4b52e2b8687
1 /* IDirectMusicTimeSigTrack 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 "dmime_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
24 /*****************************************************************************
25 * IDirectMusicTimeSigTrack implementation
27 typedef struct IDirectMusicTimeSigTrack {
28 IDirectMusicTrack IDirectMusicTrack_iface;
29 const IPersistStreamVtbl *PersistStreamVtbl;
30 LONG ref;
31 DMUS_OBJECTDESC *pDesc;
32 } IDirectMusicTimeSigTrack;
34 /* IDirectMusicTimeSigTrack IDirectMusicTrack8 part: */
35 static inline IDirectMusicTimeSigTrack *impl_from_IDirectMusicTrack(IDirectMusicTrack *iface)
37 return CONTAINING_RECORD(iface, IDirectMusicTimeSigTrack, IDirectMusicTrack_iface);
40 static HRESULT WINAPI IDirectMusicTrackImpl_QueryInterface(IDirectMusicTrack *iface, REFIID riid,
41 void **ret_iface)
43 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
45 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
47 *ret_iface = NULL;
49 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicTrack))
50 *ret_iface = iface;
51 else if (IsEqualIID(riid, &IID_IPersistStream))
52 *ret_iface = &This->PersistStreamVtbl;
53 else {
54 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
55 return E_NOINTERFACE;
58 IUnknown_AddRef((IUnknown*)*ret_iface);
59 return S_OK;
62 static ULONG WINAPI IDirectMusicTrackImpl_AddRef(IDirectMusicTrack *iface)
64 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
65 LONG ref = InterlockedIncrement(&This->ref);
67 TRACE("(%p) ref=%d\n", This, ref);
69 return ref;
72 static ULONG WINAPI IDirectMusicTrackImpl_Release(IDirectMusicTrack *iface)
74 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
75 LONG ref = InterlockedDecrement(&This->ref);
77 TRACE("(%p) ref=%d\n", This, ref);
79 if (!ref) {
80 HeapFree(GetProcessHeap(), 0, This);
81 DMIME_UnlockModule();
84 return ref;
87 static HRESULT WINAPI IDirectMusicTrackImpl_Init(IDirectMusicTrack *iface,
88 IDirectMusicSegment *pSegment)
90 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
91 FIXME("(%p, %p): stub\n", This, pSegment);
92 return S_OK;
95 static HRESULT WINAPI IDirectMusicTrackImpl_InitPlay(IDirectMusicTrack *iface,
96 IDirectMusicSegmentState *pSegmentState, IDirectMusicPerformance *pPerformance,
97 void **ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags)
99 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
100 FIXME("(%p, %p, %p, %p, %d, %d): stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
101 return S_OK;
104 static HRESULT WINAPI IDirectMusicTrackImpl_EndPlay(IDirectMusicTrack *iface, void *pStateData)
106 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
107 FIXME("(%p, %p): stub\n", This, pStateData);
108 return S_OK;
111 static HRESULT WINAPI IDirectMusicTrackImpl_Play(IDirectMusicTrack *iface, void *pStateData,
112 MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags,
113 IDirectMusicPerformance *pPerf, IDirectMusicSegmentState *pSegSt, DWORD dwVirtualID)
115 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
116 FIXME("(%p, %p, %d, %d, %d, %d, %p, %p, %d): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
117 return S_OK;
120 static HRESULT WINAPI IDirectMusicTrackImpl_GetParam(IDirectMusicTrack *iface, REFGUID rguidType,
121 MUSIC_TIME mtTime, MUSIC_TIME *pmtNext, void *pParam)
123 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
124 FIXME("(%p, %s, %d, %p, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pmtNext, pParam);
125 return S_OK;
128 static HRESULT WINAPI IDirectMusicTrackImpl_SetParam(IDirectMusicTrack *iface, REFGUID rguidType,
129 MUSIC_TIME mtTime, void *pParam)
131 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
132 FIXME("(%p, %s, %d, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pParam);
133 return S_OK;
136 static HRESULT WINAPI IDirectMusicTrackImpl_IsParamSupported(IDirectMusicTrack *iface,
137 REFGUID rguidType)
139 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
141 TRACE("(%p, %s)\n", This, debugstr_dmguid(rguidType));
142 if (IsEqualGUID (rguidType, &GUID_DisableTimeSig)
143 || IsEqualGUID (rguidType, &GUID_EnableTimeSig)
144 || IsEqualGUID (rguidType, &GUID_TimeSignature)) {
145 TRACE("param supported\n");
146 return S_OK;
148 TRACE("param unsupported\n");
149 return DMUS_E_TYPE_UNSUPPORTED;
152 static HRESULT WINAPI IDirectMusicTrackImpl_AddNotificationType(IDirectMusicTrack *iface,
153 REFGUID rguidNotificationType)
155 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
156 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
157 return S_OK;
160 static HRESULT WINAPI IDirectMusicTrackImpl_RemoveNotificationType(IDirectMusicTrack *iface,
161 REFGUID rguidNotificationType)
163 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
164 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
165 return S_OK;
168 static HRESULT WINAPI IDirectMusicTrackImpl_Clone(IDirectMusicTrack *iface, MUSIC_TIME mtStart,
169 MUSIC_TIME mtEnd, IDirectMusicTrack **ppTrack)
171 IDirectMusicTimeSigTrack *This = impl_from_IDirectMusicTrack(iface);
172 FIXME("(%p, %d, %d, %p): stub\n", This, mtStart, mtEnd, ppTrack);
173 return S_OK;
176 static const IDirectMusicTrackVtbl dmtack_vtbl = {
177 IDirectMusicTrackImpl_QueryInterface,
178 IDirectMusicTrackImpl_AddRef,
179 IDirectMusicTrackImpl_Release,
180 IDirectMusicTrackImpl_Init,
181 IDirectMusicTrackImpl_InitPlay,
182 IDirectMusicTrackImpl_EndPlay,
183 IDirectMusicTrackImpl_Play,
184 IDirectMusicTrackImpl_GetParam,
185 IDirectMusicTrackImpl_SetParam,
186 IDirectMusicTrackImpl_IsParamSupported,
187 IDirectMusicTrackImpl_AddNotificationType,
188 IDirectMusicTrackImpl_RemoveNotificationType,
189 IDirectMusicTrackImpl_Clone
192 /* IDirectMusicTimeSigTrack IPersistStream part: */
193 static HRESULT WINAPI IDirectMusicTimeSigTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
194 ICOM_THIS_MULTI(IDirectMusicTimeSigTrack, PersistStreamVtbl, iface);
195 return IDirectMusicTrack_QueryInterface(&This->IDirectMusicTrack_iface, riid, ppobj);
198 static ULONG WINAPI IDirectMusicTimeSigTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
199 ICOM_THIS_MULTI(IDirectMusicTimeSigTrack, PersistStreamVtbl, iface);
200 return IDirectMusicTrack_AddRef(&This->IDirectMusicTrack_iface);
203 static ULONG WINAPI IDirectMusicTimeSigTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
204 ICOM_THIS_MULTI(IDirectMusicTimeSigTrack, PersistStreamVtbl, iface);
205 return IDirectMusicTrack_Release(&This->IDirectMusicTrack_iface);
208 static HRESULT WINAPI IDirectMusicTimeSigTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
209 return E_NOTIMPL;
212 static HRESULT WINAPI IDirectMusicTimeSigTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
213 return E_NOTIMPL;
216 static HRESULT WINAPI IDirectMusicTimeSigTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
217 FIXME(": Loading not implemented yet\n");
218 return S_OK;
221 static HRESULT WINAPI IDirectMusicTimeSigTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
222 return E_NOTIMPL;
225 static HRESULT WINAPI IDirectMusicTimeSigTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
226 return E_NOTIMPL;
229 static const IPersistStreamVtbl DirectMusicTimeSigTrack_PersistStream_Vtbl = {
230 IDirectMusicTimeSigTrack_IPersistStream_QueryInterface,
231 IDirectMusicTimeSigTrack_IPersistStream_AddRef,
232 IDirectMusicTimeSigTrack_IPersistStream_Release,
233 IDirectMusicTimeSigTrack_IPersistStream_GetClassID,
234 IDirectMusicTimeSigTrack_IPersistStream_IsDirty,
235 IDirectMusicTimeSigTrack_IPersistStream_Load,
236 IDirectMusicTimeSigTrack_IPersistStream_Save,
237 IDirectMusicTimeSigTrack_IPersistStream_GetSizeMax
240 /* for ClassFactory */
241 HRESULT WINAPI create_dmtimesigtrack(REFIID lpcGUID, void **ppobj)
243 IDirectMusicTimeSigTrack *track;
244 HRESULT hr;
246 track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
247 if (!track) {
248 *ppobj = NULL;
249 return E_OUTOFMEMORY;
251 track->IDirectMusicTrack_iface.lpVtbl = &dmtack_vtbl;
252 track->PersistStreamVtbl = &DirectMusicTimeSigTrack_PersistStream_Vtbl;
253 track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
254 DM_STRUCT_INIT(track->pDesc);
255 track->pDesc->dwValidData |= DMUS_OBJ_CLASS;
256 track->pDesc->guidClass = CLSID_DirectMusicTimeSigTrack;
257 track->ref = 1;
259 DMIME_LockModule();
260 hr = IDirectMusicTrack_QueryInterface(&track->IDirectMusicTrack_iface, lpcGUID, ppobj);
261 IDirectMusicTrack_Release(&track->IDirectMusicTrack_iface);
263 return hr;