ole32/tests: Test creation of a storage on an ILockBytes containing data.
[wine.git] / dlls / dsound / dsound_private.h
blob61c8b0d0f97beb7b27e75c8507c0aa6b771d5cff
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 DirectSoundDevice DirectSoundDevice;
61 typedef struct DirectSoundCaptureDevice DirectSoundCaptureDevice;
63 /* dsound_convert.h */
64 typedef void (*bitsconvertfunc)(const void *, void *, UINT, UINT, INT, UINT, UINT);
65 extern const bitsconvertfunc convertbpp[5][4] DECLSPEC_HIDDEN;
66 typedef void (*mixfunc)(const void *, void *, unsigned);
67 extern const mixfunc mixfunctions[4] DECLSPEC_HIDDEN;
68 typedef void (*normfunc)(const void *, void *, unsigned);
69 extern const normfunc normfunctions[4] DECLSPEC_HIDDEN;
71 /*****************************************************************************
72 * IDirectSoundDevice implementation structure
74 struct DirectSoundDevice
76 LONG ref;
78 GUID guid;
79 PIDSDRIVER driver;
80 DSDRIVERDESC drvdesc;
81 DSDRIVERCAPS drvcaps;
82 DWORD priolevel;
83 PWAVEFORMATEX pwfx;
84 HWAVEOUT hwo;
85 LPWAVEHDR pwave;
86 UINT timerID, pwplay, pwqueue, prebuf, helfrags;
87 DWORD fraglen;
88 PIDSDRIVERBUFFER hwbuf;
89 LPBYTE buffer;
90 DWORD writelead, buflen, state, playpos, mixpos;
91 int nrofbuffers;
92 IDirectSoundBufferImpl** buffers;
93 RTL_RWLOCK buffer_list_lock;
94 CRITICAL_SECTION mixlock;
95 IDirectSoundBufferImpl *primary;
96 DWORD speaker_config;
97 LPBYTE tmp_buffer, mix_buffer;
98 DWORD tmp_buffer_len, mix_buffer_len;
100 DSVOLUMEPAN volpan;
102 mixfunc mixfunction;
103 normfunc normfunction;
105 /* DirectSound3DListener fields */
106 IDirectSound3DListenerImpl* listener;
107 DS3DLISTENER ds3dl;
108 BOOL ds3dl_need_recalc;
111 /* reference counted buffer memory for duplicated buffer memory */
112 typedef struct BufferMemory
114 LONG ref;
115 LPBYTE memory;
116 struct list buffers;
117 } BufferMemory;
119 ULONG DirectSoundDevice_Release(DirectSoundDevice * device) DECLSPEC_HIDDEN;
120 HRESULT DirectSoundDevice_Initialize(
121 DirectSoundDevice ** ppDevice,
122 LPCGUID lpcGUID) DECLSPEC_HIDDEN;
123 HRESULT DirectSoundDevice_AddBuffer(
124 DirectSoundDevice * device,
125 IDirectSoundBufferImpl * pDSB) DECLSPEC_HIDDEN;
126 HRESULT DirectSoundDevice_RemoveBuffer(
127 DirectSoundDevice * device,
128 IDirectSoundBufferImpl * pDSB) DECLSPEC_HIDDEN;
129 HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice * device, LPDSCAPS lpDSCaps) DECLSPEC_HIDDEN;
130 HRESULT DirectSoundDevice_CreateSoundBuffer(
131 DirectSoundDevice * device,
132 LPCDSBUFFERDESC dsbd,
133 LPLPDIRECTSOUNDBUFFER ppdsb,
134 LPUNKNOWN lpunk,
135 BOOL from8) DECLSPEC_HIDDEN;
136 HRESULT DirectSoundDevice_DuplicateSoundBuffer(
137 DirectSoundDevice * device,
138 LPDIRECTSOUNDBUFFER psb,
139 LPLPDIRECTSOUNDBUFFER ppdsb) DECLSPEC_HIDDEN;
140 HRESULT DirectSoundDevice_SetCooperativeLevel(
141 DirectSoundDevice * devcie,
142 HWND hwnd,
143 DWORD level) DECLSPEC_HIDDEN;
144 HRESULT DirectSoundDevice_Compact(DirectSoundDevice * device) DECLSPEC_HIDDEN;
145 HRESULT DirectSoundDevice_GetSpeakerConfig(
146 DirectSoundDevice * device,
147 LPDWORD lpdwSpeakerConfig) DECLSPEC_HIDDEN;
148 HRESULT DirectSoundDevice_SetSpeakerConfig(
149 DirectSoundDevice * device,
150 DWORD config) DECLSPEC_HIDDEN;
151 HRESULT DirectSoundDevice_VerifyCertification(DirectSoundDevice * device,
152 LPDWORD pdwCertified) DECLSPEC_HIDDEN;
154 /*****************************************************************************
155 * IDirectSoundBuffer implementation structure
157 struct IDirectSoundBufferImpl
159 IDirectSoundBuffer8 IDirectSoundBuffer8_iface;
160 LONG numIfaces; /* "in use interfaces" refcount */
161 LONG ref;
162 /* IDirectSoundBufferImpl fields */
163 DirectSoundDevice* device;
164 RTL_RWLOCK lock;
165 PIDSDRIVERBUFFER hwbuf;
166 PWAVEFORMATEX pwfx;
167 BufferMemory* buffer;
168 LPBYTE tmp_buffer;
169 DWORD playflags,state,leadin;
170 DWORD writelead,buflen;
171 DWORD nAvgBytesPerSec;
172 DWORD freq, tmp_buffer_len, max_buffer_len;
173 DSVOLUMEPAN volpan;
174 DSBUFFERDESC dsbd;
175 /* used for frequency conversion (PerfectPitch) */
176 ULONG freqneeded, freqAdjust, freqAcc, freqAccNext, resampleinmixer;
177 /* used for mixing */
178 DWORD primary_mixpos, buf_mixpos, sec_mixpos;
180 /* IDirectSoundNotifyImpl fields */
181 IDirectSoundNotifyImpl* notify;
182 LPDSBPOSITIONNOTIFY notifies;
183 int nrofnotifies;
184 PIDSDRIVERNOTIFY hwnotify;
186 /* DirectSound3DBuffer fields */
187 IDirectSound3DBufferImpl* ds3db;
188 DS3DBUFFER ds3db_ds3db;
189 LONG ds3db_lVolume;
190 BOOL ds3db_need_recalc;
192 /* IKsPropertySet fields */
193 IKsBufferPropertySetImpl* iks;
194 bitsconvertfunc convert;
195 struct list entry;
198 HRESULT IDirectSoundBufferImpl_Create(
199 DirectSoundDevice *device,
200 IDirectSoundBufferImpl **ppdsb,
201 LPCDSBUFFERDESC dsbd) DECLSPEC_HIDDEN;
202 HRESULT IDirectSoundBufferImpl_Destroy(
203 IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN;
204 HRESULT IDirectSoundBufferImpl_Duplicate(
205 DirectSoundDevice *device,
206 IDirectSoundBufferImpl **ppdsb,
207 IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN;
208 void secondarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
210 /*****************************************************************************
211 * DirectSoundCaptureDevice implementation structure
213 struct DirectSoundCaptureDevice
215 /* IDirectSoundCaptureImpl fields */
216 GUID guid;
217 LONG ref;
219 /* DirectSound driver stuff */
220 PIDSCDRIVER driver;
221 DSDRIVERDESC drvdesc;
222 DSCDRIVERCAPS drvcaps;
223 PIDSCDRIVERBUFFER hwbuf;
225 /* wave driver info */
226 HWAVEIN hwi;
228 /* more stuff */
229 LPBYTE buffer;
230 DWORD buflen;
232 PWAVEFORMATEX pwfx;
234 IDirectSoundCaptureBufferImpl* capture_buffer;
235 DWORD state;
236 LPWAVEHDR pwave;
237 int nrofpwaves;
238 int index;
239 CRITICAL_SECTION lock;
242 /*****************************************************************************
243 * IDirectSoundCaptureBuffer implementation structure
245 struct IDirectSoundCaptureBufferImpl
247 /* IUnknown fields */
248 const IDirectSoundCaptureBuffer8Vtbl *lpVtbl;
249 LONG ref;
251 /* IDirectSoundCaptureBufferImpl fields */
252 DirectSoundCaptureDevice* device;
253 /* FIXME: don't need this */
254 LPDSCBUFFERDESC pdscbd;
255 DWORD flags;
257 /* IDirectSoundCaptureNotifyImpl fields */
258 IDirectSoundCaptureNotifyImpl* notify;
259 LPDSBPOSITIONNOTIFY notifies;
260 int nrofnotifies;
261 PIDSDRIVERNOTIFY hwnotify;
264 /*****************************************************************************
265 * IDirectSound3DListener implementation structure
267 struct IDirectSound3DListenerImpl
269 /* IUnknown fields */
270 const IDirectSound3DListenerVtbl *lpVtbl;
271 LONG ref;
272 /* IDirectSound3DListenerImpl fields */
273 DirectSoundDevice* device;
276 HRESULT IDirectSound3DListenerImpl_Create(
277 DirectSoundDevice *device,
278 IDirectSound3DListenerImpl **pdsl) DECLSPEC_HIDDEN;
280 /*****************************************************************************
281 * IKsBufferPropertySet implementation structure
283 struct IKsBufferPropertySetImpl
285 /* IUnknown fields */
286 const IKsPropertySetVtbl *lpVtbl;
287 LONG ref;
288 /* IKsPropertySetImpl fields */
289 IDirectSoundBufferImpl* dsb;
292 HRESULT IKsBufferPropertySetImpl_Create(
293 IDirectSoundBufferImpl *dsb,
294 IKsBufferPropertySetImpl **piks) DECLSPEC_HIDDEN;
295 HRESULT IKsBufferPropertySetImpl_Destroy(
296 IKsBufferPropertySetImpl *piks) DECLSPEC_HIDDEN;
298 HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, IKsPropertySet **piks) DECLSPEC_HIDDEN;
300 /*****************************************************************************
301 * IDirectSound3DBuffer implementation structure
303 struct IDirectSound3DBufferImpl
305 /* IUnknown fields */
306 const IDirectSound3DBufferVtbl *lpVtbl;
307 LONG ref;
308 /* IDirectSound3DBufferImpl fields */
309 IDirectSoundBufferImpl* dsb;
312 HRESULT IDirectSound3DBufferImpl_Create(
313 IDirectSoundBufferImpl *dsb,
314 IDirectSound3DBufferImpl **pds3db) DECLSPEC_HIDDEN;
315 HRESULT IDirectSound3DBufferImpl_Destroy(
316 IDirectSound3DBufferImpl *pds3db) DECLSPEC_HIDDEN;
318 /*******************************************************************************
321 /* dsound.c */
323 HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS) DECLSPEC_HIDDEN;
324 HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS) DECLSPEC_HIDDEN;
326 /* primary.c */
328 DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign) DECLSPEC_HIDDEN;
329 HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device) DECLSPEC_HIDDEN;
330 HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device) DECLSPEC_HIDDEN;
331 HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device) DECLSPEC_HIDDEN;
332 HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device) DECLSPEC_HIDDEN;
333 HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos) DECLSPEC_HIDDEN;
334 LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
335 HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) DECLSPEC_HIDDEN;
336 HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb,
337 const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN;
338 void primarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
339 HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
341 /* duplex.c */
343 HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX* ppDSFD) DECLSPEC_HIDDEN;
345 /* mixer.c */
346 DWORD DSOUND_bufpos_to_mixpos(const DirectSoundDevice* device, DWORD pos) DECLSPEC_HIDDEN;
347 void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len) DECLSPEC_HIDDEN;
348 void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN;
349 void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN;
350 void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN;
351 void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen, BOOL inmixer) DECLSPEC_HIDDEN;
352 DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD* overshot) DECLSPEC_HIDDEN;
354 void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN;
355 void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN;
357 /* sound3d.c */
359 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN;
361 /* capture.c */
363 HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC) DECLSPEC_HIDDEN;
364 HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8) DECLSPEC_HIDDEN;
366 #define STATE_STOPPED 0
367 #define STATE_STARTING 1
368 #define STATE_PLAYING 2
369 #define STATE_CAPTURING 2
370 #define STATE_STOPPING 3
372 #define DSOUND_FREQSHIFT (20)
374 extern DirectSoundDevice* DSOUND_renderer[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
375 extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
377 extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
378 extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
380 HRESULT mmErr(UINT err) DECLSPEC_HIDDEN;
381 void setup_dsound_options(void) DECLSPEC_HIDDEN;
382 const char * dumpCooperativeLevel(DWORD level) DECLSPEC_HIDDEN;