2012-04-06 13:39:02 +02:00
|
|
|
/*
|
|
|
|
* Unit tests for dmsynth functions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Christian Costa
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include "uuids.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "initguid.h"
|
|
|
|
#include "dmusics.h"
|
|
|
|
#include "dmusici.h"
|
2012-05-03 23:05:42 +02:00
|
|
|
#include "dmksctrl.h"
|
2012-04-06 13:39:02 +02:00
|
|
|
|
2016-07-19 09:51:36 +02:00
|
|
|
static BOOL missing_dmsynth(void)
|
|
|
|
{
|
|
|
|
IDirectMusicSynth *dms;
|
|
|
|
HRESULT hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectMusicSynth, (void**)&dms);
|
|
|
|
|
|
|
|
if (hr == S_OK && dms)
|
|
|
|
{
|
|
|
|
IDirectMusicSynth_Release(dms);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-01-03 00:16:03 +01:00
|
|
|
static ULONG get_refcount(void *iface)
|
|
|
|
{
|
|
|
|
IUnknown *unknown = iface;
|
|
|
|
IUnknown_AddRef(unknown);
|
|
|
|
return IUnknown_Release(unknown);
|
|
|
|
}
|
|
|
|
|
2022-02-22 00:49:57 +01:00
|
|
|
static void test_synth_getformat(IDirectMusicSynth *synth, DMUS_PORTPARAMS *params, const char *context)
|
|
|
|
{
|
|
|
|
WAVEFORMATEX format;
|
|
|
|
DWORD size;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
winetest_push_context(context);
|
|
|
|
|
|
|
|
size = sizeof(format);
|
|
|
|
hr = IDirectMusicSynth_GetFormat(synth, &format, &size);
|
|
|
|
ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
|
|
|
|
ok(format.wFormatTag == WAVE_FORMAT_PCM, "wFormatTag: %#x\n", format.wFormatTag);
|
|
|
|
ok(format.nChannels == params->dwAudioChannels, "nChannels: %d\n", format.nChannels);
|
|
|
|
ok(format.nSamplesPerSec == params->dwSampleRate, "nSamplesPerSec: %ld\n", format.nSamplesPerSec);
|
|
|
|
ok(format.wBitsPerSample == 16, "wBitsPerSample: %d\n", format.wBitsPerSample);
|
|
|
|
ok(format.nBlockAlign == params->dwAudioChannels * format.wBitsPerSample / 8, "nBlockAlign: %d\n",
|
|
|
|
format.nBlockAlign);
|
|
|
|
ok(format.nAvgBytesPerSec == params->dwSampleRate * format.nBlockAlign, "nAvgBytesPerSec: %ld\n",
|
|
|
|
format.nAvgBytesPerSec);
|
|
|
|
ok(format.cbSize == 0, "cbSize: %d\n", format.cbSize);
|
|
|
|
|
|
|
|
winetest_pop_context();
|
|
|
|
}
|
|
|
|
|
2012-04-06 13:39:02 +02:00
|
|
|
static void test_dmsynth(void)
|
|
|
|
{
|
|
|
|
IDirectMusicSynth *dmsynth = NULL;
|
2022-01-19 18:48:50 +01:00
|
|
|
IDirectMusicSynthSink *dmsynth_sink = NULL, *dmsynth_sink2 = NULL;
|
2012-05-03 23:05:33 +02:00
|
|
|
IReferenceClock* clock_synth = NULL;
|
2012-04-30 11:43:26 +02:00
|
|
|
IReferenceClock* clock_sink = NULL;
|
2012-05-03 23:05:42 +02:00
|
|
|
IKsControl* control_synth = NULL;
|
|
|
|
IKsControl* control_sink = NULL;
|
2022-01-03 00:16:03 +01:00
|
|
|
ULONG ref_clock_synth, ref_clock_sink;
|
2012-04-06 13:39:02 +02:00
|
|
|
HRESULT hr;
|
2012-09-21 15:44:37 +02:00
|
|
|
KSPROPERTY property;
|
|
|
|
ULONG value;
|
|
|
|
ULONG bytes;
|
2022-01-25 23:11:24 +01:00
|
|
|
DMUS_PORTCAPS caps;
|
2022-02-08 00:52:00 +01:00
|
|
|
DMUS_PORTPARAMS params;
|
|
|
|
const DWORD all_params = DMUS_PORTPARAMS_VOICES|DMUS_PORTPARAMS_CHANNELGROUPS|DMUS_PORTPARAMS_AUDIOCHANNELS|
|
|
|
|
DMUS_PORTPARAMS_SAMPLERATE|DMUS_PORTPARAMS_EFFECTS|DMUS_PORTPARAMS_SHARE|DMUS_PORTPARAMS_FEATURES;
|
2022-02-22 00:49:57 +01:00
|
|
|
WAVEFORMATEX format;
|
|
|
|
DWORD size;
|
2012-04-06 13:39:02 +02:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth, (LPVOID*)&dmsynth);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "CoCreateInstance returned: %#lx\n", hr);
|
2012-04-06 13:39:02 +02:00
|
|
|
|
2022-01-19 18:48:50 +01:00
|
|
|
hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynthSink,
|
|
|
|
(void **)&dmsynth_sink);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "CoCreateInstance returned: %#lx\n", hr);
|
2022-01-19 18:48:50 +01:00
|
|
|
hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynthSink,
|
|
|
|
(void **)&dmsynth_sink2);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "CoCreateInstance returned: %#lx\n", hr);
|
2012-04-06 13:39:02 +02:00
|
|
|
|
2012-05-03 23:05:42 +02:00
|
|
|
hr = IDirectMusicSynth_QueryInterface(dmsynth, &IID_IKsControl, (LPVOID*)&control_synth);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IDirectMusicSynth_QueryInterface returned: %#lx\n", hr);
|
2012-09-21 15:44:37 +02:00
|
|
|
|
2013-05-04 09:30:49 +02:00
|
|
|
S(U(property)).Id = 0;
|
|
|
|
S(U(property)).Flags = KSPROPERTY_TYPE_GET;
|
2012-09-21 15:44:37 +02:00
|
|
|
|
2013-05-04 09:30:49 +02:00
|
|
|
S(U(property)).Set = GUID_DMUS_PROP_INSTRUMENT2;
|
2012-09-21 15:44:37 +02:00
|
|
|
hr = IKsControl_KsProperty(control_synth, &property, sizeof(property), &value, sizeof(value), &bytes);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IKsControl_KsProperty returned: %#lx\n", hr);
|
|
|
|
ok(bytes == sizeof(DWORD), "Returned bytes: %lu, should be 4\n", bytes);
|
|
|
|
ok(value == TRUE, "Return value: %lu, should be 1\n", value);
|
2013-05-04 09:30:49 +02:00
|
|
|
S(U(property)).Set = GUID_DMUS_PROP_DLS2;
|
2012-09-21 15:44:37 +02:00
|
|
|
hr = IKsControl_KsProperty(control_synth, &property, sizeof(property), &value, sizeof(value), &bytes);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IKsControl_KsProperty returned: %#lx\n", hr);
|
|
|
|
ok(bytes == sizeof(DWORD), "Returned bytes: %lu, should be 4\n", bytes);
|
|
|
|
ok(value == TRUE, "Return value: %lu, should be 1\n", value);
|
2013-05-04 09:30:49 +02:00
|
|
|
S(U(property)).Set = GUID_DMUS_PROP_GM_Hardware;
|
2012-09-21 15:44:37 +02:00
|
|
|
hr = IKsControl_KsProperty(control_synth, &property, sizeof(property), &value, sizeof(value), &bytes);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IKsControl_KsProperty returned: %#lx\n", hr);
|
|
|
|
ok(bytes == sizeof(DWORD), "Returned bytes: %lu, should be 4\n", bytes);
|
|
|
|
ok(value == FALSE, "Return value: %lu, should be 0\n", value);
|
2013-05-04 09:30:49 +02:00
|
|
|
S(U(property)).Set = GUID_DMUS_PROP_GS_Hardware;
|
2012-09-21 15:44:37 +02:00
|
|
|
hr = IKsControl_KsProperty(control_synth, &property, sizeof(property), &value, sizeof(value), &bytes);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IKsControl_KsProperty returned: %#lx\n", hr);
|
|
|
|
ok(bytes == sizeof(DWORD), "Returned bytes: %lu, should be 4\n", bytes);
|
|
|
|
ok(value == FALSE, "Return value: %lu, should be 0\n", value);
|
2013-05-04 09:30:49 +02:00
|
|
|
S(U(property)).Set = GUID_DMUS_PROP_XG_Hardware;
|
2012-09-21 15:44:37 +02:00
|
|
|
hr = IKsControl_KsProperty(control_synth, &property, sizeof(property), &value, sizeof(value), &bytes);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IKsControl_KsProperty returned: %#lx\n", hr);
|
|
|
|
ok(bytes == sizeof(DWORD), "Returned bytes: %lu, should be 4\n", bytes);
|
|
|
|
ok(value == FALSE, "Return value: %lu, should be 0\n", value);
|
2012-09-21 15:44:37 +02:00
|
|
|
|
2012-05-03 23:05:42 +02:00
|
|
|
hr = IDirectMusicSynthSink_QueryInterface(dmsynth_sink, &IID_IKsControl, (LPVOID*)&control_sink);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IDirectMusicSynthSink_QueryInterface returned: %#lx\n", hr);
|
2012-05-03 23:05:42 +02:00
|
|
|
|
2013-05-04 09:30:49 +02:00
|
|
|
S(U(property)).Set = GUID_DMUS_PROP_SinkUsesDSound;
|
2012-09-21 15:44:37 +02:00
|
|
|
hr = IKsControl_KsProperty(control_sink, &property, sizeof(property), &value, sizeof(value), &bytes);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IKsControl_KsProperty returned: %#lx\n", hr);
|
|
|
|
ok(bytes == sizeof(DWORD), "Returned bytes: %lu, should be 4\n", bytes);
|
|
|
|
ok(value == TRUE, "Return value: %lu, should be 1\n", value);
|
2012-09-21 15:44:37 +02:00
|
|
|
|
2022-01-03 00:16:03 +01:00
|
|
|
/* Synth isn't fully initialized yet */
|
|
|
|
hr = IDirectMusicSynth_Activate(dmsynth, TRUE);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == DMUS_E_NOSYNTHSINK, "IDirectMusicSynth_Activate returned: %#lx\n", hr);
|
2022-02-22 00:49:58 +01:00
|
|
|
hr = IDirectMusicSynthSink_GetDesiredBufferSize(dmsynth_sink, &size);
|
|
|
|
ok(hr == DMUS_E_SYNTHNOTCONFIGURED, "IDirectMusicSynthSink_GetDesiredBufferSize returned: %#lx\n", hr);
|
2022-01-03 00:16:03 +01:00
|
|
|
|
2022-02-08 00:52:00 +01:00
|
|
|
/* Open / Close */
|
|
|
|
hr = IDirectMusicSynth_Open(dmsynth, NULL);
|
|
|
|
ok(hr == S_OK, "Open failed: %#lx\n", hr);
|
|
|
|
hr = IDirectMusicSynth_Open(dmsynth, NULL);
|
|
|
|
ok(hr == DMUS_E_ALREADYOPEN, "Open failed: %#lx\n", hr);
|
|
|
|
hr = IDirectMusicSynth_Close(dmsynth);
|
|
|
|
ok(hr == S_OK, "Close failed: %#lx\n", hr);
|
|
|
|
hr = IDirectMusicSynth_Close(dmsynth);
|
|
|
|
ok(hr == DMUS_E_ALREADYCLOSED, "Close failed: %#lx\n", hr);
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
hr = IDirectMusicSynth_Open(dmsynth, ¶ms);
|
|
|
|
ok(hr == E_INVALIDARG, "Open failed: %#lx\n", hr);
|
|
|
|
params.dwSize = sizeof(DMUS_PORTPARAMS7);
|
|
|
|
hr = IDirectMusicSynth_Open(dmsynth, ¶ms);
|
|
|
|
ok(hr == S_OK, "Open failed: %#lx\n", hr);
|
|
|
|
IDirectMusicSynth_Close(dmsynth);
|
|
|
|
/* All params supported and set to 0 */
|
|
|
|
params.dwSize = sizeof(params);
|
|
|
|
params.dwValidParams = all_params;
|
|
|
|
hr = IDirectMusicSynth_Open(dmsynth, ¶ms);
|
|
|
|
ok(hr == S_OK, "Open failed: %#lx\n", hr);
|
|
|
|
ok(params.dwSize == sizeof(params), "dwSize: %ld\n", params.dwSize);
|
|
|
|
ok(params.dwValidParams == all_params, "dwValidParams: %#lx\n", params.dwValidParams);
|
|
|
|
ok(params.dwVoices == 32, "dwVoices: %ld\n", params.dwVoices);
|
|
|
|
ok(params.dwChannelGroups == 2, "dwChannelGroups: %ld\n", params.dwChannelGroups);
|
|
|
|
ok(params.dwAudioChannels == 2, "dwAudioChannels: %ld\n", params.dwAudioChannels);
|
|
|
|
ok(params.dwSampleRate == 22050, "dwSampleRate: %ld\n", params.dwSampleRate);
|
|
|
|
ok(params.dwEffectFlags == DMUS_EFFECT_REVERB, "params.dwEffectFlags: %#lx\n", params.dwEffectFlags);
|
|
|
|
ok(params.fShare == FALSE, "fShare: %d\n", params.fShare);
|
|
|
|
ok(params.dwFeatures == 0, "dwFeatures: %#lx\n", params.dwFeatures);
|
2022-02-22 00:49:57 +01:00
|
|
|
test_synth_getformat(dmsynth, ¶ms, "defaults");
|
2022-02-08 00:52:00 +01:00
|
|
|
IDirectMusicSynth_Close(dmsynth);
|
|
|
|
/* Requesting more than supported */
|
|
|
|
params.dwValidParams = DMUS_PORTPARAMS_SAMPLERATE;
|
|
|
|
params.dwSampleRate = 100003;
|
|
|
|
hr = IDirectMusicSynth_Open(dmsynth, ¶ms);
|
|
|
|
ok(hr == S_FALSE, "Open failed: %#lx\n", hr);
|
|
|
|
ok(params.dwValidParams == all_params, "dwValidParams: %#lx\n", params.dwValidParams);
|
|
|
|
ok(params.dwSampleRate == 96000, "dwSampleRate: %ld\n", params.dwSampleRate);
|
2022-02-22 00:49:57 +01:00
|
|
|
test_synth_getformat(dmsynth, ¶ms, "max");
|
2022-02-08 00:52:00 +01:00
|
|
|
IDirectMusicSynth_Close(dmsynth);
|
|
|
|
/* Minimums */
|
|
|
|
params.dwValidParams = DMUS_PORTPARAMS_VOICES|DMUS_PORTPARAMS_CHANNELGROUPS|DMUS_PORTPARAMS_AUDIOCHANNELS|
|
|
|
|
DMUS_PORTPARAMS_SAMPLERATE;
|
|
|
|
params.dwVoices = 1;
|
|
|
|
params.dwChannelGroups = 1;
|
|
|
|
params.dwAudioChannels = 1;
|
|
|
|
params.dwSampleRate = 1;
|
|
|
|
hr = IDirectMusicSynth_Open(dmsynth, ¶ms);
|
|
|
|
ok(hr == S_FALSE, "Open failed: %#lx\n", hr);
|
|
|
|
ok(params.dwValidParams == all_params, "dwValidParams: %#lx\n", params.dwValidParams);
|
|
|
|
ok(params.dwVoices == 1, "dwVoices: %ld\n", params.dwVoices);
|
|
|
|
ok(params.dwChannelGroups == 1, "dwChannelGroups: %ld\n", params.dwChannelGroups);
|
|
|
|
ok(params.dwAudioChannels == 1, "dwAudioChannels: %ld\n", params.dwAudioChannels);
|
|
|
|
ok(params.dwSampleRate == 11025, "dwSampleRate: %ld\n", params.dwSampleRate);
|
2022-02-22 00:49:57 +01:00
|
|
|
test_synth_getformat(dmsynth, ¶ms, "min");
|
2022-02-08 00:52:00 +01:00
|
|
|
IDirectMusicSynth_Close(dmsynth);
|
|
|
|
/* Test share and features */
|
|
|
|
params.dwValidParams = DMUS_PORTPARAMS_SHARE|DMUS_PORTPARAMS_FEATURES;
|
|
|
|
params.fShare = TRUE;
|
|
|
|
params.dwFeatures = DMUS_PORT_FEATURE_AUDIOPATH|DMUS_PORT_FEATURE_STREAMING;
|
|
|
|
hr = IDirectMusicSynth_Open(dmsynth, ¶ms);
|
|
|
|
ok(hr == S_FALSE, "Open failed: %#lx\n", hr);
|
|
|
|
ok(params.dwValidParams == all_params, "dwValidParams: %#lx\n", params.dwValidParams);
|
|
|
|
ok(params.fShare == FALSE, "fShare: %d\n", params.fShare);
|
|
|
|
ok(params.dwFeatures == (DMUS_PORT_FEATURE_AUDIOPATH|DMUS_PORT_FEATURE_STREAMING),
|
|
|
|
"dwFeatures: %#lx\n", params.dwFeatures);
|
2022-02-22 00:49:57 +01:00
|
|
|
test_synth_getformat(dmsynth, ¶ms, "features");
|
2022-02-08 00:52:00 +01:00
|
|
|
IDirectMusicSynth_Close(dmsynth);
|
|
|
|
|
2012-04-30 11:43:26 +02:00
|
|
|
/* Synth has no default clock */
|
2012-05-03 23:05:33 +02:00
|
|
|
hr = IDirectMusicSynth_GetLatencyClock(dmsynth, &clock_synth);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == DMUS_E_NOSYNTHSINK, "IDirectMusicSynth_GetLatencyClock returned: %#lx\n", hr);
|
2012-04-30 11:43:26 +02:00
|
|
|
|
|
|
|
/* SynthSink has a default clock */
|
|
|
|
hr = IDirectMusicSynthSink_GetLatencyClock(dmsynth_sink, &clock_sink);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IDirectMusicSynth_GetLatencyClock returned: %#lx\n", hr);
|
2012-05-03 23:05:33 +02:00
|
|
|
ok(clock_sink != NULL, "No clock returned\n");
|
2022-01-03 00:16:03 +01:00
|
|
|
ref_clock_sink = get_refcount(clock_sink);
|
2012-04-30 11:43:26 +02:00
|
|
|
|
2022-01-03 00:16:03 +01:00
|
|
|
/* This will Init() the SynthSink and finish initializing the Synth */
|
2022-01-25 00:25:06 +01:00
|
|
|
hr = IDirectMusicSynthSink_Init(dmsynth_sink2, NULL);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IDirectMusicSynthSink_Init returned: %#lx\n", hr);
|
2022-01-19 18:48:50 +01:00
|
|
|
hr = IDirectMusicSynth_SetSynthSink(dmsynth, dmsynth_sink2);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IDirectMusicSynth_SetSynthSink returned: %#lx\n", hr);
|
2012-04-30 11:43:26 +02:00
|
|
|
hr = IDirectMusicSynth_SetSynthSink(dmsynth, dmsynth_sink);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IDirectMusicSynth_SetSynthSink returned: %#lx\n", hr);
|
2012-04-30 11:43:26 +02:00
|
|
|
|
|
|
|
/* Check clocks are the same */
|
2012-05-03 23:05:33 +02:00
|
|
|
hr = IDirectMusicSynth_GetLatencyClock(dmsynth, &clock_synth);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "IDirectMusicSynth_GetLatencyClock returned: %#lx\n", hr);
|
2012-05-03 23:05:33 +02:00
|
|
|
ok(clock_synth != NULL, "No clock returned\n");
|
|
|
|
ok(clock_synth == clock_sink, "Synth and SynthSink clocks are not the same\n");
|
2022-01-03 00:16:03 +01:00
|
|
|
ref_clock_synth = get_refcount(clock_synth);
|
|
|
|
ok(ref_clock_synth > ref_clock_sink + 1, "Latency clock refcount didn't increase\n");
|
2012-04-30 11:43:26 +02:00
|
|
|
|
2022-01-25 23:11:24 +01:00
|
|
|
/* GetPortCaps */
|
|
|
|
hr = IDirectMusicSynth_GetPortCaps(dmsynth, NULL);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == E_INVALIDARG, "GetPortCaps failed: %#lx\n", hr);
|
2022-01-25 23:11:24 +01:00
|
|
|
memset(&caps, 0, sizeof(caps));
|
|
|
|
hr = IDirectMusicSynth_GetPortCaps(dmsynth, &caps);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == E_INVALIDARG, "GetPortCaps failed: %#lx\n", hr);
|
2022-01-25 23:11:24 +01:00
|
|
|
caps.dwSize = sizeof(caps) + 1;
|
|
|
|
hr = IDirectMusicSynth_GetPortCaps(dmsynth, &caps);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "GetPortCaps failed: %#lx\n", hr);
|
2022-01-25 23:11:24 +01:00
|
|
|
|
2022-02-22 00:49:57 +01:00
|
|
|
/* GetFormat */
|
|
|
|
hr = IDirectMusicSynth_GetFormat(dmsynth, NULL, NULL);
|
|
|
|
ok(hr == E_POINTER, "GetFormat failed: %#lx\n", hr);
|
|
|
|
hr = IDirectMusicSynth_GetFormat(dmsynth, NULL, &size);
|
|
|
|
ok(hr == DMUS_E_SYNTHNOTCONFIGURED, "GetFormat failed: %#lx\n", hr);
|
|
|
|
hr = IDirectMusicSynth_Open(dmsynth, NULL);
|
|
|
|
ok(hr == S_OK, "Open failed: %#lx\n", hr);
|
|
|
|
hr = IDirectMusicSynth_GetFormat(dmsynth, NULL, &size);
|
|
|
|
ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
|
|
|
|
ok(size == sizeof(format), "GetFormat size mismatch, got %ld\n", size);
|
|
|
|
size = 1;
|
|
|
|
hr = IDirectMusicSynth_GetFormat(dmsynth, &format, &size);
|
|
|
|
ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
|
|
|
|
ok(size == sizeof(format), "GetFormat size mismatch, got %ld\n", size);
|
|
|
|
size = sizeof(format) + 1;
|
|
|
|
hr = IDirectMusicSynth_GetFormat(dmsynth, &format, &size);
|
|
|
|
ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
|
|
|
|
ok(size == sizeof(format), "GetFormat size mismatch, got %ld\n", size);
|
2022-02-22 00:49:58 +01:00
|
|
|
IDirectMusicSynth_Close(dmsynth);
|
|
|
|
|
|
|
|
/* GetDesiredBufferSize */
|
|
|
|
hr = IDirectMusicSynthSink_GetDesiredBufferSize(dmsynth_sink, NULL);
|
|
|
|
ok(hr == E_POINTER, "IDirectMusicSynthSink_GetDesiredBufferSize returned: %#lx\n", hr);
|
|
|
|
hr = IDirectMusicSynthSink_GetDesiredBufferSize(dmsynth_sink, &size);
|
|
|
|
ok(hr == E_UNEXPECTED, "IDirectMusicSynthSink_GetDesiredBufferSize returned: %#lx\n", hr);
|
|
|
|
params.dwValidParams = 0;
|
|
|
|
hr = IDirectMusicSynth_Open(dmsynth, ¶ms);
|
|
|
|
ok(hr == S_OK, "Open failed: %#lx\n", hr);
|
|
|
|
hr = IDirectMusicSynthSink_GetDesiredBufferSize(dmsynth_sink, &size);
|
|
|
|
ok(hr == S_OK, "IDirectMusicSynthSink_GetDesiredBufferSize returned: %#lx\n", hr);
|
|
|
|
ok(size == params.dwSampleRate * params.dwAudioChannels * 4, "size: %ld\n", size);
|
|
|
|
IDirectMusicSynth_Close(dmsynth);
|
|
|
|
params.dwValidParams = DMUS_PORTPARAMS_AUDIOCHANNELS;
|
|
|
|
params.dwAudioChannels = 1;
|
|
|
|
hr = IDirectMusicSynth_Open(dmsynth, ¶ms);
|
|
|
|
ok(hr == S_OK, "Open failed: %#lx\n", hr);
|
|
|
|
hr = IDirectMusicSynthSink_GetDesiredBufferSize(dmsynth_sink, &size);
|
|
|
|
ok(hr == S_OK, "IDirectMusicSynthSink_GetDesiredBufferSize returned: %#lx\n", hr);
|
|
|
|
ok(size == params.dwSampleRate * params.dwAudioChannels * 4, "size: %ld\n", size);
|
|
|
|
IDirectMusicSynth_Close(dmsynth);
|
2022-02-22 00:49:57 +01:00
|
|
|
|
2012-05-03 23:05:42 +02:00
|
|
|
if (control_synth)
|
|
|
|
IDirectMusicSynth_Release(control_synth);
|
|
|
|
if (control_sink)
|
|
|
|
IDirectMusicSynth_Release(control_sink);
|
2012-05-03 23:05:33 +02:00
|
|
|
if (clock_synth)
|
|
|
|
IReferenceClock_Release(clock_synth);
|
|
|
|
if (clock_sink)
|
|
|
|
IReferenceClock_Release(clock_sink);
|
2012-04-06 13:39:02 +02:00
|
|
|
if (dmsynth_sink)
|
|
|
|
IDirectMusicSynthSink_Release(dmsynth_sink);
|
2022-01-19 18:48:50 +01:00
|
|
|
if (dmsynth_sink2)
|
|
|
|
IDirectMusicSynthSink_Release(dmsynth_sink2);
|
2012-04-06 13:39:02 +02:00
|
|
|
IDirectMusicSynth_Release(dmsynth);
|
|
|
|
}
|
|
|
|
|
2016-07-19 09:52:25 +02:00
|
|
|
static void test_COM(void)
|
|
|
|
{
|
|
|
|
IDirectMusicSynth8 *dms8 = (IDirectMusicSynth8*)0xdeadbeef;
|
|
|
|
IKsControl *iksc;
|
|
|
|
IUnknown *unk;
|
|
|
|
ULONG refcount;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* COM aggregation */
|
2017-04-24 20:19:16 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_DirectMusicSynth, (IUnknown *)0xdeadbeef, CLSCTX_INPROC_SERVER,
|
2016-07-19 09:52:25 +02:00
|
|
|
&IID_IUnknown, (void**)&dms8);
|
|
|
|
ok(hr == CLASS_E_NOAGGREGATION,
|
2022-02-02 23:40:32 +01:00
|
|
|
"DirectMusicSynth create failed: %#lx, expected CLASS_E_NOAGGREGATION\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
ok(!dms8, "dms8 = %p\n", dms8);
|
|
|
|
|
|
|
|
/* Invalid RIID */
|
|
|
|
hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectMusicObject, (void**)&dms8);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == E_NOINTERFACE, "DirectMusicSynth create failed: %#lx, expected E_NOINTERFACE\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
|
|
|
|
/* Same refcount for all DirectMusicSynth interfaces */
|
|
|
|
hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectMusicSynth8, (void**)&dms8);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "DirectMusicSynth create failed: %#lx, expected S_OK\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
refcount = IDirectMusicSynth8_AddRef(dms8);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(refcount == 2, "refcount == %lu, expected 2\n", refcount);
|
2016-07-19 09:52:25 +02:00
|
|
|
|
|
|
|
hr = IDirectMusicSynth8_QueryInterface(dms8, &IID_IKsControl, (void**)&iksc);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IKsControl failed: %#lx\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
refcount = IKsControl_AddRef(iksc);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(refcount == 4, "refcount == %lu, expected 4\n", refcount);
|
2016-07-19 09:52:25 +02:00
|
|
|
IKsControl_Release(iksc);
|
|
|
|
|
|
|
|
hr = IDirectMusicSynth8_QueryInterface(dms8, &IID_IUnknown, (void**)&unk);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %#lx\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
refcount = IUnknown_AddRef(unk);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(refcount == 5, "refcount == %lu, expected 5\n", refcount);
|
2016-07-19 09:52:25 +02:00
|
|
|
IUnknown_Release(unk);
|
|
|
|
|
|
|
|
/* Unsupported interfaces */
|
|
|
|
hr = IDirectMusicSynth8_QueryInterface(dms8, &IID_IDirectMusicSynthSink, (void**)&unk);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectMusicSynthSink failed: %#lx\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
hr = IDirectMusicSynth8_QueryInterface(dms8, &IID_IReferenceClock, (void**)&unk);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == E_NOINTERFACE, "QueryInterface for IID_IReferenceClock failed: %#lx\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
|
|
|
|
while (IDirectMusicSynth8_Release(dms8));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_COM_synthsink(void)
|
|
|
|
{
|
|
|
|
IDirectMusicSynthSink *dmss = (IDirectMusicSynthSink*)0xdeadbeef;
|
|
|
|
IKsControl *iksc;
|
|
|
|
IUnknown *unk;
|
|
|
|
ULONG refcount;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* COM aggregation */
|
2017-04-24 20:19:16 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, (IUnknown *)0xdeadbeef, CLSCTX_INPROC_SERVER,
|
2016-07-19 09:52:25 +02:00
|
|
|
&IID_IUnknown, (void**)&dmss);
|
|
|
|
ok(hr == CLASS_E_NOAGGREGATION,
|
2022-02-02 23:40:32 +01:00
|
|
|
"DirectMusicSynthSink create failed: %#lx, expected CLASS_E_NOAGGREGATION\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
ok(!dmss, "dmss = %p\n", dmss);
|
|
|
|
|
|
|
|
/* Invalid RIID */
|
|
|
|
hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectMusicObject, (void**)&dmss);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == E_NOINTERFACE, "DirectMusicSynthSink create failed: %#lx, expected E_NOINTERFACE\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
|
|
|
|
/* Same refcount for all DirectMusicSynthSink interfaces */
|
|
|
|
hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectMusicSynthSink, (void**)&dmss);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "DirectMusicSynthSink create failed: %#lx, expected S_OK\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
refcount = IDirectMusicSynthSink_AddRef(dmss);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(refcount == 2, "refcount == %lu, expected 2\n", refcount);
|
2016-07-19 09:52:25 +02:00
|
|
|
|
|
|
|
hr = IDirectMusicSynthSink_QueryInterface(dmss, &IID_IKsControl, (void**)&iksc);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IKsControl failed: %#lx\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
refcount = IKsControl_AddRef(iksc);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(refcount == 4, "refcount == %lu, expected 4\n", refcount);
|
2016-07-19 09:52:25 +02:00
|
|
|
IKsControl_Release(iksc);
|
|
|
|
|
|
|
|
hr = IDirectMusicSynthSink_QueryInterface(dmss, &IID_IUnknown, (void**)&unk);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %#lx\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
refcount = IUnknown_AddRef(unk);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(refcount == 5, "refcount == %lu, expected 5\n", refcount);
|
2016-07-19 09:52:25 +02:00
|
|
|
IUnknown_Release(unk);
|
|
|
|
|
|
|
|
/* Unsupported interfaces */
|
|
|
|
hr = IDirectMusicSynthSink_QueryInterface(dmss, &IID_IReferenceClock, (void**)&unk);
|
2022-02-02 23:40:32 +01:00
|
|
|
ok(hr == E_NOINTERFACE, "QueryInterface for IID_IReferenceClock failed: %#lx\n", hr);
|
2016-07-19 09:52:25 +02:00
|
|
|
|
|
|
|
while (IDirectMusicSynthSink_Release(dmss));
|
|
|
|
}
|
2012-04-06 13:39:02 +02:00
|
|
|
START_TEST(dmsynth)
|
|
|
|
{
|
|
|
|
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
|
|
|
|
2016-07-19 09:51:36 +02:00
|
|
|
if (missing_dmsynth())
|
|
|
|
{
|
|
|
|
skip("dmsynth not available\n");
|
|
|
|
CoUninitialize();
|
|
|
|
return;
|
|
|
|
}
|
2012-04-06 13:39:02 +02:00
|
|
|
test_dmsynth();
|
2016-07-19 09:52:25 +02:00
|
|
|
test_COM();
|
|
|
|
test_COM_synthsink();
|
2012-04-06 13:39:02 +02:00
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|