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 /* Check wrong params */
70 hr
= IDirectMusic_CreatePort(dmusic
, &GUID_NULL
, &port_params
, &port
, (IUnknown
*)dmusic
);
71 ok(hr
== CLASS_E_NOAGGREGATION
, "IDirectMusic_CreatePort returned: %x\n", hr
);
72 hr
= IDirectMusic_CreatePort(dmusic
, NULL
, &port_params
, &port
, NULL
);
73 ok(hr
== E_POINTER
, "IDirectMusic_CreatePort returned: %x\n", hr
);
74 hr
= IDirectMusic_CreatePort(dmusic
, &GUID_NULL
, NULL
, &port
, NULL
);
75 ok(hr
== E_INVALIDARG
, "IDirectMusic_CreatePort returned: %x\n", hr
);
76 hr
= IDirectMusic_CreatePort(dmusic
, &GUID_NULL
, &port_params
, NULL
, NULL
);
77 ok(hr
== E_POINTER
, "IDirectMusic_CreatePort returned: %x\n", hr
);
79 /* Test creation of default port with GUID_NULL */
80 hr
= IDirectMusic_CreatePort(dmusic
, &GUID_NULL
, &port_params
, &port
, NULL
);
81 ok(hr
== S_OK
, "IDirectMusic_CreatePort returned: %x\n", hr
);
83 port_caps
.dwSize
= sizeof(port_caps
);
84 while (IDirectMusic_EnumPort(dmusic
, index
, &port_caps
) == S_OK
)
86 ok(port_caps
.dwSize
== sizeof(port_caps
), "DMUS_PORTCAPS dwSize member is wrong (%u)\n", port_caps
.dwSize
);
87 trace("Port %u:\n", index
);
88 trace(" dwFlags = %x\n", port_caps
.dwFlags
);
89 trace(" guidPort = %s\n", debugstr_guid(&port_caps
.guidPort
));
90 trace(" dwClass = %u\n", port_caps
.dwClass
);
91 trace(" dwType = %u\n", port_caps
.dwType
);
92 trace(" dwMemorySize = %u\n", port_caps
.dwMemorySize
);
93 trace(" dwMaxChannelGroups = %u\n", port_caps
.dwMaxChannelGroups
);
94 trace(" dwMaxVoices = %u\n", port_caps
.dwMaxVoices
);
95 trace(" dwMaxAudioChannels = %u\n", port_caps
.dwMaxAudioChannels
);
96 trace(" dwEffectFlags = %x\n", port_caps
.dwEffectFlags
);
97 trace(" wszDescription = %s\n", wine_dbgstr_w(port_caps
.wszDescription
));
102 IDirectMusicPort_Release(port
);
103 IDirectMusic_Release(dmusic
);
108 CoInitializeEx(NULL
, COINIT_MULTITHREADED
);