tools: Preserve ordinal when updating specfiles.
[wine/multimedia.git] / dlls / dsound / dsound_private.h
blob3e17301d85666ecb008af507e1bc0be3ba8059a0
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 #include "wine/list.h"
28 /* direct sound hardware acceleration levels */
29 #define DS_HW_ACCEL_FULL 0 /* default on Windows 98 */
30 #define DS_HW_ACCEL_STANDARD 1 /* default on Windows 2000 */
31 #define DS_HW_ACCEL_BASIC 2
32 #define DS_HW_ACCEL_EMULATION 3
34 extern int ds_emuldriver DECLSPEC_HIDDEN;
35 extern int ds_hel_buflen DECLSPEC_HIDDEN;
36 extern int ds_snd_queue_max DECLSPEC_HIDDEN;
37 extern int ds_snd_queue_min DECLSPEC_HIDDEN;
38 extern int ds_snd_shadow_maxsize DECLSPEC_HIDDEN;
39 extern int ds_hw_accel DECLSPEC_HIDDEN;
40 extern int ds_default_sample_rate DECLSPEC_HIDDEN;
41 extern int ds_default_bits_per_sample DECLSPEC_HIDDEN;
43 /*****************************************************************************
44 * Predeclare the interface implementation structures
46 typedef struct IDirectSoundImpl IDirectSoundImpl;
47 typedef struct IDirectSound_IUnknown IDirectSound_IUnknown;
48 typedef struct IDirectSound_IDirectSound IDirectSound_IDirectSound;
49 typedef struct IDirectSound8_IUnknown IDirectSound8_IUnknown;
50 typedef struct IDirectSound8_IDirectSound IDirectSound8_IDirectSound;
51 typedef struct IDirectSound8_IDirectSound8 IDirectSound8_IDirectSound8;
52 typedef struct IDirectSoundBufferImpl IDirectSoundBufferImpl;
53 typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl;
54 typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
55 typedef struct IDirectSoundNotifyImpl IDirectSoundNotifyImpl;
56 typedef struct IDirectSoundCaptureNotifyImpl IDirectSoundCaptureNotifyImpl;
57 typedef struct IDirectSound3DListenerImpl IDirectSound3DListenerImpl;
58 typedef struct IDirectSound3DBufferImpl IDirectSound3DBufferImpl;
59 typedef struct IKsBufferPropertySetImpl IKsBufferPropertySetImpl;
60 typedef struct PrimaryBufferImpl PrimaryBufferImpl;
61 typedef struct SecondaryBufferImpl SecondaryBufferImpl;
62 typedef struct DirectSoundDevice DirectSoundDevice;
63 typedef struct DirectSoundCaptureDevice DirectSoundCaptureDevice;
65 /* dsound_convert.h */
66 typedef void (*bitsconvertfunc)(const void *, void *, UINT, UINT, INT, UINT, UINT);
67 extern const bitsconvertfunc convertbpp[5][4] DECLSPEC_HIDDEN;
68 typedef void (*mixfunc)(const void *, void *, unsigned);
69 extern const mixfunc mixfunctions[4] DECLSPEC_HIDDEN;
70 typedef void (*normfunc)(const void *, void *, unsigned);
71 extern const normfunc normfunctions[4] DECLSPEC_HIDDEN;
73 /*****************************************************************************
74 * IDirectSoundDevice implementation structure
76 struct DirectSoundDevice
78 LONG ref;
80 GUID guid;
81 PIDSDRIVER driver;
82 DSDRIVERDESC drvdesc;
83 DSDRIVERCAPS drvcaps;
84 DWORD priolevel;
85 PWAVEFORMATEX pwfx;
86 HWAVEOUT hwo;
87 LPWAVEHDR pwave;
88 UINT timerID, pwplay, pwqueue, prebuf, helfrags;
89 DWORD fraglen;
90 PIDSDRIVERBUFFER hwbuf;
91 LPBYTE buffer;
92 DWORD writelead, buflen, state, playpos, mixpos;
93 int nrofbuffers;
94 IDirectSoundBufferImpl** buffers;
95 RTL_RWLOCK buffer_list_lock;
96 CRITICAL_SECTION mixlock;
97 PrimaryBufferImpl* primary;
98 DSBUFFERDESC dsbd;
99 DWORD speaker_config;
100 LPBYTE tmp_buffer, mix_buffer;
101 DWORD tmp_buffer_len, mix_buffer_len;
103 DSVOLUMEPAN volpan;
105 mixfunc mixfunction;
106 normfunc normfunction;
108 /* DirectSound3DListener fields */
109 IDirectSound3DListenerImpl* listener;
110 DS3DLISTENER ds3dl;
111 BOOL ds3dl_need_recalc;
114 /* reference counted buffer memory for duplicated buffer memory */
115 typedef struct BufferMemory
117 LONG ref;
118 LPBYTE memory;
119 struct list buffers;
120 } BufferMemory;
122 ULONG DirectSoundDevice_Release(DirectSoundDevice * device) DECLSPEC_HIDDEN;
123 HRESULT DirectSoundDevice_Initialize(
124 DirectSoundDevice ** ppDevice,
125 LPCGUID lpcGUID) DECLSPEC_HIDDEN;
126 HRESULT DirectSoundDevice_AddBuffer(
127 DirectSoundDevice * device,
128 IDirectSoundBufferImpl * pDSB) DECLSPEC_HIDDEN;
129 HRESULT DirectSoundDevice_RemoveBuffer(
130 DirectSoundDevice * device,
131 IDirectSoundBufferImpl * pDSB) DECLSPEC_HIDDEN;
132 HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice * device, LPDSCAPS lpDSCaps) DECLSPEC_HIDDEN;
133 HRESULT DirectSoundDevice_CreateSoundBuffer(
134 DirectSoundDevice * device,
135 LPCDSBUFFERDESC dsbd,
136 LPLPDIRECTSOUNDBUFFER ppdsb,
137 LPUNKNOWN lpunk,
138 BOOL from8) DECLSPEC_HIDDEN;
139 HRESULT DirectSoundDevice_DuplicateSoundBuffer(
140 DirectSoundDevice * device,
141 LPDIRECTSOUNDBUFFER psb,
142 LPLPDIRECTSOUNDBUFFER ppdsb) DECLSPEC_HIDDEN;
143 HRESULT DirectSoundDevice_SetCooperativeLevel(
144 DirectSoundDevice * devcie,
145 HWND hwnd,
146 DWORD level) DECLSPEC_HIDDEN;
147 HRESULT DirectSoundDevice_Compact(DirectSoundDevice * device) DECLSPEC_HIDDEN;
148 HRESULT DirectSoundDevice_GetSpeakerConfig(
149 DirectSoundDevice * device,
150 LPDWORD lpdwSpeakerConfig) DECLSPEC_HIDDEN;
151 HRESULT DirectSoundDevice_SetSpeakerConfig(
152 DirectSoundDevice * device,
153 DWORD config) DECLSPEC_HIDDEN;
154 HRESULT DirectSoundDevice_VerifyCertification(DirectSoundDevice * device,
155 LPDWORD pdwCertified) DECLSPEC_HIDDEN;
157 /*****************************************************************************
158 * IDirectSoundBuffer implementation structure
160 struct IDirectSoundBufferImpl
162 /* FIXME: document */
163 /* IUnknown fields */
164 const IDirectSoundBuffer8Vtbl *lpVtbl;
165 LONG ref;
166 /* IDirectSoundBufferImpl fields */
167 SecondaryBufferImpl* secondary;
168 DirectSoundDevice* device;
169 RTL_RWLOCK lock;
170 PIDSDRIVERBUFFER hwbuf;
171 PWAVEFORMATEX pwfx;
172 BufferMemory* buffer;
173 LPBYTE tmp_buffer;
174 DWORD playflags,state,leadin;
175 DWORD writelead,buflen;
176 DWORD nAvgBytesPerSec;
177 DWORD freq, tmp_buffer_len, max_buffer_len;
178 DSVOLUMEPAN volpan;
179 DSBUFFERDESC dsbd;
180 /* used for frequency conversion (PerfectPitch) */
181 ULONG freqneeded, freqAdjust, freqAcc, freqAccNext, resampleinmixer;
182 /* used for mixing */
183 DWORD primary_mixpos, buf_mixpos, sec_mixpos;
185 /* IDirectSoundNotifyImpl fields */
186 IDirectSoundNotifyImpl* notify;
187 LPDSBPOSITIONNOTIFY notifies;
188 int nrofnotifies;
189 PIDSDRIVERNOTIFY hwnotify;
191 /* DirectSound3DBuffer fields */
192 IDirectSound3DBufferImpl* ds3db;
193 DS3DBUFFER ds3db_ds3db;
194 LONG ds3db_lVolume;
195 BOOL ds3db_need_recalc;
197 /* IKsPropertySet fields */
198 IKsBufferPropertySetImpl* iks;
199 bitsconvertfunc convert;
200 struct list entry;
203 HRESULT IDirectSoundBufferImpl_Create(
204 DirectSoundDevice *device,
205 IDirectSoundBufferImpl **ppdsb,
206 LPCDSBUFFERDESC dsbd) DECLSPEC_HIDDEN;
207 HRESULT IDirectSoundBufferImpl_Destroy(
208 IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN;
209 HRESULT IDirectSoundBufferImpl_Duplicate(
210 DirectSoundDevice *device,
211 IDirectSoundBufferImpl **ppdsb,
212 IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN;
214 /*****************************************************************************
215 * SecondaryBuffer implementation structure
217 struct SecondaryBufferImpl
219 const IDirectSoundBuffer8Vtbl *lpVtbl;
220 LONG ref;
221 IDirectSoundBufferImpl* dsb;
224 HRESULT SecondaryBufferImpl_Create(
225 IDirectSoundBufferImpl *dsb,
226 SecondaryBufferImpl **pdsb) DECLSPEC_HIDDEN;
228 /*****************************************************************************
229 * PrimaryBuffer implementation structure
231 struct PrimaryBufferImpl
233 const IDirectSoundBufferVtbl *lpVtbl;
234 LONG ref;
235 DirectSoundDevice* device;
238 HRESULT PrimaryBufferImpl_Create(
239 DirectSoundDevice * device,
240 PrimaryBufferImpl **ppdsb,
241 LPCDSBUFFERDESC dsbd) DECLSPEC_HIDDEN;
243 /*****************************************************************************
244 * DirectSoundCaptureDevice implementation structure
246 struct DirectSoundCaptureDevice
248 /* IDirectSoundCaptureImpl fields */
249 GUID guid;
250 LONG ref;
252 /* DirectSound driver stuff */
253 PIDSCDRIVER driver;
254 DSDRIVERDESC drvdesc;
255 DSCDRIVERCAPS drvcaps;
256 PIDSCDRIVERBUFFER hwbuf;
258 /* wave driver info */
259 HWAVEIN hwi;
261 /* more stuff */
262 LPBYTE buffer;
263 DWORD buflen;
265 PWAVEFORMATEX pwfx;
267 IDirectSoundCaptureBufferImpl* capture_buffer;
268 DWORD state;
269 LPWAVEHDR pwave;
270 int nrofpwaves;
271 int index;
272 CRITICAL_SECTION lock;
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 /*****************************************************************************
298 * IDirectSound3DListener implementation structure
300 struct IDirectSound3DListenerImpl
302 /* IUnknown fields */
303 const IDirectSound3DListenerVtbl *lpVtbl;
304 LONG ref;
305 /* IDirectSound3DListenerImpl fields */
306 DirectSoundDevice* device;
309 HRESULT IDirectSound3DListenerImpl_Create(
310 DirectSoundDevice *device,
311 IDirectSound3DListenerImpl **pdsl) DECLSPEC_HIDDEN;
313 /*****************************************************************************
314 * IKsBufferPropertySet implementation structure
316 struct IKsBufferPropertySetImpl
318 /* IUnknown fields */
319 const IKsPropertySetVtbl *lpVtbl;
320 LONG ref;
321 /* IKsPropertySetImpl fields */
322 IDirectSoundBufferImpl* dsb;
325 HRESULT IKsBufferPropertySetImpl_Create(
326 IDirectSoundBufferImpl *dsb,
327 IKsBufferPropertySetImpl **piks) DECLSPEC_HIDDEN;
328 HRESULT IKsBufferPropertySetImpl_Destroy(
329 IKsBufferPropertySetImpl *piks) DECLSPEC_HIDDEN;
331 HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, IKsPropertySet **piks) DECLSPEC_HIDDEN;
333 /*****************************************************************************
334 * IDirectSound3DBuffer implementation structure
336 struct IDirectSound3DBufferImpl
338 /* IUnknown fields */
339 const IDirectSound3DBufferVtbl *lpVtbl;
340 LONG ref;
341 /* IDirectSound3DBufferImpl fields */
342 IDirectSoundBufferImpl* dsb;
345 HRESULT IDirectSound3DBufferImpl_Create(
346 IDirectSoundBufferImpl *dsb,
347 IDirectSound3DBufferImpl **pds3db) DECLSPEC_HIDDEN;
348 HRESULT IDirectSound3DBufferImpl_Destroy(
349 IDirectSound3DBufferImpl *pds3db) DECLSPEC_HIDDEN;
351 /*******************************************************************************
354 /* dsound.c */
356 HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS) DECLSPEC_HIDDEN;
357 HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS) DECLSPEC_HIDDEN;
359 /* primary.c */
361 DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign) DECLSPEC_HIDDEN;
362 HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device) DECLSPEC_HIDDEN;
363 HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device) DECLSPEC_HIDDEN;
364 HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device) DECLSPEC_HIDDEN;
365 HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device) DECLSPEC_HIDDEN;
366 HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos) DECLSPEC_HIDDEN;
367 LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
368 HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) DECLSPEC_HIDDEN;
370 /* duplex.c */
372 HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX* ppDSFD) DECLSPEC_HIDDEN;
374 /* mixer.c */
375 DWORD DSOUND_bufpos_to_mixpos(const DirectSoundDevice* device, DWORD pos) DECLSPEC_HIDDEN;
376 void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len) DECLSPEC_HIDDEN;
377 void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN;
378 void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN;
379 void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN;
380 void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen, BOOL inmixer) DECLSPEC_HIDDEN;
381 DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD* overshot) DECLSPEC_HIDDEN;
383 void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN;
384 void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN;
386 /* sound3d.c */
388 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN;
390 /* capture.c */
392 HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC) DECLSPEC_HIDDEN;
393 HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8) DECLSPEC_HIDDEN;
395 #define STATE_STOPPED 0
396 #define STATE_STARTING 1
397 #define STATE_PLAYING 2
398 #define STATE_CAPTURING 2
399 #define STATE_STOPPING 3
401 #define DSOUND_FREQSHIFT (20)
403 extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
404 extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
406 extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
407 extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
409 HRESULT mmErr(UINT err) DECLSPEC_HIDDEN;
410 void setup_dsound_options(void) DECLSPEC_HIDDEN;
411 const char * dumpCooperativeLevel(DWORD level) DECLSPEC_HIDDEN;