fa26700fb8994a3b4fa3815e71e8a69046a9d0ff
[reactos.git] / reactos / dll / directx / wine / dmusic / dmusic_private.h
1 /*
2 * DirectMusic Private Include
3 *
4 * Copyright (C) 2003-2004 Rok Mandeljc
5 * Copyright (C) 2012 Christian Costa
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #ifndef __WINE_DMUSIC_PRIVATE_H
23 #define __WINE_DMUSIC_PRIVATE_H
24
25 #include <wine/config.h>
26
27 #include <stdarg.h>
28
29 #define WIN32_NO_STATUS
30 #define _INC_WINDOWS
31 #define COM_NO_WINDOWS_H
32
33 #define COBJMACROS
34
35 #include <windef.h>
36 #include <winbase.h>
37 #include <objbase.h>
38 #include <dmusici.h>
39 #include <dmusics.h>
40 #include <dmksctrl.h>
41
42 #include <wine/debug.h>
43 #include <wine/list.h>
44 #include <wine/unicode.h>
45
46 #include "dmobject.h"
47
48 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
49
50 /*****************************************************************************
51 * Interfaces
52 */
53 typedef struct IDirectMusic8Impl IDirectMusic8Impl;
54 typedef struct IDirectMusicBufferImpl IDirectMusicBufferImpl;
55 typedef struct IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstrumentImpl;
56 typedef struct IDirectMusicDownloadImpl IDirectMusicDownloadImpl;
57 typedef struct IReferenceClockImpl IReferenceClockImpl;
58
59 typedef struct IDirectMusicInstrumentImpl IDirectMusicInstrumentImpl;
60
61 typedef struct SynthPortImpl SynthPortImpl;
62
63 /*****************************************************************************
64 * Some stuff to make my life easier :=)
65 */
66
67 /* some sort of aux. midi channel: big fake at the moment; accepts only priority
68 changes... more coming soon */
69 typedef struct DMUSIC_PRIVATE_MCHANNEL_ {
70 DWORD priority;
71 } DMUSIC_PRIVATE_MCHANNEL, *LPDMUSIC_PRIVATE_MCHANNEL;
72
73 /* some sort of aux. channel group: collection of 16 midi channels */
74 typedef struct DMUSIC_PRIVATE_CHANNEL_GROUP_ {
75 DMUSIC_PRIVATE_MCHANNEL channel[16]; /* 16 channels in a group */
76 } DMUSIC_PRIVATE_CHANNEL_GROUP, *LPDMUSIC_PRIVATE_CHANNEL_GROUP;
77
78 typedef struct port_info {
79 DMUS_PORTCAPS caps;
80 HRESULT (*create)(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device);
81 ULONG device;
82 } port_info;
83
84 typedef struct instrument_region {
85 RGNHEADER header;
86 WAVELINK wave_link;
87 WSMPL wave_sample;
88 WLOOP wave_loop;
89 BOOL loop_present;
90 } instrument_region;
91
92 typedef struct instrument_articulation {
93 CONNECTIONLIST connections_list;
94 CONNECTION *connections;
95 } instrument_articulation;
96
97 /*****************************************************************************
98 * ClassFactory
99 */
100
101 /* CLSID */
102 extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
103 extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
104
105 /* Internal */
106 extern HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface) DECLSPEC_HIDDEN;
107 extern HRESULT DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
108 extern HRESULT DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
109 extern HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
110
111 /*****************************************************************************
112 * IDirectMusic8Impl implementation structure
113 */
114 struct IDirectMusic8Impl {
115 /* IUnknown fields */
116 IDirectMusic8 IDirectMusic8_iface;
117 LONG ref;
118
119 /* IDirectMusicImpl fields */
120 IReferenceClockImpl* pMasterClock;
121 IDirectMusicPort** ppPorts;
122 int nrofports;
123 port_info* system_ports;
124 int nb_system_ports;
125 };
126
127 /*****************************************************************************
128 * IDirectMusicBufferImpl implementation structure
129 */
130 struct IDirectMusicBufferImpl {
131 /* IUnknown fields */
132 IDirectMusicBuffer IDirectMusicBuffer_iface;
133 LONG ref;
134
135 /* IDirectMusicBufferImpl fields */
136 GUID format;
137 DWORD size;
138 LPBYTE data;
139 DWORD write_pos;
140 REFERENCE_TIME start_time;
141 };
142
143 /*****************************************************************************
144 * IDirectMusicDownloadedInstrumentImpl implementation structure
145 */
146 struct IDirectMusicDownloadedInstrumentImpl {
147 /* IUnknown fields */
148 IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument_iface;
149 LONG ref;
150
151 /* IDirectMusicDownloadedInstrumentImpl fields */
152 BOOL downloaded;
153 void *data;
154 };
155
156 /*****************************************************************************
157 * IDirectMusicDownloadImpl implementation structure
158 */
159 struct IDirectMusicDownloadImpl {
160 /* IUnknown fields */
161 IDirectMusicDownload IDirectMusicDownload_iface;
162 LONG ref;
163
164 /* IDirectMusicDownloadImpl fields */
165 };
166
167 /*****************************************************************************
168 * SynthPortImpl implementation structure
169 */
170 struct SynthPortImpl {
171 /* IUnknown fields */
172 IDirectMusicPort IDirectMusicPort_iface;
173 IDirectMusicPortDownload IDirectMusicPortDownload_iface;
174 IDirectMusicThru IDirectMusicThru_iface;
175 IKsControl IKsControl_iface;
176 LONG ref;
177
178 /* IDirectMusicPort fields */
179 IDirectSound* pDirectSound;
180 IReferenceClock* pLatencyClock;
181 IDirectMusicSynth* synth;
182 IDirectMusicSynthSink* synth_sink;
183 BOOL fActive;
184 DMUS_PORTCAPS caps;
185 DMUS_PORTPARAMS params;
186 int nrofgroups;
187 DMUSIC_PRIVATE_CHANNEL_GROUP group[1];
188 };
189
190 /** Internal factory */
191 extern HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
192 extern HRESULT DMUSIC_CreateMidiOutPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
193 extern HRESULT DMUSIC_CreateMidiInPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
194
195 /*****************************************************************************
196 * IReferenceClockImpl implementation structure
197 */
198 struct IReferenceClockImpl {
199 /* IUnknown fields */
200 IReferenceClock IReferenceClock_iface;
201 LONG ref;
202
203 /* IReferenceClockImpl fields */
204 REFERENCE_TIME rtTime;
205 DMUS_CLOCKINFO pClockInfo;
206 };
207
208 typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY {
209 struct list entry; /* for listing elements */
210 IDirectMusicInstrument* pInstrument;
211 } DMUS_PRIVATE_INSTRUMENTENTRY, *LPDMUS_PRIVATE_INSTRUMENTENTRY;
212
213 typedef struct _DMUS_PRIVATE_POOLCUE {
214 struct list entry; /* for listing elements */
215 } DMUS_PRIVATE_POOLCUE, *LPDMUS_PRIVATE_POOLCUE;
216
217 /*****************************************************************************
218 * IDirectMusicInstrumentImpl implementation structure
219 */
220 struct IDirectMusicInstrumentImpl {
221 /* IUnknown fields */
222 IDirectMusicInstrument IDirectMusicInstrument_iface;
223 LONG ref;
224
225 /* IDirectMusicInstrumentImpl fields */
226 LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */
227 ULONG length; /* Length of the instrument in the stream */
228 GUID id;
229 INSTHEADER header;
230 WCHAR wszName[DMUS_MAX_NAME];
231 /* instrument data */
232 BOOL loaded;
233 instrument_region *regions;
234 ULONG nb_articulations;
235 instrument_articulation *articulations;
236 };
237
238 static inline IDirectMusicInstrumentImpl *impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
239 {
240 return CONTAINING_RECORD(iface, IDirectMusicInstrumentImpl, IDirectMusicInstrument_iface);
241 }
242
243 /* custom :) */
244 extern HRESULT IDirectMusicInstrumentImpl_CustomLoad(IDirectMusicInstrument *iface, IStream *stream) DECLSPEC_HIDDEN;
245
246 /**********************************************************************
247 * Dll lifetime tracking declaration for dmusic.dll
248 */
249 extern LONG DMUSIC_refCount DECLSPEC_HIDDEN;
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 /* for simpler reading */
258 typedef struct _DMUS_PRIVATE_CHUNK {
259 FOURCC fccID; /* FOURCC ID of the chunk */
260 DWORD dwSize; /* size of the chunk */
261 } DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_CHUNK;
262
263 /* used for generic dumping (copied from ddraw) */
264 typedef struct {
265 DWORD val;
266 const char* name;
267 } flag_info;
268
269 typedef struct {
270 const GUID *guid;
271 const char* name;
272 } guid_info;
273
274 #define FE(x) { x, #x }
275 #define GE(x) { &x, #x }
276
277 /* dwPatch from MIDILOCALE */
278 extern DWORD MIDILOCALE2Patch (const MIDILOCALE *pLocale) DECLSPEC_HIDDEN;
279 /* MIDILOCALE from dwPatch */
280 extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale) DECLSPEC_HIDDEN;
281
282 /* check whether the given DWORD is even (return 0) or odd (return 1) */
283 extern int even_or_odd (DWORD number) DECLSPEC_HIDDEN;
284 /* FOURCC to string conversion for debug messages */
285 extern const char *debugstr_fourcc (DWORD fourcc) DECLSPEC_HIDDEN;
286 /* returns name of given GUID */
287 extern const char *debugstr_dmguid (const GUID *id) DECLSPEC_HIDDEN;
288 /* Dump whole DMUS_OBJECTDESC struct */
289 extern void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc) DECLSPEC_HIDDEN;
290 /* Dump whole DMUS_PORTPARAMS struct */
291 extern void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params) DECLSPEC_HIDDEN;
292
293 #endif /* __WINE_DMUSIC_PRIVATE_H */