Assorted spelling fixes.
[wine/wine-gecko.git] / dlls / dsound / dsound_private.h
blobca4932c90a3b63be0f0b5ff0307cf7160f738d05
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 10 /* Resolution of multimedia timer */
24 #define DS_TIME_DEL 10 /* Delay of multimedia timer callback, and duration of HEL fragment */
26 #define DS_HEL_FRAGS 48 /* HEL only: number of waveOut fragments in primary buffer
27 * (changing this won't help you) */
29 /* direct sound hardware acceleration levels */
30 #define DS_HW_ACCEL_FULL 0 /* default on Windows 98 */
31 #define DS_HW_ACCEL_STANDARD 1 /* default on Windows 2000 */
32 #define DS_HW_ACCEL_BASIC 2
33 #define DS_HW_ACCEL_EMULATION 3
35 extern int ds_emuldriver;
36 extern int ds_hel_margin;
37 extern int ds_hel_queue;
38 extern int ds_snd_queue_max;
39 extern int ds_snd_queue_min;
40 extern int ds_hw_accel;
41 extern int ds_default_playback;
42 extern int ds_default_capture;
43 extern int ds_default_sample_rate;
44 extern int ds_default_bits_per_sample;
46 /*****************************************************************************
47 * Predeclare the interface implementation structures
49 typedef struct IDirectSoundImpl IDirectSoundImpl;
50 typedef struct IDirectSound_IUnknown IDirectSound_IUnknown;
51 typedef struct IDirectSound_IDirectSound IDirectSound_IDirectSound;
52 typedef struct IDirectSound8_IUnknown IDirectSound8_IUnknown;
53 typedef struct IDirectSound8_IDirectSound IDirectSound8_IDirectSound;
54 typedef struct IDirectSound8_IDirectSound8 IDirectSound8_IDirectSound8;
55 typedef struct IDirectSoundBufferImpl IDirectSoundBufferImpl;
56 typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl;
57 typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
58 typedef struct IDirectSoundFullDuplexImpl IDirectSoundFullDuplexImpl;
59 typedef struct IDirectSoundFullDuplex_IUnknown IDirectSoundFullDuplex_IUnknown;
60 typedef struct IDirectSoundFullDuplex_IDirectSound IDirectSoundFullDuplex_IDirectSound;
61 typedef struct IDirectSoundFullDuplex_IDirectSound8 IDirectSoundFullDuplex_IDirectSound8;
62 typedef struct IDirectSoundFullDuplex_IDirectSoundCapture IDirectSoundFullDuplex_IDirectSoundCapture;
63 typedef struct IDirectSoundNotifyImpl IDirectSoundNotifyImpl;
64 typedef struct IDirectSoundCaptureNotifyImpl IDirectSoundCaptureNotifyImpl;
65 typedef struct IDirectSound3DListenerImpl IDirectSound3DListenerImpl;
66 typedef struct IDirectSound3DBufferImpl IDirectSound3DBufferImpl;
67 typedef struct IKsBufferPropertySetImpl IKsBufferPropertySetImpl;
68 typedef struct IKsPrivatePropertySetImpl IKsPrivatePropertySetImpl;
69 typedef struct PrimaryBufferImpl PrimaryBufferImpl;
70 typedef struct SecondaryBufferImpl SecondaryBufferImpl;
71 typedef struct DirectSoundDevice DirectSoundDevice;
72 typedef struct DirectSoundCaptureDevice DirectSoundCaptureDevice;
74 /*****************************************************************************
75 * IDirectSoundDevice implementation structure
77 struct DirectSoundDevice
79 LONG ref;
81 GUID guid;
82 PIDSDRIVER driver;
83 DSDRIVERDESC drvdesc;
84 DSDRIVERCAPS drvcaps;
85 DWORD priolevel;
86 PWAVEFORMATEX pwfx;
87 HWAVEOUT hwo;
88 LPWAVEHDR pwave[DS_HEL_FRAGS];
89 UINT timerID, pwplay, pwwrite, pwqueue, prebuf, precount;
90 DWORD fraglen;
91 PIDSDRIVERBUFFER hwbuf;
92 LPBYTE buffer;
93 DWORD writelead, buflen, state, playpos, mixpos;
94 BOOL need_remix;
95 int nrofbuffers;
96 IDirectSoundBufferImpl** buffers;
97 RTL_RWLOCK buffer_list_lock;
98 CRITICAL_SECTION mixlock;
99 PrimaryBufferImpl* primary;
100 DSBUFFERDESC dsbd;
101 DWORD speaker_config;
102 LPBYTE tmp_buffer;
103 DWORD tmp_buffer_len;
105 /* DirectSound3DListener fields */
106 IDirectSound3DListenerImpl* listener;
107 DS3DLISTENER ds3dl;
108 BOOL ds3dl_need_recalc;
111 /* reference counted buffer memory for duplicated buffer memory */
112 typedef struct BufferMemory
114 LONG ref;
115 LPBYTE memory;
116 } BufferMemory;
118 ULONG DirectSoundDevice_Release(DirectSoundDevice * device);
119 HRESULT DirectSoundDevice_Initialize(
120 DirectSoundDevice ** ppDevice,
121 LPCGUID lpcGUID);
122 HRESULT DirectSoundDevice_AddBuffer(
123 DirectSoundDevice * device,
124 IDirectSoundBufferImpl * pDSB);
125 HRESULT DirectSoundDevice_RemoveBuffer(
126 DirectSoundDevice * device,
127 IDirectSoundBufferImpl * pDSB);
128 HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice * device, LPDSCAPS lpDSCaps);
129 HRESULT DirectSoundDevice_CreateSoundBuffer(
130 DirectSoundDevice * device,
131 LPCDSBUFFERDESC dsbd,
132 LPLPDIRECTSOUNDBUFFER ppdsb,
133 LPUNKNOWN lpunk,
134 BOOL from8);
135 HRESULT DirectSoundDevice_DuplicateSoundBuffer(
136 DirectSoundDevice * device,
137 LPDIRECTSOUNDBUFFER psb,
138 LPLPDIRECTSOUNDBUFFER ppdsb);
139 HRESULT DirectSoundDevice_SetCooperativeLevel(
140 DirectSoundDevice * devcie,
141 HWND hwnd,
142 DWORD level);
143 HRESULT DirectSoundDevice_Compact(DirectSoundDevice * device);
144 HRESULT DirectSoundDevice_GetSpeakerConfig(
145 DirectSoundDevice * device,
146 LPDWORD lpdwSpeakerConfig);
147 HRESULT DirectSoundDevice_SetSpeakerConfig(
148 DirectSoundDevice * device,
149 DWORD config);
151 /*****************************************************************************
152 * IDirectSoundBuffer implementation structure
154 struct IDirectSoundBufferImpl
156 /* FIXME: document */
157 /* IUnknown fields */
158 const IDirectSoundBuffer8Vtbl *lpVtbl;
159 LONG ref;
160 /* IDirectSoundBufferImpl fields */
161 SecondaryBufferImpl* secondary;
162 DirectSoundDevice* device;
163 CRITICAL_SECTION lock;
164 PIDSDRIVERBUFFER hwbuf;
165 PWAVEFORMATEX pwfx;
166 BufferMemory* buffer;
167 DWORD playflags,state,leadin;
168 DWORD playpos,startpos,writelead,buflen;
169 DWORD nAvgBytesPerSec;
170 DWORD freq;
171 DSVOLUMEPAN volpan, cvolpan;
172 DSBUFFERDESC dsbd;
173 /* used for frequency conversion (PerfectPitch) */
174 ULONG freqAdjust, freqAcc;
175 /* used for intelligent (well, sort of) prebuffering */
176 DWORD probably_valid_to, last_playpos;
177 DWORD primary_mixpos, buf_mixpos;
178 BOOL need_remix;
180 /* IDirectSoundNotifyImpl fields */
181 IDirectSoundNotifyImpl* notify;
182 LPDSBPOSITIONNOTIFY notifies;
183 int nrofnotifies;
184 PIDSDRIVERNOTIFY hwnotify;
186 /* DirectSound3DBuffer fields */
187 IDirectSound3DBufferImpl* ds3db;
188 DS3DBUFFER ds3db_ds3db;
189 LONG ds3db_lVolume;
190 BOOL ds3db_need_recalc;
192 /* IKsPropertySet fields */
193 IKsBufferPropertySetImpl* iks;
196 HRESULT IDirectSoundBufferImpl_Create(
197 DirectSoundDevice *device,
198 IDirectSoundBufferImpl **ppdsb,
199 LPCDSBUFFERDESC dsbd);
200 HRESULT IDirectSoundBufferImpl_Destroy(
201 IDirectSoundBufferImpl *pdsb);
202 HRESULT IDirectSoundBufferImpl_Duplicate(
203 DirectSoundDevice *device,
204 IDirectSoundBufferImpl **ppdsb,
205 IDirectSoundBufferImpl *pdsb);
207 /*****************************************************************************
208 * SecondaryBuffer implementation structure
210 struct SecondaryBufferImpl
212 const IDirectSoundBuffer8Vtbl *lpVtbl;
213 LONG ref;
214 IDirectSoundBufferImpl* dsb;
217 HRESULT SecondaryBufferImpl_Create(
218 IDirectSoundBufferImpl *dsb,
219 SecondaryBufferImpl **pdsb);
221 /*****************************************************************************
222 * PrimaryBuffer implementation structure
224 struct PrimaryBufferImpl
226 const IDirectSoundBuffer8Vtbl *lpVtbl;
227 LONG ref;
228 DirectSoundDevice* device;
231 HRESULT PrimaryBufferImpl_Create(
232 DirectSoundDevice * device,
233 PrimaryBufferImpl **ppdsb,
234 LPCDSBUFFERDESC dsbd);
236 /*****************************************************************************
237 * DirectSoundCaptureDevice implementation structure
239 struct DirectSoundCaptureDevice
241 /* IDirectSoundCaptureImpl fields */
242 GUID guid;
243 LONG ref;
245 /* DirectSound driver stuff */
246 PIDSCDRIVER driver;
247 DSDRIVERDESC drvdesc;
248 DSCDRIVERCAPS drvcaps;
249 PIDSCDRIVERBUFFER hwbuf;
251 /* wave driver info */
252 HWAVEIN hwi;
254 /* more stuff */
255 LPBYTE buffer;
256 DWORD buflen;
257 DWORD read_position;
259 PWAVEFORMATEX pwfx;
261 IDirectSoundCaptureBufferImpl* capture_buffer;
262 DWORD state;
263 LPWAVEHDR pwave;
264 int nrofpwaves;
265 int index;
266 CRITICAL_SECTION lock;
269 HRESULT DirectSoundCaptureDevice_Initialize(
270 DirectSoundCaptureDevice ** ppDevice,
271 LPCGUID lpcGUID);
272 ULONG DirectSoundCaptureDevice_Release(
273 DirectSoundCaptureDevice * device);
275 /*****************************************************************************
276 * IDirectSoundCaptureBuffer implementation structure
278 struct IDirectSoundCaptureBufferImpl
280 /* IUnknown fields */
281 const IDirectSoundCaptureBuffer8Vtbl *lpVtbl;
282 LONG ref;
284 /* IDirectSoundCaptureBufferImpl fields */
285 DirectSoundCaptureDevice* device;
286 /* FIXME: don't need this */
287 LPDSCBUFFERDESC pdscbd;
288 DWORD flags;
290 /* IDirectSoundCaptureNotifyImpl fields */
291 IDirectSoundCaptureNotifyImpl* notify;
292 LPDSBPOSITIONNOTIFY notifies;
293 int nrofnotifies;
294 PIDSDRIVERNOTIFY hwnotify;
297 HRESULT IDirectSoundCaptureBufferImpl_Create(
298 DirectSoundCaptureDevice *device,
299 IDirectSoundCaptureBufferImpl ** ppobj,
300 LPCDSCBUFFERDESC lpcDSCBufferDesc);
302 /*****************************************************************************
303 * IDirectSoundFullDuplex implementation structure
305 struct IDirectSoundFullDuplexImpl
307 /* IUnknown fields */
308 const IDirectSoundFullDuplexVtbl *lpVtbl;
309 LONG ref;
311 /* IDirectSoundFullDuplexImpl fields */
312 DirectSoundDevice *renderer_device;
313 DirectSoundCaptureDevice *capture_device;
315 LPUNKNOWN pUnknown;
316 LPDIRECTSOUND pDS;
317 LPDIRECTSOUND8 pDS8;
318 LPDIRECTSOUNDCAPTURE pDSC;
321 /*****************************************************************************
322 * IDirectSoundFullDuplex COM components
324 struct IDirectSoundFullDuplex_IUnknown {
325 const IUnknownVtbl *lpVtbl;
326 LONG ref;
327 IDirectSoundFullDuplexImpl *pdsfd;
330 struct IDirectSoundFullDuplex_IDirectSound {
331 const IDirectSoundVtbl *lpVtbl;
332 LONG ref;
333 IDirectSoundFullDuplexImpl *pdsfd;
336 struct IDirectSoundFullDuplex_IDirectSound8 {
337 const IDirectSound8Vtbl *lpVtbl;
338 LONG ref;
339 IDirectSoundFullDuplexImpl *pdsfd;
342 struct IDirectSoundFullDuplex_IDirectSoundCapture {
343 const IDirectSoundCaptureVtbl *lpVtbl;
344 LONG ref;
345 IDirectSoundFullDuplexImpl *pdsfd;
348 /*****************************************************************************
349 * IDirectSound3DListener implementation structure
351 struct IDirectSound3DListenerImpl
353 /* IUnknown fields */
354 const IDirectSound3DListenerVtbl *lpVtbl;
355 LONG ref;
356 /* IDirectSound3DListenerImpl fields */
357 DirectSoundDevice* device;
360 HRESULT IDirectSound3DListenerImpl_Create(
361 DirectSoundDevice *device,
362 IDirectSound3DListenerImpl **pdsl);
364 /*****************************************************************************
365 * IKsBufferPropertySet implementation structure
367 struct IKsBufferPropertySetImpl
369 /* IUnknown fields */
370 const IKsPropertySetVtbl *lpVtbl;
371 LONG ref;
372 /* IKsPropertySetImpl fields */
373 IDirectSoundBufferImpl* dsb;
376 HRESULT IKsBufferPropertySetImpl_Create(
377 IDirectSoundBufferImpl *dsb,
378 IKsBufferPropertySetImpl **piks);
379 HRESULT IKsBufferPropertySetImpl_Destroy(
380 IKsBufferPropertySetImpl *piks);
382 /*****************************************************************************
383 * IKsPrivatePropertySet implementation structure
385 struct IKsPrivatePropertySetImpl
387 /* IUnknown fields */
388 const IKsPropertySetVtbl *lpVtbl;
389 LONG ref;
392 HRESULT IKsPrivatePropertySetImpl_Create(
393 REFIID riid,
394 IKsPrivatePropertySetImpl **piks);
396 /*****************************************************************************
397 * IDirectSound3DBuffer implementation structure
399 struct IDirectSound3DBufferImpl
401 /* IUnknown fields */
402 const IDirectSound3DBufferVtbl *lpVtbl;
403 LONG ref;
404 /* IDirectSound3DBufferImpl fields */
405 IDirectSoundBufferImpl* dsb;
408 HRESULT IDirectSound3DBufferImpl_Create(
409 IDirectSoundBufferImpl *dsb,
410 IDirectSound3DBufferImpl **pds3db);
411 HRESULT IDirectSound3DBufferImpl_Destroy(
412 IDirectSound3DBufferImpl *pds3db);
414 /*******************************************************************************
417 /* dsound.c */
419 HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS);
420 HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS);
422 /* primary.c */
424 HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device);
425 HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device);
426 HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device);
427 HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device);
428 HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos);
429 HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex);
431 /* duplex.c */
433 HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX* ppDSFD);
435 /* buffer.c */
437 DWORD DSOUND_CalcPlayPosition(IDirectSoundBufferImpl *This, DWORD pplay, DWORD pwrite);
439 /* mixer.c */
441 void DSOUND_CheckEvent(IDirectSoundBufferImpl *dsb, int len);
442 void DSOUND_ForceRemix(IDirectSoundBufferImpl *dsb);
443 void DSOUND_MixCancelAt(IDirectSoundBufferImpl *dsb, DWORD buf_writepos);
444 void DSOUND_WaveQueue(DirectSoundDevice *device, DWORD mixq);
445 void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan);
446 void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan);
447 void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb);
448 void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2);
449 void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2);
451 /* sound3d.c */
453 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb);
455 /* capture.c */
457 HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC);
458 HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8);
459 HRESULT WINAPI IDirectSoundCaptureImpl_CreateCaptureBuffer(
460 LPDIRECTSOUNDCAPTURE iface,
461 LPCDSCBUFFERDESC lpcDSCBufferDesc,
462 LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
463 LPUNKNOWN pUnk);
464 HRESULT WINAPI IDirectSoundCaptureImpl_GetCaps(
465 LPDIRECTSOUNDCAPTURE iface,
466 LPDSCCAPS lpDSCCaps);
467 HRESULT WINAPI IDirectSoundCaptureImpl_Initialize(
468 LPDIRECTSOUNDCAPTURE iface,
469 LPCGUID lpcGUID);
471 #define STATE_STOPPED 0
472 #define STATE_STARTING 1
473 #define STATE_PLAYING 2
474 #define STATE_CAPTURING 2
475 #define STATE_STOPPING 3
477 #define DSOUND_FREQSHIFT (14)
479 extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
480 extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
482 extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS];
483 extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
485 HRESULT mmErr(UINT err);
486 void setup_dsound_options(void);
487 const char * dumpCooperativeLevel(DWORD level);