dinput8: DirectInput8Create rewrite.
[wine] / dlls / dsound / dsound_private.h
1 /*                      DirectSound
2  *
3  * Copyright 1998 Marcus Meissner
4  * Copyright 1998 Rob Riggs
5  * Copyright 2000-2001 TransGaming Technologies, Inc.
6  *
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.
11  *
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.
16  *
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
20  */
21
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 */
25
26 #define DS_HEL_FRAGS 48 /* HEL only: number of waveOut fragments in primary buffer
27                          * (changing this won't help you) */
28
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
34
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;
45
46 /*****************************************************************************
47  * Predeclare the interface implementation structures
48  */
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 IClassFactoryImpl             IClassFactoryImpl;
72 typedef struct DirectSoundDevice             DirectSoundDevice;
73 typedef struct DirectSoundCaptureDevice      DirectSoundCaptureDevice;
74
75 /*****************************************************************************
76  * IDirectSound implementation structure
77  */
78 struct IDirectSoundImpl
79 {
80     LONG                        ref;
81
82     DirectSoundDevice          *device;
83     LPUNKNOWN                   pUnknown;
84     LPDIRECTSOUND               pDS;
85     LPDIRECTSOUND8              pDS8;
86 };
87
88 HRESULT IDirectSoundImpl_Create(
89     LPDIRECTSOUND8 * ppds);
90
91 /*****************************************************************************
92  * IDirectSoundDevice implementation structure
93  */
94 struct DirectSoundDevice
95 {
96     LONG                        ref;
97
98     GUID                        guid;
99     PIDSDRIVER                  driver;
100     DSDRIVERDESC                drvdesc;
101     DSDRIVERCAPS                drvcaps;
102     DWORD                       priolevel;
103     PWAVEFORMATEX               pwfx;
104     HWAVEOUT                    hwo;
105     LPWAVEHDR                   pwave[DS_HEL_FRAGS];
106     UINT                        timerID, pwplay, pwwrite, pwqueue, prebuf, precount;
107     DWORD                       fraglen;
108     PIDSDRIVERBUFFER            hwbuf;
109     LPBYTE                      buffer;
110     DWORD                       writelead, buflen, state, playpos, mixpos;
111     BOOL                        need_remix;
112     int                         nrofbuffers;
113     IDirectSoundBufferImpl**    buffers;
114     RTL_RWLOCK                  buffer_list_lock;
115     CRITICAL_SECTION            mixlock;
116     PrimaryBufferImpl*          primary;
117     DSBUFFERDESC                dsbd;
118     DWORD                       speaker_config;
119     LPBYTE                      tmp_buffer;
120     DWORD                       tmp_buffer_len;
121
122     /* DirectSound3DListener fields */
123     IDirectSound3DListenerImpl* listener;
124     DS3DLISTENER                ds3dl;
125     BOOL                        ds3dl_need_recalc;
126 };
127
128 /* reference counted buffer memory for duplicated buffer memory */
129 typedef struct BufferMemory
130 {
131     LONG                        ref;
132     LPBYTE                      memory;
133 } BufferMemory;
134
135 HRESULT DirectSoundDevice_Create(DirectSoundDevice ** ppDevice);
136 ULONG DirectSoundDevice_AddRef(DirectSoundDevice * device);
137 ULONG DirectSoundDevice_Release(DirectSoundDevice * device);
138 HRESULT DirectSoundDevice_Initialize(
139     DirectSoundDevice ** ppDevice,
140     LPCGUID lpcGUID);
141 HRESULT DirectSoundDevice_AddBuffer(
142     DirectSoundDevice * device,
143     IDirectSoundBufferImpl * pDSB);
144 HRESULT DirectSoundDevice_RemoveBuffer(
145     DirectSoundDevice * device,
146     IDirectSoundBufferImpl * pDSB);
147 HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice * device, LPDSCAPS lpDSCaps);
148 HRESULT DirectSoundDevice_CreateSoundBuffer(
149     DirectSoundDevice * device,
150     LPCDSBUFFERDESC dsbd,
151     LPLPDIRECTSOUNDBUFFER ppdsb,
152     LPUNKNOWN lpunk,
153     BOOL from8);
154 HRESULT DirectSoundDevice_DuplicateSoundBuffer(
155     DirectSoundDevice * device,
156     LPDIRECTSOUNDBUFFER psb,
157     LPLPDIRECTSOUNDBUFFER ppdsb);
158 HRESULT DirectSoundDevice_SetCooperativeLevel(
159     DirectSoundDevice * devcie,
160     HWND hwnd,
161     DWORD level);
162 HRESULT DirectSoundDevice_Compact(DirectSoundDevice * device);
163 HRESULT DirectSoundDevice_GetSpeakerConfig(
164     DirectSoundDevice * device,
165     LPDWORD lpdwSpeakerConfig);
166 HRESULT DirectSoundDevice_SetSpeakerConfig(
167     DirectSoundDevice * device,
168     DWORD config);
169 HRESULT DirectSoundDevice_VerifyCertification(
170     DirectSoundDevice * device,
171     LPDWORD pdwCertified);
172
173 /*****************************************************************************
174  * IDirectSound COM components
175  */
176 struct IDirectSound_IUnknown {
177     const IUnknownVtbl         *lpVtbl;
178     LONG                        ref;
179     LPDIRECTSOUND8              pds;
180 };
181
182 HRESULT IDirectSound_IUnknown_Create(
183     LPDIRECTSOUND8 pds,
184     LPUNKNOWN * ppunk);
185
186 struct IDirectSound_IDirectSound {
187     const IDirectSoundVtbl     *lpVtbl;
188     LONG                        ref;
189     LPDIRECTSOUND8              pds;
190 };
191
192 HRESULT IDirectSound_IDirectSound_Create(
193     LPDIRECTSOUND8 pds,
194     LPDIRECTSOUND * ppds);
195
196 /*****************************************************************************
197  * IDirectSound8 COM components
198  */
199 struct IDirectSound8_IUnknown {
200     const IUnknownVtbl         *lpVtbl;
201     LONG                        ref;
202     LPDIRECTSOUND8              pds;
203 };
204
205 HRESULT IDirectSound8_IUnknown_Create(
206     LPDIRECTSOUND8 pds,
207     LPUNKNOWN * ppunk);
208
209 struct IDirectSound8_IDirectSound {
210     const IDirectSoundVtbl     *lpVtbl;
211     LONG                        ref;
212     LPDIRECTSOUND8              pds;
213 };
214
215 HRESULT IDirectSound8_IDirectSound_Create(
216     LPDIRECTSOUND8 pds,
217     LPDIRECTSOUND * ppds);
218
219 struct IDirectSound8_IDirectSound8 {
220     const IDirectSound8Vtbl    *lpVtbl;
221     LONG                        ref;
222     LPDIRECTSOUND8              pds;
223 };
224
225 HRESULT IDirectSound8_IDirectSound8_Create(
226     LPDIRECTSOUND8 pds,
227     LPDIRECTSOUND8 * ppds);
228
229 /*****************************************************************************
230  * IDirectSoundBuffer implementation structure
231  */
232 struct IDirectSoundBufferImpl
233 {
234     /* FIXME: document */
235     /* IUnknown fields */
236     const IDirectSoundBuffer8Vtbl *lpVtbl;
237     LONG                        ref;
238     /* IDirectSoundBufferImpl fields */
239     SecondaryBufferImpl*        secondary;
240     DirectSoundDevice*          device;
241     CRITICAL_SECTION            lock;
242     PIDSDRIVERBUFFER            hwbuf;
243     PWAVEFORMATEX               pwfx;
244     BufferMemory*               buffer;
245     DWORD                       playflags,state,leadin;
246     DWORD                       playpos,startpos,writelead,buflen;
247     DWORD                       nAvgBytesPerSec;
248     DWORD                       freq;
249     DSVOLUMEPAN                 volpan, cvolpan;
250     DSBUFFERDESC                dsbd;
251     /* used for frequency conversion (PerfectPitch) */
252     ULONG                       freqAdjust, freqAcc;
253     /* used for intelligent (well, sort of) prebuffering */
254     DWORD                       probably_valid_to, last_playpos;
255     DWORD                       primary_mixpos, buf_mixpos;
256     BOOL                        need_remix;
257
258     /* IDirectSoundNotifyImpl fields */
259     IDirectSoundNotifyImpl*     notify;
260     LPDSBPOSITIONNOTIFY         notifies;
261     int                         nrofnotifies;
262     PIDSDRIVERNOTIFY            hwnotify;
263
264     /* DirectSound3DBuffer fields */
265     IDirectSound3DBufferImpl*   ds3db;
266     DS3DBUFFER                  ds3db_ds3db;
267     LONG                        ds3db_lVolume;
268     BOOL                        ds3db_need_recalc;
269
270     /* IKsPropertySet fields */
271     IKsBufferPropertySetImpl*   iks;
272 };
273
274 HRESULT IDirectSoundBufferImpl_Create(
275     DirectSoundDevice *device,
276     IDirectSoundBufferImpl **ppdsb,
277     LPCDSBUFFERDESC dsbd);
278 HRESULT IDirectSoundBufferImpl_Destroy(
279     IDirectSoundBufferImpl *pdsb);
280 HRESULT IDirectSoundBufferImpl_Duplicate(
281     DirectSoundDevice *device,
282     IDirectSoundBufferImpl **ppdsb,
283     IDirectSoundBufferImpl *pdsb);
284
285 /*****************************************************************************
286  * SecondaryBuffer implementation structure
287  */
288 struct SecondaryBufferImpl
289 {
290     const IDirectSoundBuffer8Vtbl *lpVtbl;
291     LONG                        ref;
292     IDirectSoundBufferImpl*     dsb;
293 };
294
295 HRESULT SecondaryBufferImpl_Create(
296     IDirectSoundBufferImpl *dsb,
297     SecondaryBufferImpl **pdsb);
298 HRESULT SecondaryBufferImpl_Destroy(
299     SecondaryBufferImpl *pdsb);
300
301 /*****************************************************************************
302  * PrimaryBuffer implementation structure
303  */
304 struct PrimaryBufferImpl
305 {
306     const IDirectSoundBuffer8Vtbl *lpVtbl;
307     LONG                        ref;
308     DirectSoundDevice*          device;
309 };
310
311 HRESULT PrimaryBufferImpl_Create(
312     DirectSoundDevice * device,
313     PrimaryBufferImpl **ppdsb,
314     LPCDSBUFFERDESC dsbd);
315
316 /*****************************************************************************
317  * IDirectSoundCapture implementation structure
318  */
319 struct IDirectSoundCaptureImpl
320 {
321     /* IUnknown fields */
322     const IDirectSoundCaptureVtbl     *lpVtbl;
323     LONG                               ref;
324
325     DirectSoundCaptureDevice          *device;
326 };
327
328 HRESULT IDirectSoundCaptureImpl_Create(
329     LPDIRECTSOUNDCAPTURE8 * ppds);
330
331 /*****************************************************************************
332  * DirectSoundCaptureDevice implementation structure
333  */
334 struct DirectSoundCaptureDevice
335 {
336     /* IDirectSoundCaptureImpl fields */
337     GUID                               guid;
338     LONG                               ref;
339
340     /* DirectSound driver stuff */
341     PIDSCDRIVER                        driver;
342     DSDRIVERDESC                       drvdesc;
343     DSCDRIVERCAPS                      drvcaps;
344     PIDSCDRIVERBUFFER                  hwbuf;
345
346     /* wave driver info */
347     HWAVEIN                            hwi;
348
349     /* more stuff */
350     LPBYTE                             buffer;
351     DWORD                              buflen;
352     DWORD                              read_position;
353
354     PWAVEFORMATEX                      pwfx;
355
356     IDirectSoundCaptureBufferImpl*     capture_buffer;
357     DWORD                              state;
358     LPWAVEHDR                          pwave;
359     int                                nrofpwaves;
360     int                                index;
361     CRITICAL_SECTION                   lock;
362 };
363
364 HRESULT DirectSoundCaptureDevice_Initialize(
365     DirectSoundCaptureDevice ** ppDevice,
366     LPCGUID lpcGUID);
367 ULONG DirectSoundCaptureDevice_Release(
368     DirectSoundCaptureDevice * device);
369
370 /*****************************************************************************
371  * IDirectSoundCaptureBuffer implementation structure
372  */
373 struct IDirectSoundCaptureBufferImpl
374 {
375     /* IUnknown fields */
376     const IDirectSoundCaptureBuffer8Vtbl *lpVtbl;
377     LONG                                ref;
378
379     /* IDirectSoundCaptureBufferImpl fields */
380     DirectSoundCaptureDevice*           device;
381     /* FIXME: don't need this */
382     LPDSCBUFFERDESC                     pdscbd;
383     DWORD                               flags;
384
385     /* IDirectSoundCaptureNotifyImpl fields */
386     IDirectSoundCaptureNotifyImpl*      notify;
387     LPDSBPOSITIONNOTIFY                 notifies;
388     int                                 nrofnotifies;
389     PIDSDRIVERNOTIFY                    hwnotify;
390 };
391
392 HRESULT IDirectSoundCaptureBufferImpl_Create(
393     DirectSoundCaptureDevice *device,
394     IDirectSoundCaptureBufferImpl ** ppobj,
395     LPCDSCBUFFERDESC lpcDSCBufferDesc);
396
397 /*****************************************************************************
398  * IDirectSoundFullDuplex implementation structure
399  */
400 struct IDirectSoundFullDuplexImpl
401 {
402     /* IUnknown fields */
403     const IDirectSoundFullDuplexVtbl *lpVtbl;
404     LONG                              ref;
405
406     /* IDirectSoundFullDuplexImpl fields */
407     DirectSoundDevice                *renderer_device;
408     DirectSoundCaptureDevice         *capture_device;
409
410     LPUNKNOWN                         pUnknown;
411     LPDIRECTSOUND                     pDS;
412     LPDIRECTSOUND8                    pDS8;
413     LPDIRECTSOUNDCAPTURE              pDSC;
414 };
415
416 /*****************************************************************************
417  * IDirectSoundFullDuplex COM components
418  */
419 struct IDirectSoundFullDuplex_IUnknown {
420     const IUnknownVtbl         *lpVtbl;
421     LONG                        ref;
422     IDirectSoundFullDuplexImpl *pdsfd;
423 };
424
425 struct IDirectSoundFullDuplex_IDirectSound {
426     const IDirectSoundVtbl     *lpVtbl;
427     LONG                        ref;
428     IDirectSoundFullDuplexImpl *pdsfd;
429 };
430
431 struct IDirectSoundFullDuplex_IDirectSound8 {
432     const IDirectSound8Vtbl    *lpVtbl;
433     LONG                        ref;
434     IDirectSoundFullDuplexImpl *pdsfd;
435 };
436
437 struct IDirectSoundFullDuplex_IDirectSoundCapture {
438     const IDirectSoundCaptureVtbl *lpVtbl;
439     LONG                           ref;
440     IDirectSoundFullDuplexImpl    *pdsfd;
441 };
442
443 /*****************************************************************************
444  * IDirectSoundNotify implementation structure
445  */
446 struct IDirectSoundNotifyImpl
447 {
448     /* IUnknown fields */
449     const IDirectSoundNotifyVtbl *lpVtbl;
450     LONG                        ref;
451     IDirectSoundBufferImpl*     dsb;
452 };
453
454 HRESULT IDirectSoundNotifyImpl_Create(
455     IDirectSoundBufferImpl *dsb,
456     IDirectSoundNotifyImpl **pdsn);
457 HRESULT IDirectSoundNotifyImpl_Destroy(
458     IDirectSoundNotifyImpl *pdsn);
459
460 /*****************************************************************************
461  * IDirectSoundCaptureNotify implementation structure
462  */
463 struct IDirectSoundCaptureNotifyImpl
464 {
465     /* IUnknown fields */
466     const IDirectSoundNotifyVtbl       *lpVtbl;
467     LONG                                ref;
468     IDirectSoundCaptureBufferImpl*      dscb;
469 };
470
471 HRESULT IDirectSoundCaptureNotifyImpl_Create(
472     IDirectSoundCaptureBufferImpl *dscb,
473     IDirectSoundCaptureNotifyImpl ** pdscn);
474
475 /*****************************************************************************
476  *  IDirectSound3DListener implementation structure
477  */
478 struct IDirectSound3DListenerImpl
479 {
480     /* IUnknown fields */
481     const IDirectSound3DListenerVtbl *lpVtbl;
482     LONG                        ref;
483     /* IDirectSound3DListenerImpl fields */
484     DirectSoundDevice*          device;
485 };
486
487 HRESULT IDirectSound3DListenerImpl_Create(
488     DirectSoundDevice           *device,
489     IDirectSound3DListenerImpl **pdsl);
490
491 /*****************************************************************************
492  *  IKsBufferPropertySet implementation structure
493  */
494 struct IKsBufferPropertySetImpl
495 {
496     /* IUnknown fields */
497     const IKsPropertySetVtbl   *lpVtbl;
498     LONG                        ref;
499     /* IKsPropertySetImpl fields */
500     IDirectSoundBufferImpl*     dsb;
501 };
502
503 HRESULT IKsBufferPropertySetImpl_Create(
504     IDirectSoundBufferImpl *dsb,
505     IKsBufferPropertySetImpl **piks);
506 HRESULT IKsBufferPropertySetImpl_Destroy(
507     IKsBufferPropertySetImpl *piks);
508
509 /*****************************************************************************
510  *  IKsPrivatePropertySet implementation structure
511  */
512 struct IKsPrivatePropertySetImpl
513 {
514     /* IUnknown fields */
515     const IKsPropertySetVtbl   *lpVtbl;
516     LONG                        ref;
517 };
518
519 HRESULT IKsPrivatePropertySetImpl_Create(
520     IKsPrivatePropertySetImpl **piks);
521
522 /*****************************************************************************
523  * IDirectSound3DBuffer implementation structure
524  */
525 struct IDirectSound3DBufferImpl
526 {
527     /* IUnknown fields */
528     const IDirectSound3DBufferVtbl *lpVtbl;
529     LONG                        ref;
530     /* IDirectSound3DBufferImpl fields */
531     IDirectSoundBufferImpl*     dsb;
532 };
533
534 HRESULT IDirectSound3DBufferImpl_Create(
535     IDirectSoundBufferImpl *dsb,
536     IDirectSound3DBufferImpl **pds3db);
537 HRESULT IDirectSound3DBufferImpl_Destroy(
538     IDirectSound3DBufferImpl *pds3db);
539
540 /*******************************************************************************
541  * DirectSound ClassFactory implementation structure
542  */
543 struct IClassFactoryImpl
544 {
545     /* IUnknown fields */
546     const IClassFactoryVtbl    *lpVtbl;
547     LONG                        ref;
548 };
549
550 extern IClassFactoryImpl DSOUND_CAPTURE_CF;
551 extern IClassFactoryImpl DSOUND_FULLDUPLEX_CF;
552
553 /*******************************************************************************
554  */
555
556 /* dsound.c */
557
558 HRESULT DSOUND_Create(LPDIRECTSOUND *ppDS, IUnknown *pUnkOuter);
559 HRESULT DSOUND_Create8(LPDIRECTSOUND8 *ppDS, IUnknown *pUnkOuter);
560
561 /* primary.c */
562
563 HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device);
564 HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device);
565 HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device);
566 HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device);
567 HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos);
568 HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex);
569
570 /* buffer.c */
571
572 DWORD DSOUND_CalcPlayPosition(IDirectSoundBufferImpl *This, DWORD pplay, DWORD pwrite);
573
574 /* mixer.c */
575
576 void DSOUND_CheckEvent(IDirectSoundBufferImpl *dsb, int len);
577 void DSOUND_ForceRemix(IDirectSoundBufferImpl *dsb);
578 void DSOUND_MixCancelAt(IDirectSoundBufferImpl *dsb, DWORD buf_writepos);
579 void DSOUND_WaveQueue(DirectSoundDevice *device, DWORD mixq);
580 void DSOUND_PerformMix(DirectSoundDevice *device);
581 void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan);
582 void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan);
583 void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb);
584 void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2);
585 void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2);
586
587 /* sound3d.c */
588
589 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb);
590
591 /* duplex.c */
592
593 HRESULT DSOUND_FullDuplexCreate(LPDIRECTSOUNDFULLDUPLEX* ppDSFD, IUnknown *pUnkOuter);
594
595 /* capture.c */
596
597 HRESULT WINAPI IDirectSoundCaptureImpl_CreateCaptureBuffer(
598     LPDIRECTSOUNDCAPTURE iface,
599     LPCDSCBUFFERDESC lpcDSCBufferDesc,
600     LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
601     LPUNKNOWN pUnk);
602 HRESULT WINAPI IDirectSoundCaptureImpl_GetCaps(
603     LPDIRECTSOUNDCAPTURE iface,
604     LPDSCCAPS lpDSCCaps);
605 HRESULT WINAPI IDirectSoundCaptureImpl_Initialize(
606     LPDIRECTSOUNDCAPTURE iface,
607     LPCGUID lpcGUID);
608
609 #define STATE_STOPPED   0
610 #define STATE_STARTING  1
611 #define STATE_PLAYING   2
612 #define STATE_CAPTURING 2
613 #define STATE_STOPPING  3
614
615 #define DSOUND_FREQSHIFT (14)
616
617 extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
618 extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
619
620 extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS];
621 extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
622
623 HRESULT mmErr(UINT err);
624 void setup_dsound_options(void);
625 const char * get_device_id(LPCGUID pGuid);
626 const char * dumpCooperativeLevel(DWORD level);