2 * DirectMusic Private Include
4 * Copyright (C) 2003-2004 Rok Mandeljc
5 * Copyright (C) 2012 Christian Costa
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.
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.
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
22 #ifndef __WINE_DMUSIC_PRIVATE_H
23 #define __WINE_DMUSIC_PRIVATE_H
28 #define WIN32_NO_STATUS
30 #define COM_NO_WINDOWS_H
33 //#include "winbase.h"
36 //#include "winuser.h"
38 #include <wine/debug.h>
39 #include <wine/list.h>
40 #include <wine/unicode.h>
48 /*****************************************************************************
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
;
57 typedef struct IDirectMusicCollectionImpl IDirectMusicCollectionImpl
;
58 typedef struct IDirectMusicInstrumentImpl IDirectMusicInstrumentImpl
;
60 typedef struct SynthPortImpl SynthPortImpl
;
62 /*****************************************************************************
63 * Some stuff to make my life easier :=)
66 /* some sort of aux. midi channel: big fake at the moment; accepts only priority
67 changes... more coming soon */
68 typedef struct DMUSIC_PRIVATE_MCHANNEL_
{
70 } DMUSIC_PRIVATE_MCHANNEL
, *LPDMUSIC_PRIVATE_MCHANNEL
;
72 /* some sort of aux. channel group: collection of 16 midi channels */
73 typedef struct DMUSIC_PRIVATE_CHANNEL_GROUP_
{
74 DMUSIC_PRIVATE_MCHANNEL channel
[16]; /* 16 channels in a group */
75 } DMUSIC_PRIVATE_CHANNEL_GROUP
, *LPDMUSIC_PRIVATE_CHANNEL_GROUP
;
77 typedef struct port_info
{
79 HRESULT (*create
)(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
);
83 typedef struct instrument_region
{
91 typedef struct instrument_articulation
{
92 CONNECTIONLIST connections_list
;
93 CONNECTION
*connections
;
94 } instrument_articulation
;
96 /*****************************************************************************
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
;
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
;
110 /*****************************************************************************
111 * IDirectMusic8Impl implementation structure
113 struct IDirectMusic8Impl
{
114 /* IUnknown fields */
115 IDirectMusic8 IDirectMusic8_iface
;
118 /* IDirectMusicImpl fields */
119 IReferenceClockImpl
* pMasterClock
;
120 IDirectMusicPort
** ppPorts
;
122 port_info
* system_ports
;
126 /*****************************************************************************
127 * IDirectMusicBufferImpl implementation structure
129 struct IDirectMusicBufferImpl
{
130 /* IUnknown fields */
131 IDirectMusicBuffer IDirectMusicBuffer_iface
;
134 /* IDirectMusicBufferImpl fields */
139 REFERENCE_TIME start_time
;
142 /*****************************************************************************
143 * IDirectMusicDownloadedInstrumentImpl implementation structure
145 struct IDirectMusicDownloadedInstrumentImpl
{
146 /* IUnknown fields */
147 IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument_iface
;
150 /* IDirectMusicDownloadedInstrumentImpl fields */
155 /*****************************************************************************
156 * IDirectMusicDownloadImpl implementation structure
158 struct IDirectMusicDownloadImpl
{
159 /* IUnknown fields */
160 IDirectMusicDownload IDirectMusicDownload_iface
;
163 /* IDirectMusicDownloadImpl fields */
166 /*****************************************************************************
167 * SynthPortImpl implementation structure
169 struct SynthPortImpl
{
170 /* IUnknown fields */
171 IDirectMusicPort IDirectMusicPort_iface
;
172 IDirectMusicPortDownload IDirectMusicPortDownload_iface
;
173 IDirectMusicThru IDirectMusicThru_iface
;
176 /* IDirectMusicPort fields */
177 IDirectSound
* pDirectSound
;
178 IReferenceClock
* pLatencyClock
;
179 IDirectMusicSynth
* synth
;
180 IDirectMusicSynthSink
* synth_sink
;
183 DMUS_PORTPARAMS params
;
185 DMUSIC_PRIVATE_CHANNEL_GROUP group
[1];
188 /** Internal factory */
189 extern HRESULT
DMUSIC_CreateSynthPortImpl(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
) DECLSPEC_HIDDEN
;
190 extern HRESULT
DMUSIC_CreateMidiOutPortImpl(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
) DECLSPEC_HIDDEN
;
191 extern HRESULT
DMUSIC_CreateMidiInPortImpl(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
) DECLSPEC_HIDDEN
;
193 /*****************************************************************************
194 * IReferenceClockImpl implementation structure
196 struct IReferenceClockImpl
{
197 /* IUnknown fields */
198 IReferenceClock IReferenceClock_iface
;
201 /* IReferenceClockImpl fields */
202 REFERENCE_TIME rtTime
;
203 DMUS_CLOCKINFO pClockInfo
;
206 typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY
{
207 struct list entry
; /* for listing elements */
208 IDirectMusicInstrument
* pInstrument
;
209 } DMUS_PRIVATE_INSTRUMENTENTRY
, *LPDMUS_PRIVATE_INSTRUMENTENTRY
;
211 typedef struct _DMUS_PRIVATE_POOLCUE
{
212 struct list entry
; /* for listing elements */
213 } DMUS_PRIVATE_POOLCUE
, *LPDMUS_PRIVATE_POOLCUE
;
215 /*****************************************************************************
216 * IDirectMusicCollectionImpl implementation structure
218 struct IDirectMusicCollectionImpl
{
219 /* IUnknown fields */
220 IDirectMusicCollection IDirectMusicCollection_iface
;
221 IDirectMusicObject IDirectMusicObject_iface
;
222 IPersistStream IPersistStream_iface
;
225 /* IDirectMusicCollectionImpl fields */
226 IStream
*pStm
; /* stream from which we load collection and later instruments */
227 LARGE_INTEGER liCollectionPosition
; /* offset in a stream where collection was loaded from */
228 LARGE_INTEGER liWavePoolTablePosition
; /* offset in a stream where wave pool table can be found */
229 LPDMUS_OBJECTDESC pDesc
;
230 CHAR
* szCopyright
; /* FIXME: should probably placed somewhere else */
233 LPPOOLTABLE pPoolTable
;
236 struct list Instruments
;
239 /*****************************************************************************
240 * IDirectMusicInstrumentImpl implementation structure
242 struct IDirectMusicInstrumentImpl
{
243 /* IUnknown fields */
244 IDirectMusicInstrument IDirectMusicInstrument_iface
;
247 /* IDirectMusicInstrumentImpl fields */
248 LARGE_INTEGER liInstrumentPosition
; /* offset in a stream where instrument chunk can be found */
249 ULONG length
; /* Length of the instrument in the stream */
252 WCHAR wszName
[DMUS_MAX_NAME
];
253 /* instrument data */
255 instrument_region
*regions
;
256 ULONG nb_articulations
;
257 instrument_articulation
*articulations
;
260 static inline IDirectMusicInstrumentImpl
*impl_from_IDirectMusicInstrument(IDirectMusicInstrument
*iface
)
262 return CONTAINING_RECORD(iface
, IDirectMusicInstrumentImpl
, IDirectMusicInstrument_iface
);
266 extern HRESULT
IDirectMusicInstrumentImpl_CustomLoad(IDirectMusicInstrument
*iface
, IStream
*stream
) DECLSPEC_HIDDEN
;
268 /**********************************************************************
269 * Dll lifetime tracking declaration for dmusic.dll
271 extern LONG DMUSIC_refCount DECLSPEC_HIDDEN
;
272 static inline void DMUSIC_LockModule(void) { InterlockedIncrement( &DMUSIC_refCount
); }
273 static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_refCount
); }
276 /*****************************************************************************
279 /* my custom ICOM stuff */
280 #define ICOM_NAME_MULTI(impl,field,iface,name) impl* const name=(impl*)((char*)(iface) - offsetof(impl,field))
281 #define ICOM_THIS_MULTI(impl,field,iface) ICOM_NAME_MULTI(impl,field,iface,This)
283 /* for simpler reading */
284 typedef struct _DMUS_PRIVATE_CHUNK
{
285 FOURCC fccID
; /* FOURCC ID of the chunk */
286 DWORD dwSize
; /* size of the chunk */
287 } DMUS_PRIVATE_CHUNK
, *LPDMUS_PRIVATE_CHUNK
;
289 /* used for generic dumping (copied from ddraw) */
300 /* used for initialising structs (primarily for DMUS_OBJECTDESC) */
301 #define DM_STRUCT_INIT(x) \
303 memset((x), 0, sizeof(*(x))); \
304 (x)->dwSize = sizeof(*x); \
307 #define FE(x) { x, #x }
308 #define GE(x) { &x, #x }
310 /* dwPatch from MIDILOCALE */
311 extern DWORD
MIDILOCALE2Patch (const MIDILOCALE
*pLocale
) DECLSPEC_HIDDEN
;
312 /* MIDILOCALE from dwPatch */
313 extern void Patch2MIDILOCALE (DWORD dwPatch
, LPMIDILOCALE pLocale
) DECLSPEC_HIDDEN
;
315 /* check whether the given DWORD is even (return 0) or odd (return 1) */
316 extern int even_or_odd (DWORD number
) DECLSPEC_HIDDEN
;
317 /* FOURCC to string conversion for debug messages */
318 extern const char *debugstr_fourcc (DWORD fourcc
) DECLSPEC_HIDDEN
;
319 /* returns name of given GUID */
320 extern const char *debugstr_dmguid (const GUID
*id
) DECLSPEC_HIDDEN
;
321 /* Dump whole DMUS_OBJECTDESC struct */
322 extern void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc
) DECLSPEC_HIDDEN
;
323 /* Dump whole DMUS_PORTPARAMS struct */
324 extern void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params
) DECLSPEC_HIDDEN
;
326 #endif /* __WINE_DMUSIC_PRIVATE_H */