ReactOS  0.4.14-dev-337-gf981a68
dsound_private.h
Go to the documentation of this file.
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 #ifndef _DSOUND_PRIVATE_H_
23 #define _DSOUND_PRIVATE_H_
24 
25 #include <wine/config.h>
26 
27 #include <assert.h>
28 #include <math.h>
29 #include <stdarg.h>
30 
31 #define WIN32_NO_STATUS
32 #define _INC_WINDOWS
33 #define COM_NO_WINDOWS_H
34 
35 #define COBJMACROS
36 #define NONAMELESSSTRUCT
37 #define NONAMELESSUNION
38 
39 #include <windef.h>
40 #include <winbase.h>
41 #include <winnls.h>
42 #include <wingdi.h>
43 #include <winternl.h>
44 #include <objbase.h>
45 #include <audioclient.h>
46 #include <mmddk.h>
47 #include <dsound.h>
48 #include <dsconf.h>
49 #include <dsdriver.h>
50 #include <vfwmsgs.h>
51 
52 #include <wine/debug.h>
53 #include <wine/list.h>
54 
56 
57 /* Linux does not support better timing than 10ms */
58 #define DS_TIME_RES 2 /* Resolution of multimedia timer */
59 #define DS_TIME_DEL 10 /* Delay of multimedia timer callback, and duration of HEL fragment */
60 
61 /* direct sound hardware acceleration levels */
62 #define DS_HW_ACCEL_FULL 0 /* default on Windows 98 */
63 #define DS_HW_ACCEL_STANDARD 1 /* default on Windows 2000 */
64 #define DS_HW_ACCEL_BASIC 2
65 #define DS_HW_ACCEL_EMULATION 3
66 
72 extern int ds_hw_accel DECLSPEC_HIDDEN;
75 
76 /*****************************************************************************
77  * Predeclare the interface implementation structures
78  */
95 
96 /* dsound_convert.h */
97 typedef void (*bitsconvertfunc)(const void *, void *, UINT, UINT, INT, UINT, UINT);
98 extern const bitsconvertfunc convertbpp[5][4] DECLSPEC_HIDDEN;
99 typedef void (*mixfunc)(const void *, void *, unsigned);
100 extern const mixfunc mixfunctions[4] DECLSPEC_HIDDEN;
101 typedef void (*normfunc)(const void *, void *, unsigned);
102 extern const normfunc normfunctions[4] DECLSPEC_HIDDEN;
103 
104 /*****************************************************************************
105  * IDirectSoundDevice implementation structure
106  */
108 {
110 
117  HWAVEOUT hwo;
132 
134 
137 
138  /* DirectSound3DListener fields */
142 };
143 
144 /* reference counted buffer memory for duplicated buffer memory */
145 typedef struct BufferMemory
146 {
149  struct list buffers;
150 } BufferMemory;
151 
154  DirectSoundDevice ** ppDevice,
155  LPCGUID lpcGUID) DECLSPEC_HIDDEN;
165  LPCDSBUFFERDESC dsbd,
166  LPLPDIRECTSOUNDBUFFER ppdsb,
167  LPUNKNOWN lpunk,
168  BOOL from8) DECLSPEC_HIDDEN;
174  DirectSoundDevice * devcie,
175  HWND hwnd,
180  LPDWORD lpdwSpeakerConfig) DECLSPEC_HIDDEN;
185  LPDWORD pdwCertified) DECLSPEC_HIDDEN;
186 
187 /*****************************************************************************
188  * IDirectSoundBuffer implementation structure
189  */
191 {
192  IDirectSoundBuffer8 IDirectSoundBuffer8_iface;
193  LONG numIfaces; /* "in use interfaces" refcount */
195  /* IDirectSoundBufferImpl fields */
208  /* used for frequency conversion (PerfectPitch) */
210  /* used for mixing */
212 
213  /* IDirectSoundNotifyImpl fields */
218 
219  /* DirectSound3DBuffer fields */
224 
225  /* IKsPropertySet fields */
228  struct list entry;
229 };
230 
233  IDirectSoundBufferImpl **ppdsb,
239  IDirectSoundBufferImpl **ppdsb,
242 
243 /*****************************************************************************
244  * DirectSoundCaptureDevice implementation structure
245  */
247 {
248  /* IDirectSoundCaptureImpl fields */
251 
252  /* DirectSound driver stuff */
257 
258  /* wave driver info */
259  HWAVEIN hwi;
260 
261  /* more stuff */
264 
266 
271  int index;
273 };
274 
275 /*****************************************************************************
276  * IDirectSoundCaptureBuffer implementation structure
277  */
279 {
280  /* IUnknown fields */
281  const IDirectSoundCaptureBuffer8Vtbl *lpVtbl;
283 
284  /* IDirectSoundCaptureBufferImpl fields */
286  /* FIXME: don't need this */
289 
290  /* IDirectSoundCaptureNotifyImpl fields */
295 };
296 
297 /*****************************************************************************
298  * IDirectSound3DListener implementation structure
299  */
301 {
302  /* IUnknown fields */
303  const IDirectSound3DListenerVtbl *lpVtbl;
305  /* IDirectSound3DListenerImpl fields */
307 };
308 
312 
313 /*****************************************************************************
314  * IKsBufferPropertySet implementation structure
315  */
317 {
318  /* IUnknown fields */
319  const IKsPropertySetVtbl *lpVtbl;
321  /* IKsPropertySetImpl fields */
323 };
324 
330 
332 
333 /*****************************************************************************
334  * IDirectSound3DBuffer implementation structure
335  */
337 {
338  /* IUnknown fields */
339  const IDirectSound3DBufferVtbl *lpVtbl;
341  /* IDirectSound3DBufferImpl fields */
343 };
344 
350 
351 /*******************************************************************************
352  */
353 
354 /* dsound.c */
355 
358 
359 /* primary.c */
360 
361 DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign) DECLSPEC_HIDDEN;
370  const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN;
373 
374 /* duplex.c */
375 
377 
378 /* mixer.c */
380 void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len) DECLSPEC_HIDDEN;
384 void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen, BOOL inmixer) DECLSPEC_HIDDEN;
385 DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD* overshot) DECLSPEC_HIDDEN;
386 
388 void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN;
389 
390 /* sound3d.c */
391 
393 
394 /* capture.c */
395 
398 
399 #define STATE_STOPPED 0
400 #define STATE_STARTING 1
401 #define STATE_PLAYING 2
402 #define STATE_CAPTURING 2
403 #define STATE_STOPPING 3
404 
405 #define DSOUND_FREQSHIFT (20)
406 
409 
412 
416 
417 #endif /* _DSOUND_PRIVATE_H_ */
struct BufferMemory BufferMemory
const normfunc normfunctions[4]
int ds_snd_queue_min
Definition: dsound_main.c:75
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
GLint level
Definition: gl.h:1546
WINE_DEFAULT_DEBUG_CHANNEL(dsound)
HRESULT IKsBufferPropertySetImpl_Create(IDirectSoundBufferImpl *dsb, IKsBufferPropertySetImpl **piks) DECLSPEC_HIDDEN
Definition: buffer.c:1390
RTL_RWLOCK buffer_list_lock
IDirectSoundBufferImpl * dsb
IDirectSoundCaptureNotifyImpl * notify
#define REFIID
Definition: guiddef.h:118
void(* normfunc)(const void *, void *, unsigned)
HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos) DECLSPEC_HIDDEN
Definition: primary.c:402
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
HRESULT DirectSoundDevice_AddBuffer(DirectSoundDevice *device, IDirectSoundBufferImpl *pDSB) DECLSPEC_HIDDEN
Definition: dsound.c:1761
IDirectSoundNotifyImpl * notify
struct IDsCaptureDriver * PIDSCDRIVER
Definition: dsdriver.h:45
REFIID riid
Definition: precomp.h:44
int ds_emuldriver
Definition: dsound_main.c:72
void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN
Definition: sound3d.c:141
void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN
Definition: mixer.c:1011
DWORD DSOUND_bufpos_to_mixpos(const DirectSoundDevice *device, DWORD pos) DECLSPEC_HIDDEN
Definition: mixer.c:84
HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) DECLSPEC_HIDDEN
Definition: primary.c:73
void secondarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN
Definition: buffer.c:1113
#define INT
Definition: polytest.cpp:20
#define CALLBACK
Definition: compat.h:27
HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN
Definition: primary.c:460
HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice *device, LPDSCAPS lpDSCaps) DECLSPEC_HIDDEN
Definition: dsound.c:1272
PIDSDRIVERBUFFER hwbuf
HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb, const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN
Definition: primary.c:1223
DSDRIVERCAPS drvcaps
struct IDsDriverNotify * PIDSDRIVERNOTIFY
Definition: dsdriver.h:42
IDirectSoundBufferImpl ** buffers
const IDirectSound3DListenerVtbl * lpVtbl
const GLuint * buffers
Definition: glext.h:5916
HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC) DECLSPEC_HIDDEN
Definition: capture.c:1330
IDirectSound3DBufferImpl * ds3db
int ds_emuldriver DECLSPEC_HIDDEN
IDirectSound3DListenerImpl * listener
HRESULT IDirectSound3DBufferImpl_Destroy(IDirectSound3DBufferImpl *pds3db) DECLSPEC_HIDDEN
Definition: sound3d.c:709
HRESULT IDirectSound3DBufferImpl_Create(IDirectSoundBufferImpl *dsb, IDirectSound3DBufferImpl **pds3db) DECLSPEC_HIDDEN
Definition: sound3d.c:667
HRESULT IDirectSoundBufferImpl_Create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb, LPCDSBUFFERDESC dsbd) DECLSPEC_HIDDEN
Definition: buffer.c:931
PWAVEFORMATEX pwfx
const IDirectSound3DBufferVtbl * lpVtbl
HRESULT DirectSoundDevice_DuplicateSoundBuffer(DirectSoundDevice *device, LPDIRECTSOUNDBUFFER psb, LPLPDIRECTSOUNDBUFFER ppdsb) DECLSPEC_HIDDEN
Definition: dsound.c:1621
struct IDirectSoundFullDuplex * LPDIRECTSOUNDFULLDUPLEX
Definition: dsound.h:103
HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, IKsPropertySet **piks) DECLSPEC_HIDDEN
Definition: propset.c:615
DirectSoundCaptureDevice * device
DirectSoundDevice * device
HRESULT DirectSoundDevice_GetSpeakerConfig(DirectSoundDevice *device, LPDWORD lpdwSpeakerConfig) DECLSPEC_HIDDEN
Definition: dsound.c:1701
unsigned char * LPBYTE
Definition: typedefs.h:52
void setup_dsound_options(void) DECLSPEC_HIDDEN
Definition: dsound_main.c:101
HRESULT mmErr(UINT err) DECLSPEC_HIDDEN
Definition: dsound_main.c:44
LPDSBPOSITIONNOTIFY notifies
unsigned int BOOL
Definition: ntddk_ex.h:94
HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device) DECLSPEC_HIDDEN
Definition: primary.c:304
long LONG
Definition: pedump.c:60
Definition: devices.h:37
GUID DSOUND_capture_guids[MAXWAVEDRIVERS]
Definition: dsound_main.c:42
IDirectSoundBufferImpl * primary
HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS) DECLSPEC_HIDDEN
Definition: dsound.c:963
struct IDirectSoundCapture * LPDIRECTSOUNDCAPTURE8
Definition: dsound.h:94
static LPUNKNOWN
Definition: ndr_ole.c:49
IDirectSoundCaptureBufferImpl * capture_buffer
void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN
Definition: mixer.c:162
DirectSoundDevice * DSOUND_renderer[MAXWAVEDRIVERS]
Definition: dsound_main.c:40
struct IDirectSoundBuffer ** LPLPDIRECTSOUNDBUFFER
Definition: dsound.h:76
HRESULT DirectSoundDevice_VerifyCertification(DirectSoundDevice *device, LPDWORD pdwCertified) DECLSPEC_HIDDEN
Definition: dsound.c:1738
void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN
Definition: mixer.c:984
const IKsPropertySetVtbl * lpVtbl
HRESULT DirectSoundDevice_RemoveBuffer(DirectSoundDevice *device, IDirectSoundBufferImpl *pDSB) DECLSPEC_HIDDEN
Definition: dsound.c:1796
struct IDsDriver * PIDSDRIVER
Definition: dsdriver.h:33
bitsconvertfunc convert
void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN
Definition: mixer.c:46
const bitsconvertfunc convertbpp[5][4]
HRESULT IDirectSound3DListenerImpl_Create(DirectSoundDevice *device, IDirectSound3DListenerImpl **pdsl) DECLSPEC_HIDDEN
Definition: sound3d.c:1034
LONG HRESULT
Definition: typedefs.h:77
HRESULT DirectSoundDevice_SetSpeakerConfig(DirectSoundDevice *device, DWORD config) DECLSPEC_HIDDEN
Definition: dsound.c:1722
LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN
Definition: primary.c:437
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device) DECLSPEC_HIDDEN
Definition: primary.c:321
#define MAXWAVEDRIVERS
Definition: mmddk.h:33
HRESULT IDirectSoundBufferImpl_Destroy(IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN
Definition: buffer.c:1137
void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len) DECLSPEC_HIDDEN
Definition: mixer.c:221
HRESULT IDirectSoundBufferImpl_Duplicate(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb, IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN
Definition: buffer.c:1169
HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS) DECLSPEC_HIDDEN
Definition: dsound.c:1050
struct IDirectSound8 * LPDIRECTSOUND8
Definition: dsound.h:73
const mixfunc mixfunctions[4]
void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen, BOOL inmixer) DECLSPEC_HIDDEN
Definition: mixer.c:332
GLenum GLsizei len
Definition: glext.h:6722
IKsBufferPropertySetImpl * iks
Definition: _list.h:228
PIDSCDRIVERBUFFER hwbuf
DirectSoundDevice * device
#define err(...)
const char * dumpCooperativeLevel(DWORD level) DECLSPEC_HIDDEN
Definition: dsound.c:92
uint32_t DWORD_PTR
Definition: typedefs.h:63
HRESULT IKsBufferPropertySetImpl_Destroy(IKsBufferPropertySetImpl *piks) DECLSPEC_HIDDEN
Definition: buffer.c:1416
struct IDirectSoundCapture * LPDIRECTSOUNDCAPTURE
Definition: dsound.h:92
struct IDirectSoundBuffer * LPDIRECTSOUNDBUFFER
Definition: dsound.h:76
DS3DLISTENER ds3dl
HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8) DECLSPEC_HIDDEN
Definition: capture.c:1359
int ds_hel_buflen
Definition: dsound_main.c:73
int ds_default_sample_rate
Definition: dsound_main.c:78
DSDRIVERDESC drvdesc
DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign) DECLSPEC_HIDDEN
Definition: primary.c:36
struct IDsDriverBuffer * PIDSDRIVERBUFFER
Definition: dsdriver.h:36
HRESULT DirectSoundDevice_Compact(DirectSoundDevice *device) DECLSPEC_HIDDEN
Definition: dsound.c:1683
IDirectSoundBufferImpl * dsb
void primarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN
Definition: primary.c:763
PIDSDRIVERBUFFER hwbuf
CRITICAL_SECTION mixlock
unsigned int UINT
Definition: ndis.h:50
int ds_snd_queue_max
Definition: dsound_main.c:74
void(* mixfunc)(const void *, void *, unsigned)
HRESULT DirectSoundDevice_Initialize(DirectSoundDevice **ppDevice, LPCGUID lpcGUID) DECLSPEC_HIDDEN
Definition: dsound.c:1326
DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD *overshot) DECLSPEC_HIDDEN
Definition: mixer.c:99
IDirectSoundBuffer8 IDirectSoundBuffer8_iface
LPDSBPOSITIONNOTIFY notifies
void(* bitsconvertfunc)(const void *, void *, UINT, UINT, INT, UINT, UINT)
ULONG DirectSoundDevice_Release(DirectSoundDevice *device) DECLSPEC_HIDDEN
Definition: dsound.c:1216
struct IDirectSound * LPDIRECTSOUND
Definition: dsound.h:70
#define msg(x)
Definition: auth_time.c:54
PIDSDRIVERNOTIFY hwnotify
uint32_t * LPDWORD
Definition: typedefs.h:57
HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device) DECLSPEC_HIDDEN
Definition: primary.c:345
unsigned int ULONG
Definition: retypes.h:1
HRESULT DirectSoundDevice_CreateSoundBuffer(DirectSoundDevice *device, LPCDSBUFFERDESC dsbd, LPLPDIRECTSOUNDBUFFER ppdsb, LPUNKNOWN lpunk, BOOL from8) DECLSPEC_HIDDEN
Definition: dsound.c:1482
const IDirectSoundCaptureBuffer8Vtbl * lpVtbl
int ds_snd_shadow_maxsize
Definition: dsound_main.c:76
int ds_default_bits_per_sample
Definition: dsound_main.c:79
GUID DSOUND_renderer_guids[MAXWAVEDRIVERS]
Definition: dsound_main.c:41
struct IDsCaptureDriverBuffer * PIDSCDRIVERBUFFER
Definition: dsdriver.h:48
HRESULT DirectSoundDevice_SetCooperativeLevel(DirectSoundDevice *devcie, HWND hwnd, DWORD level) DECLSPEC_HIDDEN
Definition: dsound.c:1662
HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX *ppDSFD) DECLSPEC_HIDDEN
Definition: duplex.c:604
DSVOLUMEPAN volpan
HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device) DECLSPEC_HIDDEN
Definition: primary.c:363
DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS]
Definition: capture.c:965
void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN
Definition: mixer.c:27
int ds_hw_accel
Definition: dsound_main.c:77