usp10/test: Add Tibetan shaping test.
[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
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 #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  * Some stuff to make my life easier :=)
61  */
62  
63 /* some sort of aux. midi channel: big fake at the moment; accepts only priority
64    changes... more coming soon */
65 typedef struct DMUSIC_PRIVATE_MCHANNEL_ {
66         DWORD priority;
67 } DMUSIC_PRIVATE_MCHANNEL, *LPDMUSIC_PRIVATE_MCHANNEL;
68
69 /* some sort of aux. channel group: collection of 16 midi channels */
70 typedef struct DMUSIC_PRIVATE_CHANNEL_GROUP_ {
71         DMUSIC_PRIVATE_MCHANNEL channel[16]; /* 16 channels in a group */
72 } DMUSIC_PRIVATE_CHANNEL_GROUP, *LPDMUSIC_PRIVATE_CHANNEL_GROUP;
73
74
75 /*****************************************************************************
76  * ClassFactory
77  */
78 extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
79 extern HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
80 extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
81 extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
82 extern HRESULT WINAPI DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
83
84 extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
85 extern HRESULT WINAPI DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
86
87 /*****************************************************************************
88  * IDirectMusic8Impl implementation structure
89  */
90 struct IDirectMusic8Impl {
91   /* IUnknown fields */
92   const IDirectMusic8Vtbl *lpVtbl;
93   LONG           ref;
94
95   /* IDirectMusicImpl fields */
96   IReferenceClockImpl* pMasterClock;
97   IDirectMusicPort** ppPorts;
98   int nrofports;
99 };
100
101 /*****************************************************************************
102  * IDirectMusicBufferImpl implementation structure
103  */
104 struct IDirectMusicBufferImpl {
105   /* IUnknown fields */
106   const IDirectMusicBufferVtbl *lpVtbl;
107   LONG           ref;
108
109   /* IDirectMusicBufferImpl fields */
110 };
111
112 /*****************************************************************************
113  * IDirectMusicDownloadedInstrumentImpl implementation structure
114  */
115 struct IDirectMusicDownloadedInstrumentImpl {
116   /* IUnknown fields */
117   const IDirectMusicDownloadedInstrumentVtbl *lpVtbl;
118   LONG           ref;
119
120   /* IDirectMusicDownloadedInstrumentImpl fields */
121 };
122
123 /*****************************************************************************
124  * IDirectMusicDownloadImpl implementation structure
125  */
126 struct IDirectMusicDownloadImpl {
127   /* IUnknown fields */
128   const IDirectMusicDownloadVtbl *lpVtbl;
129   LONG           ref;
130
131   /* IDirectMusicDownloadImpl fields */
132 };
133
134 /*****************************************************************************
135  * IDirectMusicPortImpl implementation structure
136  */
137 struct IDirectMusicPortImpl {
138   /* IUnknown fields */
139   const IDirectMusicPortVtbl *lpVtbl;
140   const IDirectMusicPortDownloadVtbl *lpDownloadVtbl;
141   const IDirectMusicThruVtbl *lpThruVtbl;
142   LONG           ref;
143
144   /* IDirectMusicPortImpl fields */
145   IDirectSound* pDirectSound;
146   IReferenceClock* pLatencyClock;
147   BOOL fActive;
148   DMUS_PORTCAPS caps;
149   DMUS_PORTPARAMS params;
150   int nrofgroups;
151   DMUSIC_PRIVATE_CHANNEL_GROUP group[1];
152 };
153
154 extern HRESULT WINAPI IDirectMusicPortImpl_Activate (LPDIRECTMUSICPORT iface, BOOL fActive) DECLSPEC_HIDDEN;
155
156 /** Internal factory */
157 extern HRESULT WINAPI DMUSIC_CreateDirectMusicPortImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter, LPDMUS_PORTPARAMS pPortParams, LPDMUS_PORTCAPS pPortCaps) DECLSPEC_HIDDEN;
158
159 /*****************************************************************************
160  * IReferenceClockImpl implementation structure
161  */
162 struct IReferenceClockImpl {
163   /* IUnknown fields */
164   const IReferenceClockVtbl *lpVtbl;
165   LONG           ref;
166
167   /* IReferenceClockImpl fields */
168   REFERENCE_TIME rtTime;
169   DMUS_CLOCKINFO pClockInfo;
170 };
171
172 typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY {
173         struct list entry; /* for listing elements */
174         IDirectMusicInstrument* pInstrument;
175 } DMUS_PRIVATE_INSTRUMENTENTRY, *LPDMUS_PRIVATE_INSTRUMENTENTRY;
176
177 typedef struct _DMUS_PRIVATE_POOLCUE {
178         struct list entry; /* for listing elements */
179 } DMUS_PRIVATE_POOLCUE, *LPDMUS_PRIVATE_POOLCUE;
180
181 /*****************************************************************************
182  * IDirectMusicCollectionImpl implementation structure
183  */
184 struct IDirectMusicCollectionImpl {
185   /* IUnknown fields */
186   const IUnknownVtbl *UnknownVtbl;
187   const IDirectMusicCollectionVtbl *CollectionVtbl;
188   const IDirectMusicObjectVtbl *ObjectVtbl;
189   const IPersistStreamVtbl *PersistStreamVtbl;
190   LONG           ref;
191
192   /* IDirectMusicCollectionImpl fields */
193   IStream *pStm; /* stream from which we load collection and later instruments */
194   LARGE_INTEGER liCollectionPosition; /* offset in a stream where collection was loaded from */
195   LARGE_INTEGER liWavePoolTablePosition; /* offset in a stream where wave pool table can be found */
196   LPDMUS_OBJECTDESC pDesc;
197   CHAR* szCopyright; /* FIXME: should probably placed somewhere else */
198   LPDLSHEADER pHeader;
199   /* pool table */
200   LPPOOLTABLE pPoolTable;
201   LPPOOLCUE pPoolCues;
202   /* instruments */
203   struct list Instruments;
204 };
205
206 /*****************************************************************************
207  * IDirectMusicInstrumentImpl implementation structure
208  */
209 struct IDirectMusicInstrumentImpl {
210   /* IUnknown fields */
211   const IUnknownVtbl *UnknownVtbl;
212   const IDirectMusicInstrumentVtbl *InstrumentVtbl;
213   LONG           ref;
214
215   /* IDirectMusicInstrumentImpl fields */
216   LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */
217   LPGUID pInstrumentID;
218   LPINSTHEADER pHeader;
219   WCHAR wszName[DMUS_MAX_NAME];
220   /* instrument data */
221 };
222
223 /* custom :) */
224 extern HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm) DECLSPEC_HIDDEN;
225
226 /**********************************************************************
227  * Dll lifetime tracking declaration for dmusic.dll
228  */
229 extern LONG DMUSIC_refCount DECLSPEC_HIDDEN;
230 static inline void DMUSIC_LockModule(void) { InterlockedIncrement( &DMUSIC_refCount ); }
231 static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_refCount ); }
232
233
234 /*****************************************************************************
235  * Misc.
236  */
237 /* my custom ICOM stuff */
238 #define ICOM_NAME_MULTI(impl,field,iface,name)  impl* const name=(impl*)((char*)(iface) - offsetof(impl,field))
239 #define ICOM_THIS_MULTI(impl,field,iface) ICOM_NAME_MULTI(impl,field,iface,This)
240  
241 /* for simpler reading */
242 typedef struct _DMUS_PRIVATE_CHUNK {
243         FOURCC fccID; /* FOURCC ID of the chunk */
244         DWORD dwSize; /* size of the chunk */
245 } DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_CHUNK;
246
247 /* used for generic dumping (copied from ddraw) */
248 typedef struct {
249     DWORD val;
250     const char* name;
251 } flag_info;
252
253 typedef struct {
254     const GUID *guid;
255     const char* name;
256 } guid_info;
257
258 /* used for initialising structs (primarily for DMUS_OBJECTDESC) */
259 #define DM_STRUCT_INIT(x)                               \
260         do {                                                            \
261                 memset((x), 0, sizeof(*(x)));   \
262                 (x)->dwSize = sizeof(*x);               \
263         } while (0)
264
265 #define FE(x) { x, #x } 
266 #define GE(x) { &x, #x }
267
268 /* dwPatch from MIDILOCALE */
269 extern DWORD MIDILOCALE2Patch (const MIDILOCALE *pLocale) DECLSPEC_HIDDEN;
270 /* MIDILOCALE from dwPatch */
271 extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale) DECLSPEC_HIDDEN;
272
273 /* check whether the given DWORD is even (return 0) or odd (return 1) */
274 extern int even_or_odd (DWORD number) DECLSPEC_HIDDEN;
275 /* FOURCC to string conversion for debug messages */
276 extern const char *debugstr_fourcc (DWORD fourcc) DECLSPEC_HIDDEN;
277 /* returns name of given GUID */
278 extern const char *debugstr_dmguid (const GUID *id) DECLSPEC_HIDDEN;
279 /* dump whole DMUS_OBJECTDESC struct */
280 extern const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) DECLSPEC_HIDDEN;
281
282 #endif  /* __WINE_DMUSIC_PRIVATE_H */