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
25 #include "wine/test.h"
31 static inline char* debugstr_guid(CONST GUID *id)
33 static char string[39];
34 sprintf(string, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
35 id->Data1, id->Data2, id->Data3,
36 id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
37 id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
41 static void test_dmusic(void)
43 IDirectMusic *dmusic = NULL;
46 DMUS_PORTCAPS port_caps;
47 DMUS_PORTPARAMS port_params;
48 IDirectMusicPort *port = NULL;
50 hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic, (LPVOID*)&dmusic);
53 skip("Cannot create DirectMusic object (%x)\n", hr);
57 port_params.dwSize = sizeof(port_params);
58 port_params.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS | DMUS_PORTPARAMS_AUDIOCHANNELS;
59 port_params.dwChannelGroups = 1;
60 port_params.dwAudioChannels = 2;
62 /* No port can be created before SetDirectSound is called */
63 hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &port_params, &port, NULL);
64 todo_wine ok(hr == DMUS_E_DSOUND_NOT_SET, "IDirectMusic_CreatePort returned: %x\n", hr);
66 hr = IDirectMusic_SetDirectSound(dmusic, NULL, NULL);
67 ok(hr == S_OK, "IDirectMusic_SetDirectSound returned: %x\n", hr);
69 /* Test creation of default port with GUID_NULL */
70 hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &port_params, &port, NULL);
71 ok(hr == S_OK, "IDirectMusic_CreatePort returned: %x\n", hr);
73 port_caps.dwSize = sizeof(port_caps);
74 while (IDirectMusic_EnumPort(dmusic, index, &port_caps) == S_OK)
76 ok(port_caps.dwSize == sizeof(port_caps), "DMUS_PORTCAPS dwSize member is wrong (%u)\n", port_caps.dwSize);
77 trace("Port %u:\n", index);
78 trace(" dwFlags = %x\n", port_caps.dwFlags);
79 trace(" guidPort = %s\n", debugstr_guid(&port_caps.guidPort));
80 trace(" dwClass = %u\n", port_caps.dwClass);
81 trace(" dwType = %u\n", port_caps.dwType);
82 trace(" dwMemorySize = %u\n", port_caps.dwMemorySize);
83 trace(" dwMaxChannelGroups = %u\n", port_caps.dwMaxChannelGroups);
84 trace(" dwMaxVoices = %u\n", port_caps.dwMaxVoices);
85 trace(" dwMaxAudioChannels = %u\n", port_caps.dwMaxAudioChannels);
86 trace(" dwEffectFlags = %x\n", port_caps.dwEffectFlags);
87 trace(" wszDescription = %s\n", wine_dbgstr_w(port_caps.wszDescription));
92 IDirectMusicPort_Release(port);
94 IDirectMusic_Release(dmusic);
99 CoInitializeEx(NULL, COINIT_MULTITHREADED);