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