d3d9/tests: Allow a width and height to be passed to create_device() in the d3d9ex...
[wine.git] / dlls / dmscript / scripttrack.c
blobddae8b5e5241a994b8c3452f68cb28bd92edf077
1 /* IDirectMusicScriptTrack 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 "dmscript_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmscript);
24 /*****************************************************************************
25 * IDirectMusicScriptTrack implementation
28 typedef struct DirectMusicScriptTrack {
29 IDirectMusicTrack8 IDirectMusicTrack8_iface;
30 IPersistStream IPersistStream_iface;
31 LONG ref;
32 DMUS_OBJECTDESC desc;
33 } DirectMusicScriptTrack;
35 static inline DirectMusicScriptTrack *impl_from_IDirectMusicTrack8(IDirectMusicTrack8 *iface)
37 return CONTAINING_RECORD(iface, DirectMusicScriptTrack, IDirectMusicTrack8_iface);
40 static inline DirectMusicScriptTrack *impl_from_IPersistStream(IPersistStream *iface)
42 return CONTAINING_RECORD(iface, DirectMusicScriptTrack, IPersistStream_iface);
45 /* DirectMusicScriptTrack IDirectMusicTrack8 part: */
46 static HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface(IDirectMusicTrack8 *iface, REFIID riid,
47 void **ret_iface)
49 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
51 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
53 *ret_iface = NULL;
55 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicTrack) ||
56 IsEqualIID(riid, &IID_IDirectMusicTrack8))
57 *ret_iface = iface;
58 else if (IsEqualIID(riid, &IID_IPersistStream))
59 *ret_iface = &This->IPersistStream_iface;
60 else {
61 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
62 return E_NOINTERFACE;
65 IUnknown_AddRef((IUnknown*)*ret_iface);
66 return S_OK;
69 static ULONG WINAPI IDirectMusicTrack8Impl_AddRef(IDirectMusicTrack8 *iface)
71 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
72 LONG ref = InterlockedIncrement(&This->ref);
74 TRACE("(%p) ref=%d\n", This, ref);
76 return ref;
79 static ULONG WINAPI IDirectMusicTrack8Impl_Release(IDirectMusicTrack8 *iface)
81 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
82 LONG ref = InterlockedDecrement(&This->ref);
84 TRACE("(%p) ref=%d\n", This, ref);
86 if (!ref) {
87 HeapFree(GetProcessHeap(), 0, This);
88 DMSCRIPT_UnlockModule();
91 return ref;
94 static HRESULT WINAPI IDirectMusicTrack8Impl_Init(IDirectMusicTrack8 *iface,
95 IDirectMusicSegment *pSegment)
97 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
98 FIXME("(%p, %p): stub\n", This, pSegment);
99 return S_OK;
102 static HRESULT WINAPI IDirectMusicTrack8Impl_InitPlay(IDirectMusicTrack8 *iface,
103 IDirectMusicSegmentState *pSegmentState, IDirectMusicPerformance *pPerformance,
104 void **ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags)
106 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
107 FIXME("(%p, %p, %p, %p, %d, %d): stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
108 return S_OK;
111 static HRESULT WINAPI IDirectMusicTrack8Impl_EndPlay(IDirectMusicTrack8 *iface, void *pStateData)
113 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
114 FIXME("(%p, %p): stub\n", This, pStateData);
115 return S_OK;
118 static HRESULT WINAPI IDirectMusicTrack8Impl_Play(IDirectMusicTrack8 *iface, void *pStateData,
119 MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags,
120 IDirectMusicPerformance *pPerf, IDirectMusicSegmentState *pSegSt, DWORD dwVirtualID)
122 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
123 FIXME("(%p, %p, %d, %d, %d, %d, %p, %p, %d): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
124 return S_OK;
127 static HRESULT WINAPI IDirectMusicTrack8Impl_GetParam(IDirectMusicTrack8 *iface, REFGUID rguidType,
128 MUSIC_TIME mtTime, MUSIC_TIME *pmtNext, void *pParam)
130 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
131 FIXME("(%p, %s, %d, %p, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pmtNext, pParam);
132 return S_OK;
135 static HRESULT WINAPI IDirectMusicTrack8Impl_SetParam(IDirectMusicTrack8 *iface, REFGUID rguidType,
136 MUSIC_TIME mtTime, void *pParam)
138 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
139 FIXME("(%p, %s, %d, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pParam);
140 return S_OK;
143 static HRESULT WINAPI IDirectMusicTrack8Impl_IsParamSupported(IDirectMusicTrack8 *iface,
144 REFGUID rguidType)
146 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
148 TRACE("(%p, %s)\n", This, debugstr_dmguid(rguidType));
149 /* didn't find any params */
150 TRACE("param unsupported\n");
151 return DMUS_E_TYPE_UNSUPPORTED;
154 static HRESULT WINAPI IDirectMusicTrack8Impl_AddNotificationType(IDirectMusicTrack8 *iface,
155 REFGUID rguidNotificationType)
157 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
158 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
159 return S_OK;
162 static HRESULT WINAPI IDirectMusicTrack8Impl_RemoveNotificationType(IDirectMusicTrack8 *iface,
163 REFGUID rguidNotificationType)
165 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
166 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
167 return S_OK;
170 static HRESULT WINAPI IDirectMusicTrack8Impl_Clone(IDirectMusicTrack8 *iface, MUSIC_TIME mtStart,
171 MUSIC_TIME mtEnd, IDirectMusicTrack **ppTrack)
173 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
174 FIXME("(%p, %d, %d, %p): stub\n", This, mtStart, mtEnd, ppTrack);
175 return S_OK;
178 static HRESULT WINAPI IDirectMusicTrack8Impl_PlayEx(IDirectMusicTrack8 *iface, void *pStateData,
179 REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags,
180 IDirectMusicPerformance *pPerf, IDirectMusicSegmentState *pSegSt, DWORD dwVirtualID)
182 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
183 FIXME("(%p, %p, 0x%s, 0x%s, 0x%s, %d, %p, %p, %d): stub\n", This, pStateData, wine_dbgstr_longlong(rtStart),
184 wine_dbgstr_longlong(rtEnd), wine_dbgstr_longlong(rtOffset), dwFlags, pPerf, pSegSt, dwVirtualID);
185 return S_OK;
188 static HRESULT WINAPI IDirectMusicTrack8Impl_GetParamEx(IDirectMusicTrack8 *iface,
189 REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME *prtNext, void *pParam,
190 void *pStateData, DWORD dwFlags)
192 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
193 FIXME("(%p, %s, 0x%s, %p, %p, %p, %d): stub\n", This, debugstr_dmguid(rguidType),
194 wine_dbgstr_longlong(rtTime), prtNext, pParam, pStateData, dwFlags);
195 return S_OK;
198 static HRESULT WINAPI IDirectMusicTrack8Impl_SetParamEx(IDirectMusicTrack8 *iface,
199 REFGUID rguidType, REFERENCE_TIME rtTime, void *pParam, void *pStateData, DWORD dwFlags)
201 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
202 FIXME("(%p, %s, 0x%s, %p, %p, %d): stub\n", This, debugstr_dmguid(rguidType),
203 wine_dbgstr_longlong(rtTime), pParam, pStateData, dwFlags);
204 return S_OK;
207 static HRESULT WINAPI IDirectMusicTrack8Impl_Compose(IDirectMusicTrack8 *iface, IUnknown *pContext,
208 DWORD dwTrackGroup, IDirectMusicTrack **ppResultTrack)
210 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
211 FIXME("(%p, %p, %d, %p): stub\n", This, pContext, dwTrackGroup, ppResultTrack);
212 return S_OK;
215 static HRESULT WINAPI IDirectMusicTrack8Impl_Join(IDirectMusicTrack8 *iface,
216 IDirectMusicTrack *pNewTrack, MUSIC_TIME mtJoin, IUnknown *pContext, DWORD dwTrackGroup,
217 IDirectMusicTrack **ppResultTrack)
219 DirectMusicScriptTrack *This = impl_from_IDirectMusicTrack8(iface);
220 FIXME("(%p, %p, %d, %p, %d, %p): stub\n", This, pNewTrack, mtJoin, pContext, dwTrackGroup, ppResultTrack);
221 return S_OK;
224 static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = {
225 IDirectMusicTrack8Impl_QueryInterface,
226 IDirectMusicTrack8Impl_AddRef,
227 IDirectMusicTrack8Impl_Release,
228 IDirectMusicTrack8Impl_Init,
229 IDirectMusicTrack8Impl_InitPlay,
230 IDirectMusicTrack8Impl_EndPlay,
231 IDirectMusicTrack8Impl_Play,
232 IDirectMusicTrack8Impl_GetParam,
233 IDirectMusicTrack8Impl_SetParam,
234 IDirectMusicTrack8Impl_IsParamSupported,
235 IDirectMusicTrack8Impl_AddNotificationType,
236 IDirectMusicTrack8Impl_RemoveNotificationType,
237 IDirectMusicTrack8Impl_Clone,
238 IDirectMusicTrack8Impl_PlayEx,
239 IDirectMusicTrack8Impl_GetParamEx,
240 IDirectMusicTrack8Impl_SetParamEx,
241 IDirectMusicTrack8Impl_Compose,
242 IDirectMusicTrack8Impl_Join
245 /* IDirectMusicScriptTrack IPersistStream part: */
246 static HRESULT WINAPI IPersistStreamImpl_QueryInterface(IPersistStream *iface, REFIID riid,
247 void **ret_iface)
249 DirectMusicScriptTrack *This = impl_from_IPersistStream(iface);
250 return IDirectMusicTrack8_QueryInterface(&This->IDirectMusicTrack8_iface, riid, ret_iface);
253 static ULONG WINAPI IPersistStreamImpl_AddRef(IPersistStream *iface)
255 DirectMusicScriptTrack *This = impl_from_IPersistStream(iface);
256 return IDirectMusicTrack8_AddRef(&This->IDirectMusicTrack8_iface);
259 static ULONG WINAPI IPersistStreamImpl_Release(IPersistStream *iface)
261 DirectMusicScriptTrack *This = impl_from_IPersistStream(iface);
262 return IDirectMusicTrack8_Release(&This->IDirectMusicTrack8_iface);
265 static HRESULT WINAPI IPersistStreamImpl_GetClassID(IPersistStream *iface, CLSID *pClassID)
267 return E_NOTIMPL;
270 static HRESULT WINAPI IPersistStreamImpl_IsDirty(IPersistStream *iface)
272 return E_NOTIMPL;
275 static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pStm)
277 FIXME(": Loading not implemented yet\n");
278 return S_OK;
281 static HRESULT WINAPI IPersistStreamImpl_Save(IPersistStream *iface, IStream *pStm,
282 BOOL fClearDirty)
284 return E_NOTIMPL;
287 static HRESULT WINAPI IPersistStreamImpl_GetSizeMax(IPersistStream *iface, ULARGE_INTEGER *pcbSize)
289 return E_NOTIMPL;
292 static const IPersistStreamVtbl persist_vtbl = {
293 IPersistStreamImpl_QueryInterface,
294 IPersistStreamImpl_AddRef,
295 IPersistStreamImpl_Release,
296 IPersistStreamImpl_GetClassID,
297 IPersistStreamImpl_IsDirty,
298 IPersistStreamImpl_Load,
299 IPersistStreamImpl_Save,
300 IPersistStreamImpl_GetSizeMax
303 /* for ClassFactory */
304 HRESULT WINAPI DMUSIC_CreateDirectMusicScriptTrack(REFIID riid, void **ret_iface,
305 IUnknown *pUnkOuter)
307 DirectMusicScriptTrack *track;
308 HRESULT hr;
310 *ret_iface = NULL;
312 if (pUnkOuter)
313 return CLASS_E_NOAGGREGATION;
315 track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
316 if (!track)
317 return E_OUTOFMEMORY;
319 track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
320 track->IPersistStream_iface.lpVtbl = &persist_vtbl;
321 track->desc.dwSize = sizeof(track->desc);
322 track->desc.dwValidData |= DMUS_OBJ_CLASS;
323 track->desc.guidClass = CLSID_DirectMusicScriptTrack;
324 track->ref = 1;
326 DMSCRIPT_LockModule();
327 hr = IDirectMusicTrack8_QueryInterface(&track->IDirectMusicTrack8_iface, riid, ret_iface);
328 IDirectMusicTrack8_Release(&track->IDirectMusicTrack8_iface);
330 return hr;