oleaut32: Make some functions static.
[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);
79 extern HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
80 extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
81 extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
82 extern HRESULT WINAPI DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
83
84 extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
85 extern HRESULT WINAPI DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
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  * IDirectMusicPortDownloadImpl implementation structure
136  */
137 struct IDirectMusicPortDownloadImpl {
138   /* IUnknown fields */
139   const IDirectMusicPortDownloadVtbl *lpVtbl;
140   LONG           ref;
141
142   /* IDirectMusicPortDownloadImpl fields */
143 };
144
145 /*****************************************************************************
146  * IDirectMusicPortImpl implementation structure
147  */
148 struct IDirectMusicPortImpl {
149   /* IUnknown fields */
150   const IDirectMusicPortVtbl *lpVtbl;
151   LONG           ref;
152
153   /* IDirectMusicPortImpl fields */
154   IDirectSound* pDirectSound;
155   IReferenceClock* pLatencyClock;
156   BOOL fActive;
157   DMUS_PORTCAPS caps;
158   DMUS_PORTPARAMS params;
159   int nrofgroups;
160   DMUSIC_PRIVATE_CHANNEL_GROUP group[1];
161 };
162
163 extern HRESULT WINAPI IDirectMusicPortImpl_Activate (LPDIRECTMUSICPORT iface, BOOL fActive);
164
165 /** Internal factory */
166 extern HRESULT WINAPI DMUSIC_CreateDirectMusicPortImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter, LPDMUS_PORTPARAMS pPortParams, LPDMUS_PORTCAPS pPortCaps);
167
168 /*****************************************************************************
169  * IDirectMusicThruImpl implementation structure
170  */
171 struct IDirectMusicThruImpl {
172   /* IUnknown fields */
173   const IDirectMusicThruVtbl *lpVtbl;
174   LONG           ref;
175
176   /* IDirectMusicThruImpl fields */
177 };
178
179 /*****************************************************************************
180  * IReferenceClockImpl implementation structure
181  */
182 struct IReferenceClockImpl {
183   /* IUnknown fields */
184   const IReferenceClockVtbl *lpVtbl;
185   LONG           ref;
186
187   /* IReferenceClockImpl fields */
188   REFERENCE_TIME rtTime;
189   DMUS_CLOCKINFO pClockInfo;
190 };
191
192 typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY {
193         struct list entry; /* for listing elements */
194         IDirectMusicInstrument* pInstrument;
195 } DMUS_PRIVATE_INSTRUMENTENTRY, *LPDMUS_PRIVATE_INSTRUMENTENTRY;
196
197 typedef struct _DMUS_PRIVATE_POOLCUE {
198         struct list entry; /* for listing elements */
199 } DMUS_PRIVATE_POOLCUE, *LPDMUS_PRIVATE_POOLCUE;
200
201 /*****************************************************************************
202  * IDirectMusicCollectionImpl implementation structure
203  */
204 struct IDirectMusicCollectionImpl {
205   /* IUnknown fields */
206   const IUnknownVtbl *UnknownVtbl;
207   const IDirectMusicCollectionVtbl *CollectionVtbl;
208   const IDirectMusicObjectVtbl *ObjectVtbl;
209   const IPersistStreamVtbl *PersistStreamVtbl;
210   LONG           ref;
211
212   /* IDirectMusicCollectionImpl fields */
213   IStream *pStm; /* stream from which we load collection and later instruments */
214   LARGE_INTEGER liCollectionPosition; /* offset in a stream where collection was loaded from */
215   LARGE_INTEGER liWavePoolTablePosition; /* offset in a stream where wave pool table can be found */
216   LPDMUS_OBJECTDESC pDesc;
217   CHAR* szCopyright; /* FIXME: should probably placed somewhere else */
218   LPDLSHEADER pHeader;
219   /* pool table */
220   LPPOOLTABLE pPoolTable;
221   LPPOOLCUE pPoolCues;
222   /* instruments */
223   struct list Instruments;
224 };
225
226 /*****************************************************************************
227  * IDirectMusicInstrumentImpl implementation structure
228  */
229 struct IDirectMusicInstrumentImpl {
230   /* IUnknown fields */
231   const IUnknownVtbl *UnknownVtbl;
232   const IDirectMusicInstrumentVtbl *InstrumentVtbl;
233   LONG           ref;
234
235   /* IDirectMusicInstrumentImpl fields */
236   LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */
237   LPGUID pInstrumentID;
238   LPINSTHEADER pHeader;
239   WCHAR wszName[DMUS_MAX_NAME];
240   /* instrument data */
241 };
242
243 /* custom :) */
244 extern HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm);
245
246 /**********************************************************************
247  * Dll lifetime tracking declaration for dmusic.dll
248  */
249 extern LONG DMUSIC_refCount;
250 static inline void DMUSIC_LockModule(void) { InterlockedIncrement( &DMUSIC_refCount ); }
251 static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_refCount ); }
252
253
254 /*****************************************************************************
255  * Misc.
256  */
257 /* my custom ICOM stuff */
258 #define ICOM_NAME_MULTI(impl,field,iface,name)  impl* const name=(impl*)((char*)(iface) - offsetof(impl,field))
259 #define ICOM_THIS_MULTI(impl,field,iface) ICOM_NAME_MULTI(impl,field,iface,This)
260  
261 /* for simpler reading */
262 typedef struct _DMUS_PRIVATE_CHUNK {
263         FOURCC fccID; /* FOURCC ID of the chunk */
264         DWORD dwSize; /* size of the chunk */
265 } DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_CHUNK;
266
267 /* used for generic dumping (copied from ddraw) */
268 typedef struct {
269     DWORD val;
270     const char* name;
271 } flag_info;
272
273 typedef struct {
274     const GUID *guid;
275     const char* name;
276 } guid_info;
277
278 /* used for initialising structs (primarily for DMUS_OBJECTDESC) */
279 #define DM_STRUCT_INIT(x)                               \
280         do {                                                            \
281                 memset((x), 0, sizeof(*(x)));   \
282                 (x)->dwSize = sizeof(*x);               \
283         } while (0)
284
285 #define FE(x) { x, #x } 
286 #define GE(x) { &x, #x }
287
288 /* dwPatch from MIDILOCALE */
289 extern DWORD MIDILOCALE2Patch (LPMIDILOCALE pLocale);
290 /* MIDILOCALE from dwPatch */
291 extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale);
292
293 /* check whether the given DWORD is even (return 0) or odd (return 1) */
294 extern int even_or_odd (DWORD number);
295 /* FOURCC to string conversion for debug messages */
296 extern const char *debugstr_fourcc (DWORD fourcc);
297 /* returns name of given GUID */
298 extern const char *debugstr_dmguid (const GUID *id);
299 /* dump whole DMUS_OBJECTDESC struct */
300 extern const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc);
301
302 #endif  /* __WINE_DMUSIC_PRIVATE_H */