dmusic_private.h 10.9 KB
Newer Older
1 2
/* DirectMusic Private Include
 *
3
 * Copyright (C) 2003-2004 Rok Mandeljc
4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18 19 20 21 22
 */

#ifndef __WINE_DMUSIC_PRIVATE_H
#define __WINE_DMUSIC_PRIVATE_H

23 24
#include <stdarg.h>

25 26
#define COBJMACROS

27 28 29
#include "windef.h"
#include "winbase.h"
#include "winnt.h"
30
#include "wingdi.h"
31 32 33 34 35 36
#include "winuser.h"

#include "wine/debug.h"
#include "wine/list.h"
#include "wine/unicode.h"
#include "winreg.h"
37
#include "objbase.h"
38

39 40
#include "dmusici.h"
#include "dmusicf.h"
41
#include "dmusics.h"
42 43 44 45 46 47 48 49 50 51 52

/*****************************************************************************
 * Interfaces
 */
typedef struct IDirectMusic8Impl IDirectMusic8Impl;
typedef struct IDirectMusicBufferImpl IDirectMusicBufferImpl;
typedef struct IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstrumentImpl;
typedef struct IDirectMusicDownloadImpl IDirectMusicDownloadImpl;
typedef struct IDirectMusicPortDownloadImpl IDirectMusicPortDownloadImpl;
typedef struct IDirectMusicPortImpl IDirectMusicPortImpl;
typedef struct IDirectMusicThruImpl IDirectMusicThruImpl;
53
typedef struct IReferenceClockImpl IReferenceClockImpl;
54

55 56 57
typedef struct IDirectMusicCollectionImpl IDirectMusicCollectionImpl;
typedef struct IDirectMusicInstrumentImpl IDirectMusicInstrumentImpl;

58
	
59 60 61
/*****************************************************************************
 * Predeclare the interface implementation structures
 */
62
extern const IDirectMusicPortVtbl DirectMusicPort_Vtbl;
63

Rok Mandeljc's avatar
Rok Mandeljc committed
64 65 66 67 68 69
/*****************************************************************************
 * Some stuff to make my life easier :=)
 */
 
/* some sort of aux. midi channel: big fake at the moment; accepts only priority
   changes... more coming soon */
70
typedef struct DMUSIC_PRIVATE_MCHANNEL_ {
Rok Mandeljc's avatar
Rok Mandeljc committed
71 72 73 74
	DWORD priority;
} DMUSIC_PRIVATE_MCHANNEL, *LPDMUSIC_PRIVATE_MCHANNEL;

/* some sort of aux. channel group: collection of 16 midi channels */
75
typedef struct DMUSIC_PRIVATE_CHANNEL_GROUP_ {
Rok Mandeljc's avatar
Rok Mandeljc committed
76 77 78
	DMUSIC_PRIVATE_MCHANNEL channel[16]; /* 16 channels in a group */
} DMUSIC_PRIVATE_CHANNEL_GROUP, *LPDMUSIC_PRIVATE_CHANNEL_GROUP;

79

80
/*****************************************************************************
81
 * ClassFactory
82
 */
83 84 85 86 87
extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
88

89 90
extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
91

92 93 94
/*****************************************************************************
 * IDirectMusic8Impl implementation structure
 */
95
struct IDirectMusic8Impl {
96
  /* IUnknown fields */
97
  const IDirectMusic8Vtbl *lpVtbl;
98
  LONG           ref;
99

100
  /* IDirectMusicImpl fields */
101
  IReferenceClockImpl* pMasterClock;
102
  IDirectMusicPort** ppPorts;
Rok Mandeljc's avatar
Rok Mandeljc committed
103
  int nrofports;
104 105 106 107 108
};

/*****************************************************************************
 * IDirectMusicBufferImpl implementation structure
 */
109
struct IDirectMusicBufferImpl {
110
  /* IUnknown fields */
111
  const IDirectMusicBufferVtbl *lpVtbl;
112
  LONG           ref;
113 114 115 116 117 118 119

  /* IDirectMusicBufferImpl fields */
};

/*****************************************************************************
 * IDirectMusicDownloadedInstrumentImpl implementation structure
 */
120
struct IDirectMusicDownloadedInstrumentImpl {
121
  /* IUnknown fields */
122
  const IDirectMusicDownloadedInstrumentVtbl *lpVtbl;
123
  LONG           ref;
124 125 126 127 128 129 130

  /* IDirectMusicDownloadedInstrumentImpl fields */
};

/*****************************************************************************
 * IDirectMusicDownloadImpl implementation structure
 */
131
struct IDirectMusicDownloadImpl {
132
  /* IUnknown fields */
133
  const IDirectMusicDownloadVtbl *lpVtbl;
134
  LONG           ref;
135 136 137 138 139 140 141

  /* IDirectMusicDownloadImpl fields */
};

/*****************************************************************************
 * IDirectMusicPortDownloadImpl implementation structure
 */
142
struct IDirectMusicPortDownloadImpl {
143
  /* IUnknown fields */
144
  const IDirectMusicPortDownloadVtbl *lpVtbl;
145
  LONG           ref;
146 147 148 149 150 151 152

  /* IDirectMusicPortDownloadImpl fields */
};

/*****************************************************************************
 * IDirectMusicPortImpl implementation structure
 */
153
struct IDirectMusicPortImpl {
154
  /* IUnknown fields */
155
  const IDirectMusicPortVtbl *lpVtbl;
156
  LONG           ref;
157 158

  /* IDirectMusicPortImpl fields */
159 160 161
  IDirectSound* pDirectSound;
  IReferenceClock* pLatencyClock;
  BOOL fActive;
162 163
  DMUS_PORTCAPS caps;
  DMUS_PORTPARAMS params;
Rok Mandeljc's avatar
Rok Mandeljc committed
164 165
  int nrofgroups;
  DMUSIC_PRIVATE_CHANNEL_GROUP group[1];
166 167
};

168 169 170 171
extern HRESULT WINAPI IDirectMusicPortImpl_Activate (LPDIRECTMUSICPORT iface, BOOL fActive);

/** Internal factory */
extern HRESULT WINAPI DMUSIC_CreateDirectMusicPortImpl (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter, LPDMUS_PORTPARAMS pPortParams, LPDMUS_PORTCAPS pPortCaps);
172 173 174 175

/*****************************************************************************
 * IDirectMusicThruImpl implementation structure
 */
176
struct IDirectMusicThruImpl {
177
  /* IUnknown fields */
178
  const IDirectMusicThruVtbl *lpVtbl;
179
  LONG           ref;
180 181 182 183

  /* IDirectMusicThruImpl fields */
};

184
/*****************************************************************************
185
 * IReferenceClockImpl implementation structure
186
 */
187
struct IReferenceClockImpl {
188
  /* IUnknown fields */
189
  const IReferenceClockVtbl *lpVtbl;
190
  LONG           ref;
191

192 193 194
  /* IReferenceClockImpl fields */
  REFERENCE_TIME rtTime;
  DMUS_CLOCKINFO pClockInfo;
195 196
};

197 198 199 200 201 202 203 204 205
typedef struct _DMUS_PRIVATE_INSTRUMENT_ENTRY {
	struct list entry; /* for listing elements */
	IDirectMusicInstrument* pInstrument;
} DMUS_PRIVATE_INSTRUMENTENTRY, *LPDMUS_PRIVATE_INSTRUMENTENTRY;

typedef struct _DMUS_PRIVATE_POOLCUE {
	struct list entry; /* for listing elements */
} DMUS_PRIVATE_POOLCUE, *LPDMUS_PRIVATE_POOLCUE;

206
/*****************************************************************************
207
 * IDirectMusicCollectionImpl implementation structure
208
 */
209
struct IDirectMusicCollectionImpl {
210
  /* IUnknown fields */
211 212 213 214
  const IUnknownVtbl *UnknownVtbl;
  const IDirectMusicCollectionVtbl *CollectionVtbl;
  const IDirectMusicObjectVtbl *ObjectVtbl;
  const IPersistStreamVtbl *PersistStreamVtbl;
215
  LONG           ref;
216

217 218 219 220
  /* IDirectMusicCollectionImpl fields */
  IStream *pStm; /* stream from which we load collection and later instruments */
  LARGE_INTEGER liCollectionPosition; /* offset in a stream where collection was loaded from */
  LARGE_INTEGER liWavePoolTablePosition; /* offset in a stream where wave pool table can be found */
221
  LPDMUS_OBJECTDESC pDesc;
222 223 224 225 226 227 228
  CHAR* szCopyright; /* FIXME: should probably placed somewhere else */
  LPDLSHEADER pHeader;
  /* pool table */
  LPPOOLTABLE pPoolTable;
  LPPOOLCUE pPoolCues;
  /* instruments */
  struct list Instruments;
229 230 231
};

/*****************************************************************************
232
 * IDirectMusicInstrumentImpl implementation structure
233
 */
234
struct IDirectMusicInstrumentImpl {
235
  /* IUnknown fields */
236 237
  const IUnknownVtbl *UnknownVtbl;
  const IDirectMusicInstrumentVtbl *InstrumentVtbl;
238
  LONG           ref;
239

240 241 242 243 244 245
  /* IDirectMusicInstrumentImpl fields */
  LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */
  LPGUID pInstrumentID;
  LPINSTHEADER pHeader;
  WCHAR wszName[DMUS_MAX_NAME];
  /* instrument data */
246 247
};

248 249
/* custom :) */
extern HRESULT WINAPI IDirectMusicInstrumentImpl_Custom_Load (LPDIRECTMUSICINSTRUMENT iface, LPSTREAM pStm);
250

251 252 253 254
/**********************************************************************
 * Dll lifetime tracking declaration for dmusic.dll
 */
extern LONG DMUSIC_refCount;
255 256
static inline void DMUSIC_LockModule(void) { InterlockedIncrement( &DMUSIC_refCount ); }
static inline void DMUSIC_UnlockModule(void) { InterlockedDecrement( &DMUSIC_refCount ); }
257

258 259 260 261 262
/*****************************************************************************
 * Helper Functions
 */
void register_waveport (LPGUID lpGUID, LPCSTR lpszDesc, LPCSTR lpszDrvName, LPVOID lpContext);

263 264 265 266 267 268

/*****************************************************************************
 * Misc.
 */
/* my custom ICOM stuff */
#define ICOM_NAME_MULTI(impl,field,iface,name)  impl* const name=(impl*)((char*)(iface) - offsetof(impl,field))
269
#define ICOM_THIS_MULTI(impl,field,iface) ICOM_NAME_MULTI(impl,field,iface,This)
270 271 272 273 274 275 276
 
/* for simpler reading */
typedef struct _DMUS_PRIVATE_CHUNK {
	FOURCC fccID; /* FOURCC ID of the chunk */
	DWORD dwSize; /* size of the chunk */
} DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_CHUNK;

277 278 279 280 281
/* used for generic dumping (copied from ddraw) */
typedef struct {
    DWORD val;
    const char* name;
} flag_info;
282

283 284 285 286
typedef struct {
    const GUID *guid;
    const char* name;
} guid_info;
287 288 289 290 291 292 293 294

/* used for initialising structs (primarily for DMUS_OBJECTDESC) */
#define DM_STRUCT_INIT(x) 				\
	do {								\
		memset((x), 0, sizeof(*(x)));	\
		(x)->dwSize = sizeof(*x);		\
	} while (0)

295 296
#define FE(x) { x, #x }	
#define GE(x) { &x, #x }
297

298 299 300 301
/* dwPatch from MIDILOCALE */
extern DWORD MIDILOCALE2Patch (LPMIDILOCALE pLocale);
/* MIDILOCALE from dwPatch */
extern void Patch2MIDILOCALE (DWORD dwPatch, LPMIDILOCALE pLocale);
302

303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
/* check whether the given DWORD is even (return 0) or odd (return 1) */
extern int even_or_odd (DWORD number);
/* FOURCC to string conversion for debug messages */
extern const char *debugstr_fourcc (DWORD fourcc);
/* DMUS_VERSION struct to string conversion for debug messages */
extern const char *debugstr_dmversion (LPDMUS_VERSION version);
/* returns name of given GUID */
extern const char *debugstr_dmguid (const GUID *id);
/* returns name of given error code */
extern const char *debugstr_dmreturn (DWORD code);
/* generic flags-dumping function */
extern const char *debugstr_flags (DWORD flags, const flag_info* names, size_t num_names);
extern const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask);
/* dump whole DMUS_OBJECTDESC struct */
extern const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc);
318

319
#endif	/* __WINE_DMUSIC_PRIVATE_H */