- Implement CoSetProxyBlanket, CoQueryProxyBlanket and CoCopyProxy.
[wine] / dlls / dmusic / dmusic_private.h
1 /* DirectMusic Private Include
2  *
3  * Copyright (C) 2003-2004 Rok Mandeljc
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (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
13  * GNU Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __WINE_DMUSIC_PRIVATE_H
21 #define __WINE_DMUSIC_PRIVATE_H
22
23 #include <stdarg.h>
24
25 #define COBJMACROS
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winnt.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32
33 #include "wine/debug.h"
34 #include "wine/list.h"
35 #include "wine/unicode.h"
36 #include "winreg.h"
37 #include "objbase.h"
38
39 #include "dmusici.h"
40 #include "dmusicf.h"
41 #include "dmusics.h"
42
43 /*****************************************************************************
44  * Interfaces
45  */
46 typedef struct IDirectMusic8Impl IDirectMusic8Impl;
47 typedef struct IDirectMusicBufferImpl IDirectMusicBufferImpl;
48 typedef struct IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstrumentImpl;
49 typedef struct IDirectMusicDownloadImpl IDirectMusicDownloadImpl;
50 typedef struct IDirectMusicPortDownloadImpl IDirectMusicPortDownloadImpl;
51 typedef struct IDirectMusicPortImpl IDirectMusicPortImpl;
52 typedef struct IDirectMusicThruImpl IDirectMusicThruImpl;
53 typedef struct IReferenceClockImpl IReferenceClockImpl;
54
55 typedef struct IDirectMusicCollectionImpl IDirectMusicCollectionImpl;
56 typedef struct IDirectMusicInstrumentImpl IDirectMusicInstrumentImpl;
57
58         
59 /*****************************************************************************
60  * Predeclare the interface implementation structures
61  */
62 extern IDirectMusic8Vtbl DirectMusic8_Vtbl;
63 extern IDirectMusicBufferVtbl DirectMusicBuffer_Vtbl;
64 extern IDirectMusicDownloadedInstrumentVtbl DirectMusicDownloadedInstrument_Vtbl;
65 extern IDirectMusicDownloadVtbl DirectMusicDownload_Vtbl;
66 extern IDirectMusicPortDownloadVtbl DirectMusicPortDownload_Vtbl;
67 extern IDirectMusicPortVtbl DirectMusicPort_Vtbl;
68 extern IDirectMusicThruVtbl DirectMusicThru_Vtbl;
69 extern IReferenceClockVtbl ReferenceClock_Vtbl;
70
71 extern IUnknownVtbl               DirectMusicCollection_Unknown_Vtbl;
72 extern IDirectMusicCollectionVtbl DirectMusicCollection_Collection_Vtbl;
73 extern IDirectMusicObjectVtbl     DirectMusicCollection_Object_Vtbl;
74 extern IPersistStreamVtbl         DirectMusicCollection_PersistStream_Vtbl;
75
76 extern IUnknownVtbl               DirectMusicInstrument_Unknown_Vtbl;
77 extern IDirectMusicInstrumentVtbl DirectMusicInstrument_Instrument_Vtbl;
78
79 /*****************************************************************************
80  * Some stuff to make my life easier :=)
81  */
82  
83 /* some sort of aux. midi channel: big fake at the moment; accepts only priority
84    changes... more coming soon */
85 typedef struct DMUSIC_PRIVATE_MCHANNEL_ {
86         DWORD priority;
87 } DMUSIC_PRIVATE_MCHANNEL, *LPDMUSIC_PRIVATE_MCHANNEL;
88
89 /* some sort of aux. channel group: collection of 16 midi channels */
90 typedef struct DMUSIC_PRIVATE_CHANNEL_GROUP_ {
91         DMUSIC_PRIVATE_MCHANNEL channel[16]; /* 16 channels in a group */
92 } DMUSIC_PRIVATE_CHANNEL_GROUP, *LPDMUSIC_PRIVATE_CHANNEL_GROUP;
93
94
95 /*****************************************************************************
96  * ClassFactory
97  */
98 extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
99 extern HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
100 extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
101 extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
102 extern HRESULT WINAPI DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
103
104 extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
105 extern HRESULT WINAPI DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
106
107 /*****************************************************************************
108  * IDirectMusic8Impl implementation structure
109  */
110 struct IDirectMusic8Impl {
111   /* IUnknown fields */
112   IDirectMusic8Vtbl *lpVtbl;
113   DWORD          ref;
114
115   /* IDirectMusicImpl fields */
116   IReferenceClockImpl* pMasterClock;
117   IDirectMusicPortImpl** ppPorts;
118   int nrofports;
119 };
120
121 /* IUnknown: */
122 extern HRESULT WINAPI IDirectMusic8Impl_QueryInterface (LPDIRECTMUSIC8 iface, REFIID riid, LPVOID *ppobj);
123 extern ULONG WINAPI   IDirectMusic8Impl_AddRef (LPDIRECTMUSIC8 iface);
124 extern ULONG WINAPI   IDirectMusic8Impl_Release (LPDIRECTMUSIC8 iface);
125 /* IDirectMusic: */
126 extern HRESULT WINAPI IDirectMusic8Impl_EnumPort (LPDIRECTMUSIC8 iface, DWORD dwIndex, LPDMUS_PORTCAPS pPortCaps);
127 extern HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer (LPDIRECTMUSIC8 iface, LPDMUS_BUFFERDESC pBufferDesc, LPDIRECTMUSICBUFFER** ppBuffer, LPUNKNOWN pUnkOuter);
128 extern HRESULT WINAPI IDirectMusic8Impl_CreatePort (LPDIRECTMUSIC8 iface, REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT* ppPort, LPUNKNOWN pUnkOuter);
129 extern HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock (LPDIRECTMUSIC8 iface, DWORD dwIndex, LPDMUS_CLOCKINFO lpClockInfo);
130 extern HRESULT WINAPI IDirectMusic8Impl_GetMasterClock (LPDIRECTMUSIC8 iface, LPGUID pguidClock, IReferenceClock** ppReferenceClock);
131 extern HRESULT WINAPI IDirectMusic8Impl_SetMasterClock (LPDIRECTMUSIC8 iface, REFGUID rguidClock);
132 extern HRESULT WINAPI IDirectMusic8Impl_Activate (LPDIRECTMUSIC8 iface, BOOL fEnable);
133 extern HRESULT WINAPI IDirectMusic8Impl_GetDefaultPort (LPDIRECTMUSIC8 iface, LPGUID pguidPort);
134 extern HRESULT WINAPI IDirectMusic8Impl_SetDirectSound (LPDIRECTMUSIC8 iface, LPDIRECTSOUND pDirectSound, HWND hWnd);
135 /* IDirectMusic8: */
136 extern HRESULT WINAPI IDirectMusic8Impl_SetExternalMasterClock (LPDIRECTMUSIC8 iface, IReferenceClock* pClock);
137
138 /*****************************************************************************
139  * IDirectMusicBufferImpl implementation structure
140  */
141 struct IDirectMusicBufferImpl {
142   /* IUnknown fields */
143   IDirectMusicBufferVtbl *lpVtbl;
144   DWORD          ref;
145
146   /* IDirectMusicBufferImpl fields */
147 };
148
149 /* IUnknown: */
150 extern HRESULT WINAPI IDirectMusicBufferImpl_QueryInterface (LPDIRECTMUSICBUFFER iface, REFIID riid, LPVOID *ppobj);
151 extern ULONG WINAPI   IDirectMusicBufferImpl_AddRef (LPDIRECTMUSICBUFFER iface);
152 extern ULONG WINAPI   IDirectMusicBufferImpl_Release (LPDIRECTMUSICBUFFER iface);
153 /* IDirectMusicBufferImpl: */
154 extern HRESULT WINAPI IDirectMusicBufferImpl_Flush (LPDIRECTMUSICBUFFER iface);
155 extern HRESULT WINAPI IDirectMusicBufferImpl_TotalTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prtTime);
156 extern HRESULT WINAPI IDirectMusicBufferImpl_PackStructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD dwChannelMessage);
157 extern HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD cb, LPBYTE lpb);
158 extern HRESULT WINAPI IDirectMusicBufferImpl_ResetReadPtr (LPDIRECTMUSICBUFFER iface);
159 extern HRESULT WINAPI IDirectMusicBufferImpl_GetNextEvent (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt, LPDWORD pdwChannelGroup, LPDWORD pdwLength, LPBYTE* ppData);
160 extern HRESULT WINAPI IDirectMusicBufferImpl_GetRawBufferPtr (LPDIRECTMUSICBUFFER iface, LPBYTE* ppData);
161 extern HRESULT WINAPI IDirectMusicBufferImpl_GetStartTime (LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt);
162 extern HRESULT WINAPI IDirectMusicBufferImpl_GetUsedBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb);
163 extern HRESULT WINAPI IDirectMusicBufferImpl_GetMaxBytes (LPDIRECTMUSICBUFFER iface, LPDWORD pcb);
164 extern HRESULT WINAPI IDirectMusicBufferImpl_GetBufferFormat (LPDIRECTMUSICBUFFER iface, LPGUID pGuidFormat);
165 extern HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime (LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt);
166 extern HRESULT WINAPI IDirectMusicBufferImpl_SetUsedBytes (LPDIRECTMUSICBUFFER iface, DWORD cb);
167
168
169 /*****************************************************************************
170  * IDirectMusicDownloadedInstrumentImpl implementation structure
171  */
172 struct IDirectMusicDownloadedInstrumentImpl {
173   /* IUnknown fields */
174   IDirectMusicDownloadedInstrumentVtbl *lpVtbl;
175   DWORD          ref;
176
177   /* IDirectMusicDownloadedInstrumentImpl fields */
178 };
179
180 /* IUnknown: */
181 extern HRESULT WINAPI IDirectMusicDownloadedInstrumentImpl_QueryInterface (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface, REFIID riid, LPVOID *ppobj);
182 extern ULONG WINAPI   IDirectMusicDownloadedInstrumentImpl_AddRef (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface);
183 extern ULONG WINAPI   IDirectMusicDownloadedInstrumentImpl_Release (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface);
184 /* IDirectMusicDownloadedInstrumentImpl: */
185 /* none yet */
186
187
188 /*****************************************************************************
189  * IDirectMusicDownloadImpl implementation structure
190  */
191 struct IDirectMusicDownloadImpl {
192   /* IUnknown fields */
193   IDirectMusicDownloadVtbl *lpVtbl;
194   DWORD          ref;
195
196   /* IDirectMusicDownloadImpl fields */
197 };
198
199 /* IUnknown: */
200 extern HRESULT WINAPI IDirectMusicDownloadImpl_QueryInterface (LPDIRECTMUSICDOWNLOAD iface, REFIID riid, LPVOID *ppobj);
201 extern ULONG WINAPI   IDirectMusicDownloadImpl_AddRef (LPDIRECTMUSICDOWNLOAD iface);
202 extern ULONG WINAPI   IDirectMusicDownloadImpl_Release (LPDIRECTMUSICDOWNLOAD iface);
203 /* IDirectMusicImpl: */
204 extern HRESULT WINAPI IDirectMusicDownloadImpl_GetBuffer (LPDIRECTMUSICDOWNLOAD iface, void** ppvBuffer, DWORD* pdwSize);
205
206
207 /*****************************************************************************
208  * IDirectMusicPortDownloadImpl implementation structure
209  */
210 struct IDirectMusicPortDownloadImpl {
211   /* IUnknown fields */
212   IDirectMusicPortDownloadVtbl *lpVtbl;
213   DWORD          ref;
214
215   /* IDirectMusicPortDownloadImpl fields */
216 };
217
218 /* IUnknown: */
219 extern HRESULT WINAPI IDirectMusicPortDownloadImpl_QueryInterface (LPDIRECTMUSICPORTDOWNLOAD iface, REFIID riid, LPVOID *ppobj);
220 extern ULONG WINAPI   IDirectMusicPortDownloadImpl_AddRef (LPDIRECTMUSICPORTDOWNLOAD iface);
221 extern ULONG WINAPI   IDirectMusicPortDownloadImpl_Release (LPDIRECTMUSICPORTDOWNLOAD iface);
222 /* IDirectMusicPortDownloadImpl: */
223 extern HRESULT WINAPI IDirectMusicPortDownloadImpl_GetBuffer (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD dwDLId, IDirectMusicDownload** ppIDMDownload);
224 extern HRESULT WINAPI IDirectMusicPortDownloadImpl_AllocateBuffer (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD dwSize, IDirectMusicDownload** ppIDMDownload);
225 extern HRESULT WINAPI IDirectMusicPortDownloadImpl_GetDLId (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* pdwStartDLId, DWORD dwCount);
226 extern HRESULT WINAPI IDirectMusicPortDownloadImpl_GetAppend (LPDIRECTMUSICPORTDOWNLOAD iface, DWORD* pdwAppend);
227 extern HRESULT WINAPI IDirectMusicPortDownloadImpl_Download (LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* pIDMDownload);
228 extern HRESULT WINAPI IDirectMusicPortDownloadImpl_Unload (LPDIRECTMUSICPORTDOWNLOAD iface, IDirectMusicDownload* pIDMDownload);
229
230 /*****************************************************************************
231  * IDirectMusicPortImpl implementation structure
232  */
233 struct IDirectMusicPortImpl {
234   /* IUnknown fields */
235   IDirectMusicPortVtbl *lpVtbl;
236   DWORD          ref;
237
238   /* IDirectMusicPortImpl fields */
239   IDirectSound* pDirectSound;
240   IReferenceClock* pLatencyClock;
241   BOOL fActive;
242   LPDMUS_PORTCAPS pCaps;
243   LPDMUS_PORTPARAMS pParams;
244   int nrofgroups;
245   DMUSIC_PRIVATE_CHANNEL_GROUP group[1];
246 };
247
248 /* IUnknown: */
249 extern HRESULT WINAPI IDirectMusicPortImpl_QueryInterface (LPDIRECTMUSICPORT iface, REFIID riid, LPVOID *ppobj);
250 extern ULONG WINAPI   IDirectMusicPortImpl_AddRef (LPDIRECTMUSICPORT iface);
251 extern ULONG WINAPI   IDirectMusicPortImpl_Release (LPDIRECTMUSICPORT iface);
252 /* IDirectMusicPortImpl: */
253 extern HRESULT WINAPI IDirectMusicPortImpl_PlayBuffer (LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER pBuffer);
254 extern HRESULT WINAPI IDirectMusicPortImpl_SetReadNotificationHandle (LPDIRECTMUSICPORT iface, HANDLE hEvent);
255 extern HRESULT WINAPI IDirectMusicPortImpl_Read (LPDIRECTMUSICPORT iface, LPDIRECTMUSICBUFFER pBuffer);
256 extern HRESULT WINAPI IDirectMusicPortImpl_DownloadInstrument (LPDIRECTMUSICPORT iface, IDirectMusicInstrument* pInstrument, IDirectMusicDownloadedInstrument** ppDownloadedInstrument, DMUS_NOTERANGE* pNoteRanges, DWORD dwNumNoteRanges);
257 extern HRESULT WINAPI IDirectMusicPortImpl_UnloadInstrument (LPDIRECTMUSICPORT iface, IDirectMusicDownloadedInstrument *pDownloadedInstrument);
258 extern HRESULT WINAPI IDirectMusicPortImpl_GetLatencyClock (LPDIRECTMUSICPORT iface, IReferenceClock** ppClock);
259 extern HRESULT WINAPI IDirectMusicPortImpl_GetRunningStats (LPDIRECTMUSICPORT iface, LPDMUS_SYNTHSTATS pStats);
260 extern HRESULT WINAPI IDirectMusicPortImpl_Compact (LPDIRECTMUSICPORT iface);
261 extern HRESULT WINAPI IDirectMusicPortImpl_GetCaps (LPDIRECTMUSICPORT iface, LPDMUS_PORTCAPS pPortCaps);
262 extern HRESULT WINAPI IDirectMusicPortImpl_DeviceIoControl (LPDIRECTMUSICPORT iface, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped);
263 extern HRESULT WINAPI IDirectMusicPortImpl_SetNumChannelGroups (LPDIRECTMUSICPORT iface, DWORD dwChannelGroups);
264 extern HRESULT WINAPI IDirectMusicPortImpl_GetNumChannelGroups (LPDIRECTMUSICPORT iface, LPDWORD pdwChannelGroups);
265 extern HRESULT WINAPI IDirectMusicPortImpl_Activate (LPDIRECTMUSICPORT iface, BOOL fActive);
266 extern HRESULT WINAPI IDirectMusicPortImpl_SetChannelPriority (LPDIRECTMUSICPORT iface, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwPriority);
267 extern HRESULT WINAPI IDirectMusicPortImpl_GetChannelPriority (LPDIRECTMUSICPORT iface, DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwPriority);
268 extern HRESULT WINAPI IDirectMusicPortImpl_SetDirectSound (LPDIRECTMUSICPORT iface, LPDIRECTSOUND pDirectSound, LPDIRECTSOUNDBUFFER pDirectSoundBuffer);
269 extern HRESULT WINAPI IDirectMusicPortImpl_GetFormat (LPDIRECTMUSICPORT iface, LPWAVEFORMATEX pWaveFormatEx, LPDWORD pdwWaveFormatExSize, LPDWORD pdwBufferSize);
270
271 /*****************************************************************************
272  * IDirectMusicThruImpl implementation structure
273  */
274 struct IDirectMusicThruImpl {
275   /* IUnknown fields */
276   IDirectMusicThruVtbl *lpVtbl;
277   DWORD          ref;
278
279   /* IDirectMusicThruImpl fields */
280 };
281
282 /* IUnknown: */
283 extern HRESULT WINAPI IDirectMusicThruImpl_QueryInterface (LPDIRECTMUSICTHRU iface, REFIID riid, LPVOID *ppobj);
284 extern ULONG WINAPI   IDirectMusicThruImpl_AddRef (LPDIRECTMUSICTHRU iface);
285 extern ULONG WINAPI   IDirectMusicThruImpl_Release (LPDIRECTMUSICTHRU iface);
286 /* IDirectMusicPortDownloadImpl: */
287 extern HRESULT WINAPI ThruChannel (LPDIRECTMUSICTHRU iface, DWORD dwSourceChannelGroup, DWORD dwSourceChannel, DWORD dwDestinationChannelGroup, DWORD dwDestinationChannel, LPDIRECTMUSICPORT pDestinationPort);
288
289 /*****************************************************************************
290  * IReferenceClockImpl implementation structure
291  */
292 struct IReferenceClockImpl {
293   /* IUnknown fields */
294   IReferenceClockVtbl *lpVtbl;
295   DWORD          ref;
296
297   /* IReferenceClockImpl fields */
298   REFERENCE_TIME rtTime;
299   DMUS_CLOCKINFO pClockInfo;
300 };
301
302 /* IUnknown: */
303 extern HRESULT WINAPI IReferenceClockImpl_QueryInterface (IReferenceClock *iface, REFIID riid, LPVOID *ppobj);
304 extern ULONG WINAPI   IReferenceClockImpl_AddRef (IReferenceClock *iface);
305 extern ULONG WINAPI   IReferenceClockImpl_Release (IReferenceClock *iface);
306 /* IReferenceClock: */
307 extern HRESULT WINAPI IReferenceClockImpl_GetTime (IReferenceClock *iface, REFERENCE_TIME* pTime);
308 extern HRESULT WINAPI IReferenceClockImpl_AdviseTime (IReferenceClock *iface, REFERENCE_TIME baseTime, REFERENCE_TIME streamTime, HANDLE hEvent, DWORD* pdwAdviseCookie);
309 extern HRESULT WINAPI IReferenceClockImpl_AdvisePeriodic (IReferenceClock *iface, REFERENCE_TIME startTime, REFERENCE_TIME periodTime, HANDLE hSemaphore, DWORD* pdwAdviseCookie);
310 extern HRESULT WINAPI IReferenceClockImpl_Unadvise (IReferenceClock *iface, DWORD dwAdviseCookie);
311
312
313 typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY {
314         struct list entry; /* for listing elements */
315         IDirectMusicInstrument* pInstrument;
316 } DMUS_PRIVATE_INSTRUMENTENTRY, *LPDMUS_PRIVATE_INSTRUMENTENTRY;
317
318 typedef struct _DMUS_PRIVATE_POOLCUE {
319         struct list entry; /* for listing elements */
320 } DMUS_PRIVATE_POOLCUE, *LPDMUS_PRIVATE_POOLCUE;
321
322 /*****************************************************************************
323  * IDirectMusicCollectionImpl implementation structure
324  */
325 struct IDirectMusicCollectionImpl {
326   /* IUnknown fields */
327   IUnknownVtbl *UnknownVtbl;
328   IDirectMusicCollectionVtbl *CollectionVtbl;
329   IDirectMusicObjectVtbl *ObjectVtbl;
330   IPersistStreamVtbl *PersistStreamVtbl;
331   DWORD          ref;
332
333   /* IDirectMusicCollectionImpl fields */
334   IStream *pStm; /* stream from which we load collection and later instruments */
335   LARGE_INTEGER liCollectionPosition; /* offset in a stream where collection was loaded from */
336   LARGE_INTEGER liWavePoolTablePosition; /* offset in a stream where wave pool table can be found */
337   LPDMUS_OBJECTDESC pDesc;
338   CHAR* szCopyright; /* FIXME: should probably placed somewhere else */
339   LPDLSHEADER pHeader;
340   /* pool table */
341   LPPOOLTABLE pPoolTable;
342   LPPOOLCUE pPoolCues;
343   /* instruments */
344   struct list Instruments;
345 };
346
347 /* IUnknown: */
348 extern HRESULT WINAPI IDirectMusicCollectionImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj);
349 extern ULONG WINAPI   IDirectMusicCollectionImpl_IUnknown_AddRef (LPUNKNOWN iface);
350 extern ULONG WINAPI   IDirectMusicCollectionImpl_IUnknown_Release (LPUNKNOWN iface);
351 /* IDirectMusicCollection: */
352 extern HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_QueryInterface (LPDIRECTMUSICCOLLECTION iface, REFIID riid, LPVOID *ppobj);
353 extern ULONG WINAPI   IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef (LPDIRECTMUSICCOLLECTION iface);
354 extern ULONG WINAPI   IDirectMusicCollectionImpl_IDirectMusicCollection_Release (LPDIRECTMUSICCOLLECTION iface);
355 extern HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_GetInstrument (LPDIRECTMUSICCOLLECTION iface, DWORD dwPatch, IDirectMusicInstrument** ppInstrument);
356 extern HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_EnumInstrument (LPDIRECTMUSICCOLLECTION iface, DWORD dwIndex, DWORD* pdwPatch, LPWSTR pwszName, DWORD dwNameLen);
357 /* IDirectMusicObject: */
358 extern HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj);
359 extern ULONG WINAPI   IDirectMusicCollectionImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface);
360 extern ULONG WINAPI   IDirectMusicCollectionImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface);
361 extern HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc);
362 extern HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc);
363 extern HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc);
364 /* IPersistStream: */
365 extern HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, void** ppvObject);
366 extern ULONG WINAPI   IDirectMusicCollectionImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface);
367 extern ULONG WINAPI   IDirectMusicCollectionImpl_IPersistStream_Release (LPPERSISTSTREAM iface);
368 extern HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID);
369 extern HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface);
370 extern HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm);
371 extern HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty);
372 extern HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize);
373
374
375 /*****************************************************************************
376  * IDirectMusicInstrumentImpl implementation structure
377  */
378 struct IDirectMusicInstrumentImpl {
379   /* IUnknown fields */
380   IUnknownVtbl *UnknownVtbl;
381   IDirectMusicInstrumentVtbl *InstrumentVtbl;
382   DWORD          ref;
383
384   /* IDirectMusicInstrumentImpl fields */
385   LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */
386   LPGUID pInstrumentID;
387   LPINSTHEADER pHeader;
388   WCHAR wszName[DMUS_MAX_NAME];
389   /* instrument data */
390 };
391
392 /* IUnknown: */
393 extern HRESULT WINAPI IDirectMusicInstrumentImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj);
394 extern ULONG WINAPI   IDirectMusicInstrumentImpl_IUnknown_AddRef (LPUNKNOWN iface);
395 extern ULONG WINAPI   IDirectMusicInstrumentImpl_IUnknown_Release (LPUNKNOWN iface);
396 /* IDirectMusicInstrumentImpl: */
397 extern HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_QueryInterface (LPDIRECTMUSICINSTRUMENT iface, REFIID riid, LPVOID *ppobj);
398 extern ULONG WINAPI   IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef (LPDIRECTMUSICINSTRUMENT iface);
399 extern ULONG WINAPI   IDirectMusicInstrumentImpl_IDirectMusicInstrument_Release (LPDIRECTMUSICINSTRUMENT iface);
400 extern HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_GetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD* pdwPatch);
401 extern HRESULT WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_SetPatch (LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch);
402 /* custom :) */
403 extern HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm);
404
405 /**********************************************************************
406  * Dll lifetime tracking declaration for dmusic.dll
407  */
408 extern LONG DMUSIC_refCount;
409 static inline void DMUSIC_LockModule() { InterlockedIncrement( &DMUSIC_refCount ); }
410 static inline void DMUSIC_UnlockModule() { InterlockedDecrement( &DMUSIC_refCount ); }
411
412 /*****************************************************************************
413  * Helper Functions
414  */
415 void register_waveport (LPGUID lpGUID, LPCSTR lpszDesc, LPCSTR lpszDrvName, LPVOID lpContext);
416
417
418 /*****************************************************************************
419  * Misc.
420  */
421 /* my custom ICOM stuff */
422 #define ICOM_NAME_MULTI(impl,field,iface,name)  impl* const name=(impl*)((char*)(iface) - offsetof(impl,field))
423 #define ICOM_THIS_MULTI(impl,field,iface) ICOM_NAME_MULTI(impl,field,iface,This)
424  
425 /* for simpler reading */
426 typedef struct _DMUS_PRIVATE_CHUNK {
427         FOURCC fccID; /* FOURCC ID of the chunk */
428         DWORD dwSize; /* size of the chunk */
429 } DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_CHUNK;
430
431 /* used for generic dumping (copied from ddraw) */
432 typedef struct {
433     DWORD val;
434     const char* name;
435 } flag_info;
436
437 typedef struct {
438     const GUID *guid;
439     const char* name;
440 } guid_info;
441
442 /* used for initialising structs (primarily for DMUS_OBJECTDESC) */
443 #define DM_STRUCT_INIT(x)                               \
444         do {                                                            \
445                 memset((x), 0, sizeof(*(x)));   \
446                 (x)->dwSize = sizeof(*x);               \
447         } while (0)
448
449 #define FE(x) { x, #x } 
450 #define GE(x) { &x, #x }
451
452 /* dwPatch from MIDILOCALE */
453 extern DWORD MIDILOCALE2Patch (LPMIDILOCALE pLocale);
454 /* MIDILOCALE from dwPatch */
455 extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale);
456
457 /* check whether the given DWORD is even (return 0) or odd (return 1) */
458 extern int even_or_odd (DWORD number);
459 /* FOURCC to string conversion for debug messages */
460 extern const char *debugstr_fourcc (DWORD fourcc);
461 /* DMUS_VERSION struct to string conversion for debug messages */
462 extern const char *debugstr_dmversion (LPDMUS_VERSION version);
463 /* returns name of given GUID */
464 extern const char *debugstr_dmguid (const GUID *id);
465 /* returns name of given error code */
466 extern const char *debugstr_dmreturn (DWORD code);
467 /* generic flags-dumping function */
468 extern const char *debugstr_flags (DWORD flags, const flag_info* names, size_t num_names);
469 extern const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask);
470 /* dump whole DMUS_OBJECTDESC struct */
471 extern const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc);
472
473 #endif  /* __WINE_DMUSIC_PRIVATE_H */