Commit 47ce8c97 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

dmusic: Support creating default ports with GUID_NULL.

parent b74c9a64
......@@ -24,23 +24,44 @@
#include <wine/test.h>
#include <dmusici.h>
static IDirectMusicPerformance8 *idmusicperformance;
#include <stdio.h>
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
DEFINE_GUID(GUID_Bunk,0xFFFFFFFF,0xFFFF,0xFFFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF);
static const char *debugstr_guid(REFIID riid)
{
static char buf[50];
sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
riid->Data4[5], riid->Data4[6], riid->Data4[7]);
return buf;
}
static HRESULT test_InitAudio(void)
{
IDirectMusicPerformance8 *idmusicperformance;
IDirectSound *pDirectSound;
IDirectMusicPort *pDirectMusicPort;
IDirectMusicAudioPath *pDirectMusicAudioPath;
HRESULT hr;
hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL,
CLSCTX_INPROC_SERVER, &IID_IDirectMusicPerformance8, (LPVOID *)&idmusicperformance);
if (hr != S_OK) {
skip("Cannot create DirectMusicPerformance object (%x)\n", hr);
CoUninitialize();
return hr;
}
pDirectSound = NULL;
hr = IDirectMusicPerformance8_InitAudio(idmusicperformance ,NULL,
&pDirectSound, NULL, DMUS_APATH_SHARED_STEREOPLUSREVERB, 128, DMUS_AUDIOF_ALL, NULL);
if(hr != S_OK)
return hr;
}
static void test_PChannelInfo(void)
{
IDirectMusicPort *pDirectMusicPort;
HRESULT hr;
pDirectMusicPort = NULL;
hr = IDirectMusicPerformance8_PChannelInfo(idmusicperformance, 0, &pDirectMusicPort, NULL, NULL);
......@@ -48,25 +69,130 @@ static void test_PChannelInfo(void)
ok(pDirectMusicPort != NULL, "IDirectMusicPort not set\n");
if (hr == S_OK && pDirectMusicPort != NULL)
IDirectMusicPort_Release(pDirectMusicPort);
}
static void test_GetDefaultAudioPath(void)
{
IDirectMusicAudioPath *pDirectMusicAudioPath;
HRESULT hr;
hr = IDirectMusicPerformance8_GetDefaultAudioPath(idmusicperformance, &pDirectMusicAudioPath);
ok(hr == S_OK, "Failed to call GetDefaultAudioPath (%x)\n", hr);
if (hr == S_OK)
IDirectMusicAudioPath_Release(pDirectMusicAudioPath);
hr = IDirectMusicPerformance8_CloseDown(idmusicperformance);
ok(hr == S_OK, "Failed to call CloseDown (%x)\n", hr);
IDirectMusicPerformance8_Release(idmusicperformance);
return S_OK;
}
static void test_CloseDown(void)
static void test_createport(void)
{
IDirectMusicPerformance8 *perf;
IDirectMusic *music = NULL;
IDirectMusicPort *port = NULL;
DMUS_PORTCAPS portcaps;
DMUS_PORTPARAMS portparams;
DWORD i;
HRESULT hr;
hr = IDirectMusicPerformance8_CloseDown(idmusicperformance);
ok(hr == S_OK, "Failed to call CloseDown (%x)\n", hr);
hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL,
CLSCTX_INPROC_SERVER, &IID_IDirectMusicPerformance8, (void**)&perf);
ok(hr == S_OK, "CoCreateInstance failed: %08x\n", hr);
hr = IDirectMusicPerformance8_Init(perf, &music, NULL, NULL);
ok(hr == S_OK, "Init failed: %08x\n", hr);
ok(music != NULL, "Didn't get IDirectMusic pointer\n");
i = 0;
while(1){
portcaps.dwSize = sizeof(portcaps);
hr = IDirectMusic_EnumPort(music, i, &portcaps);
ok(hr == S_OK || hr == S_FALSE || (i == 0 && hr == E_INVALIDARG), "EnumPort failed: %08x\n", hr);
if(hr != S_OK)
break;
ok(portcaps.dwSize == sizeof(portcaps), "Got unexpected portcaps struct size: %08x\n", portcaps.dwSize);
trace("portcaps(%u).dwFlags: %08x\n", i, portcaps.dwFlags);
trace("portcaps(%u).guidPort: %s\n", i, debugstr_guid(&portcaps.guidPort));
trace("portcaps(%u).dwClass: %08x\n", i, portcaps.dwClass);
trace("portcaps(%u).dwType: %08x\n", i, portcaps.dwType);
trace("portcaps(%u).dwMemorySize: %08x\n", i, portcaps.dwMemorySize);
trace("portcaps(%u).dwMaxChannelGroups: %08x\n", i, portcaps.dwMaxChannelGroups);
trace("portcaps(%u).dwMaxVoices: %08x\n", i, portcaps.dwMaxVoices);
trace("portcaps(%u).dwMaxAudioChannels: %08x\n", i, portcaps.dwMaxAudioChannels);
trace("portcaps(%u).dwEffectFlags: %08x\n", i, portcaps.dwEffectFlags);
trace("portcaps(%u).wszDescription: %s\n", i, wine_dbgstr_w(portcaps.wszDescription));
++i;
}
if(i == 0){
win_skip("No ports available, skipping tests\n");
return;
}
portparams.dwSize = sizeof(portparams);
/* dwValidParams == 0 -> S_OK, filled struct */
portparams.dwValidParams = 0;
hr = IDirectMusic_CreatePort(music, &CLSID_DirectMusicSynth,
&portparams, &port, NULL);
ok(hr == S_OK, "CreatePort failed: %08x\n", hr);
ok(port != NULL, "Didn't get IDirectMusicPort pointer\n");
IDirectMusicPort_Release(port);
port = NULL;
todo_wine ok(portparams.dwValidParams != 0, "portparams struct was not filled in\n");
/* dwValidParams != 0, invalid param -> S_FALSE, filled struct */
portparams.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS;
portparams.dwChannelGroups = 0;
hr = IDirectMusic_CreatePort(music, &CLSID_DirectMusicSynth,
&portparams, &port, NULL);
todo_wine ok(hr == S_FALSE, "CreatePort failed: %08x\n", hr);
ok(port != NULL, "Didn't get IDirectMusicPort pointer\n");
IDirectMusicPort_Release(port);
port = NULL;
ok(portparams.dwValidParams != 0, "portparams struct was not filled in\n");
/* dwValidParams != 0, valid params -> S_OK */
hr = IDirectMusic_CreatePort(music, &CLSID_DirectMusicSynth,
&portparams, &port, NULL);
ok(hr == S_OK, "CreatePort failed: %08x\n", hr);
ok(port != NULL, "Didn't get IDirectMusicPort pointer\n");
IDirectMusicPort_Release(port);
port = NULL;
/* GUID_NULL succeeds */
portparams.dwValidParams = 0;
hr = IDirectMusic_CreatePort(music, &GUID_NULL, &portparams, &port, NULL);
ok(hr == S_OK, "CreatePort failed: %08x\n", hr);
ok(port != NULL, "Didn't get IDirectMusicPort pointer\n");
IDirectMusicPort_Release(port);
port = NULL;
todo_wine ok(portparams.dwValidParams != 0, "portparams struct was not filled in\n");
/* null GUID fails */
portparams.dwValidParams = 0;
hr = IDirectMusic_CreatePort(music, NULL, &portparams, &port, NULL);
ok(hr == E_POINTER, "CreatePort failed: %08x\n", hr);
ok(port == NULL, "Get IDirectMusicPort pointer? %p\n", port);
ok(portparams.dwValidParams == 0, "portparams struct was filled in?\n");
/* garbage GUID fails */
portparams.dwValidParams = 0;
hr = IDirectMusic_CreatePort(music, &GUID_Bunk, &portparams, &port, NULL);
ok(hr == E_NOINTERFACE, "CreatePort failed: %08x\n", hr);
ok(port == NULL, "Get IDirectMusicPort pointer? %p\n", port);
ok(portparams.dwValidParams == 0, "portparams struct was filled in?\n");
IDirectMusic_Release(music);
IDirectMusicPerformance_Release(perf);
}
START_TEST( performance )
......@@ -79,24 +205,13 @@ START_TEST( performance )
return;
}
hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL,
CLSCTX_INPROC_SERVER, &IID_IDirectMusicPerformance8, (LPVOID *)&idmusicperformance);
if (hr != S_OK) {
skip("Cannot create DirectMusicPerformance object (%x)\n", hr);
CoUninitialize();
return;
}
hr = test_InitAudio();
if (hr != S_OK) {
skip("InitAudio failed (%x)\n", hr);
return;
}
test_GetDefaultAudioPath();
test_PChannelInfo();
test_CloseDown();
test_createport();
IDirectMusicPerformance8_Release(idmusicperformance);
CoUninitialize();
}
......@@ -123,17 +123,30 @@ static HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer (LPDIRECTMUSIC8 iface,
static HRESULT WINAPI IDirectMusic8Impl_CreatePort (LPDIRECTMUSIC8 iface, REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT* ppPort, LPUNKNOWN pUnkOuter) {
IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface;
int i/*, j*/;
int i;
DMUS_PORTCAPS PortCaps;
IDirectMusicPort* pNewPort = NULL;
HRESULT hr = E_FAIL;
HRESULT hr;
GUID default_port;
const GUID *request_port = rclsidPort;
TRACE("(%p, %s, %p, %p, %p)\n", This, debugstr_dmguid(rclsidPort), pPortParams, ppPort, pUnkOuter);
if(!rclsidPort)
return E_POINTER;
ZeroMemory(&PortCaps, sizeof(DMUS_PORTCAPS));
PortCaps.dwSize = sizeof(DMUS_PORTCAPS);
if(IsEqualGUID(request_port, &GUID_NULL)){
hr = IDirectMusic8_GetDefaultPort(iface, &default_port);
if(FAILED(hr))
return hr;
request_port = &default_port;
}
for (i = 0; S_FALSE != IDirectMusic8Impl_EnumPort(iface, i, &PortCaps); i++) {
if (IsEqualCLSID (rclsidPort, &PortCaps.guidPort)) {
if (IsEqualCLSID (request_port, &PortCaps.guidPort)) {
hr = DMUSIC_CreateDirectMusicPortImpl(&IID_IDirectMusicPort, (LPVOID*) &pNewPort, (LPUNKNOWN) This, pPortParams, &PortCaps);
if (FAILED(hr)) {
*ppPort = NULL;
......@@ -147,7 +160,6 @@ static HRESULT WINAPI IDirectMusic8Impl_CreatePort (LPDIRECTMUSIC8 iface, REFCLS
return S_OK;
}
}
/* FIXME: place correct error here */
return E_NOINTERFACE;
}
......
......@@ -68,7 +68,7 @@ static void test_dmusic(void)
/* Test creation of default port with GUID_NULL */
hr = IDirectMusic_CreatePort(dmusic, &GUID_NULL, &port_params, &port, NULL);
todo_wine ok(hr == S_OK, "IDirectMusic_CreatePort returned: %x\n", hr);
ok(hr == S_OK, "IDirectMusic_CreatePort returned: %x\n", hr);
port_caps.dwSize = sizeof(port_caps);
while (IDirectMusic_EnumPort(dmusic, index, &port_caps) == S_OK)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment