msi/tests: Avoid #if 0 to make sure code still compiles.
[wine/multimedia.git] / dlls / dsound / dsound_private.h
blob633ef4dfc74edb46a5d1aa8e479d3b6b1c1fd733
1 /* DirectSound
3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998 Rob Riggs
5 * Copyright 2000-2001 TransGaming Technologies, Inc.
7 * This library 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 library 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 library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 /* Linux does not support better timing than 10ms */
23 #define DS_TIME_RES 2 /* Resolution of multimedia timer */
24 #define DS_TIME_DEL 10 /* Delay of multimedia timer callback, and duration of HEL fragment */
26 #include "wine/list.h"
28 extern int ds_emuldriver DECLSPEC_HIDDEN;
29 extern int ds_hel_buflen DECLSPEC_HIDDEN;
30 extern int ds_snd_queue_max DECLSPEC_HIDDEN;
31 extern int ds_snd_shadow_maxsize DECLSPEC_HIDDEN;
32 extern int ds_default_sample_rate DECLSPEC_HIDDEN;
33 extern int ds_default_bits_per_sample DECLSPEC_HIDDEN;
35 /*****************************************************************************
36 * Predeclare the interface implementation structures
38 typedef struct IDirectSoundImpl IDirectSoundImpl;
39 typedef struct IDirectSound_IUnknown IDirectSound_IUnknown;
40 typedef struct IDirectSound_IDirectSound IDirectSound_IDirectSound;
41 typedef struct IDirectSound8_IUnknown IDirectSound8_IUnknown;
42 typedef struct IDirectSound8_IDirectSound IDirectSound8_IDirectSound;
43 typedef struct IDirectSound8_IDirectSound8 IDirectSound8_IDirectSound8;
44 typedef struct IDirectSoundBufferImpl IDirectSoundBufferImpl;
45 typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl;
46 typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
47 typedef struct IDirectSoundNotifyImpl IDirectSoundNotifyImpl;
48 typedef struct IDirectSoundCaptureNotifyImpl IDirectSoundCaptureNotifyImpl;
49 typedef struct IDirectSound3DListenerImpl IDirectSound3DListenerImpl;
50 typedef struct IDirectSound3DBufferImpl IDirectSound3DBufferImpl;
51 typedef struct IKsBufferPropertySetImpl IKsBufferPropertySetImpl;
52 typedef struct DirectSoundDevice DirectSoundDevice;
53 typedef struct DirectSoundCaptureDevice DirectSoundCaptureDevice;
55 /* dsound_convert.h */
56 typedef void (*bitsconvertfunc)(const void *, void *, UINT, UINT, INT, UINT, UINT);
57 extern const bitsconvertfunc convertbpp[5][4] DECLSPEC_HIDDEN;
58 typedef void (*mixfunc)(const void *, void *, unsigned);
59 extern const mixfunc mixfunctions[4] DECLSPEC_HIDDEN;
60 typedef void (*normfunc)(const void *, void *, unsigned);
61 extern const normfunc normfunctions[4] DECLSPEC_HIDDEN;
63 typedef struct _DSDRIVERDESC
65 DWORD dwFlags;
66 CHAR szDesc[256];
67 CHAR szDrvname[256];
68 DWORD dnDevNode;
69 WORD wVxdId;
70 WORD wReserved;
71 ULONG ulDeviceNum;
72 DWORD dwHeapType;
73 LPVOID pvDirectDrawHeap;
74 DWORD dwMemStartAddress;
75 DWORD dwMemEndAddress;
76 DWORD dwMemAllocExtra;
77 LPVOID pvReserved1;
78 LPVOID pvReserved2;
79 } DSDRIVERDESC,*PDSDRIVERDESC;
81 typedef struct _DSDRIVERCAPS
83 DWORD dwFlags;
84 DWORD dwMinSecondarySampleRate;
85 DWORD dwMaxSecondarySampleRate;
86 DWORD dwPrimaryBuffers;
87 DWORD dwMaxHwMixingAllBuffers;
88 DWORD dwMaxHwMixingStaticBuffers;
89 DWORD dwMaxHwMixingStreamingBuffers;
90 DWORD dwFreeHwMixingAllBuffers;
91 DWORD dwFreeHwMixingStaticBuffers;
92 DWORD dwFreeHwMixingStreamingBuffers;
93 DWORD dwMaxHw3DAllBuffers;
94 DWORD dwMaxHw3DStaticBuffers;
95 DWORD dwMaxHw3DStreamingBuffers;
96 DWORD dwFreeHw3DAllBuffers;
97 DWORD dwFreeHw3DStaticBuffers;
98 DWORD dwFreeHw3DStreamingBuffers;
99 DWORD dwTotalHwMemBytes;
100 DWORD dwFreeHwMemBytes;
101 DWORD dwMaxContigFreeHwMemBytes;
102 } DSDRIVERCAPS,*PDSDRIVERCAPS;
104 typedef struct _DSVOLUMEPAN
106 DWORD dwTotalLeftAmpFactor;
107 DWORD dwTotalRightAmpFactor;
108 LONG lVolume;
109 DWORD dwVolAmpFactor;
110 LONG lPan;
111 DWORD dwPanLeftAmpFactor;
112 DWORD dwPanRightAmpFactor;
113 } DSVOLUMEPAN,*PDSVOLUMEPAN;
115 typedef struct _DSCDRIVERCAPS
117 DWORD dwSize;
118 DWORD dwFlags;
119 DWORD dwFormats;
120 DWORD dwChannels;
121 } DSCDRIVERCAPS,*PDSCDRIVERCAPS;
123 /*****************************************************************************
124 * IDirectSoundDevice implementation structure
126 struct DirectSoundDevice
128 LONG ref;
130 GUID guid;
131 DSDRIVERDESC drvdesc;
132 DSDRIVERCAPS drvcaps;
133 DWORD priolevel;
134 PWAVEFORMATEX pwfx;
135 HWAVEOUT hwo;
136 LPWAVEHDR pwave;
137 UINT timerID, pwplay, pwqueue, prebuf, helfrags;
138 DWORD fraglen;
139 LPBYTE buffer;
140 DWORD writelead, buflen, state, playpos, mixpos;
141 int nrofbuffers;
142 IDirectSoundBufferImpl** buffers;
143 RTL_RWLOCK buffer_list_lock;
144 CRITICAL_SECTION mixlock;
145 IDirectSoundBufferImpl *primary;
146 DWORD speaker_config;
147 LPBYTE tmp_buffer, mix_buffer;
148 DWORD tmp_buffer_len, mix_buffer_len;
150 DSVOLUMEPAN volpan;
152 mixfunc mixfunction;
153 normfunc normfunction;
155 /* DirectSound3DListener fields */
156 IDirectSound3DListenerImpl* listener;
157 DS3DLISTENER ds3dl;
158 BOOL ds3dl_need_recalc;
161 /* reference counted buffer memory for duplicated buffer memory */
162 typedef struct BufferMemory
164 LONG ref;
165 LPBYTE memory;
166 struct list buffers;
167 } BufferMemory;
169 ULONG DirectSoundDevice_Release(DirectSoundDevice * device) DECLSPEC_HIDDEN;
170 HRESULT DirectSoundDevice_Initialize(
171 DirectSoundDevice ** ppDevice,
172 LPCGUID lpcGUID) DECLSPEC_HIDDEN;
173 HRESULT DirectSoundDevice_AddBuffer(
174 DirectSoundDevice * device,
175 IDirectSoundBufferImpl * pDSB) DECLSPEC_HIDDEN;
176 HRESULT DirectSoundDevice_RemoveBuffer(
177 DirectSoundDevice * device,
178 IDirectSoundBufferImpl * pDSB) DECLSPEC_HIDDEN;
179 HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice * device, LPDSCAPS lpDSCaps) DECLSPEC_HIDDEN;
180 HRESULT DirectSoundDevice_CreateSoundBuffer(
181 DirectSoundDevice * device,
182 LPCDSBUFFERDESC dsbd,
183 LPLPDIRECTSOUNDBUFFER ppdsb,
184 LPUNKNOWN lpunk,
185 BOOL from8) DECLSPEC_HIDDEN;
186 HRESULT DirectSoundDevice_DuplicateSoundBuffer(
187 DirectSoundDevice * device,
188 LPDIRECTSOUNDBUFFER psb,
189 LPLPDIRECTSOUNDBUFFER ppdsb) DECLSPEC_HIDDEN;
190 HRESULT DirectSoundDevice_SetCooperativeLevel(
191 DirectSoundDevice * devcie,
192 HWND hwnd,
193 DWORD level) DECLSPEC_HIDDEN;
194 HRESULT DirectSoundDevice_Compact(DirectSoundDevice * device) DECLSPEC_HIDDEN;
195 HRESULT DirectSoundDevice_GetSpeakerConfig(
196 DirectSoundDevice * device,
197 LPDWORD lpdwSpeakerConfig) DECLSPEC_HIDDEN;
198 HRESULT DirectSoundDevice_SetSpeakerConfig(
199 DirectSoundDevice * device,
200 DWORD config) DECLSPEC_HIDDEN;
201 HRESULT DirectSoundDevice_VerifyCertification(DirectSoundDevice * device,
202 LPDWORD pdwCertified) DECLSPEC_HIDDEN;
204 /*****************************************************************************
205 * IDirectSoundBuffer implementation structure
207 struct IDirectSoundBufferImpl
209 IDirectSoundBuffer8 IDirectSoundBuffer8_iface;
210 LONG numIfaces; /* "in use interfaces" refcount */
211 LONG ref;
212 /* IDirectSoundBufferImpl fields */
213 DirectSoundDevice* device;
214 RTL_RWLOCK lock;
215 PWAVEFORMATEX pwfx;
216 BufferMemory* buffer;
217 LPBYTE tmp_buffer;
218 DWORD playflags,state,leadin;
219 DWORD writelead,buflen;
220 DWORD nAvgBytesPerSec;
221 DWORD freq, tmp_buffer_len, max_buffer_len;
222 DSVOLUMEPAN volpan;
223 DSBUFFERDESC dsbd;
224 /* used for frequency conversion (PerfectPitch) */
225 ULONG freqneeded, freqAdjust, freqAcc, freqAccNext, resampleinmixer;
226 /* used for mixing */
227 DWORD primary_mixpos, buf_mixpos, sec_mixpos;
229 /* IDirectSoundNotifyImpl fields */
230 IDirectSoundNotifyImpl* notify;
231 LPDSBPOSITIONNOTIFY notifies;
232 int nrofnotifies;
234 /* DirectSound3DBuffer fields */
235 IDirectSound3DBufferImpl* ds3db;
236 DS3DBUFFER ds3db_ds3db;
237 LONG ds3db_lVolume;
238 BOOL ds3db_need_recalc;
240 /* IKsPropertySet fields */
241 IKsBufferPropertySetImpl* iks;
242 bitsconvertfunc convert;
243 struct list entry;
246 HRESULT IDirectSoundBufferImpl_Create(
247 DirectSoundDevice *device,
248 IDirectSoundBufferImpl **ppdsb,
249 LPCDSBUFFERDESC dsbd) DECLSPEC_HIDDEN;
250 HRESULT IDirectSoundBufferImpl_Destroy(
251 IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN;
252 HRESULT IDirectSoundBufferImpl_Duplicate(
253 DirectSoundDevice *device,
254 IDirectSoundBufferImpl **ppdsb,
255 IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN;
256 void secondarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
258 /*****************************************************************************
259 * DirectSoundCaptureDevice implementation structure
261 struct DirectSoundCaptureDevice
263 /* IDirectSoundCaptureImpl fields */
264 GUID guid;
265 LONG ref;
267 /* DirectSound driver stuff */
268 DSDRIVERDESC drvdesc;
269 DSCDRIVERCAPS drvcaps;
271 /* wave driver info */
272 HWAVEIN hwi;
274 /* more stuff */
275 LPBYTE buffer;
276 DWORD buflen;
278 PWAVEFORMATEX pwfx;
280 IDirectSoundCaptureBufferImpl* capture_buffer;
281 DWORD state;
282 LPWAVEHDR pwave;
283 int nrofpwaves;
284 int index;
285 CRITICAL_SECTION lock;
288 /*****************************************************************************
289 * IDirectSoundCaptureBuffer implementation structure
291 struct IDirectSoundCaptureBufferImpl
293 /* IUnknown fields */
294 const IDirectSoundCaptureBuffer8Vtbl *lpVtbl;
295 LONG ref;
297 /* IDirectSoundCaptureBufferImpl fields */
298 DirectSoundCaptureDevice* device;
299 /* FIXME: don't need this */
300 LPDSCBUFFERDESC pdscbd;
301 DWORD flags;
303 /* IDirectSoundCaptureNotifyImpl fields */
304 IDirectSoundCaptureNotifyImpl* notify;
305 LPDSBPOSITIONNOTIFY notifies;
306 int nrofnotifies;
309 /*****************************************************************************
310 * IDirectSound3DListener implementation structure
312 struct IDirectSound3DListenerImpl
314 /* IUnknown fields */
315 const IDirectSound3DListenerVtbl *lpVtbl;
316 LONG ref;
317 /* IDirectSound3DListenerImpl fields */
318 DirectSoundDevice* device;
321 HRESULT IDirectSound3DListenerImpl_Create(
322 DirectSoundDevice *device,
323 IDirectSound3DListenerImpl **pdsl) DECLSPEC_HIDDEN;
325 /*****************************************************************************
326 * IKsBufferPropertySet implementation structure
328 struct IKsBufferPropertySetImpl
330 /* IUnknown fields */
331 const IKsPropertySetVtbl *lpVtbl;
332 LONG ref;
333 /* IKsPropertySetImpl fields */
334 IDirectSoundBufferImpl* dsb;
337 HRESULT IKsBufferPropertySetImpl_Create(
338 IDirectSoundBufferImpl *dsb,
339 IKsBufferPropertySetImpl **piks) DECLSPEC_HIDDEN;
340 HRESULT IKsBufferPropertySetImpl_Destroy(
341 IKsBufferPropertySetImpl *piks) DECLSPEC_HIDDEN;
343 HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, IKsPropertySet **piks) DECLSPEC_HIDDEN;
345 /*****************************************************************************
346 * IDirectSound3DBuffer implementation structure
348 struct IDirectSound3DBufferImpl
350 /* IUnknown fields */
351 const IDirectSound3DBufferVtbl *lpVtbl;
352 LONG ref;
353 /* IDirectSound3DBufferImpl fields */
354 IDirectSoundBufferImpl* dsb;
357 HRESULT IDirectSound3DBufferImpl_Create(
358 IDirectSoundBufferImpl *dsb,
359 IDirectSound3DBufferImpl **pds3db) DECLSPEC_HIDDEN;
360 HRESULT IDirectSound3DBufferImpl_Destroy(
361 IDirectSound3DBufferImpl *pds3db) DECLSPEC_HIDDEN;
363 /*******************************************************************************
366 /* dsound.c */
368 HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS) DECLSPEC_HIDDEN;
369 HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS) DECLSPEC_HIDDEN;
371 /* primary.c */
373 DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign) DECLSPEC_HIDDEN;
374 HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device) DECLSPEC_HIDDEN;
375 HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device) DECLSPEC_HIDDEN;
376 HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device) DECLSPEC_HIDDEN;
377 HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device) DECLSPEC_HIDDEN;
378 HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos) DECLSPEC_HIDDEN;
379 LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
380 HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) DECLSPEC_HIDDEN;
381 HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb,
382 const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN;
383 void primarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
384 HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
386 /* duplex.c */
388 HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX* ppDSFD) DECLSPEC_HIDDEN;
390 /* mixer.c */
391 DWORD DSOUND_bufpos_to_mixpos(const DirectSoundDevice* device, DWORD pos) DECLSPEC_HIDDEN;
392 void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len) DECLSPEC_HIDDEN;
393 void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN;
394 void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN;
395 void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN;
396 void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen, BOOL inmixer) DECLSPEC_HIDDEN;
397 DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD* overshot) DECLSPEC_HIDDEN;
399 void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN;
400 void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN;
402 /* sound3d.c */
404 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN;
406 /* capture.c */
408 HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC) DECLSPEC_HIDDEN;
409 HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8) DECLSPEC_HIDDEN;
411 #define STATE_STOPPED 0
412 #define STATE_STARTING 1
413 #define STATE_PLAYING 2
414 #define STATE_CAPTURING 2
415 #define STATE_STOPPING 3
417 #define DSOUND_FREQSHIFT (20)
419 extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
420 extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
422 extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
423 extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
425 HRESULT mmErr(UINT err) DECLSPEC_HIDDEN;
426 void setup_dsound_options(void) DECLSPEC_HIDDEN;
427 const char * dumpCooperativeLevel(DWORD level) DECLSPEC_HIDDEN;