dmusic: Pass creation parameters to DMUSIC_CreateDirectMusicBufferImpl then allocate...
[wine/multimedia.git] / dlls / dmusic / dmusic_private.h
blob069df24db93fc6efb7925a21940249e6625335fe
1 /* DirectMusic Private Include
3 * Copyright (C) 2003-2004 Rok Mandeljc
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.
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.
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
20 #ifndef __WINE_DMUSIC_PRIVATE_H
21 #define __WINE_DMUSIC_PRIVATE_H
23 #include <stdarg.h>
25 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winnt.h"
30 #include "wingdi.h"
31 #include "winuser.h"
33 #include "wine/debug.h"
34 #include "wine/list.h"
35 #include "wine/unicode.h"
36 #include "winreg.h"
37 #include "objbase.h"
39 #include "dmusici.h"
40 #include "dmusicf.h"
41 #include "dmusics.h"
43 /*****************************************************************************
44 * Interfaces
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 * Some stuff to make my life easier :=)
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;
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;
75 /*****************************************************************************
76 * ClassFactory
79 /* CLSID */
80 extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
81 extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
83 /* Internal */
84 extern HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface) DECLSPEC_HIDDEN;
85 extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
86 extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
87 extern HRESULT WINAPI DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
88 extern HRESULT WINAPI DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
90 /*****************************************************************************
91 * IDirectMusic8Impl implementation structure
93 struct IDirectMusic8Impl {
94 /* IUnknown fields */
95 const IDirectMusic8Vtbl *lpVtbl;
96 LONG ref;
98 /* IDirectMusicImpl fields */
99 IReferenceClockImpl* pMasterClock;
100 IDirectMusicPort** ppPorts;
101 int nrofports;
104 /*****************************************************************************
105 * IDirectMusicBufferImpl implementation structure
107 struct IDirectMusicBufferImpl {
108 /* IUnknown fields */
109 const IDirectMusicBufferVtbl *lpVtbl;
110 LONG ref;
112 /* IDirectMusicBufferImpl fields */
113 GUID format;
114 DWORD size;
115 LPBYTE data;
118 /*****************************************************************************
119 * IDirectMusicDownloadedInstrumentImpl implementation structure
121 struct IDirectMusicDownloadedInstrumentImpl {
122 /* IUnknown fields */
123 const IDirectMusicDownloadedInstrumentVtbl *lpVtbl;
124 LONG ref;
126 /* IDirectMusicDownloadedInstrumentImpl fields */
129 /*****************************************************************************
130 * IDirectMusicDownloadImpl implementation structure
132 struct IDirectMusicDownloadImpl {
133 /* IUnknown fields */
134 const IDirectMusicDownloadVtbl *lpVtbl;
135 LONG ref;
137 /* IDirectMusicDownloadImpl fields */
140 /*****************************************************************************
141 * IDirectMusicPortImpl implementation structure
143 struct IDirectMusicPortImpl {
144 /* IUnknown fields */
145 const IDirectMusicPortVtbl *lpVtbl;
146 const IDirectMusicPortDownloadVtbl *lpDownloadVtbl;
147 const IDirectMusicThruVtbl *lpThruVtbl;
148 LONG ref;
150 /* IDirectMusicPortImpl fields */
151 IDirectSound* pDirectSound;
152 IReferenceClock* pLatencyClock;
153 BOOL fActive;
154 DMUS_PORTCAPS caps;
155 DMUS_PORTPARAMS params;
156 int nrofgroups;
157 DMUSIC_PRIVATE_CHANNEL_GROUP group[1];
160 /** Internal factory */
161 extern HRESULT WINAPI DMUSIC_CreateDirectMusicPortImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter, LPDMUS_PORTPARAMS pPortParams, LPDMUS_PORTCAPS pPortCaps) DECLSPEC_HIDDEN;
163 /*****************************************************************************
164 * IReferenceClockImpl implementation structure
166 struct IReferenceClockImpl {
167 /* IUnknown fields */
168 const IReferenceClockVtbl *lpVtbl;
169 LONG ref;
171 /* IReferenceClockImpl fields */
172 REFERENCE_TIME rtTime;
173 DMUS_CLOCKINFO pClockInfo;
176 typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY {
177 struct list entry; /* for listing elements */
178 IDirectMusicInstrument* pInstrument;
179 } DMUS_PRIVATE_INSTRUMENTENTRY, *LPDMUS_PRIVATE_INSTRUMENTENTRY;
181 typedef struct _DMUS_PRIVATE_POOLCUE {
182 struct list entry; /* for listing elements */
183 } DMUS_PRIVATE_POOLCUE, *LPDMUS_PRIVATE_POOLCUE;
185 /*****************************************************************************
186 * IDirectMusicCollectionImpl implementation structure
188 struct IDirectMusicCollectionImpl {
189 /* IUnknown fields */
190 const IUnknownVtbl *UnknownVtbl;
191 const IDirectMusicCollectionVtbl *CollectionVtbl;
192 const IDirectMusicObjectVtbl *ObjectVtbl;
193 const IPersistStreamVtbl *PersistStreamVtbl;
194 LONG ref;
196 /* IDirectMusicCollectionImpl fields */
197 IStream *pStm; /* stream from which we load collection and later instruments */
198 LARGE_INTEGER liCollectionPosition; /* offset in a stream where collection was loaded from */
199 LARGE_INTEGER liWavePoolTablePosition; /* offset in a stream where wave pool table can be found */
200 LPDMUS_OBJECTDESC pDesc;
201 CHAR* szCopyright; /* FIXME: should probably placed somewhere else */
202 LPDLSHEADER pHeader;
203 /* pool table */
204 LPPOOLTABLE pPoolTable;
205 LPPOOLCUE pPoolCues;
206 /* instruments */
207 struct list Instruments;
210 /*****************************************************************************
211 * IDirectMusicInstrumentImpl implementation structure
213 struct IDirectMusicInstrumentImpl {
214 /* IUnknown fields */
215 const IUnknownVtbl *UnknownVtbl;
216 const IDirectMusicInstrumentVtbl *InstrumentVtbl;
217 LONG ref;
219 /* IDirectMusicInstrumentImpl fields */
220 LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */
221 LPGUID pInstrumentID;
222 LPINSTHEADER pHeader;
223 WCHAR wszName[DMUS_MAX_NAME];
224 /* instrument data */
227 /* custom :) */
228 extern HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm) DECLSPEC_HIDDEN;
230 /**********************************************************************
231 * Dll lifetime tracking declaration for dmusic.dll
233 extern LONG DMUSIC_refCount DECLSPEC_HIDDEN;
234 static inline void DMUSIC_LockModule(void) { InterlockedIncrement( &DMUSIC_refCount ); }
235 static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_refCount ); }
238 /*****************************************************************************
239 * Misc.
241 /* my custom ICOM stuff */
242 #define ICOM_NAME_MULTI(impl,field,iface,name) impl* const name=(impl*)((char*)(iface) - offsetof(impl,field))
243 #define ICOM_THIS_MULTI(impl,field,iface) ICOM_NAME_MULTI(impl,field,iface,This)
245 /* for simpler reading */
246 typedef struct _DMUS_PRIVATE_CHUNK {
247 FOURCC fccID; /* FOURCC ID of the chunk */
248 DWORD dwSize; /* size of the chunk */
249 } DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_CHUNK;
251 /* used for generic dumping (copied from ddraw) */
252 typedef struct {
253 DWORD val;
254 const char* name;
255 } flag_info;
257 typedef struct {
258 const GUID *guid;
259 const char* name;
260 } guid_info;
262 /* used for initialising structs (primarily for DMUS_OBJECTDESC) */
263 #define DM_STRUCT_INIT(x) \
264 do { \
265 memset((x), 0, sizeof(*(x))); \
266 (x)->dwSize = sizeof(*x); \
267 } while (0)
269 #define FE(x) { x, #x }
270 #define GE(x) { &x, #x }
272 /* dwPatch from MIDILOCALE */
273 extern DWORD MIDILOCALE2Patch (const MIDILOCALE *pLocale) DECLSPEC_HIDDEN;
274 /* MIDILOCALE from dwPatch */
275 extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale) DECLSPEC_HIDDEN;
277 /* check whether the given DWORD is even (return 0) or odd (return 1) */
278 extern int even_or_odd (DWORD number) DECLSPEC_HIDDEN;
279 /* FOURCC to string conversion for debug messages */
280 extern const char *debugstr_fourcc (DWORD fourcc) DECLSPEC_HIDDEN;
281 /* returns name of given GUID */
282 extern const char *debugstr_dmguid (const GUID *id) DECLSPEC_HIDDEN;
283 /* Dump whole DMUS_OBJECTDESC struct */
284 extern void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc) DECLSPEC_HIDDEN;
285 /* Dump whole DMUS_PORTPARAMS struct */
286 extern void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params) DECLSPEC_HIDDEN;
288 #endif /* __WINE_DMUSIC_PRIVATE_H */