[DMUSIC] Sync with Wine Staging 3.3. CORE-14434
[reactos.git] / 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 <stdarg.h>
26
27 #define COBJMACROS
28 #define NONAMELESSUNION
29 #define NONAMELESSSTRUCT
30
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winnt.h"
34 #include "wingdi.h"
35 #include "winuser.h"
36
37 #include "wine/debug.h"
38 #include "wine/list.h"
39 #include "wine/unicode.h"
40 #include "winreg.h"
41 #include "objbase.h"
42
43 #include "dmusici.h"
44 #include "dmusicf.h"
45 #include "dmusics.h"
46 #include "dmksctrl.h"
47
48 /*****************************************************************************
49 * Interfaces
50 */
51 typedef struct IDirectMusic8Impl IDirectMusic8Impl;
52 typedef struct IDirectMusicBufferImpl IDirectMusicBufferImpl;
53 typedef struct IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstrumentImpl;
54 typedef struct IDirectMusicDownloadImpl IDirectMusicDownloadImpl;
55 typedef struct IReferenceClockImpl IReferenceClockImpl;
56
57 typedef struct IDirectMusicInstrumentImpl IDirectMusicInstrumentImpl;
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 typedef struct port_info {
75 DMUS_PORTCAPS caps;
76 HRESULT (*create)(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params,
77 DMUS_PORTCAPS *port_caps, IDirectMusicPort **port);
78 ULONG device;
79 } port_info;
80
81 typedef struct instrument_region {
82 RGNHEADER header;
83 WAVELINK wave_link;
84 WSMPL wave_sample;
85 WLOOP wave_loop;
86 BOOL loop_present;
87 } instrument_region;
88
89 typedef struct instrument_articulation {
90 CONNECTIONLIST connections_list;
91 CONNECTION *connections;
92 } instrument_articulation;
93
94 /*****************************************************************************
95 * ClassFactory
96 */
97
98 /* CLSID */
99 extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
100 extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
101
102 /* Internal */
103 extern HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface) DECLSPEC_HIDDEN;
104 extern HRESULT DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
105 extern HRESULT DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
106 extern HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
107
108 /*****************************************************************************
109 * IDirectMusic8Impl implementation structure
110 */
111 struct IDirectMusic8Impl {
112 IDirectMusic8 IDirectMusic8_iface;
113 LONG ref;
114 IDirectSound *dsound;
115 IReferenceClockImpl *master_clock;
116 IDirectMusicPort **ports;
117 int num_ports;
118 port_info *system_ports;
119 int num_system_ports;
120 };
121
122 /*****************************************************************************
123 * IDirectMusicBufferImpl implementation structure
124 */
125 struct IDirectMusicBufferImpl {
126 /* IUnknown fields */
127 IDirectMusicBuffer IDirectMusicBuffer_iface;
128 LONG ref;
129
130 /* IDirectMusicBufferImpl fields */
131 GUID format;
132 DWORD size;
133 LPBYTE data;
134 DWORD write_pos;
135 REFERENCE_TIME start_time;
136 };
137
138 /*****************************************************************************
139 * IDirectMusicDownloadedInstrumentImpl implementation structure
140 */
141 struct IDirectMusicDownloadedInstrumentImpl {
142 /* IUnknown fields */
143 IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument_iface;
144 LONG ref;
145
146 /* IDirectMusicDownloadedInstrumentImpl fields */
147 BOOL downloaded;
148 void *data;
149 };
150
151 /*****************************************************************************
152 * IDirectMusicDownloadImpl implementation structure
153 */
154 struct IDirectMusicDownloadImpl {
155 /* IUnknown fields */
156 IDirectMusicDownload IDirectMusicDownload_iface;
157 LONG ref;
158
159 /* IDirectMusicDownloadImpl fields */
160 };
161
162 /** Internal factory */
163 extern HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params,
164 DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) DECLSPEC_HIDDEN;
165 extern HRESULT midi_out_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params,
166 DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) DECLSPEC_HIDDEN;
167 extern HRESULT midi_in_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params,
168 DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) DECLSPEC_HIDDEN;
169
170 /*****************************************************************************
171 * IReferenceClockImpl implementation structure
172 */
173 struct IReferenceClockImpl {
174 /* IUnknown fields */
175 IReferenceClock IReferenceClock_iface;
176 LONG ref;
177
178 /* IReferenceClockImpl fields */
179 REFERENCE_TIME rtTime;
180 DMUS_CLOCKINFO pClockInfo;
181 };
182
183 typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY {
184 struct list entry; /* for listing elements */
185 IDirectMusicInstrument* pInstrument;
186 } DMUS_PRIVATE_INSTRUMENTENTRY, *LPDMUS_PRIVATE_INSTRUMENTENTRY;
187
188 typedef struct _DMUS_PRIVATE_POOLCUE {
189 struct list entry; /* for listing elements */
190 } DMUS_PRIVATE_POOLCUE, *LPDMUS_PRIVATE_POOLCUE;
191
192 /*****************************************************************************
193 * IDirectMusicInstrumentImpl implementation structure
194 */
195 struct IDirectMusicInstrumentImpl {
196 /* IUnknown fields */
197 IDirectMusicInstrument IDirectMusicInstrument_iface;
198 LONG ref;
199
200 /* IDirectMusicInstrumentImpl fields */
201 LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */
202 ULONG length; /* Length of the instrument in the stream */
203 GUID id;
204 INSTHEADER header;
205 WCHAR wszName[DMUS_MAX_NAME];
206 /* instrument data */
207 BOOL loaded;
208 instrument_region *regions;
209 ULONG nb_articulations;
210 instrument_articulation *articulations;
211 };
212
213 static inline IDirectMusicInstrumentImpl *impl_from_IDirectMusicInstrument(IDirectMusicInstrument *iface)
214 {
215 return CONTAINING_RECORD(iface, IDirectMusicInstrumentImpl, IDirectMusicInstrument_iface);
216 }
217
218 /* custom :) */
219 extern HRESULT IDirectMusicInstrumentImpl_CustomLoad(IDirectMusicInstrument *iface, IStream *stream) DECLSPEC_HIDDEN;
220
221 /**********************************************************************
222 * Dll lifetime tracking declaration for dmusic.dll
223 */
224 extern LONG DMUSIC_refCount DECLSPEC_HIDDEN;
225 static inline void DMUSIC_LockModule(void) { InterlockedIncrement( &DMUSIC_refCount ); }
226 static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_refCount ); }
227
228
229 /*****************************************************************************
230 * Misc.
231 */
232 void dmusic_remove_port(IDirectMusic8Impl *dmusic, IDirectMusicPort *port) DECLSPEC_HIDDEN;
233
234 /* for simpler reading */
235 typedef struct _DMUS_PRIVATE_CHUNK {
236 FOURCC fccID; /* FOURCC ID of the chunk */
237 DWORD dwSize; /* size of the chunk */
238 } DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_CHUNK;
239
240 /* used for generic dumping (copied from ddraw) */
241 typedef struct {
242 DWORD val;
243 const char* name;
244 } flag_info;
245
246 typedef struct {
247 const GUID *guid;
248 const char* name;
249 } guid_info;
250
251 #define FE(x) { x, #x }
252 #define GE(x) { &x, #x }
253
254 /* dwPatch from MIDILOCALE */
255 extern DWORD MIDILOCALE2Patch (const MIDILOCALE *pLocale) DECLSPEC_HIDDEN;
256 /* MIDILOCALE from dwPatch */
257 extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale) DECLSPEC_HIDDEN;
258
259 /* check whether the given DWORD is even (return 0) or odd (return 1) */
260 extern int even_or_odd (DWORD number) DECLSPEC_HIDDEN;
261 /* FOURCC to string conversion for debug messages */
262 extern const char *debugstr_fourcc (DWORD fourcc) DECLSPEC_HIDDEN;
263 /* returns name of given GUID */
264 extern const char *debugstr_dmguid (const GUID *id) DECLSPEC_HIDDEN;
265 /* Dump whole DMUS_OBJECTDESC struct */
266 extern void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc) DECLSPEC_HIDDEN;
267 /* Dump whole DMUS_PORTPARAMS struct */
268 extern void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params) DECLSPEC_HIDDEN;
269
270 #endif /* __WINE_DMUSIC_PRIVATE_H */