dsound: Constify DSOUND_CheckEvent.
[wine/wine-gecko.git] / dlls / dsound / dsound_private.h
blobf55f46d1ffad1bc14c15553d519a2d22429f302b
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 #define DS_HEL_BUFLEN 0x8000 /* HEL: The buffer length of the emulated buffer */
27 #define DS_HEL_FRAGS 0x10 /* HEL only: number of waveOut fragments in primary buffer
28 * (changing this won't help you) */
30 /* direct sound hardware acceleration levels */
31 #define DS_HW_ACCEL_FULL 0 /* default on Windows 98 */
32 #define DS_HW_ACCEL_STANDARD 1 /* default on Windows 2000 */
33 #define DS_HW_ACCEL_BASIC 2
34 #define DS_HW_ACCEL_EMULATION 3
36 extern int ds_emuldriver;
37 extern int ds_snd_queue_max;
38 extern int ds_hw_accel;
39 extern int ds_default_playback;
40 extern int ds_default_capture;
41 extern int ds_default_sample_rate;
42 extern int ds_default_bits_per_sample;
44 /*****************************************************************************
45 * Predeclare the interface implementation structures
47 typedef struct IDirectSoundImpl IDirectSoundImpl;
48 typedef struct IDirectSound_IUnknown IDirectSound_IUnknown;
49 typedef struct IDirectSound_IDirectSound IDirectSound_IDirectSound;
50 typedef struct IDirectSound8_IUnknown IDirectSound8_IUnknown;
51 typedef struct IDirectSound8_IDirectSound IDirectSound8_IDirectSound;
52 typedef struct IDirectSound8_IDirectSound8 IDirectSound8_IDirectSound8;
53 typedef struct IDirectSoundBufferImpl IDirectSoundBufferImpl;
54 typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl;
55 typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
56 typedef struct IDirectSoundFullDuplexImpl IDirectSoundFullDuplexImpl;
57 typedef struct IDirectSoundFullDuplex_IUnknown IDirectSoundFullDuplex_IUnknown;
58 typedef struct IDirectSoundFullDuplex_IDirectSound IDirectSoundFullDuplex_IDirectSound;
59 typedef struct IDirectSoundFullDuplex_IDirectSound8 IDirectSoundFullDuplex_IDirectSound8;
60 typedef struct IDirectSoundFullDuplex_IDirectSoundCapture IDirectSoundFullDuplex_IDirectSoundCapture;
61 typedef struct IDirectSoundNotifyImpl IDirectSoundNotifyImpl;
62 typedef struct IDirectSoundCaptureNotifyImpl IDirectSoundCaptureNotifyImpl;
63 typedef struct IDirectSound3DListenerImpl IDirectSound3DListenerImpl;
64 typedef struct IDirectSound3DBufferImpl IDirectSound3DBufferImpl;
65 typedef struct IKsBufferPropertySetImpl IKsBufferPropertySetImpl;
66 typedef struct IKsPrivatePropertySetImpl IKsPrivatePropertySetImpl;
67 typedef struct PrimaryBufferImpl PrimaryBufferImpl;
68 typedef struct SecondaryBufferImpl SecondaryBufferImpl;
69 typedef struct DirectSoundDevice DirectSoundDevice;
70 typedef struct DirectSoundCaptureDevice DirectSoundCaptureDevice;
72 /*****************************************************************************
73 * IDirectSoundDevice implementation structure
75 struct DirectSoundDevice
77 LONG ref;
79 GUID guid;
80 PIDSDRIVER driver;
81 DSDRIVERDESC drvdesc;
82 DSDRIVERCAPS drvcaps;
83 DWORD priolevel;
84 PWAVEFORMATEX pwfx;
85 HWAVEOUT hwo;
86 LPWAVEHDR pwave[DS_HEL_FRAGS];
87 UINT timerID, pwplay, pwqueue, prebuf;
88 DWORD fraglen;
89 PIDSDRIVERBUFFER hwbuf;
90 LPBYTE buffer;
91 DWORD writelead, buflen, state, playpos, mixpos;
92 int nrofbuffers;
93 IDirectSoundBufferImpl** buffers;
94 RTL_RWLOCK buffer_list_lock;
95 CRITICAL_SECTION mixlock;
96 PrimaryBufferImpl* primary;
97 DSBUFFERDESC dsbd;
98 DWORD speaker_config;
99 LPBYTE tmp_buffer;
100 DWORD tmp_buffer_len;
102 /* DirectSound3DListener fields */
103 IDirectSound3DListenerImpl* listener;
104 DS3DLISTENER ds3dl;
105 BOOL ds3dl_need_recalc;
108 /* reference counted buffer memory for duplicated buffer memory */
109 typedef struct BufferMemory
111 LONG ref;
112 LPBYTE memory;
113 } BufferMemory;
115 ULONG DirectSoundDevice_Release(DirectSoundDevice * device);
116 HRESULT DirectSoundDevice_Initialize(
117 DirectSoundDevice ** ppDevice,
118 LPCGUID lpcGUID);
119 HRESULT DirectSoundDevice_AddBuffer(
120 DirectSoundDevice * device,
121 IDirectSoundBufferImpl * pDSB);
122 HRESULT DirectSoundDevice_RemoveBuffer(
123 DirectSoundDevice * device,
124 IDirectSoundBufferImpl * pDSB);
125 HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice * device, LPDSCAPS lpDSCaps);
126 HRESULT DirectSoundDevice_CreateSoundBuffer(
127 DirectSoundDevice * device,
128 LPCDSBUFFERDESC dsbd,
129 LPLPDIRECTSOUNDBUFFER ppdsb,
130 LPUNKNOWN lpunk,
131 BOOL from8);
132 HRESULT DirectSoundDevice_DuplicateSoundBuffer(
133 DirectSoundDevice * device,
134 LPDIRECTSOUNDBUFFER psb,
135 LPLPDIRECTSOUNDBUFFER ppdsb);
136 HRESULT DirectSoundDevice_SetCooperativeLevel(
137 DirectSoundDevice * devcie,
138 HWND hwnd,
139 DWORD level);
140 HRESULT DirectSoundDevice_Compact(DirectSoundDevice * device);
141 HRESULT DirectSoundDevice_GetSpeakerConfig(
142 DirectSoundDevice * device,
143 LPDWORD lpdwSpeakerConfig);
144 HRESULT DirectSoundDevice_SetSpeakerConfig(
145 DirectSoundDevice * device,
146 DWORD config);
148 /*****************************************************************************
149 * IDirectSoundBuffer implementation structure
151 struct IDirectSoundBufferImpl
153 /* FIXME: document */
154 /* IUnknown fields */
155 const IDirectSoundBuffer8Vtbl *lpVtbl;
156 LONG ref;
157 /* IDirectSoundBufferImpl fields */
158 SecondaryBufferImpl* secondary;
159 DirectSoundDevice* device;
160 RTL_RWLOCK lock;
161 PIDSDRIVERBUFFER hwbuf;
162 PWAVEFORMATEX pwfx;
163 BufferMemory* buffer;
164 DWORD playflags,state,leadin;
165 DWORD startpos,writelead,buflen;
166 DWORD nAvgBytesPerSec;
167 DWORD freq;
168 DSVOLUMEPAN volpan;
169 DSBUFFERDESC dsbd;
170 /* used for frequency conversion (PerfectPitch) */
171 ULONG freqAdjust, freqAcc;
172 /* used for intelligent (well, sort of) prebuffering */
173 DWORD primary_mixpos, buf_mixpos;
175 /* IDirectSoundNotifyImpl fields */
176 IDirectSoundNotifyImpl* notify;
177 LPDSBPOSITIONNOTIFY notifies;
178 int nrofnotifies;
179 PIDSDRIVERNOTIFY hwnotify;
181 /* DirectSound3DBuffer fields */
182 IDirectSound3DBufferImpl* ds3db;
183 DS3DBUFFER ds3db_ds3db;
184 LONG ds3db_lVolume;
185 BOOL ds3db_need_recalc;
187 /* IKsPropertySet fields */
188 IKsBufferPropertySetImpl* iks;
191 HRESULT IDirectSoundBufferImpl_Create(
192 DirectSoundDevice *device,
193 IDirectSoundBufferImpl **ppdsb,
194 LPCDSBUFFERDESC dsbd);
195 HRESULT IDirectSoundBufferImpl_Destroy(
196 IDirectSoundBufferImpl *pdsb);
197 HRESULT IDirectSoundBufferImpl_Duplicate(
198 DirectSoundDevice *device,
199 IDirectSoundBufferImpl **ppdsb,
200 IDirectSoundBufferImpl *pdsb);
202 /*****************************************************************************
203 * SecondaryBuffer implementation structure
205 struct SecondaryBufferImpl
207 const IDirectSoundBuffer8Vtbl *lpVtbl;
208 LONG ref;
209 IDirectSoundBufferImpl* dsb;
212 HRESULT SecondaryBufferImpl_Create(
213 IDirectSoundBufferImpl *dsb,
214 SecondaryBufferImpl **pdsb);
216 /*****************************************************************************
217 * PrimaryBuffer implementation structure
219 struct PrimaryBufferImpl
221 const IDirectSoundBufferVtbl *lpVtbl;
222 LONG ref;
223 DirectSoundDevice* device;
226 HRESULT PrimaryBufferImpl_Create(
227 DirectSoundDevice * device,
228 PrimaryBufferImpl **ppdsb,
229 LPCDSBUFFERDESC dsbd);
231 /*****************************************************************************
232 * DirectSoundCaptureDevice implementation structure
234 struct DirectSoundCaptureDevice
236 /* IDirectSoundCaptureImpl fields */
237 GUID guid;
238 LONG ref;
240 /* DirectSound driver stuff */
241 PIDSCDRIVER driver;
242 DSDRIVERDESC drvdesc;
243 DSCDRIVERCAPS drvcaps;
244 PIDSCDRIVERBUFFER hwbuf;
246 /* wave driver info */
247 HWAVEIN hwi;
249 /* more stuff */
250 LPBYTE buffer;
251 DWORD buflen;
252 DWORD read_position;
254 PWAVEFORMATEX pwfx;
256 IDirectSoundCaptureBufferImpl* capture_buffer;
257 DWORD state;
258 LPWAVEHDR pwave;
259 int nrofpwaves;
260 int index;
261 CRITICAL_SECTION lock;
264 HRESULT DirectSoundCaptureDevice_Initialize(
265 DirectSoundCaptureDevice ** ppDevice,
266 LPCGUID lpcGUID);
267 ULONG DirectSoundCaptureDevice_Release(
268 DirectSoundCaptureDevice * device);
270 /*****************************************************************************
271 * IDirectSoundCaptureBuffer implementation structure
273 struct IDirectSoundCaptureBufferImpl
275 /* IUnknown fields */
276 const IDirectSoundCaptureBuffer8Vtbl *lpVtbl;
277 LONG ref;
279 /* IDirectSoundCaptureBufferImpl fields */
280 DirectSoundCaptureDevice* device;
281 /* FIXME: don't need this */
282 LPDSCBUFFERDESC pdscbd;
283 DWORD flags;
285 /* IDirectSoundCaptureNotifyImpl fields */
286 IDirectSoundCaptureNotifyImpl* notify;
287 LPDSBPOSITIONNOTIFY notifies;
288 int nrofnotifies;
289 PIDSDRIVERNOTIFY hwnotify;
292 HRESULT IDirectSoundCaptureBufferImpl_Create(
293 DirectSoundCaptureDevice *device,
294 IDirectSoundCaptureBufferImpl ** ppobj,
295 LPCDSCBUFFERDESC lpcDSCBufferDesc);
297 /*****************************************************************************
298 * IDirectSoundFullDuplex implementation structure
300 struct IDirectSoundFullDuplexImpl
302 /* IUnknown fields */
303 const IDirectSoundFullDuplexVtbl *lpVtbl;
304 LONG ref;
306 /* IDirectSoundFullDuplexImpl fields */
307 DirectSoundDevice *renderer_device;
308 DirectSoundCaptureDevice *capture_device;
310 LPUNKNOWN pUnknown;
311 LPDIRECTSOUND pDS;
312 LPDIRECTSOUND8 pDS8;
313 LPDIRECTSOUNDCAPTURE pDSC;
316 /*****************************************************************************
317 * IDirectSoundFullDuplex COM components
319 struct IDirectSoundFullDuplex_IUnknown {
320 const IUnknownVtbl *lpVtbl;
321 LONG ref;
322 IDirectSoundFullDuplexImpl *pdsfd;
325 struct IDirectSoundFullDuplex_IDirectSound {
326 const IDirectSoundVtbl *lpVtbl;
327 LONG ref;
328 IDirectSoundFullDuplexImpl *pdsfd;
331 struct IDirectSoundFullDuplex_IDirectSound8 {
332 const IDirectSound8Vtbl *lpVtbl;
333 LONG ref;
334 IDirectSoundFullDuplexImpl *pdsfd;
337 struct IDirectSoundFullDuplex_IDirectSoundCapture {
338 const IDirectSoundCaptureVtbl *lpVtbl;
339 LONG ref;
340 IDirectSoundFullDuplexImpl *pdsfd;
343 /*****************************************************************************
344 * IDirectSound3DListener implementation structure
346 struct IDirectSound3DListenerImpl
348 /* IUnknown fields */
349 const IDirectSound3DListenerVtbl *lpVtbl;
350 LONG ref;
351 /* IDirectSound3DListenerImpl fields */
352 DirectSoundDevice* device;
355 HRESULT IDirectSound3DListenerImpl_Create(
356 DirectSoundDevice *device,
357 IDirectSound3DListenerImpl **pdsl);
359 /*****************************************************************************
360 * IKsBufferPropertySet implementation structure
362 struct IKsBufferPropertySetImpl
364 /* IUnknown fields */
365 const IKsPropertySetVtbl *lpVtbl;
366 LONG ref;
367 /* IKsPropertySetImpl fields */
368 IDirectSoundBufferImpl* dsb;
371 HRESULT IKsBufferPropertySetImpl_Create(
372 IDirectSoundBufferImpl *dsb,
373 IKsBufferPropertySetImpl **piks);
374 HRESULT IKsBufferPropertySetImpl_Destroy(
375 IKsBufferPropertySetImpl *piks);
377 /*****************************************************************************
378 * IKsPrivatePropertySet implementation structure
380 struct IKsPrivatePropertySetImpl
382 /* IUnknown fields */
383 const IKsPropertySetVtbl *lpVtbl;
384 LONG ref;
387 HRESULT IKsPrivatePropertySetImpl_Create(
388 REFIID riid,
389 IKsPrivatePropertySetImpl **piks);
391 /*****************************************************************************
392 * IDirectSound3DBuffer implementation structure
394 struct IDirectSound3DBufferImpl
396 /* IUnknown fields */
397 const IDirectSound3DBufferVtbl *lpVtbl;
398 LONG ref;
399 /* IDirectSound3DBufferImpl fields */
400 IDirectSoundBufferImpl* dsb;
403 HRESULT IDirectSound3DBufferImpl_Create(
404 IDirectSoundBufferImpl *dsb,
405 IDirectSound3DBufferImpl **pds3db);
406 HRESULT IDirectSound3DBufferImpl_Destroy(
407 IDirectSound3DBufferImpl *pds3db);
409 /*******************************************************************************
412 /* dsound.c */
414 HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS);
415 HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS);
417 /* primary.c */
419 HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device);
420 HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device);
421 HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device);
422 HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device);
423 HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos);
424 HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex);
426 /* duplex.c */
428 HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX* ppDSFD);
430 /* mixer.c */
432 void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len);
433 void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan);
434 void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan);
435 void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb);
436 void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
437 void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2);
439 /* sound3d.c */
441 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb);
443 /* capture.c */
445 HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC);
446 HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8);
447 HRESULT WINAPI IDirectSoundCaptureImpl_CreateCaptureBuffer(
448 LPDIRECTSOUNDCAPTURE iface,
449 LPCDSCBUFFERDESC lpcDSCBufferDesc,
450 LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
451 LPUNKNOWN pUnk);
452 HRESULT WINAPI IDirectSoundCaptureImpl_GetCaps(
453 LPDIRECTSOUNDCAPTURE iface,
454 LPDSCCAPS lpDSCCaps);
455 HRESULT WINAPI IDirectSoundCaptureImpl_Initialize(
456 LPDIRECTSOUNDCAPTURE iface,
457 LPCGUID lpcGUID);
459 #define STATE_STOPPED 0
460 #define STATE_STARTING 1
461 #define STATE_PLAYING 2
462 #define STATE_CAPTURING 2
463 #define STATE_STOPPING 3
465 #define DSOUND_FREQSHIFT (14)
467 extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
468 extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
470 extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS];
471 extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
473 HRESULT mmErr(UINT err);
474 void setup_dsound_options(void);
475 const char * dumpCooperativeLevel(DWORD level);