diff --git a/dlls/dmsynth/tests/dmsynth.c b/dlls/dmsynth/tests/dmsynth.c index 93212c0ae9f..ab3349f666b 100644 --- a/dlls/dmsynth/tests/dmsynth.c +++ b/dlls/dmsynth/tests/dmsynth.c @@ -51,6 +51,30 @@ static ULONG get_refcount(void *iface) 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) { IDirectMusicSynth *dmsynth = NULL; @@ -68,6 +92,8 @@ static void test_dmsynth(void) 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; + WAVEFORMATEX format; + DWORD size; hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth, (LPVOID*)&dmsynth); 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.fShare == FALSE, "fShare: %d\n", params.fShare); ok(params.dwFeatures == 0, "dwFeatures: %#lx\n", params.dwFeatures); + test_synth_getformat(dmsynth, ¶ms, "defaults"); IDirectMusicSynth_Close(dmsynth); /* Requesting more than supported */ params.dwValidParams = DMUS_PORTPARAMS_SAMPLERATE; @@ -162,6 +189,7 @@ static void test_dmsynth(void) 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); + test_synth_getformat(dmsynth, ¶ms, "max"); IDirectMusicSynth_Close(dmsynth); /* Minimums */ 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.dwAudioChannels == 1, "dwAudioChannels: %ld\n", params.dwAudioChannels); ok(params.dwSampleRate == 11025, "dwSampleRate: %ld\n", params.dwSampleRate); + test_synth_getformat(dmsynth, ¶ms, "min"); IDirectMusicSynth_Close(dmsynth); /* Test share and 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.dwFeatures == (DMUS_PORT_FEATURE_AUDIOPATH|DMUS_PORT_FEATURE_STREAMING), "dwFeatures: %#lx\n", params.dwFeatures); + test_synth_getformat(dmsynth, ¶ms, "features"); IDirectMusicSynth_Close(dmsynth); /* Synth has no default clock */ @@ -226,6 +256,25 @@ static void test_dmsynth(void) hr = IDirectMusicSynth_GetPortCaps(dmsynth, &caps); 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) IDirectMusicSynth_Release(control_synth); if (control_sink)