shlwapi: Update Finnish translation.
[wine/multimedia.git] / dlls / dsound / dsound_private.h
blob1b25ddd3b73ecedb47c3b2bdfecadfa04cc9ae52
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;
35 extern int ds_hel_buflen;
36 extern int ds_snd_queue_max;
37 extern int ds_snd_queue_min;
38 extern int ds_snd_shadow_maxsize;
39 extern int ds_hw_accel;
40 extern int ds_default_sample_rate;
41 extern int ds_default_bits_per_sample;
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 IKsPrivatePropertySetImpl IKsPrivatePropertySetImpl;
61 typedef struct PrimaryBufferImpl PrimaryBufferImpl;
62 typedef struct SecondaryBufferImpl SecondaryBufferImpl;
63 typedef struct DirectSoundDevice DirectSoundDevice;
64 typedef struct DirectSoundCaptureDevice DirectSoundCaptureDevice;
66 /* dsound_convert.h */
67 typedef void (*bitsconvertfunc)(const void *, void *, UINT, UINT, INT, UINT, UINT);
68 extern const bitsconvertfunc convertbpp[4][4];
69 typedef void (*mixfunc)(const void *, void *, unsigned);
70 extern const mixfunc mixfunctions[4];
71 typedef void (*normfunc)(const void *, void *, unsigned);
72 extern const normfunc normfunctions[4];
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;
89 UINT timerID, pwplay, pwqueue, prebuf, helfrags;
90 DWORD fraglen;
91 PIDSDRIVERBUFFER hwbuf;
92 LPBYTE buffer;
93 DWORD writelead, buflen, state, playpos, mixpos;
94 int nrofbuffers;
95 IDirectSoundBufferImpl** buffers;
96 RTL_RWLOCK buffer_list_lock;
97 CRITICAL_SECTION mixlock;
98 PrimaryBufferImpl* primary;
99 DSBUFFERDESC dsbd;
100 DWORD speaker_config;
101 LPBYTE tmp_buffer, mix_buffer;
102 DWORD tmp_buffer_len, mix_buffer_len;
104 DSVOLUMEPAN volpan;
106 mixfunc mixfunction;
107 normfunc normfunction;
109 /* DirectSound3DListener fields */
110 IDirectSound3DListenerImpl* listener;
111 DS3DLISTENER ds3dl;
112 BOOL ds3dl_need_recalc;
115 /* reference counted buffer memory for duplicated buffer memory */
116 typedef struct BufferMemory
118 LONG ref;
119 LPBYTE memory;
120 struct list buffers;
121 } BufferMemory;
123 ULONG DirectSoundDevice_Release(DirectSoundDevice * device);
124 HRESULT DirectSoundDevice_Initialize(
125 DirectSoundDevice ** ppDevice,
126 LPCGUID lpcGUID);
127 HRESULT DirectSoundDevice_AddBuffer(
128 DirectSoundDevice * device,
129 IDirectSoundBufferImpl * pDSB);
130 HRESULT DirectSoundDevice_RemoveBuffer(
131 DirectSoundDevice * device,
132 IDirectSoundBufferImpl * pDSB);
133 HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice * device, LPDSCAPS lpDSCaps);
134 HRESULT DirectSoundDevice_CreateSoundBuffer(
135 DirectSoundDevice * device,
136 LPCDSBUFFERDESC dsbd,
137 LPLPDIRECTSOUNDBUFFER ppdsb,
138 LPUNKNOWN lpunk,
139 BOOL from8);
140 HRESULT DirectSoundDevice_DuplicateSoundBuffer(
141 DirectSoundDevice * device,
142 LPDIRECTSOUNDBUFFER psb,
143 LPLPDIRECTSOUNDBUFFER ppdsb);
144 HRESULT DirectSoundDevice_SetCooperativeLevel(
145 DirectSoundDevice * devcie,
146 HWND hwnd,
147 DWORD level);
148 HRESULT DirectSoundDevice_Compact(DirectSoundDevice * device);
149 HRESULT DirectSoundDevice_GetSpeakerConfig(
150 DirectSoundDevice * device,
151 LPDWORD lpdwSpeakerConfig);
152 HRESULT DirectSoundDevice_SetSpeakerConfig(
153 DirectSoundDevice * device,
154 DWORD config);
155 HRESULT DirectSoundDevice_VerifyCertification(DirectSoundDevice * device,
156 LPDWORD pdwCertified);
158 /*****************************************************************************
159 * IDirectSoundBuffer implementation structure
161 struct IDirectSoundBufferImpl
163 /* FIXME: document */
164 /* IUnknown fields */
165 const IDirectSoundBuffer8Vtbl *lpVtbl;
166 LONG ref;
167 /* IDirectSoundBufferImpl fields */
168 SecondaryBufferImpl* secondary;
169 DirectSoundDevice* device;
170 RTL_RWLOCK lock;
171 PIDSDRIVERBUFFER hwbuf;
172 PWAVEFORMATEX pwfx;
173 BufferMemory* buffer;
174 LPBYTE tmp_buffer;
175 DWORD playflags,state,leadin;
176 DWORD writelead,buflen;
177 DWORD nAvgBytesPerSec;
178 DWORD freq, tmp_buffer_len, max_buffer_len;
179 DSVOLUMEPAN volpan;
180 DSBUFFERDESC dsbd;
181 /* used for frequency conversion (PerfectPitch) */
182 ULONG freqneeded, freqAdjust, freqAcc, freqAccNext, resampleinmixer;
183 /* used for mixing */
184 DWORD primary_mixpos, buf_mixpos, sec_mixpos;
186 /* IDirectSoundNotifyImpl fields */
187 IDirectSoundNotifyImpl* notify;
188 LPDSBPOSITIONNOTIFY notifies;
189 int nrofnotifies;
190 PIDSDRIVERNOTIFY hwnotify;
192 /* DirectSound3DBuffer fields */
193 IDirectSound3DBufferImpl* ds3db;
194 DS3DBUFFER ds3db_ds3db;
195 LONG ds3db_lVolume;
196 BOOL ds3db_need_recalc;
198 /* IKsPropertySet fields */
199 IKsBufferPropertySetImpl* iks;
200 bitsconvertfunc convert;
201 struct list entry;
204 HRESULT IDirectSoundBufferImpl_Create(
205 DirectSoundDevice *device,
206 IDirectSoundBufferImpl **ppdsb,
207 LPCDSBUFFERDESC dsbd);
208 HRESULT IDirectSoundBufferImpl_Destroy(
209 IDirectSoundBufferImpl *pdsb);
210 HRESULT IDirectSoundBufferImpl_Duplicate(
211 DirectSoundDevice *device,
212 IDirectSoundBufferImpl **ppdsb,
213 IDirectSoundBufferImpl *pdsb);
215 /*****************************************************************************
216 * SecondaryBuffer implementation structure
218 struct SecondaryBufferImpl
220 const IDirectSoundBuffer8Vtbl *lpVtbl;
221 LONG ref;
222 IDirectSoundBufferImpl* dsb;
225 HRESULT SecondaryBufferImpl_Create(
226 IDirectSoundBufferImpl *dsb,
227 SecondaryBufferImpl **pdsb);
229 /*****************************************************************************
230 * PrimaryBuffer implementation structure
232 struct PrimaryBufferImpl
234 const IDirectSoundBufferVtbl *lpVtbl;
235 LONG ref;
236 DirectSoundDevice* device;
239 HRESULT PrimaryBufferImpl_Create(
240 DirectSoundDevice * device,
241 PrimaryBufferImpl **ppdsb,
242 LPCDSBUFFERDESC dsbd);
244 /*****************************************************************************
245 * DirectSoundCaptureDevice implementation structure
247 struct DirectSoundCaptureDevice
249 /* IDirectSoundCaptureImpl fields */
250 GUID guid;
251 LONG ref;
253 /* DirectSound driver stuff */
254 PIDSCDRIVER driver;
255 DSDRIVERDESC drvdesc;
256 DSCDRIVERCAPS drvcaps;
257 PIDSCDRIVERBUFFER hwbuf;
259 /* wave driver info */
260 HWAVEIN hwi;
262 /* more stuff */
263 LPBYTE buffer;
264 DWORD buflen;
266 PWAVEFORMATEX pwfx;
268 IDirectSoundCaptureBufferImpl* capture_buffer;
269 DWORD state;
270 LPWAVEHDR pwave;
271 int nrofpwaves;
272 int index;
273 CRITICAL_SECTION lock;
276 /*****************************************************************************
277 * IDirectSoundCaptureBuffer implementation structure
279 struct IDirectSoundCaptureBufferImpl
281 /* IUnknown fields */
282 const IDirectSoundCaptureBuffer8Vtbl *lpVtbl;
283 LONG ref;
285 /* IDirectSoundCaptureBufferImpl fields */
286 DirectSoundCaptureDevice* device;
287 /* FIXME: don't need this */
288 LPDSCBUFFERDESC pdscbd;
289 DWORD flags;
291 /* IDirectSoundCaptureNotifyImpl fields */
292 IDirectSoundCaptureNotifyImpl* notify;
293 LPDSBPOSITIONNOTIFY notifies;
294 int nrofnotifies;
295 PIDSDRIVERNOTIFY hwnotify;
298 /*****************************************************************************
299 * IDirectSound3DListener implementation structure
301 struct IDirectSound3DListenerImpl
303 /* IUnknown fields */
304 const IDirectSound3DListenerVtbl *lpVtbl;
305 LONG ref;
306 /* IDirectSound3DListenerImpl fields */
307 DirectSoundDevice* device;
310 HRESULT IDirectSound3DListenerImpl_Create(
311 DirectSoundDevice *device,
312 IDirectSound3DListenerImpl **pdsl);
314 /*****************************************************************************
315 * IKsBufferPropertySet implementation structure
317 struct IKsBufferPropertySetImpl
319 /* IUnknown fields */
320 const IKsPropertySetVtbl *lpVtbl;
321 LONG ref;
322 /* IKsPropertySetImpl fields */
323 IDirectSoundBufferImpl* dsb;
326 HRESULT IKsBufferPropertySetImpl_Create(
327 IDirectSoundBufferImpl *dsb,
328 IKsBufferPropertySetImpl **piks);
329 HRESULT IKsBufferPropertySetImpl_Destroy(
330 IKsBufferPropertySetImpl *piks);
332 /*****************************************************************************
333 * IKsPrivatePropertySet implementation structure
335 struct IKsPrivatePropertySetImpl
337 /* IUnknown fields */
338 const IKsPropertySetVtbl *lpVtbl;
339 LONG ref;
342 HRESULT IKsPrivatePropertySetImpl_Create(
343 REFIID riid,
344 IKsPrivatePropertySetImpl **piks);
346 /*****************************************************************************
347 * IDirectSound3DBuffer implementation structure
349 struct IDirectSound3DBufferImpl
351 /* IUnknown fields */
352 const IDirectSound3DBufferVtbl *lpVtbl;
353 LONG ref;
354 /* IDirectSound3DBufferImpl fields */
355 IDirectSoundBufferImpl* dsb;
358 HRESULT IDirectSound3DBufferImpl_Create(
359 IDirectSoundBufferImpl *dsb,
360 IDirectSound3DBufferImpl **pds3db);
361 HRESULT IDirectSound3DBufferImpl_Destroy(
362 IDirectSound3DBufferImpl *pds3db);
364 /*******************************************************************************
367 /* dsound.c */
369 HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS);
370 HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS);
372 /* primary.c */
374 DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign);
375 HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device);
376 HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device);
377 HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device);
378 HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device);
379 HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos);
380 LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex);
381 HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave);
383 /* duplex.c */
385 HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX* ppDSFD);
387 /* mixer.c */
388 DWORD DSOUND_bufpos_to_mixpos(const DirectSoundDevice* device, DWORD pos);
389 void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len);
390 void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan);
391 void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan);
392 void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb);
393 void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen, BOOL inmixer);
394 DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD* overshot);
396 void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
397 void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
399 /* sound3d.c */
401 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb);
403 /* capture.c */
405 HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC);
406 HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8);
408 #define STATE_STOPPED 0
409 #define STATE_STARTING 1
410 #define STATE_PLAYING 2
411 #define STATE_CAPTURING 2
412 #define STATE_STOPPING 3
414 #define DSOUND_FREQSHIFT (20)
416 extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
417 extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
419 extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS];
420 extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
422 HRESULT mmErr(UINT err);
423 void setup_dsound_options(void);
424 const char * dumpCooperativeLevel(DWORD level);