d3d11: Use wined3d_device_context_dispatch_indirect().
[wine/zf.git] / dlls / dsdmo / tests / dsdmo.c
blob1ecafeb7ceb5d5455dff29c0d96bcb4eb4933c14
1 /*
2 * Copyright 2019 Alistair Leslie-Hughes
3 * Copyright 2020 Zebediah Figura
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define COBJMACROS
21 #include "windef.h"
22 #include "wingdi.h"
23 #include "mmreg.h"
24 #include "mmsystem.h"
25 #include "dmo.h"
26 #include "initguid.h"
27 #include "dsound.h"
28 #include "uuids.h"
29 #include "wine/test.h"
31 static const GUID test_iid = {0x33333333};
32 static LONG outer_ref = 1;
34 static ULONG get_refcount(void *iface)
36 IUnknown *unknown = iface;
37 IUnknown_AddRef(unknown);
38 return IUnknown_Release(unknown);
41 static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID iid, void **out)
43 if (IsEqualGUID(iid, &IID_IUnknown)
44 || IsEqualGUID(iid, &IID_IMediaObject)
45 || IsEqualGUID(iid, &test_iid))
47 *out = (IUnknown *)0xdeadbeef;
48 return S_OK;
50 ok(0, "unexpected call %s\n", wine_dbgstr_guid(iid));
51 return E_NOINTERFACE;
54 static ULONG WINAPI outer_AddRef(IUnknown *iface)
56 return InterlockedIncrement(&outer_ref);
59 static ULONG WINAPI outer_Release(IUnknown *iface)
61 return InterlockedDecrement(&outer_ref);
64 static const IUnknownVtbl outer_vtbl =
66 outer_QueryInterface,
67 outer_AddRef,
68 outer_Release,
71 static IUnknown test_outer = {&outer_vtbl};
73 static void test_aggregation(const GUID *clsid)
75 IMediaObject *dmo, *dmo2;
76 IUnknown *unk, *unk2;
77 HRESULT hr;
78 ULONG ref;
80 dmo = (IMediaObject *)0xdeadbeef;
81 hr = CoCreateInstance(clsid, &test_outer, CLSCTX_INPROC_SERVER,
82 &IID_IMediaObject, (void **)&dmo);
83 ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
84 ok(!dmo, "Got interface %p.\n", dmo);
86 hr = CoCreateInstance(clsid, &test_outer, CLSCTX_INPROC_SERVER,
87 &IID_IUnknown, (void **)&unk);
88 ok(hr == S_OK, "Got hr %#x.\n", hr);
89 ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
90 ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
91 ref = get_refcount(unk);
92 ok(ref == 1, "Got unexpected refcount %d.\n", ref);
94 ref = IUnknown_AddRef(unk);
95 ok(ref == 2, "Got unexpected refcount %d.\n", ref);
96 ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
98 ref = IUnknown_Release(unk);
99 ok(ref == 1, "Got unexpected refcount %d.\n", ref);
100 ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
102 hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void **)&unk2);
103 ok(hr == S_OK, "Got hr %#x.\n", hr);
104 ok(unk2 == unk, "Got unexpected IUnknown %p.\n", unk2);
105 IUnknown_Release(unk2);
107 hr = IUnknown_QueryInterface(unk, &IID_IMediaObject, (void **)&dmo);
108 ok(hr == S_OK, "Got hr %#x.\n", hr);
110 hr = IMediaObject_QueryInterface(dmo, &IID_IUnknown, (void **)&unk2);
111 ok(hr == S_OK, "Got hr %#x.\n", hr);
112 ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
114 hr = IMediaObject_QueryInterface(dmo, &IID_IMediaObject, (void **)&dmo2);
115 ok(hr == S_OK, "Got hr %#x.\n", hr);
116 ok(dmo2 == (IMediaObject *)0xdeadbeef, "Got unexpected IMediaObject %p.\n", dmo2);
118 hr = IUnknown_QueryInterface(unk, &test_iid, (void **)&unk2);
119 ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
120 ok(!unk2, "Got unexpected IUnknown %p.\n", unk2);
122 hr = IMediaObject_QueryInterface(dmo, &test_iid, (void **)&unk2);
123 ok(hr == S_OK, "Got hr %#x.\n", hr);
124 ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
126 IMediaObject_Release(dmo);
127 ref = IUnknown_Release(unk);
128 ok(!ref, "Got unexpected refcount %d.\n", ref);
129 ok(outer_ref == 1, "Got unexpected refcount %d.\n", outer_ref);
132 static void test_interfaces(const GUID *clsid, const GUID *iid)
134 IUnknown *unk, *unk2, *unk3;
135 HRESULT hr;
136 ULONG ref;
138 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, iid, (void **)&unk);
139 ok(hr == S_OK, "Got hr %#x.\n", hr);
141 hr = IUnknown_QueryInterface(unk, &IID_IMediaObject, (void **)&unk2);
142 ok(hr == S_OK, "Got hr %#x.\n", hr);
143 hr = IUnknown_QueryInterface(unk2, iid, (void **)&unk3);
144 ok(hr == S_OK, "Got hr %#x.\n", hr);
145 ok(unk3 == unk, "Interface pointers didn't match.\n");
146 IUnknown_Release(unk3);
147 IUnknown_Release(unk2);
149 hr = IUnknown_QueryInterface(unk, &IID_IMediaObjectInPlace, (void **)&unk2);
150 ok(hr == S_OK, "Got hr %#x.\n", hr);
151 hr = IUnknown_QueryInterface(unk2, iid, (void **)&unk3);
152 ok(hr == S_OK, "Got hr %#x.\n", hr);
153 ok(unk3 == unk, "Interface pointers didn't match.\n");
154 IUnknown_Release(unk3);
155 IUnknown_Release(unk2);
157 ref = IUnknown_Release(unk);
158 ok(!ref, "Got outstanding refcount %d.\n", ref);
161 static void build_pcm_format(WAVEFORMATEX *format, WORD tag, WORD depth, DWORD sample_rate, WORD channels)
163 format->wFormatTag = tag;
164 format->wBitsPerSample = depth;
165 format->nChannels = channels;
166 format->nSamplesPerSec = sample_rate;
167 format->nBlockAlign = channels * depth / 8;
168 format->nAvgBytesPerSec = sample_rate * channels * depth / 8;
169 format->cbSize = 0;
172 static void test_media_types(const GUID *clsid)
174 WAVEFORMATEX wfx;
175 DMO_MEDIA_TYPE mt =
177 .majortype = MEDIATYPE_Audio,
178 .subtype = MEDIASUBTYPE_PCM,
179 .formattype = FORMAT_WaveFormatEx,
180 .cbFormat = sizeof(wfx),
181 .pbFormat = (BYTE *)&wfx,
183 IMediaObject *dmo;
184 unsigned int i, j;
185 WORD channels;
186 HRESULT hr;
187 ULONG ref;
189 static const DWORD sample_rates[] = {8000, 11025, 22050, 44100, 48000, 96000};
190 static const struct
192 WORD format;
193 WORD depth;
195 depths[] =
197 {WAVE_FORMAT_PCM, 8},
198 {WAVE_FORMAT_PCM, 16},
199 {WAVE_FORMAT_IEEE_FLOAT, 32},
202 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IMediaObject, (void **)&dmo);
203 ok(hr == S_OK, "Got hr %#x.\n", hr);
205 build_pcm_format(&wfx, WAVE_FORMAT_PCM, 16, 44100, 2);
207 mt.majortype = MEDIATYPE_Video;
208 hr = IMediaObject_SetInputType(dmo, 0, &mt, 0);
209 ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr);
210 mt.majortype = GUID_NULL;
211 hr = IMediaObject_SetInputType(dmo, 0, &mt, 0);
212 ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr);
213 mt.majortype = MEDIATYPE_Audio;
215 mt.subtype = MEDIASUBTYPE_RGB8;
216 hr = IMediaObject_SetInputType(dmo, 0, &mt, 0);
217 ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr);
218 mt.subtype = GUID_NULL;
219 hr = IMediaObject_SetInputType(dmo, 0, &mt, 0);
220 ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr);
221 mt.subtype = MEDIASUBTYPE_IEEE_FLOAT;
222 hr = IMediaObject_SetInputType(dmo, 0, &mt, 0);
223 ok(hr == S_OK, "Got hr %#x.\n", hr);
224 mt.subtype = MEDIASUBTYPE_PCM;
226 mt.formattype = FORMAT_VideoInfo;
227 hr = IMediaObject_SetInputType(dmo, 0, &mt, 0);
228 ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr);
229 mt.formattype = FORMAT_None;
230 hr = IMediaObject_SetInputType(dmo, 0, &mt, 0);
231 ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr);
232 mt.formattype = GUID_NULL;
233 hr = IMediaObject_SetInputType(dmo, 0, &mt, 0);
234 ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x.\n", hr);
235 mt.formattype = FORMAT_WaveFormatEx;
237 for (i = 0; i < ARRAY_SIZE(sample_rates); ++i)
239 for (j = 0; j < ARRAY_SIZE(depths); ++j)
241 /* Waves reverberation is documented as not supporting 8-bit PCM. */
242 if (IsEqualGUID(clsid, &GUID_DSFX_WAVES_REVERB) && depths[j].depth == 8)
243 continue;
245 for (channels = 1; channels <= 2; ++channels)
247 build_pcm_format(&wfx, depths[j].format, depths[j].depth, sample_rates[i], channels);
249 hr = IMediaObject_SetInputType(dmo, 0, &mt, 0);
250 ok(hr == S_OK, "Got hr %#x for %u Hz, %u channels, format %#x, depth %u.\n",
251 hr, sample_rates[i], channels, depths[j].format, depths[j].depth);
253 /* The output type must match the input type. */
255 build_pcm_format(&wfx, depths[j].format, depths[j].depth, sample_rates[i], 3 - channels);
256 hr = IMediaObject_SetOutputType(dmo, 0, &mt, 0);
257 ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x for %u Hz, %u channels, format %#x, depth %u.\n",
258 hr, sample_rates[i], channels, depths[j].format, depths[j].depth);
260 build_pcm_format(&wfx, depths[j].format, depths[j].depth, 2 * sample_rates[i], channels);
261 hr = IMediaObject_SetOutputType(dmo, 0, &mt, 0);
262 ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x for %u Hz, %u channels, format %#x, depth %u.\n",
263 hr, sample_rates[i], channels, depths[j].format, depths[j].depth);
265 build_pcm_format(&wfx, depths[j].format, 24 - depths[j].depth, sample_rates[i], channels);
266 hr = IMediaObject_SetOutputType(dmo, 0, &mt, 0);
267 ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#x for %u Hz, %u channels, format %#x, depth %u.\n",
268 hr, sample_rates[i], channels, depths[j].format, depths[j].depth);
270 build_pcm_format(&wfx, depths[j].format, depths[j].depth, sample_rates[i], channels);
271 hr = IMediaObject_SetOutputType(dmo, 0, &mt, 0);
272 ok(hr == S_OK, "Got hr %#x for %u Hz, %u channels, format %#x, depth %u.\n",
273 hr, sample_rates[i], channels, depths[j].format, depths[j].depth);
275 hr = IMediaObject_SetInputType(dmo, 0, NULL, DMO_SET_TYPEF_CLEAR);
276 ok(hr == S_OK, "Got hr %#x for %u Hz, %u channels, format %#x, depth %u.\n",
277 hr, sample_rates[i], channels, depths[j].format, depths[j].depth);
279 hr = IMediaObject_SetOutputType(dmo, 0, NULL, DMO_SET_TYPEF_CLEAR);
280 ok(hr == S_OK, "Got hr %#x for %u Hz, %u channels, format %#x, depth %u.\n",
281 hr, sample_rates[i], channels, depths[j].format, depths[j].depth);
283 hr = IMediaObject_SetInputType(dmo, 0, NULL, DMO_SET_TYPEF_CLEAR);
284 ok(hr == S_OK, "Got hr %#x for %u Hz, %u channels, format %#x, depth %u.\n",
285 hr, sample_rates[i], channels, depths[j].format, depths[j].depth);
290 ref = IMediaObject_Release(dmo);
291 ok(!ref, "Got outstanding refcount %d.\n", ref);
294 static void test_chorus_parameters(void)
296 IDirectSoundFXChorus *chorus;
297 DSFXChorus params;
298 HRESULT hr;
299 ULONG ref;
301 hr = CoCreateInstance(&GUID_DSFX_STANDARD_CHORUS, NULL, CLSCTX_INPROC_SERVER,
302 &IID_IDirectSoundFXChorus, (void **)&chorus);
303 todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
304 if (hr != S_OK)
305 return;
307 hr = IDirectSoundFXChorus_GetAllParameters(chorus, &params);
308 ok(hr == S_OK, "Got hr %#x.\n", hr);
309 ok(params.fWetDryMix == 50.0f, "Got wetness %.8e%%.\n", params.fWetDryMix);
310 ok(params.fDepth == 10.0f, "Got depth %.8e.\n", params.fDepth);
311 ok(params.fFeedback == 25.0f, "Got feedback %.8e.\n", params.fFeedback);
312 ok(params.fFrequency == 1.1f, "Got LFO frequency %.8e.\n", params.fFrequency);
313 ok(params.lWaveform == DSFXCHORUS_WAVE_SIN, "Got LFO waveform %d.\n", params.lWaveform);
314 ok(params.fDelay == 16.0f, "Got delay %.8e.\n", params.fDelay);
315 ok(params.lPhase == 3, "Got phase differential %d.\n", params.lPhase);
317 ref = IDirectSoundFXChorus_Release(chorus);
318 ok(!ref, "Got outstanding refcount %d.\n", ref);
321 static void test_compressor_parameters(void)
323 IDirectSoundFXCompressor *compressor;
324 DSFXCompressor params;
325 HRESULT hr;
326 ULONG ref;
328 hr = CoCreateInstance(&GUID_DSFX_STANDARD_COMPRESSOR, NULL, CLSCTX_INPROC_SERVER,
329 &IID_IDirectSoundFXCompressor, (void **)&compressor);
330 todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
331 if (hr != S_OK)
332 return;
334 hr = IDirectSoundFXCompressor_GetAllParameters(compressor, &params);
335 ok(hr == S_OK, "Got hr %#x.\n", hr);
336 ok(params.fGain == 0.0f, "Got gain %.8e dB.\n", params.fGain);
337 ok(params.fAttack == 10.0f, "Got attack time %.8e ms.\n", params.fAttack);
338 ok(params.fThreshold == -20.0f, "Got threshold %.8e dB.\n", params.fThreshold);
339 ok(params.fRatio == 3.0f, "Got ratio %.8e:1.\n", params.fRatio);
340 ok(params.fPredelay == 4.0f, "Got pre-delay %.8e ms.\n", params.fPredelay);
342 ref = IDirectSoundFXCompressor_Release(compressor);
343 ok(!ref, "Got outstanding refcount %d.\n", ref);
346 static void test_distortion_parameters(void)
348 IDirectSoundFXDistortion *distortion;
349 DSFXDistortion params;
350 HRESULT hr;
351 ULONG ref;
353 hr = CoCreateInstance(&GUID_DSFX_STANDARD_DISTORTION, NULL, CLSCTX_INPROC_SERVER,
354 &IID_IDirectSoundFXDistortion, (void **)&distortion);
355 todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
356 if (hr != S_OK)
357 return;
359 hr = IDirectSoundFXDistortion_GetAllParameters(distortion, &params);
360 ok(hr == S_OK, "Got hr %#x.\n", hr);
361 ok(params.fGain == -18.0f, "Got gain %.8e dB.\n", params.fGain);
362 ok(params.fEdge == 15.0f, "Got edge %.8e%%.\n", params.fEdge);
363 ok(params.fPostEQCenterFrequency == 2400.0f, "Got center frequency %.8e Hz.\n", params.fPostEQCenterFrequency);
364 ok(params.fPostEQBandwidth == 2400.0f, "Got band width %.8e Hz.\n", params.fPostEQBandwidth);
365 ok(params.fPreLowpassCutoff == 8000.0f, "Got pre-lowpass cutoff %.8e Hz.\n", params.fPreLowpassCutoff);
367 ref = IDirectSoundFXDistortion_Release(distortion);
368 ok(!ref, "Got outstanding refcount %d.\n", ref);
371 static void test_echo_parameters(void)
373 IDirectSoundFXEcho *echo;
374 DSFXEcho params;
375 HRESULT hr;
376 ULONG ref;
378 hr = CoCreateInstance(&GUID_DSFX_STANDARD_ECHO, NULL, CLSCTX_INPROC_SERVER,
379 &IID_IDirectSoundFXEcho, (void **)&echo);
380 todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
381 if (hr != S_OK)
382 return;
384 hr = IDirectSoundFXEcho_GetAllParameters(echo, &params);
385 ok(hr == S_OK, "Got hr %#x.\n", hr);
386 ok(params.fWetDryMix == 50.0f, "Got %.8e%% wetness.\n", params.fWetDryMix);
387 ok(params.fFeedback == 50.0f, "Got %.8e%% feedback.\n", params.fFeedback);
388 ok(params.fLeftDelay == 500.0f, "Got left delay %.8e ms.\n", params.fLeftDelay);
389 ok(params.fRightDelay == 500.0f, "Got right delay %.8e ms.\n", params.fRightDelay);
390 ok(!params.lPanDelay, "Got delay swap %d.\n", params.lPanDelay);
392 ref = IDirectSoundFXEcho_Release(echo);
393 ok(!ref, "Got outstanding refcount %d.\n", ref);
396 static void test_flanger_parameters(void)
398 IDirectSoundFXFlanger *flanger;
399 DSFXFlanger params;
400 HRESULT hr;
401 ULONG ref;
403 hr = CoCreateInstance(&GUID_DSFX_STANDARD_FLANGER, NULL, CLSCTX_INPROC_SERVER,
404 &IID_IDirectSoundFXFlanger, (void **)&flanger);
405 todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
406 if (hr != S_OK)
407 return;
409 hr = IDirectSoundFXFlanger_GetAllParameters(flanger, &params);
410 ok(hr == S_OK, "Got hr %#x.\n", hr);
411 ok(params.fWetDryMix == 50.0f, "Got %.8e%% wetness.\n", params.fWetDryMix);
412 ok(params.fDepth == 100.0f, "Got %.8e * 0.01%% depth.\n", params.fDepth);
413 ok(params.fFeedback == -50.0f, "Got %.8e%% feedback.\n", params.fFeedback);
414 ok(params.lWaveform == DSFXFLANGER_WAVE_SIN, "Got LFO waveform %d.\n", params.lWaveform);
415 ok(params.fDelay == 2.0f, "Got delay %.8e ms.\n", params.fDelay);
416 ok(params.lPhase == DSFXFLANGER_PHASE_ZERO, "Got phase differential %d.\n", params.lPhase);
418 ref = IDirectSoundFXFlanger_Release(flanger);
419 ok(!ref, "Got outstanding refcount %d.\n", ref);
422 static void test_gargle_parameters(void)
424 IDirectSoundFXGargle *gargle;
425 DSFXGargle params;
426 HRESULT hr;
427 ULONG ref;
429 hr = CoCreateInstance(&GUID_DSFX_STANDARD_GARGLE, NULL, CLSCTX_INPROC_SERVER,
430 &IID_IDirectSoundFXGargle, (void **)&gargle);
431 todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
432 if (hr != S_OK)
433 return;
435 hr = IDirectSoundFXGargle_GetAllParameters(gargle, &params);
436 ok(hr == S_OK, "Got hr %#x.\n", hr);
437 ok(params.dwRateHz == 20, "Got rate %u Hz.\n", params.dwRateHz);
438 ok(params.dwWaveShape == DSFXGARGLE_WAVE_TRIANGLE, "Got wave shape %u.\n", params.dwWaveShape);
440 ref = IDirectSoundFXGargle_Release(gargle);
441 ok(!ref, "Got outstanding refcount %d.\n", ref);
444 static void test_eq_parameters(void)
446 IDirectSoundFXParamEq *eq;
447 DSFXParamEq params;
448 HRESULT hr;
449 ULONG ref;
451 hr = CoCreateInstance(&GUID_DSFX_STANDARD_PARAMEQ, NULL, CLSCTX_INPROC_SERVER,
452 &IID_IDirectSoundFXParamEq, (void **)&eq);
453 ok(hr == S_OK, "Got hr %#x.\n", hr);
455 hr = IDirectSoundFXParamEq_GetAllParameters(eq, &params);
456 ok(hr == S_OK, "Got hr %#x.\n", hr);
457 ok(params.fCenter == 8000.0f, "Got center frequency %.8e Hz.\n", params.fCenter);
458 ok(params.fBandwidth == 12.0f, "Got band width %.8e semitones.\n", params.fBandwidth);
459 ok(params.fGain == 0.0f, "Got gain %.8e.\n", params.fGain);
461 params.fCenter = 79.0f;
462 hr = IDirectSoundFXParamEq_SetAllParameters(eq, &params);
463 todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
464 params.fCenter = 16001.0f;
465 hr = IDirectSoundFXParamEq_SetAllParameters(eq, &params);
466 todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
467 params.fCenter = 738.0f;
468 hr = IDirectSoundFXParamEq_SetAllParameters(eq, &params);
469 ok(hr == S_OK, "Got hr %#x.\n", hr);
471 memset(&params, 0xcc, sizeof(params));
472 hr = IDirectSoundFXParamEq_GetAllParameters(eq, &params);
473 ok(hr == S_OK, "Got hr %#x.\n", hr);
474 ok(params.fCenter == 738.0f, "Got center frequency %.8e Hz.\n", params.fCenter);
475 ok(params.fBandwidth == 12.0f, "Got band width %.8e semitones.\n", params.fBandwidth);
476 ok(params.fGain == 0.0f, "Got gain %.8e.\n", params.fGain);
478 ref = IDirectSoundFXParamEq_Release(eq);
479 ok(!ref, "Got outstanding refcount %d.\n", ref);
482 static void test_reverb_parameters(void)
484 IDirectSoundFXI3DL2Reverb *reverb;
485 DSFXI3DL2Reverb params;
486 HRESULT hr;
487 ULONG ref;
489 hr = CoCreateInstance(&GUID_DSFX_STANDARD_I3DL2REVERB, NULL, CLSCTX_INPROC_SERVER,
490 &IID_IDirectSoundFXI3DL2Reverb, (void **)&reverb);
491 ok(hr == S_OK, "Got hr %#x.\n", hr);
493 hr = IDirectSoundFXI3DL2Reverb_GetAllParameters(reverb, &params);
494 ok(hr == S_OK, "Got hr %#x.\n", hr);
495 ok(params.lRoom == -1000, "Got room attenuation %d mB.\n", params.lRoom);
496 ok(params.lRoomHF == -100, "Got room high-frequency attenuation %d mB.\n", params.lRoomHF);
497 ok(params.flRoomRolloffFactor == 0.0f, "Got room rolloff factor %.8e.\n", params.flRoomRolloffFactor);
498 ok(params.flDecayTime == 1.49f, "Got decay time %.8e s.\n", params.flDecayTime);
499 ok(params.flDecayHFRatio == 0.83f, "Got decay time ratio %.8e.\n", params.flDecayHFRatio);
500 ok(params.lReflections == -2602, "Got early reflection attenuation %d mB.\n", params.lReflections);
501 ok(params.flReflectionsDelay == 0.007f, "Got first reflection delay %.8e s.\n", params.flReflectionsDelay);
502 ok(params.lReverb == 200, "Got reverb attenuation %d mB.\n", params.lReverb);
503 ok(params.flReverbDelay == 0.011f, "Got reverb delay %.8e s.\n", params.flReverbDelay);
504 ok(params.flDiffusion == 100.0f, "Got diffusion %.8e%%.\n", params.flDiffusion);
505 ok(params.flDensity == 100.0f, "Got density %.8e%%.\n", params.flDensity);
506 ok(params.flHFReference == 5000.0f, "Got reference high frequency %.8e Hz.\n", params.flHFReference);
508 params.lRoom = -10001;
509 hr = IDirectSoundFXI3DL2Reverb_SetAllParameters(reverb, &params);
510 todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
511 params.lRoom = 1;
512 hr = IDirectSoundFXI3DL2Reverb_SetAllParameters(reverb, &params);
513 todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
514 params.lRoom = -900;
515 hr = IDirectSoundFXI3DL2Reverb_SetAllParameters(reverb, &params);
516 ok(hr == S_OK, "Got hr %#x.\n", hr);
518 memset(&params, 0xcc, sizeof(params));
519 hr = IDirectSoundFXI3DL2Reverb_GetAllParameters(reverb, &params);
520 ok(hr == S_OK, "Got hr %#x.\n", hr);
521 ok(params.lRoom == -900, "Got room attenuation %d mB.\n", params.lRoom);
523 ref = IDirectSoundFXI3DL2Reverb_Release(reverb);
524 ok(!ref, "Got outstanding refcount %d.\n", ref);
527 START_TEST(dsdmo)
529 static const struct
531 const GUID *clsid;
532 const GUID *iid;
533 BOOL todo;
535 tests[] =
537 {&GUID_DSFX_STANDARD_CHORUS, &IID_IDirectSoundFXChorus, TRUE},
538 {&GUID_DSFX_STANDARD_COMPRESSOR, &IID_IDirectSoundFXCompressor, TRUE},
539 {&GUID_DSFX_STANDARD_DISTORTION, &IID_IDirectSoundFXDistortion, TRUE},
540 {&GUID_DSFX_STANDARD_ECHO, &IID_IDirectSoundFXEcho, TRUE},
541 {&GUID_DSFX_STANDARD_FLANGER, &IID_IDirectSoundFXFlanger, TRUE},
542 {&GUID_DSFX_STANDARD_GARGLE, &IID_IDirectSoundFXGargle, TRUE},
543 {&GUID_DSFX_STANDARD_I3DL2REVERB, &IID_IDirectSoundFXI3DL2Reverb},
544 {&GUID_DSFX_STANDARD_PARAMEQ, &IID_IDirectSoundFXParamEq},
545 {&GUID_DSFX_WAVES_REVERB, &IID_IDirectSoundFXWavesReverb},
547 unsigned int i;
549 CoInitializeEx(NULL, COINIT_MULTITHREADED);
551 for (i = 0; i < ARRAY_SIZE(tests); ++i)
553 IUnknown *unk;
554 HRESULT hr;
556 hr = CoCreateInstance(tests[i].clsid, NULL, CLSCTX_INPROC_SERVER, tests[i].iid, (void **)&unk);
557 todo_wine_if(tests[i].todo) ok(hr == S_OK, "Failed to create %s, hr %#x.\n",
558 debugstr_guid(tests[i].clsid), hr);
559 if (hr == S_OK)
560 IUnknown_Release(unk);
561 else
562 continue;
564 test_aggregation(tests[i].clsid);
565 test_interfaces(tests[i].clsid, tests[i].iid);
566 test_media_types(tests[i].clsid);
569 test_chorus_parameters();
570 test_compressor_parameters();
571 test_distortion_parameters();
572 test_echo_parameters();
573 test_flanger_parameters();
574 test_gargle_parameters();
575 test_reverb_parameters();
576 test_eq_parameters();
578 CoUninitialize();