[DMUSIC] Sync with Wine Staging 1.9.23. CORE-12409
[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 /*****************************************************************************
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)(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device);
79 ULONG device;
80 } port_info;
81
82 typedef struct instrument_region {
83 RGNHEADER header;
84 WAVELINK wave_link;
85 WSMPL wave_sample;
86 WLOOP wave_loop;
87 BOOL loop_present;
88 } instrument_region;
89
90 typedef struct instrument_articulation {
91 CONNECTIONLIST connections_list;
92 CONNECTION *connections;
93 } instrument_articulation;
94
95 /*****************************************************************************
96 * ClassFactory
97 */
98
99 /* CLSID */
100 extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
101 extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
102
103 /* Internal */
104 extern HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface) DECLSPEC_HIDDEN;
105 extern HRESULT DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
106 extern HRESULT DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
107 extern HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
108
109 /*****************************************************************************
110 * IDirectMusic8Impl implementation structure
111 */
112 struct IDirectMusic8Impl {
113 /* IUnknown fields */
114 IDirectMusic8 IDirectMusic8_iface;
115 LONG ref;
116
117 /* IDirectMusicImpl fields */
118 IReferenceClockImpl* pMasterClock;
119 IDirectMusicPort** ppPorts;
120 int nrofports;
121 port_info* system_ports;
122 int nb_system_ports;
123 };
124
125 /*****************************************************************************
126 * IDirectMusicBufferImpl implementation structure
127 */
128 struct IDirectMusicBufferImpl {
129 /* IUnknown fields */
130 IDirectMusicBuffer IDirectMusicBuffer_iface;
131 LONG ref;
132
133 /* IDirectMusicBufferImpl fields */
134 GUID format;
135 DWORD size;
136 LPBYTE data;
137 DWORD write_pos;
138 REFERENCE_TIME start_time;
139 };
140
141 /*****************************************************************************
142 * IDirectMusicDownloadedInstrumentImpl implementation structure
143 */
144 struct IDirectMusicDownloadedInstrumentImpl {
145 /* IUnknown fields */
146 IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument_iface;
147 LONG ref;
148
149 /* IDirectMusicDownloadedInstrumentImpl fields */
150 BOOL downloaded;
151 void *data;
152 };
153
154 /*****************************************************************************
155 * IDirectMusicDownloadImpl implementation structure
156 */
157 struct IDirectMusicDownloadImpl {
158 /* IUnknown fields */
159 IDirectMusicDownload IDirectMusicDownload_iface;
160 LONG ref;
161
162 /* IDirectMusicDownloadImpl fields */
163 };
164
165 /** Internal factory */
166 extern HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
167 extern HRESULT DMUSIC_CreateMidiOutPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) DECLSPEC_HIDDEN;
168 extern HRESULT DMUSIC_CreateMidiInPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) 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 /* for simpler reading */
233 typedef struct _DMUS_PRIVATE_CHUNK {
234 FOURCC fccID; /* FOURCC ID of the chunk */
235 DWORD dwSize; /* size of the chunk */
236 } DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_CHUNK;
237
238 /* used for generic dumping (copied from ddraw) */
239 typedef struct {
240 DWORD val;
241 const char* name;
242 } flag_info;
243
244 typedef struct {
245 const GUID *guid;
246 const char* name;
247 } guid_info;
248
249 #define FE(x) { x, #x }
250 #define GE(x) { &x, #x }
251
252 /* dwPatch from MIDILOCALE */
253 extern DWORD MIDILOCALE2Patch (const MIDILOCALE *pLocale) DECLSPEC_HIDDEN;
254 /* MIDILOCALE from dwPatch */
255 extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale) DECLSPEC_HIDDEN;
256
257 /* check whether the given DWORD is even (return 0) or odd (return 1) */
258 extern int even_or_odd (DWORD number) DECLSPEC_HIDDEN;
259 /* FOURCC to string conversion for debug messages */
260 extern const char *debugstr_fourcc (DWORD fourcc) DECLSPEC_HIDDEN;
261 /* returns name of given GUID */
262 extern const char *debugstr_dmguid (const GUID *id) DECLSPEC_HIDDEN;
263 /* Dump whole DMUS_OBJECTDESC struct */
264 extern void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc) DECLSPEC_HIDDEN;
265 /* Dump whole DMUS_PORTPARAMS struct */
266 extern void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params) DECLSPEC_HIDDEN;
267
268 #endif /* __WINE_DMUSIC_PRIVATE_H */