gdiplus: Implement GdipSetPathGradientBlend, with tests.
[wine/multimedia.git] / dlls / dsound / dsound_private.h
bloba7209ca212566a60a8ab0a462363b78ac320f75b
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 "wingdi.h"
27 #include "mmdeviceapi.h"
28 #include "audioclient.h"
29 #include "mmsystem.h"
31 #include "wine/list.h"
33 extern int ds_hel_buflen DECLSPEC_HIDDEN;
34 extern int ds_snd_queue_max DECLSPEC_HIDDEN;
35 extern int ds_snd_shadow_maxsize DECLSPEC_HIDDEN;
36 extern int ds_default_sample_rate DECLSPEC_HIDDEN;
37 extern int ds_default_bits_per_sample DECLSPEC_HIDDEN;
39 /*****************************************************************************
40 * Predeclare the interface implementation structures
42 typedef struct IDirectSoundImpl IDirectSoundImpl;
43 typedef struct IDirectSound_IUnknown IDirectSound_IUnknown;
44 typedef struct IDirectSound_IDirectSound IDirectSound_IDirectSound;
45 typedef struct IDirectSound8_IUnknown IDirectSound8_IUnknown;
46 typedef struct IDirectSound8_IDirectSound IDirectSound8_IDirectSound;
47 typedef struct IDirectSound8_IDirectSound8 IDirectSound8_IDirectSound8;
48 typedef struct IDirectSoundBufferImpl IDirectSoundBufferImpl;
49 typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl;
50 typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
51 typedef struct DirectSoundDevice DirectSoundDevice;
52 typedef struct DirectSoundCaptureDevice DirectSoundCaptureDevice;
54 /* dsound_convert.h */
55 typedef void (*bitsconvertfunc)(const void *, void *, UINT, UINT, INT, UINT, UINT);
56 extern const bitsconvertfunc convertbpp[5][4] DECLSPEC_HIDDEN;
57 typedef void (*mixfunc)(const void *, void *, unsigned);
58 extern const mixfunc mixfunctions[4] DECLSPEC_HIDDEN;
59 typedef void (*normfunc)(const void *, void *, unsigned);
60 extern const normfunc normfunctions[4] DECLSPEC_HIDDEN;
62 typedef struct _DSVOLUMEPAN
64 DWORD dwTotalLeftAmpFactor;
65 DWORD dwTotalRightAmpFactor;
66 LONG lVolume;
67 DWORD dwVolAmpFactor;
68 LONG lPan;
69 DWORD dwPanLeftAmpFactor;
70 DWORD dwPanRightAmpFactor;
71 } DSVOLUMEPAN,*PDSVOLUMEPAN;
73 /*****************************************************************************
74 * IDirectSoundDevice implementation structure
76 struct DirectSoundDevice
78 LONG ref;
80 GUID guid;
81 DSCAPS drvcaps;
82 DWORD priolevel;
83 PWAVEFORMATEX pwfx;
84 UINT timerID, pwplay, pwqueue, prebuf, helfrags;
85 UINT64 last_pos_bytes;
86 DWORD fraglen;
87 LPBYTE buffer;
88 DWORD writelead, buflen, state, playpos, mixpos;
89 int nrofbuffers;
90 IDirectSoundBufferImpl** buffers;
91 RTL_RWLOCK buffer_list_lock;
92 CRITICAL_SECTION mixlock;
93 IDirectSoundBufferImpl *primary;
94 DWORD speaker_config;
95 LPBYTE tmp_buffer, mix_buffer;
96 DWORD tmp_buffer_len, mix_buffer_len;
98 DSVOLUMEPAN volpan;
100 mixfunc mixfunction;
101 normfunc normfunction;
103 /* DirectSound3DListener fields */
104 DS3DLISTENER ds3dl;
105 BOOL ds3dl_need_recalc;
107 IMMDevice *mmdevice;
108 IAudioClient *client;
109 IAudioClock *clock;
110 IAudioStreamVolume *volume;
111 IAudioRenderClient *render;
113 struct list entry;
116 /* reference counted buffer memory for duplicated buffer memory */
117 typedef struct BufferMemory
119 LONG ref;
120 LPBYTE memory;
121 struct list buffers;
122 } BufferMemory;
124 ULONG DirectSoundDevice_Release(DirectSoundDevice * device) DECLSPEC_HIDDEN;
125 HRESULT DirectSoundDevice_Initialize(
126 DirectSoundDevice ** ppDevice,
127 LPCGUID lpcGUID) DECLSPEC_HIDDEN;
128 HRESULT DirectSoundDevice_AddBuffer(
129 DirectSoundDevice * device,
130 IDirectSoundBufferImpl * pDSB) DECLSPEC_HIDDEN;
131 HRESULT DirectSoundDevice_RemoveBuffer(
132 DirectSoundDevice * device,
133 IDirectSoundBufferImpl * pDSB) DECLSPEC_HIDDEN;
134 HRESULT DirectSoundDevice_GetCaps(DirectSoundDevice * device, LPDSCAPS lpDSCaps) DECLSPEC_HIDDEN;
135 HRESULT DirectSoundDevice_CreateSoundBuffer(
136 DirectSoundDevice * device,
137 LPCDSBUFFERDESC dsbd,
138 LPLPDIRECTSOUNDBUFFER ppdsb,
139 LPUNKNOWN lpunk,
140 BOOL from8) DECLSPEC_HIDDEN;
141 HRESULT DirectSoundDevice_DuplicateSoundBuffer(
142 DirectSoundDevice * device,
143 LPDIRECTSOUNDBUFFER psb,
144 LPLPDIRECTSOUNDBUFFER ppdsb) DECLSPEC_HIDDEN;
145 HRESULT DirectSoundDevice_SetCooperativeLevel(
146 DirectSoundDevice * devcie,
147 HWND hwnd,
148 DWORD level) DECLSPEC_HIDDEN;
149 HRESULT DirectSoundDevice_Compact(DirectSoundDevice * device) DECLSPEC_HIDDEN;
150 HRESULT DirectSoundDevice_GetSpeakerConfig(
151 DirectSoundDevice * device,
152 LPDWORD lpdwSpeakerConfig) DECLSPEC_HIDDEN;
153 HRESULT DirectSoundDevice_SetSpeakerConfig(
154 DirectSoundDevice * device,
155 DWORD config) DECLSPEC_HIDDEN;
156 HRESULT DirectSoundDevice_VerifyCertification(DirectSoundDevice * device,
157 LPDWORD pdwCertified) DECLSPEC_HIDDEN;
159 /*****************************************************************************
160 * IDirectSoundBuffer implementation structure
162 struct IDirectSoundBufferImpl
164 IDirectSoundBuffer8 IDirectSoundBuffer8_iface;
165 IDirectSoundNotify IDirectSoundNotify_iface;
166 IDirectSound3DListener IDirectSound3DListener_iface; /* only primary buffer */
167 IDirectSound3DBuffer IDirectSound3DBuffer_iface; /* only secondary buffer */
168 IKsPropertySet IKsPropertySet_iface;
169 LONG numIfaces; /* "in use interfaces" refcount */
170 LONG ref, refn, ref3D, refiks;
171 /* IDirectSoundBufferImpl fields */
172 DirectSoundDevice* device;
173 RTL_RWLOCK lock;
174 PWAVEFORMATEX pwfx;
175 BufferMemory* buffer;
176 DWORD playflags,state,leadin;
177 DWORD writelead,buflen;
178 DWORD nAvgBytesPerSec;
179 DWORD freq, tmp_buffer_len;
180 DSVOLUMEPAN volpan;
181 DSBUFFERDESC dsbd;
182 /* used for frequency conversion (PerfectPitch) */
183 ULONG freqneeded, freqAdjust, freqAcc, freqAccNext;
184 /* used for mixing */
185 DWORD primary_mixpos, buf_mixpos, sec_mixpos;
186 /* IDirectSoundNotify fields */
187 LPDSBPOSITIONNOTIFY notifies;
188 int nrofnotifies;
189 /* DirectSound3DBuffer fields */
190 DS3DBUFFER ds3db_ds3db;
191 LONG ds3db_lVolume;
192 BOOL ds3db_need_recalc;
193 /* IKsPropertySet fields */
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_Duplicate(
203 DirectSoundDevice *device,
204 IDirectSoundBufferImpl **ppdsb,
205 IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN;
206 void secondarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
207 const IDirectSound3DListenerVtbl ds3dlvt DECLSPEC_HIDDEN;
208 const IDirectSound3DBufferVtbl ds3dbvt DECLSPEC_HIDDEN;
209 const IKsPropertySetVtbl iksbvt DECLSPEC_HIDDEN;
211 /*****************************************************************************
212 * DirectSoundCaptureDevice implementation structure
214 struct DirectSoundCaptureDevice
216 GUID guid;
217 LONG ref;
219 DSCCAPS drvcaps;
221 LPBYTE buffer;
222 DWORD buflen, write_pos_bytes;
224 PWAVEFORMATEX pwfx;
226 IDirectSoundCaptureBufferImpl* capture_buffer;
227 DWORD state;
228 UINT timerID;
229 CRITICAL_SECTION lock;
231 IMMDevice *mmdevice;
232 IAudioClient *client;
233 IAudioCaptureClient *capture;
235 struct list entry;
238 /*****************************************************************************
239 * IDirectSoundCaptureBuffer implementation structure
241 struct IDirectSoundCaptureBufferImpl
243 IDirectSoundCaptureBuffer8 IDirectSoundCaptureBuffer8_iface;
244 IDirectSoundNotify IDirectSoundNotify_iface;
245 LONG numIfaces; /* "in use interfaces" refcount */
246 LONG ref, refn;
247 /* IDirectSoundCaptureBuffer fields */
248 DirectSoundCaptureDevice* device;
249 LPDSCBUFFERDESC pdscbd;
250 DWORD flags;
251 /* IDirectSoundNotify fields */
252 LPDSBPOSITIONNOTIFY notifies;
253 int nrofnotifies;
256 HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, IKsPropertySet **piks) DECLSPEC_HIDDEN;
258 /*******************************************************************************
261 /* dsound.c */
263 HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS) DECLSPEC_HIDDEN;
264 HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS) DECLSPEC_HIDDEN;
266 /* primary.c */
268 DWORD DSOUND_fraglen(DWORD nSamplesPerSec, DWORD nBlockAlign) DECLSPEC_HIDDEN;
269 HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device) DECLSPEC_HIDDEN;
270 HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device) DECLSPEC_HIDDEN;
271 HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device) DECLSPEC_HIDDEN;
272 HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device) DECLSPEC_HIDDEN;
273 HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos) DECLSPEC_HIDDEN;
274 LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
275 HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) DECLSPEC_HIDDEN;
276 HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb,
277 const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN;
278 void primarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
279 HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
281 /* duplex.c */
283 HRESULT DSOUND_FullDuplexCreate(REFIID riid, LPDIRECTSOUNDFULLDUPLEX* ppDSFD) DECLSPEC_HIDDEN;
285 /* mixer.c */
286 DWORD DSOUND_bufpos_to_mixpos(const DirectSoundDevice* device, DWORD pos) DECLSPEC_HIDDEN;
287 void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len) DECLSPEC_HIDDEN;
288 void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN;
289 void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan) DECLSPEC_HIDDEN;
290 void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN;
291 DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD* overshot) DECLSPEC_HIDDEN;
293 void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DECLSPEC_HIDDEN;
295 /* sound3d.c */
297 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN;
299 /* capture.c */
301 HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC) DECLSPEC_HIDDEN;
302 HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8) DECLSPEC_HIDDEN;
304 #define STATE_STOPPED 0
305 #define STATE_STARTING 1
306 #define STATE_PLAYING 2
307 #define STATE_CAPTURING 2
308 #define STATE_STOPPING 3
310 #define DSOUND_FREQSHIFT (20)
312 extern CRITICAL_SECTION DSOUND_renderers_lock DECLSPEC_HIDDEN;
313 extern CRITICAL_SECTION DSOUND_capturers_lock DECLSPEC_HIDDEN;
314 extern struct list DSOUND_capturers DECLSPEC_HIDDEN;
315 extern struct list DSOUND_renderers DECLSPEC_HIDDEN;
317 extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
318 extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
320 extern WCHAR wine_vxd_drv[] DECLSPEC_HIDDEN;
322 void setup_dsound_options(void) DECLSPEC_HIDDEN;
323 const char * dumpCooperativeLevel(DWORD level) DECLSPEC_HIDDEN;
325 HRESULT get_mmdevice(EDataFlow flow, const GUID *tgt, IMMDevice **device) DECLSPEC_HIDDEN;
327 BOOL DSOUND_check_supported(IAudioClient *client, DWORD rate,
328 DWORD depth, WORD channels) DECLSPEC_HIDDEN;
329 UINT DSOUND_create_timer(LPTIMECALLBACK cb, DWORD_PTR user) DECLSPEC_HIDDEN;
330 HRESULT enumerate_mmdevices(EDataFlow flow, GUID *guids,
331 LPDSENUMCALLBACKW cb, void *user) DECLSPEC_HIDDEN;