dmime: Split out the perf default port creation.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2020-02-14 01:21:05 +01:00 committed by Alexandre Julliard
parent 67f55f9b13
commit d966413a49
1 changed files with 49 additions and 31 deletions

View File

@ -624,39 +624,57 @@ static HRESULT WINAPI IDirectMusicPerformance8Impl_RemoveNotificationType(IDirec
return S_OK;
}
static HRESULT WINAPI IDirectMusicPerformance8Impl_AddPort(IDirectMusicPerformance8 *iface,
IDirectMusicPort *pPort)
static HRESULT perf_dmport_create(IDirectMusicPerformance8Impl *perf, DMUS_PORTPARAMS *params)
{
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
HRESULT hr = E_FAIL;
IDirectMusicPort *port;
GUID guid;
unsigned int i;
HRESULT hr;
FIXME("(%p, %p): stub\n", This, pPort);
if (!This->dmusic)
return DMUS_E_NOT_INIT;
if (NULL == pPort) {
GUID port_guid;
IDirectMusicPort* pDefaultPort = NULL;
DMUS_PORTPARAMS params;
hr = IDirectMusic8_GetDefaultPort(This->dmusic, &port_guid);
if (FAILED(hr)) return hr;
ZeroMemory(&params, sizeof(params));
params.dwSize = sizeof(params);
params.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS | DMUS_PORTPARAMS_SHARE;
params.dwChannelGroups = 1;
params.fShare = TRUE;
hr = IDirectMusic8_CreatePort(This->dmusic, &port_guid, &params, &pDefaultPort, NULL);
if (FAILED(hr)) return hr;
hr = IDirectMusicPort_Activate(pDefaultPort, TRUE);
if (FAILED(hr)) { IDirectMusicPort_Release(pDefaultPort); return hr; }
IDirectMusicPerformance8_AssignPChannelBlock(iface, 0, pDefaultPort, 1);
} else {
IDirectMusicPort_AddRef(pPort);
}
/**
* We should remember added Ports (for example using a list)
* and control if Port is registered for each api who use ports
*/
return S_OK;
if (FAILED(hr = IDirectMusic8_GetDefaultPort(perf->dmusic, &guid)))
return hr;
params->dwSize = sizeof(params);
params->dwValidParams |= DMUS_PORTPARAMS_SHARE;
params->fShare = TRUE;
if (FAILED(hr = IDirectMusic8_CreatePort(perf->dmusic, &guid, params, &port, NULL)))
return hr;
if (FAILED(hr = IDirectMusicPort_Activate(port, TRUE))) {
IDirectMusicPort_Release(port);
return hr;
}
for (i = 0; i < params->dwChannelGroups; i++)
pchannel_block_set(&perf->pchannels, i, port, i + 1, FALSE);
return S_OK;
}
static HRESULT WINAPI IDirectMusicPerformance8Impl_AddPort(IDirectMusicPerformance8 *iface,
IDirectMusicPort *port)
{
IDirectMusicPerformance8Impl *This = impl_from_IDirectMusicPerformance8(iface);
FIXME("(%p, %p): semi-stub\n", This, port);
if (!This->dmusic)
return DMUS_E_NOT_INIT;
if (!port) {
DMUS_PORTPARAMS params = {
.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS,
.dwChannelGroups = 1
};
return perf_dmport_create(This, &params);
}
IDirectMusicPort_AddRef(port);
/**
* We should remember added Ports (for example using a list)
* and control if Port is registered for each api who use ports
*/
return S_OK;
}
static HRESULT WINAPI IDirectMusicPerformance8Impl_RemovePort(IDirectMusicPerformance8 *iface,