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
35 #include "wine/debug.h"
36 #include "wine/list.h"
37 #include "wine/unicode.h"
45 /*****************************************************************************
48 typedef struct IDirectMusic8Impl IDirectMusic8Impl
;
49 typedef struct IDirectMusicBufferImpl IDirectMusicBufferImpl
;
50 typedef struct IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstrumentImpl
;
51 typedef struct IDirectMusicDownloadImpl IDirectMusicDownloadImpl
;
52 typedef struct IReferenceClockImpl IReferenceClockImpl
;
54 typedef struct IDirectMusicCollectionImpl IDirectMusicCollectionImpl
;
55 typedef struct IDirectMusicInstrumentImpl IDirectMusicInstrumentImpl
;
57 typedef struct SynthPortImpl SynthPortImpl
;
59 /*****************************************************************************
60 * Some stuff to make my life easier :=)
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_
{
67 } DMUSIC_PRIVATE_MCHANNEL
, *LPDMUSIC_PRIVATE_MCHANNEL
;
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
;
74 typedef struct port_info
{
76 HRESULT (*create
)(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
);
80 typedef struct instrument_region
{
88 typedef struct instrument_articulation
{
89 CONNECTIONLIST connections_list
;
90 CONNECTION
*connections
;
91 } instrument_articulation
;
93 /*****************************************************************************
98 extern HRESULT WINAPI
DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) DECLSPEC_HIDDEN
;
99 extern HRESULT WINAPI
DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) DECLSPEC_HIDDEN
;
102 extern HRESULT
DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc
, LPVOID
* ret_iface
) DECLSPEC_HIDDEN
;
103 extern HRESULT
DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) DECLSPEC_HIDDEN
;
104 extern HRESULT
DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) DECLSPEC_HIDDEN
;
105 extern HRESULT
DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) DECLSPEC_HIDDEN
;
107 /*****************************************************************************
108 * IDirectMusic8Impl implementation structure
110 struct IDirectMusic8Impl
{
111 /* IUnknown fields */
112 IDirectMusic8 IDirectMusic8_iface
;
115 /* IDirectMusicImpl fields */
116 IReferenceClockImpl
* pMasterClock
;
117 IDirectMusicPort
** ppPorts
;
119 port_info
* system_ports
;
123 /*****************************************************************************
124 * IDirectMusicBufferImpl implementation structure
126 struct IDirectMusicBufferImpl
{
127 /* IUnknown fields */
128 IDirectMusicBuffer IDirectMusicBuffer_iface
;
131 /* IDirectMusicBufferImpl fields */
136 REFERENCE_TIME start_time
;
139 /*****************************************************************************
140 * IDirectMusicDownloadedInstrumentImpl implementation structure
142 struct IDirectMusicDownloadedInstrumentImpl
{
143 /* IUnknown fields */
144 IDirectMusicDownloadedInstrument IDirectMusicDownloadedInstrument_iface
;
147 /* IDirectMusicDownloadedInstrumentImpl fields */
152 /*****************************************************************************
153 * IDirectMusicDownloadImpl implementation structure
155 struct IDirectMusicDownloadImpl
{
156 /* IUnknown fields */
157 IDirectMusicDownload IDirectMusicDownload_iface
;
160 /* IDirectMusicDownloadImpl fields */
163 /*****************************************************************************
164 * SynthPortImpl implementation structure
166 struct SynthPortImpl
{
167 /* IUnknown fields */
168 IDirectMusicPort IDirectMusicPort_iface
;
169 IDirectMusicPortDownload IDirectMusicPortDownload_iface
;
170 IDirectMusicThru IDirectMusicThru_iface
;
173 /* IDirectMusicPort fields */
174 IDirectSound
* pDirectSound
;
175 IReferenceClock
* pLatencyClock
;
176 IDirectMusicSynth
* synth
;
177 IDirectMusicSynthSink
* synth_sink
;
180 DMUS_PORTPARAMS params
;
182 DMUSIC_PRIVATE_CHANNEL_GROUP group
[1];
185 /** Internal factory */
186 extern HRESULT
DMUSIC_CreateSynthPortImpl(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
) DECLSPEC_HIDDEN
;
187 extern HRESULT
DMUSIC_CreateMidiOutPortImpl(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
) DECLSPEC_HIDDEN
;
188 extern HRESULT
DMUSIC_CreateMidiInPortImpl(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
) DECLSPEC_HIDDEN
;
190 /*****************************************************************************
191 * IReferenceClockImpl implementation structure
193 struct IReferenceClockImpl
{
194 /* IUnknown fields */
195 IReferenceClock IReferenceClock_iface
;
198 /* IReferenceClockImpl fields */
199 REFERENCE_TIME rtTime
;
200 DMUS_CLOCKINFO pClockInfo
;
203 typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY
{
204 struct list entry
; /* for listing elements */
205 IDirectMusicInstrument
* pInstrument
;
206 } DMUS_PRIVATE_INSTRUMENTENTRY
, *LPDMUS_PRIVATE_INSTRUMENTENTRY
;
208 typedef struct _DMUS_PRIVATE_POOLCUE
{
209 struct list entry
; /* for listing elements */
210 } DMUS_PRIVATE_POOLCUE
, *LPDMUS_PRIVATE_POOLCUE
;
212 /*****************************************************************************
213 * IDirectMusicCollectionImpl implementation structure
215 struct IDirectMusicCollectionImpl
{
216 /* IUnknown fields */
217 IDirectMusicCollection IDirectMusicCollection_iface
;
218 IDirectMusicObject IDirectMusicObject_iface
;
219 IPersistStream IPersistStream_iface
;
222 /* IDirectMusicCollectionImpl fields */
223 IStream
*pStm
; /* stream from which we load collection and later instruments */
224 LARGE_INTEGER liCollectionPosition
; /* offset in a stream where collection was loaded from */
225 LARGE_INTEGER liWavePoolTablePosition
; /* offset in a stream where wave pool table can be found */
226 LPDMUS_OBJECTDESC pDesc
;
227 CHAR
* szCopyright
; /* FIXME: should probably placed somewhere else */
230 LPPOOLTABLE pPoolTable
;
233 struct list Instruments
;
236 /*****************************************************************************
237 * IDirectMusicInstrumentImpl implementation structure
239 struct IDirectMusicInstrumentImpl
{
240 /* IUnknown fields */
241 IDirectMusicInstrument IDirectMusicInstrument_iface
;
244 /* IDirectMusicInstrumentImpl fields */
245 LARGE_INTEGER liInstrumentPosition
; /* offset in a stream where instrument chunk can be found */
246 ULONG length
; /* Length of the instrument in the stream */
249 WCHAR wszName
[DMUS_MAX_NAME
];
250 /* instrument data */
252 instrument_region
*regions
;
253 ULONG nb_articulations
;
254 instrument_articulation
*articulations
;
257 static inline IDirectMusicInstrumentImpl
*impl_from_IDirectMusicInstrument(IDirectMusicInstrument
*iface
)
259 return CONTAINING_RECORD(iface
, IDirectMusicInstrumentImpl
, IDirectMusicInstrument_iface
);
263 extern HRESULT
IDirectMusicInstrumentImpl_CustomLoad(IDirectMusicInstrument
*iface
, IStream
*stream
) DECLSPEC_HIDDEN
;
265 /**********************************************************************
266 * Dll lifetime tracking declaration for dmusic.dll
268 extern LONG DMUSIC_refCount DECLSPEC_HIDDEN
;
269 static inline void DMUSIC_LockModule(void) { InterlockedIncrement( &DMUSIC_refCount
); }
270 static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_refCount
); }
273 /*****************************************************************************
276 /* my custom ICOM stuff */
277 #define ICOM_NAME_MULTI(impl,field,iface,name) impl* const name=(impl*)((char*)(iface) - offsetof(impl,field))
278 #define ICOM_THIS_MULTI(impl,field,iface) ICOM_NAME_MULTI(impl,field,iface,This)
280 /* for simpler reading */
281 typedef struct _DMUS_PRIVATE_CHUNK
{
282 FOURCC fccID
; /* FOURCC ID of the chunk */
283 DWORD dwSize
; /* size of the chunk */
284 } DMUS_PRIVATE_CHUNK
, *LPDMUS_PRIVATE_CHUNK
;
286 /* used for generic dumping (copied from ddraw) */
297 /* used for initialising structs (primarily for DMUS_OBJECTDESC) */
298 #define DM_STRUCT_INIT(x) \
300 memset((x), 0, sizeof(*(x))); \
301 (x)->dwSize = sizeof(*x); \
304 #define FE(x) { x, #x }
305 #define GE(x) { &x, #x }
307 /* dwPatch from MIDILOCALE */
308 extern DWORD
MIDILOCALE2Patch (const MIDILOCALE
*pLocale
) DECLSPEC_HIDDEN
;
309 /* MIDILOCALE from dwPatch */
310 extern void Patch2MIDILOCALE (DWORD dwPatch
, LPMIDILOCALE pLocale
) DECLSPEC_HIDDEN
;
312 /* check whether the given DWORD is even (return 0) or odd (return 1) */
313 extern int even_or_odd (DWORD number
) DECLSPEC_HIDDEN
;
314 /* FOURCC to string conversion for debug messages */
315 extern const char *debugstr_fourcc (DWORD fourcc
) DECLSPEC_HIDDEN
;
316 /* returns name of given GUID */
317 extern const char *debugstr_dmguid (const GUID
*id
) DECLSPEC_HIDDEN
;
318 /* Dump whole DMUS_OBJECTDESC struct */
319 extern void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc
) DECLSPEC_HIDDEN
;
320 /* Dump whole DMUS_PORTPARAMS struct */
321 extern void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params
) DECLSPEC_HIDDEN
;
323 #endif /* __WINE_DMUSIC_PRIVATE_H */