secur32: Implement LsaGetLogonSessionData stub.
[wine/wine-gecko.git] / dlls / dsound / dsound_private.h
blobdc21a6280690d3ec6604db5e8594308f9dbcf382
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_hw_accel;
39 extern int ds_default_playback;
40 extern int ds_default_capture;
41 extern int ds_default_sample_rate;
42 extern int ds_default_bits_per_sample;
44 /*****************************************************************************
45 * Predeclare the interface implementation structures
47 typedef struct IDirectSoundImpl IDirectSoundImpl;
48 typedef struct IDirectSound_IUnknown IDirectSound_IUnknown;
49 typedef struct IDirectSound_IDirectSound IDirectSound_IDirectSound;
50 typedef struct IDirectSound8_IUnknown IDirectSound8_IUnknown;
51 typedef struct IDirectSound8_IDirectSound IDirectSound8_IDirectSound;
52 typedef struct IDirectSound8_IDirectSound8 IDirectSound8_IDirectSound8;
53 typedef struct IDirectSoundBufferImpl IDirectSoundBufferImpl;
54 typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl;
55 typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
56 typedef struct IDirectSoundFullDuplexImpl IDirectSoundFullDuplexImpl;
57 typedef struct IDirectSoundFullDuplex_IUnknown IDirectSoundFullDuplex_IUnknown;
58 typedef struct IDirectSoundFullDuplex_IDirectSound IDirectSoundFullDuplex_IDirectSound;
59 typedef struct IDirectSoundFullDuplex_IDirectSound8 IDirectSoundFullDuplex_IDirectSound8;
60 typedef struct IDirectSoundFullDuplex_IDirectSoundCapture IDirectSoundFullDuplex_IDirectSoundCapture;
61 typedef struct IDirectSoundNotifyImpl IDirectSoundNotifyImpl;
62 typedef struct IDirectSoundCaptureNotifyImpl IDirectSoundCaptureNotifyImpl;
63 typedef struct IDirectSound3DListenerImpl IDirectSound3DListenerImpl;
64 typedef struct IDirectSound3DBufferImpl IDirectSound3DBufferImpl;
65 typedef struct IKsBufferPropertySetImpl IKsBufferPropertySetImpl;
66 typedef struct IKsPrivatePropertySetImpl IKsPrivatePropertySetImpl;
67 typedef struct PrimaryBufferImpl PrimaryBufferImpl;
68 typedef struct SecondaryBufferImpl SecondaryBufferImpl;
69 typedef struct DirectSoundDevice DirectSoundDevice;
70 typedef struct DirectSoundCaptureDevice DirectSoundCaptureDevice;
72 /*****************************************************************************
73 * IDirectSoundDevice implementation structure
75 struct DirectSoundDevice
77 LONG ref;
79 GUID guid;
80 PIDSDRIVER driver;
81 DSDRIVERDESC drvdesc;
82 DSDRIVERCAPS drvcaps;
83 DWORD priolevel;
84 PWAVEFORMATEX pwfx;
85 HWAVEOUT hwo;
86 LPWAVEHDR pwave;
87 UINT timerID, pwplay, pwqueue, prebuf, helfrags;
88 DWORD fraglen;
89 PIDSDRIVERBUFFER hwbuf;
90 LPBYTE buffer;
91 DWORD writelead, buflen, state, playpos, mixpos;
92 int nrofbuffers;
93 IDirectSoundBufferImpl** buffers;
94 RTL_RWLOCK buffer_list_lock;
95 CRITICAL_SECTION mixlock;
96 PrimaryBufferImpl* primary;
97 DSBUFFERDESC dsbd;
98 DWORD speaker_config;
99 LPBYTE tmp_buffer;
100 DWORD tmp_buffer_len;
102 /* DirectSound3DListener fields */
103 IDirectSound3DListenerImpl* listener;
104 DS3DLISTENER ds3dl;
105 BOOL ds3dl_need_recalc;
108 /* reference counted buffer memory for duplicated buffer memory */
109 typedef struct BufferMemory
111 LONG ref;
112 LPBYTE memory;
113 struct list buffers;
114 } BufferMemory;
116 ULONG DirectSoundDevice_Release(DirectSoundDevice * device);
117 HRESULT DirectSoundDevice_Initialize(
118 DirectSoundDevice ** ppDevice,
119 LPCGUID lpcGUID);
120 HRESULT DirectSoundDevice_AddBuffer(
121 DirectSoundDevice * device,
122 IDirectSoundBufferImpl * pDSB);
123 HRESULT DirectSoundDevice_RemoveBuffer(
124 DirectSoundDevice * device,
125 IDirectSoundBufferImpl * pDSB);
126 HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice * device, LPDSCAPS lpDSCaps);
127 HRESULT DirectSoundDevice_CreateSoundBuffer(
128 DirectSoundDevice * device,
129 LPCDSBUFFERDESC dsbd,
130 LPLPDIRECTSOUNDBUFFER ppdsb,
131 LPUNKNOWN lpunk,
132 BOOL from8);
133 HRESULT DirectSoundDevice_DuplicateSoundBuffer(
134 DirectSoundDevice * device,
135 LPDIRECTSOUNDBUFFER psb,
136 LPLPDIRECTSOUNDBUFFER ppdsb);
137 HRESULT DirectSoundDevice_SetCooperativeLevel(
138 DirectSoundDevice * devcie,
139 HWND hwnd,
140 DWORD level);
141 HRESULT DirectSoundDevice_Compact(DirectSoundDevice * device);
142 HRESULT DirectSoundDevice_GetSpeakerConfig(
143 DirectSoundDevice * device,
144 LPDWORD lpdwSpeakerConfig);
145 HRESULT DirectSoundDevice_SetSpeakerConfig(
146 DirectSoundDevice * device,
147 DWORD config);
149 /*****************************************************************************
150 * IDirectSoundBuffer implementation structure
152 struct IDirectSoundBufferImpl
154 /* FIXME: document */
155 /* IUnknown fields */
156 const IDirectSoundBuffer8Vtbl *lpVtbl;
157 LONG ref;
158 /* IDirectSoundBufferImpl fields */
159 SecondaryBufferImpl* secondary;
160 DirectSoundDevice* device;
161 RTL_RWLOCK lock;
162 PIDSDRIVERBUFFER hwbuf;
163 PWAVEFORMATEX pwfx;
164 BufferMemory* buffer;
165 LPBYTE tmp_buffer;
166 DWORD playflags,state,leadin;
167 DWORD writelead,buflen;
168 DWORD nAvgBytesPerSec;
169 DWORD freq, tmp_buffer_len, max_buffer_len;
170 DSVOLUMEPAN volpan;
171 DSBUFFERDESC dsbd;
172 /* used for frequency conversion (PerfectPitch) */
173 ULONG freqneeded, freqAdjust, freqAcc, freqAccNext;
174 /* used for mixing */
175 DWORD primary_mixpos, buf_mixpos, sec_mixpos;
177 /* IDirectSoundNotifyImpl fields */
178 IDirectSoundNotifyImpl* notify;
179 LPDSBPOSITIONNOTIFY notifies;
180 int nrofnotifies;
181 PIDSDRIVERNOTIFY hwnotify;
183 /* DirectSound3DBuffer fields */
184 IDirectSound3DBufferImpl* ds3db;
185 DS3DBUFFER ds3db_ds3db;
186 LONG ds3db_lVolume;
187 BOOL ds3db_need_recalc;
189 /* IKsPropertySet fields */
190 IKsBufferPropertySetImpl* iks;
192 struct list entry;
195 HRESULT IDirectSoundBufferImpl_Create(
196 DirectSoundDevice *device,
197 IDirectSoundBufferImpl **ppdsb,
198 LPCDSBUFFERDESC dsbd);
199 HRESULT IDirectSoundBufferImpl_Destroy(
200 IDirectSoundBufferImpl *pdsb);
201 HRESULT IDirectSoundBufferImpl_Duplicate(
202 DirectSoundDevice *device,
203 IDirectSoundBufferImpl **ppdsb,
204 IDirectSoundBufferImpl *pdsb);
206 /*****************************************************************************
207 * SecondaryBuffer implementation structure
209 struct SecondaryBufferImpl
211 const IDirectSoundBuffer8Vtbl *lpVtbl;
212 LONG ref;
213 IDirectSoundBufferImpl* dsb;
216 HRESULT SecondaryBufferImpl_Create(
217 IDirectSoundBufferImpl *dsb,
218 SecondaryBufferImpl **pdsb);
220 /*****************************************************************************
221 * PrimaryBuffer implementation structure
223 struct PrimaryBufferImpl
225 const IDirectSoundBufferVtbl *lpVtbl;
226 LONG ref;
227 DirectSoundDevice* device;
230 HRESULT PrimaryBufferImpl_Create(
231 DirectSoundDevice * device,
232 PrimaryBufferImpl **ppdsb,
233 LPCDSBUFFERDESC dsbd);
235 /*****************************************************************************
236 * DirectSoundCaptureDevice implementation structure
238 struct DirectSoundCaptureDevice
240 /* IDirectSoundCaptureImpl fields */
241 GUID guid;
242 LONG ref;
244 /* DirectSound driver stuff */
245 PIDSCDRIVER driver;
246 DSDRIVERDESC drvdesc;
247 DSCDRIVERCAPS drvcaps;
248 PIDSCDRIVERBUFFER hwbuf;
250 /* wave driver info */
251 HWAVEIN hwi;
253 /* more stuff */
254 LPBYTE buffer;
255 DWORD buflen;
256 DWORD read_position;
258 PWAVEFORMATEX pwfx;
260 IDirectSoundCaptureBufferImpl* capture_buffer;
261 DWORD state;
262 LPWAVEHDR pwave;
263 int nrofpwaves;
264 int index;
265 CRITICAL_SECTION lock;
268 HRESULT DirectSoundCaptureDevice_Initialize(
269 DirectSoundCaptureDevice ** ppDevice,
270 LPCGUID lpcGUID);
271 ULONG DirectSoundCaptureDevice_Release(
272 DirectSoundCaptureDevice * device);
274 /*****************************************************************************
275 * IDirectSoundCaptureBuffer implementation structure
277 struct IDirectSoundCaptureBufferImpl
279 /* IUnknown fields */
280 const IDirectSoundCaptureBuffer8Vtbl *lpVtbl;
281 LONG ref;
283 /* IDirectSoundCaptureBufferImpl fields */
284 DirectSoundCaptureDevice* device;
285 /* FIXME: don't need this */
286 LPDSCBUFFERDESC pdscbd;
287 DWORD flags;
289 /* IDirectSoundCaptureNotifyImpl fields */
290 IDirectSoundCaptureNotifyImpl* notify;
291 LPDSBPOSITIONNOTIFY notifies;
292 int nrofnotifies;
293 PIDSDRIVERNOTIFY hwnotify;
296 HRESULT IDirectSoundCaptureBufferImpl_Create(
297 DirectSoundCaptureDevice *device,
298 IDirectSoundCaptureBufferImpl ** ppobj,
299 LPCDSCBUFFERDESC lpcDSCBufferDesc);
301 /*****************************************************************************
302 * IDirectSoundFullDuplex implementation structure
304 struct IDirectSoundFullDuplexImpl
306 /* IUnknown fields */
307 const IDirectSoundFullDuplexVtbl *lpVtbl;
308 LONG ref;
310 /* IDirectSoundFullDuplexImpl fields */
311 DirectSoundDevice *renderer_device;
312 DirectSoundCaptureDevice *capture_device;
314 LPUNKNOWN pUnknown;
315 LPDIRECTSOUND pDS;
316 LPDIRECTSOUND8 pDS8;
317 LPDIRECTSOUNDCAPTURE pDSC;
320 /*****************************************************************************
321 * IDirectSoundFullDuplex COM components
323 struct IDirectSoundFullDuplex_IUnknown {
324 const IUnknownVtbl *lpVtbl;
325 LONG ref;
326 IDirectSoundFullDuplexImpl *pdsfd;
329 struct IDirectSoundFullDuplex_IDirectSound {
330 const IDirectSoundVtbl *lpVtbl;
331 LONG ref;
332 IDirectSoundFullDuplexImpl *pdsfd;
335 struct IDirectSoundFullDuplex_IDirectSound8 {
336 const IDirectSound8Vtbl *lpVtbl;
337 LONG ref;
338 IDirectSoundFullDuplexImpl *pdsfd;
341 struct IDirectSoundFullDuplex_IDirectSoundCapture {
342 const IDirectSoundCaptureVtbl *lpVtbl;
343 LONG ref;
344 IDirectSoundFullDuplexImpl *pdsfd;
347 /*****************************************************************************
348 * IDirectSound3DListener implementation structure
350 struct IDirectSound3DListenerImpl
352 /* IUnknown fields */
353 const IDirectSound3DListenerVtbl *lpVtbl;
354 LONG ref;
355 /* IDirectSound3DListenerImpl fields */
356 DirectSoundDevice* device;
359 HRESULT IDirectSound3DListenerImpl_Create(
360 DirectSoundDevice *device,
361 IDirectSound3DListenerImpl **pdsl);
363 /*****************************************************************************
364 * IKsBufferPropertySet implementation structure
366 struct IKsBufferPropertySetImpl
368 /* IUnknown fields */
369 const IKsPropertySetVtbl *lpVtbl;
370 LONG ref;
371 /* IKsPropertySetImpl fields */
372 IDirectSoundBufferImpl* dsb;
375 HRESULT IKsBufferPropertySetImpl_Create(
376 IDirectSoundBufferImpl *dsb,
377 IKsBufferPropertySetImpl **piks);
378 HRESULT IKsBufferPropertySetImpl_Destroy(
379 IKsBufferPropertySetImpl *piks);
381 /*****************************************************************************
382 * IKsPrivatePropertySet implementation structure
384 struct IKsPrivatePropertySetImpl
386 /* IUnknown fields */
387 const IKsPropertySetVtbl *lpVtbl;
388 LONG ref;
391 HRESULT IKsPrivatePropertySetImpl_Create(
392 REFIID riid,
393 IKsPrivatePropertySetImpl **piks);
395 /*****************************************************************************
396 * IDirectSound3DBuffer implementation structure
398 struct IDirectSound3DBufferImpl
400 /* IUnknown fields */
401 const IDirectSound3DBufferVtbl *lpVtbl;
402 LONG ref;
403 /* IDirectSound3DBufferImpl fields */
404 IDirectSoundBufferImpl* dsb;
407 HRESULT IDirectSound3DBufferImpl_Create(
408 IDirectSoundBufferImpl *dsb,
409 IDirectSound3DBufferImpl **pds3db);
410 HRESULT IDirectSound3DBufferImpl_Destroy(
411 IDirectSound3DBufferImpl *pds3db);
413 /*******************************************************************************
416 /* dsound.c */
418 HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS);
419 HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS);
421 /* primary.c */
423 HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device);
424 HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device);
425 HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device);
426 HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device);
427 HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos);
428 HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex, BOOL forced);
429 HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave);
431 /* duplex.c */
433 HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX* ppDSFD);
435 /* mixer.c */
437 void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len);
438 void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan);
439 void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan);
440 void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb);
441 void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen);
442 DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD* overshot);
444 void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
445 void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2);
447 /* sound3d.c */
449 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb);
451 /* capture.c */
453 HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC);
454 HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8);
455 HRESULT WINAPI IDirectSoundCaptureImpl_CreateCaptureBuffer(
456 LPDIRECTSOUNDCAPTURE iface,
457 LPCDSCBUFFERDESC lpcDSCBufferDesc,
458 LPDIRECTSOUNDCAPTUREBUFFER* lplpDSCaptureBuffer,
459 LPUNKNOWN pUnk);
460 HRESULT WINAPI IDirectSoundCaptureImpl_GetCaps(
461 LPDIRECTSOUNDCAPTURE iface,
462 LPDSCCAPS lpDSCCaps);
463 HRESULT WINAPI IDirectSoundCaptureImpl_Initialize(
464 LPDIRECTSOUNDCAPTURE iface,
465 LPCGUID lpcGUID);
467 #define STATE_STOPPED 0
468 #define STATE_STARTING 1
469 #define STATE_PLAYING 2
470 #define STATE_CAPTURING 2
471 #define STATE_STOPPING 3
473 #define DSOUND_FREQSHIFT (20)
475 extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS];
476 extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
478 extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS];
479 extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
481 HRESULT mmErr(UINT err);
482 void setup_dsound_options(void);
483 const char * dumpCooperativeLevel(DWORD level);