ReactOS 0.4.17-dev-923-g4c9a150
commandtrack.c
Go to the documentation of this file.
1/* IDirectMusicCommandTrack Implementation
2 *
3 * Copyright (C) 2003-2004 Rok Mandeljc
4 *
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.
9 *
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.
14 *
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
18 */
19
20#include "dmstyle_private.h"
21#include "dmobject.h"
22
25
26/*****************************************************************************
27 * IDirectMusicCommandTrack implementation
28 */
30 IDirectMusicTrack8 IDirectMusicTrack8_iface;
31 struct dmobject dmobj; /* IPersistStream only */
33 struct list Commands;
35
36/* IDirectMusicCommandTrack IDirectMusicTrack8 part: */
37static inline IDirectMusicCommandTrack *impl_from_IDirectMusicTrack8(IDirectMusicTrack8 *iface)
38{
39 return CONTAINING_RECORD(iface, IDirectMusicCommandTrack, IDirectMusicTrack8_iface);
40}
41
42static HRESULT WINAPI command_track_QueryInterface(IDirectMusicTrack8 *iface, REFIID riid,
43 void **ret_iface)
44{
46
47 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
48
49 *ret_iface = NULL;
50
51 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicTrack) ||
52 IsEqualIID(riid, &IID_IDirectMusicTrack8))
53 *ret_iface = iface;
55 *ret_iface = &This->dmobj.IPersistStream_iface;
56 else {
57 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
58 return E_NOINTERFACE;
59 }
60
61 IUnknown_AddRef((IUnknown*)*ret_iface);
62 return S_OK;
63}
64
65static ULONG WINAPI command_track_AddRef(IDirectMusicTrack8 *iface)
66{
69
70 TRACE("(%p) ref=%ld\n", This, ref);
71
72 return ref;
73}
74
75static ULONG WINAPI command_track_Release(IDirectMusicTrack8 *iface)
76{
79
80 TRACE("(%p) ref=%ld\n", This, ref);
81
82 if (!ref) free(This);
83
84 return ref;
85}
86
87static HRESULT WINAPI command_track_Init(IDirectMusicTrack8 *iface, IDirectMusicSegment *pSegment)
88{
90 FIXME("(%p, %p): stub\n", This, pSegment);
91 return S_OK;
92}
93
94static HRESULT WINAPI command_track_InitPlay(IDirectMusicTrack8 *iface,
95 IDirectMusicSegmentState *pSegmentState, IDirectMusicPerformance *pPerformance,
96 void **ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags)
97{
99 FIXME("(%p, %p, %p, %p, %ld, %ld): stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
100 return S_OK;
101}
102
103static HRESULT WINAPI command_track_EndPlay(IDirectMusicTrack8 *iface, void *pStateData)
104{
106 FIXME("(%p, %p): stub\n", This, pStateData);
107 return S_OK;
108}
109
110static HRESULT WINAPI command_track_Play(IDirectMusicTrack8 *iface, void *pStateData,
111 MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags,
112 IDirectMusicPerformance *pPerf, IDirectMusicSegmentState *pSegSt, DWORD dwVirtualID)
113{
115 FIXME("(%p, %p, %ld, %ld, %ld, %ld, %p, %p, %ld): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
116 return S_OK;
117}
118
119static HRESULT WINAPI command_track_GetParam(IDirectMusicTrack8 *iface, REFGUID type,
121{
123
124 TRACE("(%p, %s, %ld, %p, %p):\n", This, debugstr_dmguid(type), time, next, param);
125
126 if (!type)
127 return E_POINTER;
128
129 if (IsEqualGUID(type, &GUID_CommandParam)) {
130 FIXME("GUID_CommandParam not handled yet\n");
131 return S_OK;
132 } else if (IsEqualGUID(type, &GUID_CommandParam2)) {
133 FIXME("GUID_CommandParam2 not handled yet\n");
134 return S_OK;
135 } else if (IsEqualGUID(type, &GUID_CommandParamNext)) {
136 FIXME("GUID_CommandParamNext not handled yet\n");
137 return S_OK;
138 }
139
141}
142
143static HRESULT WINAPI command_track_SetParam(IDirectMusicTrack8 *iface, REFGUID type,
144 MUSIC_TIME time, void *param)
145{
147
148 TRACE("(%p, %s, %ld, %p)\n", This, debugstr_dmguid(type), time, param);
149
150 if (!type)
151 return E_POINTER;
152
153 if (IsEqualGUID(type, &GUID_CommandParam)) {
154 FIXME("GUID_CommandParam not handled yet\n");
155 return S_OK;
156 } else if (IsEqualGUID(type, &GUID_CommandParamNext)) {
157 FIXME("GUID_CommandParamNext not handled yet\n");
158 return S_OK;
159 }
160
162}
163
164static HRESULT WINAPI command_track_IsParamSupported(IDirectMusicTrack8 *iface, REFGUID rguidType)
165{
167
168 TRACE("(%p, %s)\n", This, debugstr_dmguid(rguidType));
169
170 if (!rguidType)
171 return E_POINTER;
172
173 if (IsEqualGUID (rguidType, &GUID_CommandParam)
174 || IsEqualGUID (rguidType, &GUID_CommandParam2)
175 || IsEqualGUID (rguidType, &GUID_CommandParamNext)) {
176 TRACE("param supported\n");
177 return S_OK;
178 }
179
180 TRACE("param unsupported\n");
182}
183
184static HRESULT WINAPI command_track_AddNotificationType(IDirectMusicTrack8 *iface,
185 REFGUID rguidNotificationType)
186{
188 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
189 return S_OK;
190}
191
192static HRESULT WINAPI command_track_RemoveNotificationType(IDirectMusicTrack8 *iface,
193 REFGUID rguidNotificationType)
194{
196 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
197 return S_OK;
198}
199
200static HRESULT WINAPI command_track_Clone(IDirectMusicTrack8 *iface, MUSIC_TIME mtStart,
201 MUSIC_TIME mtEnd, IDirectMusicTrack **ppTrack)
202{
204 FIXME("(%p, %ld, %ld, %p): stub\n", This, mtStart, mtEnd, ppTrack);
205 return S_OK;
206}
207
208static HRESULT WINAPI command_track_PlayEx(IDirectMusicTrack8 *iface, void *pStateData,
209 REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags,
210 IDirectMusicPerformance *pPerf, IDirectMusicSegmentState *pSegSt, DWORD dwVirtualID)
211{
213 FIXME("(%p, %p, 0x%s, 0x%s, 0x%s, %ld, %p, %p, %ld): stub\n", This, pStateData, wine_dbgstr_longlong(rtStart),
214 wine_dbgstr_longlong(rtEnd), wine_dbgstr_longlong(rtOffset), dwFlags, pPerf, pSegSt, dwVirtualID);
215 return S_OK;
216}
217
218static HRESULT WINAPI command_track_GetParamEx(IDirectMusicTrack8 *iface, REFGUID rguidType,
219 REFERENCE_TIME rtTime, REFERENCE_TIME *prtNext, void *pParam,
220 void *pStateData, DWORD dwFlags)
221{
223 FIXME("(%p, %s, 0x%s, %p, %p, %p, %ld): stub\n", This, debugstr_dmguid(rguidType),
224 wine_dbgstr_longlong(rtTime), prtNext, pParam, pStateData, dwFlags);
225 return S_OK;
226}
227
228static HRESULT WINAPI command_track_SetParamEx(IDirectMusicTrack8 *iface, REFGUID rguidType,
229 REFERENCE_TIME rtTime, void *pParam, void *pStateData, DWORD dwFlags)
230{
232 FIXME("(%p, %s, 0x%s, %p, %p, %ld): stub\n", This, debugstr_dmguid(rguidType),
233 wine_dbgstr_longlong(rtTime), pParam, pStateData, dwFlags);
234 return S_OK;
235}
236
237static HRESULT WINAPI command_track_Compose(IDirectMusicTrack8 *iface, IUnknown *context,
238 DWORD trackgroup, IDirectMusicTrack **track)
239{
241
242 TRACE("(%p, %p, %ld, %p): method not implemented\n", This, context, trackgroup, track);
243 return E_NOTIMPL;
244}
245
246static HRESULT WINAPI command_track_Join(IDirectMusicTrack8 *iface, IDirectMusicTrack *pNewTrack,
247 MUSIC_TIME mtJoin, IUnknown *pContext, DWORD dwTrackGroup,
248 IDirectMusicTrack **ppResultTrack)
249{
251 FIXME("(%p, %p, %ld, %p, %ld, %p): stub\n", This, pNewTrack, mtJoin, pContext, dwTrackGroup, ppResultTrack);
252 return S_OK;
253}
254
255static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = {
274};
275
277{
278 return CONTAINING_RECORD(iface, IDirectMusicCommandTrack, dmobj.IPersistStream_iface);
279}
280
282{
284 FOURCC chunkID;
285 DWORD chunkSize, dwSizeOfStruct, nrCommands;
286 LARGE_INTEGER liMove; /* used when skipping chunks */
287
288 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
289 IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
290 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
291 switch (chunkID) {
293 DWORD count;
294 TRACE_(dmfile)(": command track chunk\n");
295 IStream_Read (pStm, &dwSizeOfStruct, sizeof(DWORD), NULL);
296 if (dwSizeOfStruct != sizeof(DMUS_IO_COMMAND)) {
297 TRACE_(dmfile)(": declared size of struct (=%ld) != actual size; indicates older direct music version\n", dwSizeOfStruct);
298 }
299 chunkSize -= sizeof(DWORD); /* now chunk size is one DWORD shorter */
300 nrCommands = chunkSize/dwSizeOfStruct; /* and this is the number of commands */
301 /* load each command separately in new entry */
302 for (count = 0; count < nrCommands; count++) {
303 LPDMUS_PRIVATE_COMMAND pNewCommand = calloc(1, sizeof(*pNewCommand));
304 IStream_Read (pStm, &pNewCommand->pCommand, dwSizeOfStruct, NULL);
305 list_add_tail (&This->Commands, &pNewCommand->entry);
306 }
307 TRACE_(dmfile)(": reading finished\n");
308 This->dmobj.desc.dwValidData |= DMUS_OBJ_LOADED;
309 break;
310 }
311 default: {
312 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
313 liMove.QuadPart = chunkSize;
314 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
315 return E_FAIL;
316 }
317 }
318
319 /* DEBUG: dumps whole band track object tree: */
320 if (TRACE_ON(dmstyle)) {
321 int r = 0;
322 DMUS_PRIVATE_COMMAND *tmpEntry;
323 struct list *listEntry;
324 TRACE("*** IDirectMusicCommandTrack (%p) ***\n", This);
325 TRACE(" - Commands:\n");
326 LIST_FOR_EACH (listEntry, &This->Commands) {
327 tmpEntry = LIST_ENTRY (listEntry, DMUS_PRIVATE_COMMAND, entry);
328 TRACE(" - Command[%i]:\n", r);
329 TRACE(" - mtTime = %li\n", tmpEntry->pCommand.mtTime);
330 TRACE(" - wMeasure = %d\n", tmpEntry->pCommand.wMeasure);
331 TRACE(" - bBeat = %i\n", tmpEntry->pCommand.bBeat);
332 TRACE(" - bCommand = %i\n", tmpEntry->pCommand.bCommand);
333 TRACE(" - bGrooveLevel = %i\n", tmpEntry->pCommand.bGrooveLevel);
334 TRACE(" - bGrooveRange = %i\n", tmpEntry->pCommand.bGrooveRange);
335 TRACE(" - bRepeatMode = %i\n", tmpEntry->pCommand.bRepeatMode);
336 r++;
337 }
338 }
339
340 return S_OK;
341}
342
344 BOOL cleardirty)
345{
347
348 FIXME("(%p, %p, %d): stub\n", This, stream, cleardirty);
349
350 if (!stream)
351 return E_POINTER;
352
353 return E_NOTIMPL;
354}
355
356static const IPersistStreamVtbl persiststream_vtbl = {
365};
366
367/* for ClassFactory */
369{
371 HRESULT hr;
372
373 *ppobj = NULL;
374 if (!(track = calloc(1, sizeof(*track)))) return E_OUTOFMEMORY;
376 track->ref = 1;
377 dmobject_init(&track->dmobj, &CLSID_DirectMusicCommandTrack,
379 track->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
380 list_init (&track->Commands);
381
383 lpcGUID, ppobj);
385
386 return hr;
387}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_init(struct list_entry *head)
Definition: list.h:51
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
Definition: list.h:39
static IDirectMusicCommandTrack * impl_from_IDirectMusicTrack8(IDirectMusicTrack8 *iface)
Definition: commandtrack.c:37
HRESULT create_dmcommandtrack(REFIID lpcGUID, void **ppobj)
Definition: commandtrack.c:368
static HRESULT WINAPI command_track_QueryInterface(IDirectMusicTrack8 *iface, REFIID riid, void **ret_iface)
Definition: commandtrack.c:42
static HRESULT WINAPI command_track_Play(IDirectMusicTrack8 *iface, void *pStateData, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags, IDirectMusicPerformance *pPerf, IDirectMusicSegmentState *pSegSt, DWORD dwVirtualID)
Definition: commandtrack.c:110
static HRESULT WINAPI command_track_RemoveNotificationType(IDirectMusicTrack8 *iface, REFGUID rguidNotificationType)
Definition: commandtrack.c:192
static HRESULT WINAPI command_track_SetParam(IDirectMusicTrack8 *iface, REFGUID type, MUSIC_TIME time, void *param)
Definition: commandtrack.c:143
static HRESULT WINAPI command_track_PlayEx(IDirectMusicTrack8 *iface, void *pStateData, REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags, IDirectMusicPerformance *pPerf, IDirectMusicSegmentState *pSegSt, DWORD dwVirtualID)
Definition: commandtrack.c:208
static HRESULT WINAPI command_track_Compose(IDirectMusicTrack8 *iface, IUnknown *context, DWORD trackgroup, IDirectMusicTrack **track)
Definition: commandtrack.c:237
static HRESULT WINAPI command_track_AddNotificationType(IDirectMusicTrack8 *iface, REFGUID rguidNotificationType)
Definition: commandtrack.c:184
static IDirectMusicCommandTrack * impl_from_IPersistStream(IPersistStream *iface)
Definition: commandtrack.c:276
static HRESULT WINAPI command_track_InitPlay(IDirectMusicTrack8 *iface, IDirectMusicSegmentState *pSegmentState, IDirectMusicPerformance *pPerformance, void **ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags)
Definition: commandtrack.c:94
static ULONG WINAPI command_track_Release(IDirectMusicTrack8 *iface)
Definition: commandtrack.c:75
static const IPersistStreamVtbl persiststream_vtbl
Definition: commandtrack.c:356
static HRESULT WINAPI command_track_GetParam(IDirectMusicTrack8 *iface, REFGUID type, MUSIC_TIME time, MUSIC_TIME *next, void *param)
Definition: commandtrack.c:119
static HRESULT WINAPI command_track_Join(IDirectMusicTrack8 *iface, IDirectMusicTrack *pNewTrack, MUSIC_TIME mtJoin, IUnknown *pContext, DWORD dwTrackGroup, IDirectMusicTrack **ppResultTrack)
Definition: commandtrack.c:246
static HRESULT WINAPI command_track_SetParamEx(IDirectMusicTrack8 *iface, REFGUID rguidType, REFERENCE_TIME rtTime, void *pParam, void *pStateData, DWORD dwFlags)
Definition: commandtrack.c:228
static const IDirectMusicTrack8Vtbl dmtrack8_vtbl
Definition: commandtrack.c:255
static HRESULT WINAPI command_track_Init(IDirectMusicTrack8 *iface, IDirectMusicSegment *pSegment)
Definition: commandtrack.c:87
static HRESULT WINAPI command_track_EndPlay(IDirectMusicTrack8 *iface, void *pStateData)
Definition: commandtrack.c:103
static HRESULT WINAPI command_track_Clone(IDirectMusicTrack8 *iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicTrack **ppTrack)
Definition: commandtrack.c:200
static HRESULT WINAPI IPersistStreamImpl_Save(IPersistStream *iface, IStream *stream, BOOL cleardirty)
Definition: commandtrack.c:343
static HRESULT WINAPI command_track_IsParamSupported(IDirectMusicTrack8 *iface, REFGUID rguidType)
Definition: commandtrack.c:164
static HRESULT WINAPI command_track_GetParamEx(IDirectMusicTrack8 *iface, REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME *prtNext, void *pParam, void *pStateData, DWORD dwFlags)
Definition: commandtrack.c:218
static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pStm)
Definition: commandtrack.c:281
static ULONG WINAPI command_track_AddRef(IDirectMusicTrack8 *iface)
Definition: commandtrack.c:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRACE_(x)
Definition: compat.h:76
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define TRACE_ON(x)
Definition: compat.h:75
#define WINE_DECLARE_DEBUG_CHANNEL(x)
Definition: compat.h:45
DWORD FOURCC
Definition: dmdls.h:25
#define DMUS_E_GET_UNSUPPORTED
Definition: dmerror.h:72
#define DMUS_E_TYPE_UNSUPPORTED
Definition: dmerror.h:112
#define DMUS_E_SET_UNSUPPORTED
Definition: dmerror.h:71
void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk)
Definition: dmobject.c:749
ULONG WINAPI dmobj_IPersistStream_Release(IPersistStream *iface)
Definition: dmobject.c:702
HRESULT WINAPI unimpl_IPersistStream_GetSizeMax(IPersistStream *iface, ULARGE_INTEGER *size)
Definition: dmobject.c:742
HRESULT WINAPI dmobj_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class)
Definition: dmobject.c:708
ULONG WINAPI dmobj_IPersistStream_AddRef(IPersistStream *iface)
Definition: dmobject.c:696
const char * debugstr_dmguid(const GUID *id)
Definition: dmobject.c:36
HRESULT WINAPI dmobj_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid, void **ret_iface)
Definition: dmobject.c:689
HRESULT WINAPI unimpl_IPersistStream_IsDirty(IPersistStream *iface)
Definition: dmobject.c:729
#define IDirectMusicTrack8_Release(p)
Definition: dmplugin.h:275
LONG MUSIC_TIME
Definition: dmplugin.h:95
#define IDirectMusicTrack8_QueryInterface(p, a, b)
Definition: dmplugin.h:273
#define DMUS_FOURCC_COMMANDTRACK_CHUNK
Definition: dmusicf.h:160
#define DMUS_OBJ_LOADED
Definition: dmusici.h:274
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLfloat param
Definition: glext.h:5796
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
uint32_t entry
Definition: isohybrid.c:63
__u16 time
Definition: mkdosfs.c:8
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
const GUID IID_IPersistStream
Definition: proxy.cpp:13
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
static unsigned __int64 next
Definition: rand_nt.c:6
#define calloc
Definition: rosglue.h:14
static __inline const char * debugstr_fourcc(unsigned int cc)
Definition: debug.h:397
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:226
#define TRACE(s)
Definition: solgame.cpp:4
IDirectMusicTrack8 IDirectMusicTrack8_iface
Definition: commandtrack.c:30
struct dmobject dmobj
Definition: commandtrack.c:31
BYTE bGrooveLevel
Definition: dmusicf.h:623
BYTE bRepeatMode
Definition: dmusicf.h:625
BYTE bGrooveRange
Definition: dmusicf.h:624
MUSIC_TIME mtTime
Definition: dmusicf.h:619
DMUS_IO_COMMAND pCommand
Definition: scsiwmi.h:51
Definition: http.c:7252
Definition: send.c:48
Definition: parse.h:23
#define LIST_ENTRY(type)
Definition: queue.h:175
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:3479
#define E_POINTER
Definition: winerror.h:3480