- fix some prototypes, remove dxroslayer from dsound
[reactos.git] / reactos / dll / directx / dsound / dsound_private.h
index 8772e09..221433f 100644 (file)
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "dxroslayer/dxros_layer.h"
-
 /* Linux does not support better timing than 10ms */
-#define DS_TIME_RES 10  /* Resolution of multimedia timer */
+#define DS_TIME_RES 2  /* Resolution of multimedia timer */
 #define DS_TIME_DEL 10  /* Delay of multimedia timer callback, and duration of HEL fragment */
 
-#define DS_HEL_FRAGS 48 /* HEL only: number of waveOut fragments in primary buffer
-                        * (changing this won't help you) */
+#include "wine/list.h"
 
-/* wine spec */
-#include "dxroslayer/dxros_layer.h"
 /* direct sound hardware acceleration levels */
 #define DS_HW_ACCEL_FULL        0      /* default on Windows 98 */
 #define DS_HW_ACCEL_STANDARD    1      /* default on Windows 2000 */
 #define DS_HW_ACCEL_EMULATION   3
 
 extern int ds_emuldriver;
-extern int ds_hel_margin;
-extern int ds_hel_queue;
+extern int ds_hel_buflen;
 extern int ds_snd_queue_max;
 extern int ds_snd_queue_min;
+extern int ds_snd_shadow_maxsize;
 extern int ds_hw_accel;
-extern int ds_default_playback;
-extern int ds_default_capture;
+extern int ds_default_sample_rate;
+extern int ds_default_bits_per_sample;
 
 /*****************************************************************************
  * Predeclare the interface implementation structures
@@ -58,6 +53,10 @@ typedef struct IDirectSoundBufferImpl        IDirectSoundBufferImpl;
 typedef struct IDirectSoundCaptureImpl       IDirectSoundCaptureImpl;
 typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
 typedef struct IDirectSoundFullDuplexImpl    IDirectSoundFullDuplexImpl;
+typedef struct IDirectSoundFullDuplex_IUnknown IDirectSoundFullDuplex_IUnknown;
+typedef struct IDirectSoundFullDuplex_IDirectSound IDirectSoundFullDuplex_IDirectSound;
+typedef struct IDirectSoundFullDuplex_IDirectSound8 IDirectSoundFullDuplex_IDirectSound8;
+typedef struct IDirectSoundFullDuplex_IDirectSoundCapture IDirectSoundFullDuplex_IDirectSoundCapture;
 typedef struct IDirectSoundNotifyImpl        IDirectSoundNotifyImpl;
 typedef struct IDirectSoundCaptureNotifyImpl IDirectSoundCaptureNotifyImpl;
 typedef struct IDirectSound3DListenerImpl    IDirectSound3DListenerImpl;
@@ -66,25 +65,20 @@ typedef struct IKsBufferPropertySetImpl      IKsBufferPropertySetImpl;
 typedef struct IKsPrivatePropertySetImpl     IKsPrivatePropertySetImpl;
 typedef struct PrimaryBufferImpl             PrimaryBufferImpl;
 typedef struct SecondaryBufferImpl           SecondaryBufferImpl;
-typedef struct IClassFactoryImpl             IClassFactoryImpl;
 typedef struct DirectSoundDevice             DirectSoundDevice;
 typedef struct DirectSoundCaptureDevice      DirectSoundCaptureDevice;
 
+/* dsound_convert.h */
+typedef void (*bitsconvertfunc)(const void *, void *, UINT, UINT, INT, UINT, UINT);
+extern const bitsconvertfunc convertbpp[4][4];
+typedef void (*mixfunc)(const void *, void *, unsigned);
+extern const mixfunc mixfunctions[4];
+typedef void (*normfunc)(const void *, void *, unsigned);
+extern const normfunc normfunctions[4];
+
 /*****************************************************************************
- * IDirectSound implementation structure
+ * IDirectSoundDevice implementation structure
  */
-struct IDirectSoundImpl
-{
-    /* IUnknown fields */
-    const IDirectSound8Vtbl    *lpVtbl;
-    LONG                        ref;
-
-    DirectSoundDevice          *device;
-    LPUNKNOWN                   pUnknown;
-    LPDIRECTSOUND               pDS;
-    LPDIRECTSOUND8              pDS8;
-};
-
 struct DirectSoundDevice
 {
     LONG                        ref;
@@ -96,13 +90,12 @@ struct DirectSoundDevice
     DWORD                       priolevel;
     PWAVEFORMATEX               pwfx;
     HWAVEOUT                    hwo;
-    LPWAVEHDR                   pwave[DS_HEL_FRAGS];
-    UINT                        timerID, pwplay, pwwrite, pwqueue, prebuf, precount;
+    LPWAVEHDR                   pwave;
+    UINT                        timerID, pwplay, pwqueue, prebuf, helfrags;
     DWORD                       fraglen;
     PIDSDRIVERBUFFER            hwbuf;
     LPBYTE                      buffer;
     DWORD                       writelead, buflen, state, playpos, mixpos;
-    BOOL                        need_remix;
     int                         nrofbuffers;
     IDirectSoundBufferImpl**    buffers;
     RTL_RWLOCK                  buffer_list_lock;
@@ -110,8 +103,13 @@ struct DirectSoundDevice
     PrimaryBufferImpl*          primary;
     DSBUFFERDESC                dsbd;
     DWORD                       speaker_config;
-    LPBYTE                      tmp_buffer;
-    DWORD                       tmp_buffer_len;
+    LPBYTE                      tmp_buffer, mix_buffer;
+    DWORD                       tmp_buffer_len, mix_buffer_len;
+
+    DSVOLUMEPAN                 volpan;
+
+    mixfunc mixfunction;
+    normfunc normfunction;
 
     /* DirectSound3DListener fields */
     IDirectSound3DListenerImpl*        listener;
@@ -124,74 +122,41 @@ typedef struct BufferMemory
 {
     LONG                        ref;
     LPBYTE                      memory;
+    struct list buffers;
 } BufferMemory;
 
-HRESULT WINAPI IDirectSoundImpl_Create(
-    LPDIRECTSOUND8 * ppds);
-
-HRESULT WINAPI DSOUND_Create(
-    LPDIRECTSOUND *ppDS,
-    IUnknown *pUnkOuter);
-
-HRESULT WINAPI DSOUND_Create8(
-    LPDIRECTSOUND8 *ppDS,
-    IUnknown *pUnkOuter);
-
-/*****************************************************************************
- * IDirectSound COM components
- */
-struct IDirectSound_IUnknown {
-    const IUnknownVtbl         *lpVtbl;
-    LONG                        ref;
-    LPDIRECTSOUND8              pds;
-};
-
-HRESULT WINAPI IDirectSound_IUnknown_Create(
-    LPDIRECTSOUND8 pds,
-    LPUNKNOWN * ppunk);
-
-struct IDirectSound_IDirectSound {
-    const IDirectSoundVtbl     *lpVtbl;
-    LONG                        ref;
-    LPDIRECTSOUND8              pds;
-};
-
-HRESULT WINAPI IDirectSound_IDirectSound_Create(
-    LPDIRECTSOUND8 pds,
-    LPDIRECTSOUND * ppds);
-
-/*****************************************************************************
- * IDirectSound8 COM components
- */
-struct IDirectSound8_IUnknown {
-    const IUnknownVtbl         *lpVtbl;
-    LONG                        ref;
-    LPDIRECTSOUND8              pds;
-};
-
-HRESULT WINAPI IDirectSound8_IUnknown_Create(
-    LPDIRECTSOUND8 pds,
-    LPUNKNOWN * ppunk);
-
-struct IDirectSound8_IDirectSound {
-    const IDirectSoundVtbl     *lpVtbl;
-    LONG                        ref;
-    LPDIRECTSOUND8              pds;
-};
-
-HRESULT WINAPI IDirectSound8_IDirectSound_Create(
-    LPDIRECTSOUND8 pds,
-    LPDIRECTSOUND * ppds);
-
-struct IDirectSound8_IDirectSound8 {
-    const IDirectSound8Vtbl    *lpVtbl;
-    LONG                        ref;
-    LPDIRECTSOUND8              pds;
-};
-
-HRESULT WINAPI IDirectSound8_IDirectSound8_Create(
-    LPDIRECTSOUND8 pds,
-    LPDIRECTSOUND8 * ppds);
+ULONG DirectSoundDevice_Release(DirectSoundDevice * device);
+HRESULT DirectSoundDevice_Initialize(
+    DirectSoundDevice ** ppDevice,
+    LPCGUID lpcGUID);
+HRESULT DirectSoundDevice_AddBuffer(
+    DirectSoundDevice * device,
+    IDirectSoundBufferImpl * pDSB);
+HRESULT DirectSoundDevice_RemoveBuffer(
+    DirectSoundDevice * device,
+    IDirectSoundBufferImpl * pDSB);
+HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice * device, LPDSCAPS lpDSCaps);
+HRESULT DirectSoundDevice_CreateSoundBuffer(
+    DirectSoundDevice * device,
+    LPCDSBUFFERDESC dsbd,
+    LPLPDIRECTSOUNDBUFFER ppdsb,
+    LPUNKNOWN lpunk,
+    BOOL from8);
+HRESULT DirectSoundDevice_DuplicateSoundBuffer(
+    DirectSoundDevice * device,
+    LPDIRECTSOUNDBUFFER psb,
+    LPLPDIRECTSOUNDBUFFER ppdsb);
+HRESULT DirectSoundDevice_SetCooperativeLevel(
+    DirectSoundDevice * devcie,
+    HWND hwnd,
+    DWORD level);
+HRESULT DirectSoundDevice_Compact(DirectSoundDevice * device);
+HRESULT DirectSoundDevice_GetSpeakerConfig(
+    DirectSoundDevice * device,
+    LPDWORD lpdwSpeakerConfig);
+HRESULT DirectSoundDevice_SetSpeakerConfig(
+    DirectSoundDevice * device,
+    DWORD config);
 
 /*****************************************************************************
  * IDirectSoundBuffer implementation structure
@@ -203,24 +168,23 @@ struct IDirectSoundBufferImpl
     const IDirectSoundBuffer8Vtbl *lpVtbl;
     LONG                        ref;
     /* IDirectSoundBufferImpl fields */
-    SecondaryBufferImpl*        dsb;
-    IDirectSoundImpl*           dsound;
-    CRITICAL_SECTION            lock;
+    SecondaryBufferImpl*        secondary;
+    DirectSoundDevice*          device;
+    RTL_RWLOCK                  lock;
     PIDSDRIVERBUFFER            hwbuf;
     PWAVEFORMATEX               pwfx;
     BufferMemory*               buffer;
+    LPBYTE                      tmp_buffer;
     DWORD                       playflags,state,leadin;
-    DWORD                       playpos,startpos,writelead,buflen;
+    DWORD                       writelead,buflen;
     DWORD                       nAvgBytesPerSec;
-    DWORD                       freq;
-    DSVOLUMEPAN                 volpan, cvolpan;
+    DWORD                       freq, tmp_buffer_len, max_buffer_len;
+    DSVOLUMEPAN                 volpan;
     DSBUFFERDESC                dsbd;
     /* used for frequency conversion (PerfectPitch) */
-    ULONG                       freqAdjust, freqAcc;
-    /* used for intelligent (well, sort of) prebuffering */
-    DWORD                       probably_valid_to, last_playpos;
-    DWORD                       primary_mixpos, buf_mixpos;
-    BOOL                        need_remix;
+    ULONG                       freqneeded, freqAdjust, freqAcc, freqAccNext, resampleinmixer;
+    /* used for mixing */
+    DWORD                       primary_mixpos, buf_mixpos, sec_mixpos;
 
     /* IDirectSoundNotifyImpl fields */
     IDirectSoundNotifyImpl*     notify;
@@ -236,13 +200,19 @@ struct IDirectSoundBufferImpl
 
     /* IKsPropertySet fields */
     IKsBufferPropertySetImpl*   iks;
+    bitsconvertfunc convert;
+    struct list entry;
 };
 
-HRESULT WINAPI IDirectSoundBufferImpl_Create(
-    IDirectSoundImpl *ds,
-    IDirectSoundBufferImpl **pdsb,
+HRESULT IDirectSoundBufferImpl_Create(
+    DirectSoundDevice *device,
+    IDirectSoundBufferImpl **ppdsb,
     LPCDSBUFFERDESC dsbd);
-HRESULT WINAPI IDirectSoundBufferImpl_Destroy(
+HRESULT IDirectSoundBufferImpl_Destroy(
+    IDirectSoundBufferImpl *pdsb);
+HRESULT IDirectSoundBufferImpl_Duplicate(
+    DirectSoundDevice *device,
+    IDirectSoundBufferImpl **ppdsb,
     IDirectSoundBufferImpl *pdsb);
 
 /*****************************************************************************
@@ -255,39 +225,28 @@ struct SecondaryBufferImpl
     IDirectSoundBufferImpl*     dsb;
 };
 
-HRESULT WINAPI SecondaryBufferImpl_Create(
+HRESULT SecondaryBufferImpl_Create(
     IDirectSoundBufferImpl *dsb,
     SecondaryBufferImpl **pdsb);
-HRESULT WINAPI SecondaryBufferImpl_Destroy(
-    SecondaryBufferImpl *pdsb);
 
 /*****************************************************************************
  * PrimaryBuffer implementation structure
  */
 struct PrimaryBufferImpl
 {
-    const IDirectSoundBuffer8Vtbl *lpVtbl;
+    const IDirectSoundBufferVtbl *lpVtbl;
     LONG                        ref;
-    IDirectSoundImpl*           dsound;
+    DirectSoundDevice*          device;
 };
 
-HRESULT WINAPI PrimaryBufferImpl_Create(
-    IDirectSoundImpl *ds,
-    PrimaryBufferImpl **pdsb,
+HRESULT PrimaryBufferImpl_Create(
+    DirectSoundDevice * device,
+    PrimaryBufferImpl **ppdsb,
     LPCDSBUFFERDESC dsbd);
 
 /*****************************************************************************
- * IDirectSoundCapture implementation structure
+ * DirectSoundCaptureDevice implementation structure
  */
-struct IDirectSoundCaptureImpl
-{
-    /* IUnknown fields */
-    const IDirectSoundCaptureVtbl     *lpVtbl;
-    LONG                               ref;
-
-    DirectSoundCaptureDevice          *device;
-};
-
 struct DirectSoundCaptureDevice
 {
     /* IDirectSoundCaptureImpl fields */
@@ -306,7 +265,6 @@ struct DirectSoundCaptureDevice
     /* more stuff */
     LPBYTE                             buffer;
     DWORD                              buflen;
-    DWORD                              read_position;
 
     PWAVEFORMATEX                      pwfx;
 
@@ -318,16 +276,11 @@ struct DirectSoundCaptureDevice
     CRITICAL_SECTION                   lock;
 };
 
-HRESULT WINAPI IDirectSoundCaptureImpl_Create(
-    LPDIRECTSOUNDCAPTURE8 * ppds);
-
-HRESULT WINAPI DSOUND_CaptureCreate(
-    LPDIRECTSOUNDCAPTURE *ppDSC,
-    IUnknown *pUnkOuter);
-
-HRESULT WINAPI DSOUND_CaptureCreate8(
-    LPDIRECTSOUNDCAPTURE8 *ppDSC8,
-    IUnknown *pUnkOuter);
+HRESULT DirectSoundCaptureDevice_Initialize(
+    DirectSoundCaptureDevice ** ppDevice,
+    LPCGUID lpcGUID);
+ULONG DirectSoundCaptureDevice_Release(
+    DirectSoundCaptureDevice * device);
 
 /*****************************************************************************
  * IDirectSoundCaptureBuffer implementation structure
@@ -339,7 +292,7 @@ struct IDirectSoundCaptureBufferImpl
     LONG                                ref;
 
     /* IDirectSoundCaptureBufferImpl fields */
-    IDirectSoundCaptureImpl*            dsound;
+    DirectSoundCaptureDevice*           device;
     /* FIXME: don't need this */
     LPDSCBUFFERDESC                     pdscbd;
     DWORD                               flags;
@@ -351,6 +304,11 @@ struct IDirectSoundCaptureBufferImpl
     PIDSDRIVERNOTIFY                    hwnotify;
 };
 
+HRESULT IDirectSoundCaptureBufferImpl_Create(
+    DirectSoundCaptureDevice *device,
+    IDirectSoundCaptureBufferImpl ** ppobj,
+    LPCDSCBUFFERDESC lpcDSCBufferDesc);
+
 /*****************************************************************************
  * IDirectSoundFullDuplex implementation structure
  */
@@ -358,43 +316,44 @@ struct IDirectSoundFullDuplexImpl
 {
     /* IUnknown fields */
     const IDirectSoundFullDuplexVtbl *lpVtbl;
-    LONG                        ref;
+    LONG                              ref;
 
     /* IDirectSoundFullDuplexImpl fields */
-    CRITICAL_SECTION            lock;
+    DirectSoundDevice                *renderer_device;
+    DirectSoundCaptureDevice         *capture_device;
+
+    LPUNKNOWN                         pUnknown;
+    LPDIRECTSOUND                     pDS;
+    LPDIRECTSOUND8                    pDS8;
+    LPDIRECTSOUNDCAPTURE              pDSC;
 };
 
 /*****************************************************************************
- * IDirectSoundNotify implementation structure
+ * IDirectSoundFullDuplex COM components
  */
-struct IDirectSoundNotifyImpl
-{
-    /* IUnknown fields */
-    const IDirectSoundNotifyVtbl *lpVtbl;
+struct IDirectSoundFullDuplex_IUnknown {
+    const IUnknownVtbl         *lpVtbl;
     LONG                        ref;
-    IDirectSoundBufferImpl*     dsb;
+    IDirectSoundFullDuplexImpl *pdsfd;
 };
 
-HRESULT WINAPI IDirectSoundNotifyImpl_Create(
-    IDirectSoundBufferImpl *dsb,
-    IDirectSoundNotifyImpl **pdsn);
-HRESULT WINAPI IDirectSoundNotifyImpl_Destroy(
-    IDirectSoundNotifyImpl *pdsn);
+struct IDirectSoundFullDuplex_IDirectSound {
+    const IDirectSoundVtbl     *lpVtbl;
+    LONG                        ref;
+    IDirectSoundFullDuplexImpl *pdsfd;
+};
 
-/*****************************************************************************
- * IDirectSoundCaptureNotify implementation structure
- */
-struct IDirectSoundCaptureNotifyImpl
-{
-    /* IUnknown fields */
-    const IDirectSoundNotifyVtbl       *lpVtbl;
-    LONG                                ref;
-    IDirectSoundCaptureBufferImpl*      dscb;
+struct IDirectSoundFullDuplex_IDirectSound8 {
+    const IDirectSound8Vtbl    *lpVtbl;
+    LONG                        ref;
+    IDirectSoundFullDuplexImpl *pdsfd;
 };
 
-HRESULT WINAPI IDirectSoundCaptureNotifyImpl_Create(
-    IDirectSoundCaptureBufferImpl *dscb,
-    IDirectSoundCaptureNotifyImpl ** pdscn);
+struct IDirectSoundFullDuplex_IDirectSoundCapture {
+    const IDirectSoundCaptureVtbl *lpVtbl;
+    LONG                           ref;
+    IDirectSoundFullDuplexImpl    *pdsfd;
+};
 
 /*****************************************************************************
  *  IDirectSound3DListener implementation structure
@@ -405,11 +364,11 @@ struct IDirectSound3DListenerImpl
     const IDirectSound3DListenerVtbl *lpVtbl;
     LONG                        ref;
     /* IDirectSound3DListenerImpl fields */
-    IDirectSoundImpl*           dsound;
+    DirectSoundDevice*          device;
 };
 
-HRESULT WINAPI IDirectSound3DListenerImpl_Create(
-    PrimaryBufferImpl *pb,
+HRESULT IDirectSound3DListenerImpl_Create(
+    DirectSoundDevice           *device,
     IDirectSound3DListenerImpl **pdsl);
 
 /*****************************************************************************
@@ -424,10 +383,10 @@ struct IKsBufferPropertySetImpl
     IDirectSoundBufferImpl*    dsb;
 };
 
-HRESULT WINAPI IKsBufferPropertySetImpl_Create(
+HRESULT IKsBufferPropertySetImpl_Create(
     IDirectSoundBufferImpl *dsb,
     IKsBufferPropertySetImpl **piks);
-HRESULT WINAPI IKsBufferPropertySetImpl_Destroy(
+HRESULT IKsBufferPropertySetImpl_Destroy(
     IKsBufferPropertySetImpl *piks);
 
 /*****************************************************************************
@@ -440,7 +399,8 @@ struct IKsPrivatePropertySetImpl
     LONG                       ref;
 };
 
-HRESULT WINAPI IKsPrivatePropertySetImpl_Create(
+HRESULT IKsPrivatePropertySetImpl_Create(
+    REFIID riid,
     IKsPrivatePropertySetImpl **piks);
 
 /*****************************************************************************
@@ -455,67 +415,74 @@ struct IDirectSound3DBufferImpl
     IDirectSoundBufferImpl*     dsb;
 };
 
-HRESULT WINAPI IDirectSound3DBufferImpl_Create(
+HRESULT IDirectSound3DBufferImpl_Create(
     IDirectSoundBufferImpl *dsb,
     IDirectSound3DBufferImpl **pds3db);
-HRESULT WINAPI IDirectSound3DBufferImpl_Destroy(
+HRESULT IDirectSound3DBufferImpl_Destroy(
     IDirectSound3DBufferImpl *pds3db);
 
 /*******************************************************************************
- * DirectSound ClassFactory implementation structure
  */
-struct IClassFactoryImpl
-{
-    /* IUnknown fields */
-    const IClassFactoryVtbl    *lpVtbl;
-    LONG                        ref;
-};
-
-extern IClassFactoryImpl DSOUND_CAPTURE_CF;
-extern IClassFactoryImpl DSOUND_FULLDUPLEX_CF;
-
-void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan);
-void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan);
-void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb);
 
 /* dsound.c */
 
-HRESULT DSOUND_AddBuffer(IDirectSoundImpl * pDS, IDirectSoundBufferImpl * pDSB);
-HRESULT DSOUND_RemoveBuffer(IDirectSoundImpl * pDS, IDirectSoundBufferImpl * pDSB);
+HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS);
+HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS);
 
 /* primary.c */
 
+DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign);
 HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device);
 HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device);
 HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device);
 HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device);
 HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos);
+HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex, BOOL forced);
+HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave);
 
-/* buffer.c */
-
-DWORD DSOUND_CalcPlayPosition(IDirectSoundBufferImpl *This, DWORD pplay, DWORD pwrite);
+/* duplex.c */
+HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX* ppDSFD);
 
 /* mixer.c */
+DWORD DSOUND_bufpos_to_mixpos(const DirectSoundDevice* device, DWORD pos);
+void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len);
+void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan);
+void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan);
+void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb);
+void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen, BOOL inmixer);
+DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD* overshot);
 
-void DSOUND_CheckEvent(IDirectSoundBufferImpl *dsb, int len);
-void DSOUND_ForceRemix(IDirectSoundBufferImpl *dsb);
-void DSOUND_MixCancelAt(IDirectSoundBufferImpl *dsb, DWORD buf_writepos);
-void DSOUND_WaveQueue(DirectSoundDevice *device, DWORD mixq);
-void DSOUND_PerformMix(DirectSoundDevice *device);
-void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2);
-void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2);
+void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
+void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
 
 /* sound3d.c */
 
 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb);
 
+/* capture.c */
+HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC);
+HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8);
+HRESULT WINAPI IDirectSoundCaptureImpl_CreateCaptureBuffer(
+    LPDIRECTSOUNDCAPTURE iface,
+    LPCDSCBUFFERDESC lpcDSCBufferDesc,
+    LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
+    LPUNKNOWN pUnk);
+HRESULT WINAPI IDirectSoundCaptureImpl_GetCaps(
+    LPDIRECTSOUNDCAPTURE iface,
+    LPDSCCAPS lpDSCCaps);
+HRESULT WINAPI IDirectSoundCaptureImpl_Initialize(
+    LPDIRECTSOUNDCAPTURE iface,
+    LPCGUID lpcGUID);
+
 #define STATE_STOPPED   0
 #define STATE_STARTING  1
 #define STATE_PLAYING   2
 #define STATE_CAPTURING 2
 #define STATE_STOPPING  3
 
-#define DSOUND_FREQSHIFT (14)
+#define DSOUND_FREQSHIFT (20)
 
 extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
 extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
@@ -523,6 +490,6 @@ extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
 extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS];
 extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
 
-extern HRESULT mmErr(UINT err);
-extern void setup_dsound_options(void);
-extern const char * get_device_id(LPCGUID pGuid);
+HRESULT mmErr(UINT err);
+void setup_dsound_options(void);
+const char * dumpCooperativeLevel(DWORD level);