1 /* DirectMusic Private Include
3 * Copyright (C) 2003-2004 Rok Mandeljc
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.
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.
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.
20 #ifndef __WINE_DMUSIC_PRIVATE_H
21 #define __WINE_DMUSIC_PRIVATE_H
33 #include "wine/debug.h"
34 #include "wine/list.h"
35 #include "wine/unicode.h"
43 /*****************************************************************************
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;
55 typedef struct IDirectMusicCollectionImpl IDirectMusicCollectionImpl;
56 typedef struct IDirectMusicInstrumentImpl IDirectMusicInstrumentImpl;
59 /*****************************************************************************
60 * Predeclare the interface implementation structures
62 extern const IDirectMusicPortVtbl DirectMusicPort_Vtbl;
64 /*****************************************************************************
65 * Some stuff to make my life easier :=)
68 /* some sort of aux. midi channel: big fake at the moment; accepts only priority
69 changes... more coming soon */
70 typedef struct DMUSIC_PRIVATE_MCHANNEL_ {
72 } DMUSIC_PRIVATE_MCHANNEL, *LPDMUSIC_PRIVATE_MCHANNEL;
74 /* some sort of aux. channel group: collection of 16 midi channels */
75 typedef struct DMUSIC_PRIVATE_CHANNEL_GROUP_ {
76 DMUSIC_PRIVATE_MCHANNEL channel[16]; /* 16 channels in a group */
77 } DMUSIC_PRIVATE_CHANNEL_GROUP, *LPDMUSIC_PRIVATE_CHANNEL_GROUP;
80 /*****************************************************************************
83 extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
84 extern HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
85 extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
86 extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
87 extern HRESULT WINAPI DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
89 extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
90 extern HRESULT WINAPI DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
92 /*****************************************************************************
93 * IDirectMusic8Impl implementation structure
95 struct IDirectMusic8Impl {
97 const IDirectMusic8Vtbl *lpVtbl;
100 /* IDirectMusicImpl fields */
101 IReferenceClockImpl* pMasterClock;
102 IDirectMusicPort** ppPorts;
107 extern ULONG WINAPI IDirectMusic8Impl_AddRef (LPDIRECTMUSIC8 iface);
109 /*****************************************************************************
110 * IDirectMusicBufferImpl implementation structure
112 struct IDirectMusicBufferImpl {
113 /* IUnknown fields */
114 const IDirectMusicBufferVtbl *lpVtbl;
117 /* IDirectMusicBufferImpl fields */
121 extern ULONG WINAPI IDirectMusicBufferImpl_AddRef (LPDIRECTMUSICBUFFER iface);
123 /*****************************************************************************
124 * IDirectMusicDownloadedInstrumentImpl implementation structure
126 struct IDirectMusicDownloadedInstrumentImpl {
127 /* IUnknown fields */
128 const IDirectMusicDownloadedInstrumentVtbl *lpVtbl;
131 /* IDirectMusicDownloadedInstrumentImpl fields */
135 extern ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_AddRef (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface);
136 /* IDirectMusicDownloadedInstrumentImpl: */
139 /*****************************************************************************
140 * IDirectMusicDownloadImpl implementation structure
142 struct IDirectMusicDownloadImpl {
143 /* IUnknown fields */
144 const IDirectMusicDownloadVtbl *lpVtbl;
147 /* IDirectMusicDownloadImpl fields */
151 extern ULONG WINAPI IDirectMusicDownloadImpl_AddRef (LPDIRECTMUSICDOWNLOAD iface);
153 /*****************************************************************************
154 * IDirectMusicPortDownloadImpl implementation structure
156 struct IDirectMusicPortDownloadImpl {
157 /* IUnknown fields */
158 const IDirectMusicPortDownloadVtbl *lpVtbl;
161 /* IDirectMusicPortDownloadImpl fields */
165 extern ULONG WINAPI IDirectMusicPortDownloadImpl_AddRef (LPDIRECTMUSICPORTDOWNLOAD iface);
167 /*****************************************************************************
168 * IDirectMusicPortImpl implementation structure
170 struct IDirectMusicPortImpl {
171 /* IUnknown fields */
172 const IDirectMusicPortVtbl *lpVtbl;
175 /* IDirectMusicPortImpl fields */
176 IDirectSound* pDirectSound;
177 IReferenceClock* pLatencyClock;
180 DMUS_PORTPARAMS params;
182 DMUSIC_PRIVATE_CHANNEL_GROUP group[1];
186 extern ULONG WINAPI IDirectMusicPortImpl_AddRef (LPDIRECTMUSICPORT iface);
187 extern HRESULT WINAPI IDirectMusicPortImpl_Activate (LPDIRECTMUSICPORT iface, BOOL fActive);
189 /** Internal factory */
190 extern HRESULT WINAPI DMUSIC_CreateDirectMusicPortImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter, LPDMUS_PORTPARAMS pPortParams, LPDMUS_PORTCAPS pPortCaps);
192 /*****************************************************************************
193 * IDirectMusicThruImpl implementation structure
195 struct IDirectMusicThruImpl {
196 /* IUnknown fields */
197 const IDirectMusicThruVtbl *lpVtbl;
200 /* IDirectMusicThruImpl fields */
204 extern ULONG WINAPI IDirectMusicThruImpl_AddRef (LPDIRECTMUSICTHRU iface);
206 /*****************************************************************************
207 * IReferenceClockImpl implementation structure
209 struct IReferenceClockImpl {
210 /* IUnknown fields */
211 const IReferenceClockVtbl *lpVtbl;
214 /* IReferenceClockImpl fields */
215 REFERENCE_TIME rtTime;
216 DMUS_CLOCKINFO pClockInfo;
220 extern ULONG WINAPI IReferenceClockImpl_AddRef (IReferenceClock *iface);
222 typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY {
223 struct list entry; /* for listing elements */
224 IDirectMusicInstrument* pInstrument;
225 } DMUS_PRIVATE_INSTRUMENTENTRY, *LPDMUS_PRIVATE_INSTRUMENTENTRY;
227 typedef struct _DMUS_PRIVATE_POOLCUE {
228 struct list entry; /* for listing elements */
229 } DMUS_PRIVATE_POOLCUE, *LPDMUS_PRIVATE_POOLCUE;
231 /*****************************************************************************
232 * IDirectMusicCollectionImpl implementation structure
234 struct IDirectMusicCollectionImpl {
235 /* IUnknown fields */
236 const IUnknownVtbl *UnknownVtbl;
237 const IDirectMusicCollectionVtbl *CollectionVtbl;
238 const IDirectMusicObjectVtbl *ObjectVtbl;
239 const IPersistStreamVtbl *PersistStreamVtbl;
242 /* IDirectMusicCollectionImpl fields */
243 IStream *pStm; /* stream from which we load collection and later instruments */
244 LARGE_INTEGER liCollectionPosition; /* offset in a stream where collection was loaded from */
245 LARGE_INTEGER liWavePoolTablePosition; /* offset in a stream where wave pool table can be found */
246 LPDMUS_OBJECTDESC pDesc;
247 CHAR* szCopyright; /* FIXME: should probably placed somewhere else */
250 LPPOOLTABLE pPoolTable;
253 struct list Instruments;
257 extern ULONG WINAPI IDirectMusicCollectionImpl_IUnknown_AddRef (LPUNKNOWN iface);
258 /* IDirectMusicCollection: */
259 extern ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef (LPDIRECTMUSICCOLLECTION iface);
260 /* IDirectMusicObject: */
261 extern ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface);
262 /* IPersistStream: */
263 extern ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface);
265 /*****************************************************************************
266 * IDirectMusicInstrumentImpl implementation structure
268 struct IDirectMusicInstrumentImpl {
269 /* IUnknown fields */
270 const IUnknownVtbl *UnknownVtbl;
271 const IDirectMusicInstrumentVtbl *InstrumentVtbl;
274 /* IDirectMusicInstrumentImpl fields */
275 LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */
276 LPGUID pInstrumentID;
277 LPINSTHEADER pHeader;
278 WCHAR wszName[DMUS_MAX_NAME];
279 /* instrument data */
283 extern ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_AddRef (LPUNKNOWN iface);
284 /* IDirectMusicInstrumentImpl: */
285 extern ULONG WINAPI IDirectMusicInstrumentImpl_IDirectMusicInstrument_AddRef (LPDIRECTMUSICINSTRUMENT iface);
287 extern HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm);
289 /**********************************************************************
290 * Dll lifetime tracking declaration for dmusic.dll
292 extern LONG DMUSIC_refCount;
293 static inline void DMUSIC_LockModule(void) { InterlockedIncrement( &DMUSIC_refCount ); }
294 static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_refCount ); }
296 /*****************************************************************************
299 void register_waveport (LPGUID lpGUID, LPCSTR lpszDesc, LPCSTR lpszDrvName, LPVOID lpContext);
302 /*****************************************************************************
305 /* my custom ICOM stuff */
306 #define ICOM_NAME_MULTI(impl,field,iface,name) impl* const name=(impl*)((char*)(iface) - offsetof(impl,field))
307 #define ICOM_THIS_MULTI(impl,field,iface) ICOM_NAME_MULTI(impl,field,iface,This)
309 /* for simpler reading */
310 typedef struct _DMUS_PRIVATE_CHUNK {
311 FOURCC fccID; /* FOURCC ID of the chunk */
312 DWORD dwSize; /* size of the chunk */
313 } DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_CHUNK;
315 /* used for generic dumping (copied from ddraw) */
326 /* used for initialising structs (primarily for DMUS_OBJECTDESC) */
327 #define DM_STRUCT_INIT(x) \
329 memset((x), 0, sizeof(*(x))); \
330 (x)->dwSize = sizeof(*x); \
333 #define FE(x) { x, #x }
334 #define GE(x) { &x, #x }
336 /* dwPatch from MIDILOCALE */
337 extern DWORD MIDILOCALE2Patch (LPMIDILOCALE pLocale);
338 /* MIDILOCALE from dwPatch */
339 extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale);
341 /* check whether the given DWORD is even (return 0) or odd (return 1) */
342 extern int even_or_odd (DWORD number);
343 /* FOURCC to string conversion for debug messages */
344 extern const char *debugstr_fourcc (DWORD fourcc);
345 /* DMUS_VERSION struct to string conversion for debug messages */
346 extern const char *debugstr_dmversion (LPDMUS_VERSION version);
347 /* returns name of given GUID */
348 extern const char *debugstr_dmguid (const GUID *id);
349 /* returns name of given error code */
350 extern const char *debugstr_dmreturn (DWORD code);
351 /* generic flags-dumping function */
352 extern const char *debugstr_flags (DWORD flags, const flag_info* names, size_t num_names);
353 extern const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask);
354 /* dump whole DMUS_OBJECTDESC struct */
355 extern const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc);
357 #endif /* __WINE_DMUSIC_PRIVATE_H */