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
29 #define WIN32_NO_STATUS
31 #define COM_NO_WINDOWS_H
41 #include <wine/debug.h>
42 #include <wine/list.h>
43 #include <wine/unicode.h>
45 WINE_DEFAULT_DEBUG_CHANNEL(dmusic
);
47 /*****************************************************************************
50 typedef struct IDirectMusic8Impl IDirectMusic8Impl
;
51 typedef struct IDirectMusicBufferImpl IDirectMusicBufferImpl
;
52 typedef struct IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstrumentImpl
;
53 typedef struct IDirectMusicDownloadImpl IDirectMusicDownloadImpl
;
54 typedef struct IReferenceClockImpl IReferenceClockImpl
;
56 typedef struct IDirectMusicCollectionImpl IDirectMusicCollectionImpl
;
57 typedef struct IDirectMusicInstrumentImpl IDirectMusicInstrumentImpl
;
59 typedef struct SynthPortImpl SynthPortImpl
;
61 /*****************************************************************************
62 * Some stuff to make my life easier :=)
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_
{
69 } DMUSIC_PRIVATE_MCHANNEL
, *LPDMUSIC_PRIVATE_MCHANNEL
;
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
;
76 typedef struct port_info
{
78 HRESULT (*create
)(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
);
82 typedef struct instrument_region
{
90 typedef struct instrument_articulation
{
91 CONNECTIONLIST connections_list
;
92 CONNECTION
*connections
;
93 } instrument_articulation
;
95 /*****************************************************************************
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
;
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
;
109 /*****************************************************************************
110 * IDirectMusic8Impl implementation structure
112 struct IDirectMusic8Impl
{
113 /* IUnknown fields */
114 IDirectMusic8 IDirectMusic8_iface
;
117 /* IDirectMusicImpl fields */
118 IReferenceClockImpl
* pMasterClock
;
119 IDirectMusicPort
** ppPorts
;
121 port_info
* system_ports
;
125 /*****************************************************************************
126 * IDirectMusicBufferImpl implementation structure
128 struct IDirectMusicBufferImpl
{
129 /* IUnknown fields */
130 IDirectMusicBuffer IDirectMusicBuffer_iface
;
133 /* IDirectMusicBufferImpl fields */
138 REFERENCE_TIME start_time
;
141 /*****************************************************************************
142 * IDirectMusicDownloadedInstrumentImpl implementation structure
144 struct IDirectMusicDownloadedInstrumentImpl
{
145 /* IUnknown fields */
146 IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument_iface
;
149 /* IDirectMusicDownloadedInstrumentImpl fields */
154 /*****************************************************************************
155 * IDirectMusicDownloadImpl implementation structure
157 struct IDirectMusicDownloadImpl
{
158 /* IUnknown fields */
159 IDirectMusicDownload IDirectMusicDownload_iface
;
162 /* IDirectMusicDownloadImpl fields */
165 /*****************************************************************************
166 * SynthPortImpl implementation structure
168 struct SynthPortImpl
{
169 /* IUnknown fields */
170 IDirectMusicPort IDirectMusicPort_iface
;
171 IDirectMusicPortDownload IDirectMusicPortDownload_iface
;
172 IDirectMusicThru IDirectMusicThru_iface
;
175 /* IDirectMusicPort fields */
176 IDirectSound
* pDirectSound
;
177 IReferenceClock
* pLatencyClock
;
178 IDirectMusicSynth
* synth
;
179 IDirectMusicSynthSink
* synth_sink
;
182 DMUS_PORTPARAMS params
;
184 DMUSIC_PRIVATE_CHANNEL_GROUP group
[1];
187 /** Internal factory */
188 extern HRESULT
DMUSIC_CreateSynthPortImpl(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
) DECLSPEC_HIDDEN
;
189 extern HRESULT
DMUSIC_CreateMidiOutPortImpl(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
) DECLSPEC_HIDDEN
;
190 extern HRESULT
DMUSIC_CreateMidiInPortImpl(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
) DECLSPEC_HIDDEN
;
192 /*****************************************************************************
193 * IReferenceClockImpl implementation structure
195 struct IReferenceClockImpl
{
196 /* IUnknown fields */
197 IReferenceClock IReferenceClock_iface
;
200 /* IReferenceClockImpl fields */
201 REFERENCE_TIME rtTime
;
202 DMUS_CLOCKINFO pClockInfo
;
205 typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY
{
206 struct list entry
; /* for listing elements */
207 IDirectMusicInstrument
* pInstrument
;
208 } DMUS_PRIVATE_INSTRUMENTENTRY
, *LPDMUS_PRIVATE_INSTRUMENTENTRY
;
210 typedef struct _DMUS_PRIVATE_POOLCUE
{
211 struct list entry
; /* for listing elements */
212 } DMUS_PRIVATE_POOLCUE
, *LPDMUS_PRIVATE_POOLCUE
;
214 /*****************************************************************************
215 * IDirectMusicCollectionImpl implementation structure
217 struct IDirectMusicCollectionImpl
{
218 /* IUnknown fields */
219 IDirectMusicCollection IDirectMusicCollection_iface
;
220 IDirectMusicObject IDirectMusicObject_iface
;
221 IPersistStream IPersistStream_iface
;
224 /* IDirectMusicCollectionImpl fields */
225 IStream
*pStm
; /* stream from which we load collection and later instruments */
226 LARGE_INTEGER liCollectionPosition
; /* offset in a stream where collection was loaded from */
227 LARGE_INTEGER liWavePoolTablePosition
; /* offset in a stream where wave pool table can be found */
228 LPDMUS_OBJECTDESC pDesc
;
229 CHAR
* szCopyright
; /* FIXME: should probably placed somewhere else */
232 LPPOOLTABLE pPoolTable
;
235 struct list Instruments
;
238 /*****************************************************************************
239 * IDirectMusicInstrumentImpl implementation structure
241 struct IDirectMusicInstrumentImpl
{
242 /* IUnknown fields */
243 IDirectMusicInstrument IDirectMusicInstrument_iface
;
246 /* IDirectMusicInstrumentImpl fields */
247 LARGE_INTEGER liInstrumentPosition
; /* offset in a stream where instrument chunk can be found */
248 ULONG length
; /* Length of the instrument in the stream */
251 WCHAR wszName
[DMUS_MAX_NAME
];
252 /* instrument data */
254 instrument_region
*regions
;
255 ULONG nb_articulations
;
256 instrument_articulation
*articulations
;
259 static inline IDirectMusicInstrumentImpl
*impl_from_IDirectMusicInstrument(IDirectMusicInstrument
*iface
)
261 return CONTAINING_RECORD(iface
, IDirectMusicInstrumentImpl
, IDirectMusicInstrument_iface
);
265 extern HRESULT
IDirectMusicInstrumentImpl_CustomLoad(IDirectMusicInstrument
*iface
, IStream
*stream
) DECLSPEC_HIDDEN
;
267 /**********************************************************************
268 * Dll lifetime tracking declaration for dmusic.dll
270 extern LONG DMUSIC_refCount DECLSPEC_HIDDEN
;
271 static inline void DMUSIC_LockModule(void) { InterlockedIncrement( &DMUSIC_refCount
); }
272 static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_refCount
); }
275 /*****************************************************************************
278 /* my custom ICOM stuff */
279 #define ICOM_NAME_MULTI(impl,field,iface,name) impl* const name=(impl*)((char*)(iface) - offsetof(impl,field))
280 #define ICOM_THIS_MULTI(impl,field,iface) ICOM_NAME_MULTI(impl,field,iface,This)
282 /* for simpler reading */
283 typedef struct _DMUS_PRIVATE_CHUNK
{
284 FOURCC fccID
; /* FOURCC ID of the chunk */
285 DWORD dwSize
; /* size of the chunk */
286 } DMUS_PRIVATE_CHUNK
, *LPDMUS_PRIVATE_CHUNK
;
288 /* used for generic dumping (copied from ddraw) */
299 /* used for initialising structs (primarily for DMUS_OBJECTDESC) */
300 #define DM_STRUCT_INIT(x) \
302 memset((x), 0, sizeof(*(x))); \
303 (x)->dwSize = sizeof(*x); \
306 #define FE(x) { x, #x }
307 #define GE(x) { &x, #x }
309 /* dwPatch from MIDILOCALE */
310 extern DWORD
MIDILOCALE2Patch (const MIDILOCALE
*pLocale
) DECLSPEC_HIDDEN
;
311 /* MIDILOCALE from dwPatch */
312 extern void Patch2MIDILOCALE (DWORD dwPatch
, LPMIDILOCALE pLocale
) DECLSPEC_HIDDEN
;
314 /* check whether the given DWORD is even (return 0) or odd (return 1) */
315 extern int even_or_odd (DWORD number
) DECLSPEC_HIDDEN
;
316 /* FOURCC to string conversion for debug messages */
317 extern const char *debugstr_fourcc (DWORD fourcc
) DECLSPEC_HIDDEN
;
318 /* returns name of given GUID */
319 extern const char *debugstr_dmguid (const GUID
*id
) DECLSPEC_HIDDEN
;
320 /* Dump whole DMUS_OBJECTDESC struct */
321 extern void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc
) DECLSPEC_HIDDEN
;
322 /* Dump whole DMUS_PORTPARAMS struct */
323 extern void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params
) DECLSPEC_HIDDEN
;
325 #endif /* __WINE_DMUSIC_PRIVATE_H */