msvcp140: Add task_continuation_context constructor implementation.
[wine.git] / dlls / dmusic / tests / dmusic.c
blobb56bba4a4a15532047cb0d65841f0f2d9921b368
1 /*
2 * Unit tests for dmusic functions
4 * Copyright (C) 2012 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include <stdio.h>
25 #include "wine/test.h"
26 #include "uuids.h"
27 #include "ole2.h"
28 #include "initguid.h"
29 #include "dmusici.h"
30 #include "dmksctrl.h"
32 static inline const char* debugstr_longlong(ULONGLONG ll)
34 static char string[17];
35 if (sizeof(ll) > sizeof(unsigned long) && ll >> 32)
36 sprintf(string, "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll);
37 else
38 sprintf(string, "%lx", (unsigned long)ll);
39 return string;
42 static void test_dmusic(void)
44 IDirectMusic *dmusic = NULL;
45 HRESULT hr;
46 ULONG index = 0;
47 DMUS_PORTCAPS port_caps;
48 DMUS_PORTPARAMS port_params;
49 IDirectMusicPort *port = NULL;
50 DMUS_CLOCKINFO clock_info;
51 GUID guid_clock;
52 IReferenceClock *clock = NULL;
54 hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic, (LPVOID*)&dmusic);
55 ok(hr == S_OK, "Cannot create DirectMusic object (%x)\n", hr);
57 hr = IDirectMusic_GetMasterClock(dmusic, &guid_clock, &clock);
58 ok(hr == S_OK, "IDirectMusic_GetMasterClock returned: %x\n", hr);
59 ok(clock != NULL, "No clock returned\n");
60 trace(" guidPort = %s\n", wine_dbgstr_guid(&guid_clock));
61 if (clock)
62 IReferenceClock_Release(clock);
64 port_params.dwSize = sizeof(port_params);
65 port_params.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS | DMUS_PORTPARAMS_AUDIOCHANNELS;
66 port_params.dwChannelGroups = 1;
67 port_params.dwAudioChannels = 2;
69 /* No port can be created before SetDirectSound is called */
70 hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &port_params, &port, NULL);
71 todo_wine ok(hr == DMUS_E_DSOUND_NOT_SET, "IDirectMusic_CreatePort returned: %x\n", hr);
73 hr = IDirectMusic_SetDirectSound(dmusic, NULL, NULL);
74 ok(hr == S_OK, "IDirectMusic_SetDirectSound returned: %x\n", hr);
76 /* Check wrong params */
77 hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &port_params, &port, (IUnknown*)dmusic);
78 ok(hr == CLASS_E_NOAGGREGATION, "IDirectMusic_CreatePort returned: %x\n", hr);
79 hr = IDirectMusic_CreatePort(dmusic, NULL, &port_params, &port, NULL);
80 ok(hr == E_POINTER, "IDirectMusic_CreatePort returned: %x\n", hr);
81 hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, NULL, &port, NULL);
82 ok(hr == E_INVALIDARG, "IDirectMusic_CreatePort returned: %x\n", hr);
83 hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &port_params, NULL, NULL);
84 ok(hr == E_POINTER, "IDirectMusic_CreatePort returned: %x\n", hr);
86 /* Test creation of default port with GUID_NULL */
87 hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &port_params, &port, NULL);
88 ok(hr == S_OK, "IDirectMusic_CreatePort returned: %x\n", hr);
90 port_caps.dwSize = sizeof(port_caps);
91 while (IDirectMusic_EnumPort(dmusic, index, &port_caps) == S_OK)
93 ok(port_caps.dwSize == sizeof(port_caps), "DMUS_PORTCAPS dwSize member is wrong (%u)\n", port_caps.dwSize);
94 trace("Port %u:\n", index);
95 trace(" dwFlags = %x\n", port_caps.dwFlags);
96 trace(" guidPort = %s\n", wine_dbgstr_guid(&port_caps.guidPort));
97 trace(" dwClass = %u\n", port_caps.dwClass);
98 trace(" dwType = %u\n", port_caps.dwType);
99 trace(" dwMemorySize = %u\n", port_caps.dwMemorySize);
100 trace(" dwMaxChannelGroups = %u\n", port_caps.dwMaxChannelGroups);
101 trace(" dwMaxVoices = %u\n", port_caps.dwMaxVoices);
102 trace(" dwMaxAudioChannels = %u\n", port_caps.dwMaxAudioChannels);
103 trace(" dwEffectFlags = %x\n", port_caps.dwEffectFlags);
104 trace(" wszDescription = %s\n", wine_dbgstr_w(port_caps.wszDescription));
105 index++;
108 index = 0;
109 clock_info.dwSize = sizeof(clock_info);
110 while (IDirectMusic_EnumMasterClock(dmusic, index, &clock_info) == S_OK)
112 ok(clock_info.dwSize == sizeof(clock_info), "DMUS_CLOCKINFO dwSize member is wrong (%u)\n", clock_info.dwSize);
113 trace("Clock %u:\n", index);
114 trace(" ctType = %u\n", clock_info.ctType);
115 trace(" guidClock = %s\n", wine_dbgstr_guid(&clock_info.guidClock));
116 trace(" wszDescription = %s\n", wine_dbgstr_w(clock_info.wszDescription));
117 index++;
120 if (port)
121 IDirectMusicPort_Release(port);
122 IDirectMusic_Release(dmusic);
125 static void test_dmbuffer(void)
127 IDirectMusic *dmusic;
128 IDirectMusicBuffer *dmbuffer = NULL;
129 HRESULT hr;
130 DMUS_BUFFERDESC desc;
131 GUID format;
132 DWORD size;
133 DWORD bytes;
134 REFERENCE_TIME time;
135 LPBYTE data;
137 hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic, (LPVOID*)&dmusic);
138 ok(hr == S_OK, "Cannot create DirectMusic object (%x)\n", hr);
140 desc.dwSize = sizeof(DMUS_BUFFERDESC);
141 desc.dwFlags = 0;
142 desc.cbBuffer = 1023;
143 memcpy(&desc.guidBufferFormat, &GUID_NULL, sizeof(GUID));
145 hr = IDirectMusic_CreateMusicBuffer(dmusic, &desc, &dmbuffer, NULL);
146 ok(hr == S_OK, "IDirectMusic_CreateMusicBuffer return %x\n", hr);
148 hr = IDirectMusicBuffer_GetBufferFormat(dmbuffer, &format);
149 ok(hr == S_OK, "IDirectMusicBuffer_GetBufferFormat returned %x\n", hr);
150 ok(IsEqualGUID(&format, &KSDATAFORMAT_SUBTYPE_MIDI), "Wrong format returned %s\n", wine_dbgstr_guid(&format));
151 hr = IDirectMusicBuffer_GetMaxBytes(dmbuffer, &size);
152 ok(hr == S_OK, "IDirectMusicBuffer_GetMaxBytes returned %x\n", hr);
153 ok(size == 1024, "Buffer size is %u instead of 1024\n", size);
155 hr = IDirectMusicBuffer_GetStartTime(dmbuffer, &time);
156 ok(hr == DMUS_E_BUFFER_EMPTY, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
157 hr = IDirectMusicBuffer_SetStartTime(dmbuffer, 10);
158 ok(hr == S_OK, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
159 hr = IDirectMusicBuffer_GetStartTime(dmbuffer, &time);
160 ok(hr == DMUS_E_BUFFER_EMPTY, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
162 hr = IDirectMusicBuffer_PackStructured(dmbuffer, 20, 0, 0);
163 ok(hr == DMUS_E_INVALID_EVENT, "IDirectMusicBuffer_PackStructured returned %x\n", hr);
164 hr = IDirectMusicBuffer_PackStructured(dmbuffer, 20, 0, 0x000090); /* note on : chan 0, note 0 & vel 0 */
165 ok(hr == S_OK, "IDirectMusicBuffer_PackStructured returned %x\n", hr);
166 hr = IDirectMusicBuffer_PackStructured(dmbuffer, 30, 0, 0x000080); /* note off : chan 0, note 0 & vel 0 */
167 ok(hr == S_OK, "IDirectMusicBuffer_PackStructured returned %x\n", hr);
168 hr = IDirectMusicBuffer_GetUsedBytes(dmbuffer, &bytes);
169 ok(hr == S_OK, "IDirectMusicBuffer_GetUsedBytes returned %x\n", hr);
170 ok(bytes == 48, "Buffer size is %u instead of 48\n", bytes);
172 hr = IDirectMusicBuffer_GetStartTime(dmbuffer, &time);
173 ok(hr == S_OK, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
174 ok(time == 20, "Buffer start time is wrong\n");
175 hr = IDirectMusicBuffer_SetStartTime(dmbuffer, 40);
176 ok(hr == S_OK, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
177 hr = IDirectMusicBuffer_GetStartTime(dmbuffer, &time);
178 ok(hr == S_OK, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
179 ok(time == 40, "Buffer start time is wrong\n");
181 hr = IDirectMusicBuffer_GetRawBufferPtr(dmbuffer, &data);
182 ok(hr == S_OK, "IDirectMusicBuffer_GetRawBufferPtr returned %x\n", hr);
183 if (hr == S_OK)
185 DMUS_EVENTHEADER* header;
186 DWORD message;
188 /* Check message 1 */
189 header = (DMUS_EVENTHEADER*)data;
190 data += sizeof(DMUS_EVENTHEADER);
191 ok(header->cbEvent == 3, "cbEvent is %u instead of 3\n", header->cbEvent);
192 ok(header->dwChannelGroup == 0, "dwChannelGroup is %u instead of 0\n", header->dwChannelGroup);
193 ok(header->rtDelta == 0, "rtDelta is %s instead of 0\n", debugstr_longlong(header->rtDelta));
194 ok(header->dwFlags == DMUS_EVENT_STRUCTURED, "dwFlags is %x instead of %x\n", header->dwFlags, DMUS_EVENT_STRUCTURED);
195 message = *(DWORD*)data & 0xffffff; /* Only 3 bytes are relevant */
196 data += sizeof(DWORD);
197 ok(message == 0x000090, "Message is %0x instead of 0x000090\n", message);
199 /* Check message 2 */
200 header = (DMUS_EVENTHEADER*)data;
201 data += sizeof(DMUS_EVENTHEADER);
202 ok(header->cbEvent == 3, "cbEvent is %u instead of 3\n", header->cbEvent);
203 ok(header->dwChannelGroup == 0, "dwChannelGroup is %u instead of 0\n", header->dwChannelGroup);
204 ok(header->rtDelta == 10, "rtDelta is %s instead of 0\n", debugstr_longlong(header->rtDelta));
205 ok(header->dwFlags == DMUS_EVENT_STRUCTURED, "dwFlags is %x instead of %x\n", header->dwFlags, DMUS_EVENT_STRUCTURED);
206 message = *(DWORD*)data & 0xffffff; /* Only 3 bytes are relevant */
207 ok(message == 0x000080, "Message 2 is %0x instead of 0x000080\n", message);
210 if (dmbuffer)
211 IDirectMusicBuffer_Release(dmbuffer);
212 IDirectMusic_Release(dmusic);
215 static void test_COM(void)
217 IDirectMusic8 *dm8 = (IDirectMusic8*)0xdeadbeef;
218 IDirectMusic *dm;
219 IUnknown *unk;
220 ULONG refcount;
221 HRESULT hr;
223 /* COM aggregation */
224 hr = CoCreateInstance(&CLSID_DirectMusic, (IUnknown*)&dm8, CLSCTX_INPROC_SERVER, &IID_IUnknown,
225 (void**)&dm8);
226 ok(hr == CLASS_E_NOAGGREGATION,
227 "DirectMusic8 create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr);
228 ok(!dm8, "dm8 = %p\n", dm8);
230 /* Invalid RIID */
231 hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicObject,
232 (void**)&dm8);
233 ok(hr == E_NOINTERFACE, "DirectMusic8 create failed: %08x, expected E_NOINTERFACE\n", hr);
235 /* Same refcount for DirectMusic and DirectMusic8 */
236 hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8,
237 (void**)&dm8);
238 if (hr == E_NOINTERFACE)
240 win_skip("DirectMusic too old (no IDirectMusic8)\n");
241 return;
243 ok(hr == S_OK, "DirectMusic8 create failed: %08x, expected S_OK\n", hr);
244 refcount = IDirectMusic8_AddRef(dm8);
245 ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
247 hr = IDirectMusic8_QueryInterface(dm8, &IID_IDirectMusic, (void**)&dm);
248 ok(hr == S_OK, "QueryInterface for IID_IDirectMusic failed: %08x\n", hr);
249 refcount = IDirectMusic_AddRef(dm);
250 ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
251 IDirectMusic_Release(dm);
253 hr = IDirectMusic8_QueryInterface(dm8, &IID_IUnknown, (void**)&unk);
254 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
255 refcount = IUnknown_AddRef(unk);
256 ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
257 refcount = IUnknown_Release(unk);
259 ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
260 while (IDirectMusic8_Release(dm8));
263 static void test_COM_dmcoll(void)
265 IDirectMusicCollection *dmc = (IDirectMusicCollection*)0xdeadbeef;
266 IDirectMusicObject *dmo;
267 IPersistStream *ps;
268 IUnknown *unk;
269 ULONG refcount;
270 HRESULT hr;
272 /* COM aggregation */
273 hr = CoCreateInstance(&CLSID_DirectMusicCollection, (IUnknown*)&dmc, CLSCTX_INPROC_SERVER,
274 &IID_IUnknown, (void**)&dmc);
275 ok(hr == CLASS_E_NOAGGREGATION,
276 "DirectMusicCollection create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr);
277 ok(!dmc, "dmc = %p\n", dmc);
279 /* Invalid RIID */
280 hr = CoCreateInstance(&CLSID_DirectMusicCollection, NULL, CLSCTX_INPROC_SERVER,
281 &IID_IClassFactory, (void**)&dmc);
282 ok(hr == E_NOINTERFACE, "DirectMusicCollection create failed: %08x, expected E_NOINTERFACE\n", hr);
284 /* Same refcount for all DirectMusicCollection interfaces */
285 hr = CoCreateInstance(&CLSID_DirectMusicCollection, NULL, CLSCTX_INPROC_SERVER,
286 &IID_IDirectMusicCollection, (void**)&dmc);
287 ok(hr == S_OK, "DirectMusicCollection create failed: %08x, expected S_OK\n", hr);
288 refcount = IDirectMusicCollection_AddRef(dmc);
289 ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
291 hr = IDirectMusicCollection_QueryInterface(dmc, &IID_IDirectMusicObject, (void**)&dmo);
292 ok(hr == S_OK, "QueryInterface for IID_IDirectMusicObject failed: %08x\n", hr);
293 refcount = IDirectMusicObject_AddRef(dmo);
294 ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
295 refcount = IDirectMusicObject_Release(dmo);
297 hr = IDirectMusicCollection_QueryInterface(dmc, &IID_IPersistStream, (void**)&ps);
298 ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
299 refcount = IPersistStream_AddRef(ps);
300 ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
301 refcount = IPersistStream_Release(ps);
303 hr = IDirectMusicCollection_QueryInterface(dmc, &IID_IUnknown, (void**)&unk);
304 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
305 refcount = IUnknown_AddRef(unk);
306 ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
307 refcount = IUnknown_Release(unk);
309 ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
310 while (IDirectMusicCollection_Release(dmc));
313 static void test_dmcoll(void)
315 IDirectMusicCollection *dmc;
316 IDirectMusicObject *dmo;
317 IPersistStream *ps;
318 DMUS_OBJECTDESC desc;
319 CLSID class;
320 ULARGE_INTEGER size;
321 HRESULT hr;
323 hr = CoCreateInstance(&CLSID_DirectMusicCollection, NULL, CLSCTX_INPROC_SERVER,
324 &IID_IDirectMusicCollection, (void**)&dmc);
325 ok(hr == S_OK, "DirectMusicCollection create failed: %08x, expected S_OK\n", hr);
327 /* IDirectMusicObject */
328 hr = IDirectMusicCollection_QueryInterface(dmc, &IID_IDirectMusicObject, (void**)&dmo);
329 ok(hr == S_OK, "QueryInterface for IID_IDirectMusicObject failed: %08x\n", hr);
330 hr = IDirectMusicObject_GetDescriptor(dmo, NULL);
331 ok(hr == E_POINTER, "IDirectMusicObject_GetDescriptor: expected E_POINTER, got %08x\n", hr);
332 hr = IDirectMusicObject_SetDescriptor(dmo, NULL);
333 ok(hr == E_POINTER, "IDirectMusicObject_SetDescriptor: expected E_POINTER, got %08x\n", hr);
334 ZeroMemory(&desc, sizeof(desc));
335 hr = IDirectMusicObject_GetDescriptor(dmo, &desc);
336 ok(hr == S_OK, "IDirectMusicObject_GetDescriptor failed: %08x\n", hr);
337 ok(desc.dwValidData == DMUS_OBJ_CLASS,
338 "Fresh object has more valid data (%08x) than DMUS_OBJ_CLASS\n", desc.dwValidData);
339 /* DMUS_OBJ_CLASS is immutable */
340 desc.dwValidData = DMUS_OBJ_CLASS;
341 hr = IDirectMusicObject_SetDescriptor(dmo, &desc);
342 ok(hr == S_FALSE , "IDirectMusicObject_SetDescriptor failed: %08x\n", hr);
343 ok(!desc.dwValidData, "dwValidData wasn't cleared: %08x\n", desc.dwValidData);
344 desc.dwValidData = DMUS_OBJ_CLASS;
345 desc.guidClass = CLSID_DirectMusicSegment;
346 hr = IDirectMusicObject_SetDescriptor(dmo, &desc);
347 ok(hr == S_FALSE && !desc.dwValidData, "IDirectMusicObject_SetDescriptor failed: %08x\n", hr);
348 hr = IDirectMusicObject_GetDescriptor(dmo, &desc);
349 ok(hr == S_OK, "IDirectMusicObject_GetDescriptor failed: %08x\n", hr);
350 ok(IsEqualGUID(&desc.guidClass, &CLSID_DirectMusicCollection),
351 "guidClass changed, should be CLSID_DirectMusicCollection\n");
353 /* Unimplemented IPersistStream methods*/
354 hr = IDirectMusicCollection_QueryInterface(dmc, &IID_IPersistStream, (void**)&ps);
355 ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr);
356 hr = IPersistStream_GetClassID(ps, &class);
357 ok(hr == E_NOTIMPL, "IPersistStream_GetClassID failed: %08x\n", hr);
358 hr = IPersistStream_IsDirty(ps);
359 ok(hr == S_FALSE, "IPersistStream_IsDirty failed: %08x\n", hr);
360 hr = IPersistStream_GetSizeMax(ps, &size);
361 ok(hr == E_NOTIMPL, "IPersistStream_GetSizeMax failed: %08x\n", hr);
362 hr = IPersistStream_Save(ps, NULL, TRUE);
363 ok(hr == E_NOTIMPL, "IPersistStream_Save failed: %08x\n", hr);
365 while (IDirectMusicCollection_Release(dmc));
368 static BOOL missing_dmusic(void)
370 IDirectMusic8 *dm;
371 HRESULT hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic,
372 (void**)&dm);
374 if (hr == S_OK && dm)
376 IDirectMusic_Release(dm);
377 return FALSE;
379 return TRUE;
382 static void test_COM_synthport(void)
384 IDirectMusic *dmusic = NULL;
385 IDirectMusicPort *port = NULL;
386 IDirectMusicPortDownload *dmpd;
387 IDirectMusicThru *dmt;
388 IKsControl *iksc;
389 IReferenceClock *clock;
390 IUnknown *unk;
391 DMUS_PORTPARAMS port_params;
392 ULONG refcount;
393 HRESULT hr;
395 /* Create a IDirectMusicPort */
396 hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic,
397 (void**)&dmusic);
398 ok(hr == S_OK, "Cannot create DirectMusic object (%x)\n", hr);
399 port_params.dwSize = sizeof(port_params);
400 port_params.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS | DMUS_PORTPARAMS_AUDIOCHANNELS;
401 port_params.dwChannelGroups = 1;
402 port_params.dwAudioChannels = 2;
403 hr = IDirectMusic_SetDirectSound(dmusic, NULL, NULL);
404 ok(hr == S_OK, "IDirectMusic_SetDirectSound returned: %x\n", hr);
405 hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &port_params, &port, NULL);
406 ok(hr == S_OK, "IDirectMusic_CreatePort returned: %x\n", hr);
408 /* Same refcount for all DirectMusicPort interfaces */
409 refcount = IDirectMusicPort_AddRef(port);
410 ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
412 hr = IDirectMusicPort_QueryInterface(port, &IID_IDirectMusicPortDownload, (void**)&dmpd);
413 ok(hr == S_OK, "QueryInterface for IID_IDirectMusicPortDownload failed: %08x\n", hr);
414 refcount = IDirectMusicPortDownload_AddRef(dmpd);
415 ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
416 IDirectMusicPortDownload_Release(dmpd);
418 hr = IDirectMusicPort_QueryInterface(port, &IID_IKsControl, (void**)&iksc);
419 ok(hr == S_OK, "QueryInterface for IID_IKsControl failed: %08x\n", hr);
420 refcount = IKsControl_AddRef(iksc);
421 ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
422 IKsControl_Release(iksc);
424 hr = IDirectMusicPort_QueryInterface(port, &IID_IUnknown, (void**)&unk);
425 ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
426 refcount = IUnknown_AddRef(unk);
427 ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
428 IUnknown_Release(unk);
430 /* Unsupported interface */
431 hr = IDirectMusicPort_QueryInterface(port, &IID_IDirectMusicThru, (void**)&dmt);
432 todo_wine ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectMusicThru failed: %08x\n", hr);
433 hr = IDirectMusicPort_QueryInterface(port, &IID_IReferenceClock, (void**)&clock);
434 ok(hr == E_NOINTERFACE, "QueryInterface for IID_IReferenceClock failed: %08x\n", hr);
436 while (IDirectMusicPort_Release(port));
439 START_TEST(dmusic)
441 CoInitializeEx(NULL, COINIT_MULTITHREADED);
443 if (missing_dmusic())
445 skip("DirectMusic not available\n");
446 CoUninitialize();
447 return;
449 test_COM();
450 test_COM_dmcoll();
451 test_COM_synthport();
452 test_dmusic();
453 test_dmbuffer();
454 test_dmcoll();
456 CoUninitialize();