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"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmscript
);
25 /*****************************************************************************
26 * IDirectMusicScriptTrack implementation
29 typedef struct DirectMusicScriptTrack
{
30 IDirectMusicTrack8 IDirectMusicTrack8_iface
;
31 IPersistStream IPersistStream_iface
;
34 } DirectMusicScriptTrack
;
36 static inline DirectMusicScriptTrack
*impl_from_IDirectMusicTrack8(IDirectMusicTrack8
*iface
)
38 return CONTAINING_RECORD(iface
, DirectMusicScriptTrack
, IDirectMusicTrack8_iface
);
41 static inline DirectMusicScriptTrack
*impl_from_IPersistStream(IPersistStream
*iface
)
43 return CONTAINING_RECORD(iface
, DirectMusicScriptTrack
, IPersistStream_iface
);
46 /* DirectMusicScriptTrack IDirectMusicTrack8 part: */
47 static HRESULT WINAPI
script_track_QueryInterface(IDirectMusicTrack8
*iface
, REFIID riid
,
50 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
52 TRACE("(%p, %s, %p)\n", This
, debugstr_dmguid(riid
), ret_iface
);
56 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDirectMusicTrack
) ||
57 IsEqualIID(riid
, &IID_IDirectMusicTrack8
))
59 else if (IsEqualIID(riid
, &IID_IPersistStream
))
60 *ret_iface
= &This
->IPersistStream_iface
;
62 WARN("(%p, %s, %p): not found\n", This
, debugstr_dmguid(riid
), ret_iface
);
66 IUnknown_AddRef((IUnknown
*)*ret_iface
);
70 static ULONG WINAPI
script_track_AddRef(IDirectMusicTrack8
*iface
)
72 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
73 LONG ref
= InterlockedIncrement(&This
->ref
);
75 TRACE("(%p) ref=%d\n", This
, ref
);
80 static ULONG WINAPI
script_track_Release(IDirectMusicTrack8
*iface
)
82 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
83 LONG ref
= InterlockedDecrement(&This
->ref
);
85 TRACE("(%p) ref=%d\n", This
, ref
);
88 HeapFree(GetProcessHeap(), 0, This
);
89 DMSCRIPT_UnlockModule();
95 static HRESULT WINAPI
script_track_Init(IDirectMusicTrack8
*iface
, IDirectMusicSegment
*pSegment
)
97 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
98 FIXME("(%p, %p): stub\n", This
, pSegment
);
102 static HRESULT WINAPI
script_track_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
);
111 static HRESULT WINAPI
script_track_EndPlay(IDirectMusicTrack8
*iface
, void *pStateData
)
113 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
114 FIXME("(%p, %p): stub\n", This
, pStateData
);
118 static HRESULT WINAPI
script_track_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
);
127 static HRESULT WINAPI
script_track_GetParam(IDirectMusicTrack8
*iface
, REFGUID type
,
128 MUSIC_TIME time
, MUSIC_TIME
*next
, void *param
)
130 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
132 TRACE("(%p, %s, %d, %p, %p): not supported\n", This
, debugstr_dmguid(type
), time
, next
, param
);
134 return DMUS_E_GET_UNSUPPORTED
;
137 static HRESULT WINAPI
script_track_SetParam(IDirectMusicTrack8
*iface
, REFGUID type
,
138 MUSIC_TIME time
, void *param
)
140 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
142 TRACE("(%p, %s, %d, %p): not supported\n", This
, debugstr_dmguid(type
), time
, param
);
144 return DMUS_E_SET_UNSUPPORTED
;
147 static HRESULT WINAPI
script_track_IsParamSupported(IDirectMusicTrack8
*iface
, REFGUID type
)
149 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
151 TRACE("(%p, %s): param type not supported\n", This
, debugstr_dmguid(type
));
153 return DMUS_E_TYPE_UNSUPPORTED
;
156 static HRESULT WINAPI
script_track_AddNotificationType(IDirectMusicTrack8
*iface
, REFGUID type
)
158 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
160 TRACE("(%p, %s): method not implemented\n", This
, debugstr_dmguid(type
));
165 static HRESULT WINAPI
script_track_RemoveNotificationType(IDirectMusicTrack8
*iface
, REFGUID type
)
167 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
169 TRACE("(%p, %s): method not implemented\n", This
, debugstr_dmguid(type
));
174 static HRESULT WINAPI
script_track_Clone(IDirectMusicTrack8
*iface
, MUSIC_TIME mtStart
,
175 MUSIC_TIME mtEnd
, IDirectMusicTrack
**ppTrack
)
177 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
178 FIXME("(%p, %d, %d, %p): stub\n", This
, mtStart
, mtEnd
, ppTrack
);
182 static HRESULT WINAPI
script_track_PlayEx(IDirectMusicTrack8
*iface
, void *pStateData
,
183 REFERENCE_TIME rtStart
, REFERENCE_TIME rtEnd
, REFERENCE_TIME rtOffset
, DWORD dwFlags
,
184 IDirectMusicPerformance
*pPerf
, IDirectMusicSegmentState
*pSegSt
, DWORD dwVirtualID
)
186 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
187 FIXME("(%p, %p, 0x%s, 0x%s, 0x%s, %d, %p, %p, %d): stub\n", This
, pStateData
, wine_dbgstr_longlong(rtStart
),
188 wine_dbgstr_longlong(rtEnd
), wine_dbgstr_longlong(rtOffset
), dwFlags
, pPerf
, pSegSt
, dwVirtualID
);
192 static HRESULT WINAPI
script_track_GetParamEx(IDirectMusicTrack8
*iface
, REFGUID rguidType
,
193 REFERENCE_TIME rtTime
, REFERENCE_TIME
*prtNext
, void *pParam
, void *pStateData
,
196 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
197 FIXME("(%p, %s, 0x%s, %p, %p, %p, %d): stub\n", This
, debugstr_dmguid(rguidType
),
198 wine_dbgstr_longlong(rtTime
), prtNext
, pParam
, pStateData
, dwFlags
);
202 static HRESULT WINAPI
script_track_SetParamEx(IDirectMusicTrack8
*iface
, REFGUID rguidType
,
203 REFERENCE_TIME rtTime
, void *pParam
, void *pStateData
, DWORD dwFlags
)
205 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
206 FIXME("(%p, %s, 0x%s, %p, %p, %d): stub\n", This
, debugstr_dmguid(rguidType
),
207 wine_dbgstr_longlong(rtTime
), pParam
, pStateData
, dwFlags
);
211 static HRESULT WINAPI
script_track_Compose(IDirectMusicTrack8
*iface
, IUnknown
*context
,
212 DWORD group
, IDirectMusicTrack
**res_track
)
214 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
216 TRACE("(%p, %p, %d, %p): method not implemented\n", This
, context
, group
, res_track
);
221 static HRESULT WINAPI
script_track_Join(IDirectMusicTrack8
*iface
, IDirectMusicTrack
*track2
,
222 MUSIC_TIME join
, IUnknown
*context
, DWORD group
, IDirectMusicTrack
**res_track
)
224 DirectMusicScriptTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
226 TRACE("(%p, %p, %d, %p, %d, %p): method not implemented\n", This
, track2
, join
, context
,
232 static const IDirectMusicTrack8Vtbl dmtrack8_vtbl
= {
233 script_track_QueryInterface
,
235 script_track_Release
,
237 script_track_InitPlay
,
238 script_track_EndPlay
,
240 script_track_GetParam
,
241 script_track_SetParam
,
242 script_track_IsParamSupported
,
243 script_track_AddNotificationType
,
244 script_track_RemoveNotificationType
,
247 script_track_GetParamEx
,
248 script_track_SetParamEx
,
249 script_track_Compose
,
253 /* IDirectMusicScriptTrack IPersistStream part: */
254 static HRESULT WINAPI
IPersistStreamImpl_QueryInterface(IPersistStream
*iface
, REFIID riid
,
257 DirectMusicScriptTrack
*This
= impl_from_IPersistStream(iface
);
258 return IDirectMusicTrack8_QueryInterface(&This
->IDirectMusicTrack8_iface
, riid
, ret_iface
);
261 static ULONG WINAPI
IPersistStreamImpl_AddRef(IPersistStream
*iface
)
263 DirectMusicScriptTrack
*This
= impl_from_IPersistStream(iface
);
264 return IDirectMusicTrack8_AddRef(&This
->IDirectMusicTrack8_iface
);
267 static ULONG WINAPI
IPersistStreamImpl_Release(IPersistStream
*iface
)
269 DirectMusicScriptTrack
*This
= impl_from_IPersistStream(iface
);
270 return IDirectMusicTrack8_Release(&This
->IDirectMusicTrack8_iface
);
273 static HRESULT WINAPI
IPersistStreamImpl_GetClassID(IPersistStream
*iface
, CLSID
*pClassID
)
275 DirectMusicScriptTrack
*This
= impl_from_IPersistStream(iface
);
277 TRACE("(%p, %p)\n", This
, pClassID
);
282 *pClassID
= This
->desc
.guidClass
;
286 static HRESULT WINAPI
IPersistStreamImpl_IsDirty(IPersistStream
*iface
)
291 static HRESULT WINAPI
IPersistStreamImpl_Load(IPersistStream
*iface
, IStream
*pStm
)
293 FIXME(": Loading not implemented yet\n");
297 static HRESULT WINAPI
IPersistStreamImpl_Save(IPersistStream
*iface
, IStream
*pStm
,
303 static HRESULT WINAPI
IPersistStreamImpl_GetSizeMax(IPersistStream
*iface
, ULARGE_INTEGER
*pcbSize
)
308 static const IPersistStreamVtbl persist_vtbl
= {
309 IPersistStreamImpl_QueryInterface
,
310 IPersistStreamImpl_AddRef
,
311 IPersistStreamImpl_Release
,
312 IPersistStreamImpl_GetClassID
,
313 IPersistStreamImpl_IsDirty
,
314 IPersistStreamImpl_Load
,
315 IPersistStreamImpl_Save
,
316 IPersistStreamImpl_GetSizeMax
319 /* for ClassFactory */
320 HRESULT WINAPI
DMUSIC_CreateDirectMusicScriptTrack(REFIID riid
, void **ret_iface
,
323 DirectMusicScriptTrack
*track
;
329 return CLASS_E_NOAGGREGATION
;
331 track
= HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*track
));
333 return E_OUTOFMEMORY
;
335 track
->IDirectMusicTrack8_iface
.lpVtbl
= &dmtrack8_vtbl
;
336 track
->IPersistStream_iface
.lpVtbl
= &persist_vtbl
;
337 track
->desc
.dwSize
= sizeof(track
->desc
);
338 track
->desc
.dwValidData
= DMUS_OBJ_CLASS
;
339 track
->desc
.guidClass
= CLSID_DirectMusicScriptTrack
;
342 DMSCRIPT_LockModule();
343 hr
= IDirectMusicTrack8_QueryInterface(&track
->IDirectMusicTrack8_iface
, riid
, ret_iface
);
344 IDirectMusicTrack8_Release(&track
->IDirectMusicTrack8_iface
);