dmsynth/tests: Add synth GetFormat tests.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2022-02-22 00:49:57 +01:00 committed by Alexandre Julliard
parent 5715d2b5b2
commit a0addfe38d
1 changed files with 49 additions and 0 deletions

View File

@ -51,6 +51,30 @@ static ULONG get_refcount(void *iface)
return IUnknown_Release(unknown); return IUnknown_Release(unknown);
} }
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();
}
static void test_dmsynth(void) static void test_dmsynth(void)
{ {
IDirectMusicSynth *dmsynth = NULL; IDirectMusicSynth *dmsynth = NULL;
@ -68,6 +92,8 @@ static void test_dmsynth(void)
DMUS_PORTPARAMS params; DMUS_PORTPARAMS params;
const DWORD all_params = DMUS_PORTPARAMS_VOICES|DMUS_PORTPARAMS_CHANNELGROUPS|DMUS_PORTPARAMS_AUDIOCHANNELS| 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; DMUS_PORTPARAMS_SAMPLERATE|DMUS_PORTPARAMS_EFFECTS|DMUS_PORTPARAMS_SHARE|DMUS_PORTPARAMS_FEATURES;
WAVEFORMATEX format;
DWORD size;
hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth, (LPVOID*)&dmsynth); hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth, (LPVOID*)&dmsynth);
ok(hr == S_OK, "CoCreateInstance returned: %#lx\n", hr); ok(hr == S_OK, "CoCreateInstance returned: %#lx\n", hr);
@ -154,6 +180,7 @@ static void test_dmsynth(void)
ok(params.dwEffectFlags == DMUS_EFFECT_REVERB, "params.dwEffectFlags: %#lx\n", params.dwEffectFlags); ok(params.dwEffectFlags == DMUS_EFFECT_REVERB, "params.dwEffectFlags: %#lx\n", params.dwEffectFlags);
ok(params.fShare == FALSE, "fShare: %d\n", params.fShare); ok(params.fShare == FALSE, "fShare: %d\n", params.fShare);
ok(params.dwFeatures == 0, "dwFeatures: %#lx\n", params.dwFeatures); ok(params.dwFeatures == 0, "dwFeatures: %#lx\n", params.dwFeatures);
test_synth_getformat(dmsynth, &params, "defaults");
IDirectMusicSynth_Close(dmsynth); IDirectMusicSynth_Close(dmsynth);
/* Requesting more than supported */ /* Requesting more than supported */
params.dwValidParams = DMUS_PORTPARAMS_SAMPLERATE; params.dwValidParams = DMUS_PORTPARAMS_SAMPLERATE;
@ -162,6 +189,7 @@ static void test_dmsynth(void)
ok(hr == S_FALSE, "Open failed: %#lx\n", hr); ok(hr == S_FALSE, "Open failed: %#lx\n", hr);
ok(params.dwValidParams == all_params, "dwValidParams: %#lx\n", params.dwValidParams); ok(params.dwValidParams == all_params, "dwValidParams: %#lx\n", params.dwValidParams);
ok(params.dwSampleRate == 96000, "dwSampleRate: %ld\n", params.dwSampleRate); ok(params.dwSampleRate == 96000, "dwSampleRate: %ld\n", params.dwSampleRate);
test_synth_getformat(dmsynth, &params, "max");
IDirectMusicSynth_Close(dmsynth); IDirectMusicSynth_Close(dmsynth);
/* Minimums */ /* Minimums */
params.dwValidParams = DMUS_PORTPARAMS_VOICES|DMUS_PORTPARAMS_CHANNELGROUPS|DMUS_PORTPARAMS_AUDIOCHANNELS| params.dwValidParams = DMUS_PORTPARAMS_VOICES|DMUS_PORTPARAMS_CHANNELGROUPS|DMUS_PORTPARAMS_AUDIOCHANNELS|
@ -177,6 +205,7 @@ static void test_dmsynth(void)
ok(params.dwChannelGroups == 1, "dwChannelGroups: %ld\n", params.dwChannelGroups); ok(params.dwChannelGroups == 1, "dwChannelGroups: %ld\n", params.dwChannelGroups);
ok(params.dwAudioChannels == 1, "dwAudioChannels: %ld\n", params.dwAudioChannels); ok(params.dwAudioChannels == 1, "dwAudioChannels: %ld\n", params.dwAudioChannels);
ok(params.dwSampleRate == 11025, "dwSampleRate: %ld\n", params.dwSampleRate); ok(params.dwSampleRate == 11025, "dwSampleRate: %ld\n", params.dwSampleRate);
test_synth_getformat(dmsynth, &params, "min");
IDirectMusicSynth_Close(dmsynth); IDirectMusicSynth_Close(dmsynth);
/* Test share and features */ /* Test share and features */
params.dwValidParams = DMUS_PORTPARAMS_SHARE|DMUS_PORTPARAMS_FEATURES; params.dwValidParams = DMUS_PORTPARAMS_SHARE|DMUS_PORTPARAMS_FEATURES;
@ -188,6 +217,7 @@ static void test_dmsynth(void)
ok(params.fShare == FALSE, "fShare: %d\n", params.fShare); ok(params.fShare == FALSE, "fShare: %d\n", params.fShare);
ok(params.dwFeatures == (DMUS_PORT_FEATURE_AUDIOPATH|DMUS_PORT_FEATURE_STREAMING), ok(params.dwFeatures == (DMUS_PORT_FEATURE_AUDIOPATH|DMUS_PORT_FEATURE_STREAMING),
"dwFeatures: %#lx\n", params.dwFeatures); "dwFeatures: %#lx\n", params.dwFeatures);
test_synth_getformat(dmsynth, &params, "features");
IDirectMusicSynth_Close(dmsynth); IDirectMusicSynth_Close(dmsynth);
/* Synth has no default clock */ /* Synth has no default clock */
@ -226,6 +256,25 @@ static void test_dmsynth(void)
hr = IDirectMusicSynth_GetPortCaps(dmsynth, &caps); hr = IDirectMusicSynth_GetPortCaps(dmsynth, &caps);
ok(hr == S_OK, "GetPortCaps failed: %#lx\n", hr); ok(hr == S_OK, "GetPortCaps failed: %#lx\n", hr);
/* 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);
if (control_synth) if (control_synth)
IDirectMusicSynth_Release(control_synth); IDirectMusicSynth_Release(control_synth);
if (control_sink) if (control_sink)