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
);
81 /*****************************************************************************
86 extern HRESULT WINAPI
DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) DECLSPEC_HIDDEN
;
87 extern HRESULT WINAPI
DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) DECLSPEC_HIDDEN
;
90 extern HRESULT
DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc
, LPVOID
* ret_iface
) DECLSPEC_HIDDEN
;
91 extern HRESULT
DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) DECLSPEC_HIDDEN
;
92 extern HRESULT
DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) DECLSPEC_HIDDEN
;
93 extern HRESULT
DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) DECLSPEC_HIDDEN
;
94 extern HRESULT
DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) DECLSPEC_HIDDEN
;
96 /*****************************************************************************
97 * IDirectMusic8Impl implementation structure
99 struct IDirectMusic8Impl
{
100 /* IUnknown fields */
101 IDirectMusic8 IDirectMusic8_iface
;
104 /* IDirectMusicImpl fields */
105 IReferenceClockImpl
* pMasterClock
;
106 IDirectMusicPort
** ppPorts
;
108 port_info
* system_ports
;
112 /*****************************************************************************
113 * IDirectMusicBufferImpl implementation structure
115 struct IDirectMusicBufferImpl
{
116 /* IUnknown fields */
117 IDirectMusicBuffer IDirectMusicBuffer_iface
;
120 /* IDirectMusicBufferImpl fields */
125 REFERENCE_TIME start_time
;
128 /*****************************************************************************
129 * IDirectMusicDownloadedInstrumentImpl implementation structure
131 struct IDirectMusicDownloadedInstrumentImpl
{
132 /* IUnknown fields */
133 const IDirectMusicDownloadedInstrumentVtbl
*lpVtbl
;
136 /* IDirectMusicDownloadedInstrumentImpl fields */
139 /*****************************************************************************
140 * IDirectMusicDownloadImpl implementation structure
142 struct IDirectMusicDownloadImpl
{
143 /* IUnknown fields */
144 const IDirectMusicDownloadVtbl
*lpVtbl
;
147 /* IDirectMusicDownloadImpl fields */
150 /*****************************************************************************
151 * SynthPortImpl implementation structure
153 struct SynthPortImpl
{
154 /* IUnknown fields */
155 IDirectMusicPort IDirectMusicPort_iface
;
156 IDirectMusicPortDownload IDirectMusicPortDownload_iface
;
157 IDirectMusicThru IDirectMusicThru_iface
;
160 /* IDirectMusicPort fields */
161 IDirectSound
* pDirectSound
;
162 IReferenceClock
* pLatencyClock
;
163 IDirectMusicSynth
* synth
;
164 IDirectMusicSynthSink
* synth_sink
;
167 DMUS_PORTPARAMS params
;
169 DMUSIC_PRIVATE_CHANNEL_GROUP group
[1];
172 /** Internal factory */
173 extern HRESULT
DMUSIC_CreateSynthPortImpl(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
) DECLSPEC_HIDDEN
;
174 extern HRESULT
DMUSIC_CreateMidiOutPortImpl(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
) DECLSPEC_HIDDEN
;
175 extern HRESULT
DMUSIC_CreateMidiInPortImpl(LPCGUID guid
, LPVOID
*object
, LPUNKNOWN unkouter
, LPDMUS_PORTPARAMS port_params
, LPDMUS_PORTCAPS port_caps
, DWORD device
) DECLSPEC_HIDDEN
;
177 /*****************************************************************************
178 * IReferenceClockImpl implementation structure
180 struct IReferenceClockImpl
{
181 /* IUnknown fields */
182 IReferenceClock IReferenceClock_iface
;
185 /* IReferenceClockImpl fields */
186 REFERENCE_TIME rtTime
;
187 DMUS_CLOCKINFO pClockInfo
;
190 typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY
{
191 struct list entry
; /* for listing elements */
192 IDirectMusicInstrument
* pInstrument
;
193 } DMUS_PRIVATE_INSTRUMENTENTRY
, *LPDMUS_PRIVATE_INSTRUMENTENTRY
;
195 typedef struct _DMUS_PRIVATE_POOLCUE
{
196 struct list entry
; /* for listing elements */
197 } DMUS_PRIVATE_POOLCUE
, *LPDMUS_PRIVATE_POOLCUE
;
199 /*****************************************************************************
200 * IDirectMusicCollectionImpl implementation structure
202 struct IDirectMusicCollectionImpl
{
203 /* IUnknown fields */
204 IDirectMusicCollection IDirectMusicCollection_iface
;
205 IDirectMusicObject IDirectMusicObject_iface
;
206 IPersistStream IPersistStream_iface
;
209 /* IDirectMusicCollectionImpl fields */
210 IStream
*pStm
; /* stream from which we load collection and later instruments */
211 LARGE_INTEGER liCollectionPosition
; /* offset in a stream where collection was loaded from */
212 LARGE_INTEGER liWavePoolTablePosition
; /* offset in a stream where wave pool table can be found */
213 LPDMUS_OBJECTDESC pDesc
;
214 CHAR
* szCopyright
; /* FIXME: should probably placed somewhere else */
217 LPPOOLTABLE pPoolTable
;
220 struct list Instruments
;
223 /*****************************************************************************
224 * IDirectMusicInstrumentImpl implementation structure
226 struct IDirectMusicInstrumentImpl
{
227 /* IUnknown fields */
228 IDirectMusicInstrument IDirectMusicInstrument_iface
;
231 /* IDirectMusicInstrumentImpl fields */
232 LARGE_INTEGER liInstrumentPosition
; /* offset in a stream where instrument chunk can be found */
233 LPGUID pInstrumentID
;
234 LPINSTHEADER pHeader
;
235 WCHAR wszName
[DMUS_MAX_NAME
];
236 /* instrument data */
239 static inline IDirectMusicInstrumentImpl
*impl_from_IDirectMusicInstrument(IDirectMusicInstrument
*iface
)
241 return CONTAINING_RECORD(iface
, IDirectMusicInstrumentImpl
, IDirectMusicInstrument_iface
);
245 extern HRESULT
IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface
, LPSTREAM pStm
) DECLSPEC_HIDDEN
;
247 /**********************************************************************
248 * Dll lifetime tracking declaration for dmusic.dll
250 extern LONG DMUSIC_refCount DECLSPEC_HIDDEN
;
251 static inline void DMUSIC_LockModule(void) { InterlockedIncrement( &DMUSIC_refCount
); }
252 static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_refCount
); }
255 /*****************************************************************************
258 /* my custom ICOM stuff */
259 #define ICOM_NAME_MULTI(impl,field,iface,name) impl* const name=(impl*)((char*)(iface) - offsetof(impl,field))
260 #define ICOM_THIS_MULTI(impl,field,iface) ICOM_NAME_MULTI(impl,field,iface,This)
262 /* for simpler reading */
263 typedef struct _DMUS_PRIVATE_CHUNK
{
264 FOURCC fccID
; /* FOURCC ID of the chunk */
265 DWORD dwSize
; /* size of the chunk */
266 } DMUS_PRIVATE_CHUNK
, *LPDMUS_PRIVATE_CHUNK
;
268 /* used for generic dumping (copied from ddraw) */
279 /* used for initialising structs (primarily for DMUS_OBJECTDESC) */
280 #define DM_STRUCT_INIT(x) \
282 memset((x), 0, sizeof(*(x))); \
283 (x)->dwSize = sizeof(*x); \
286 #define FE(x) { x, #x }
287 #define GE(x) { &x, #x }
289 /* dwPatch from MIDILOCALE */
290 extern DWORD
MIDILOCALE2Patch (const MIDILOCALE
*pLocale
) DECLSPEC_HIDDEN
;
291 /* MIDILOCALE from dwPatch */
292 extern void Patch2MIDILOCALE (DWORD dwPatch
, LPMIDILOCALE pLocale
) DECLSPEC_HIDDEN
;
294 /* check whether the given DWORD is even (return 0) or odd (return 1) */
295 extern int even_or_odd (DWORD number
) DECLSPEC_HIDDEN
;
296 /* FOURCC to string conversion for debug messages */
297 extern const char *debugstr_fourcc (DWORD fourcc
) DECLSPEC_HIDDEN
;
298 /* returns name of given GUID */
299 extern const char *debugstr_dmguid (const GUID
*id
) DECLSPEC_HIDDEN
;
300 /* Dump whole DMUS_OBJECTDESC struct */
301 extern void dump_DMUS_OBJECTDESC(LPDMUS_OBJECTDESC desc
) DECLSPEC_HIDDEN
;
302 /* Dump whole DMUS_PORTPARAMS struct */
303 extern void dump_DMUS_PORTPARAMS(LPDMUS_PORTPARAMS params
) DECLSPEC_HIDDEN
;
305 #endif /* __WINE_DMUSIC_PRIVATE_H */