Michael Stefaniuc : dmsynth/tests: Add synth GetFormat tests.

Alexandre Julliard julliard at winehq.org
Tue Feb 22 16:06:49 CST 2022


Module: wine
Branch: master
Commit: a0addfe38d06eebab72b740d56ff7fe3d055875c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a0addfe38d06eebab72b740d56ff7fe3d055875c

Author: Michael Stefaniuc <mstefani at winehq.org>
Date:   Tue Feb 22 00:49:57 2022 +0100

dmsynth/tests: Add synth GetFormat tests.

Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dmsynth/tests/dmsynth.c | 49 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

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, &params, "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, &params, "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, &params, "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, &params, "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)




More information about the wine-cvs mailing list