[PATCH] mmdevapi/tests: Prevent crash when GetMixFormat fails.

Octavian Voicu octavian.voicu at gmail.com
Wed Jul 28 19:57:30 CDT 2010


Tests in mmdevapi (capture, render) crash when GetMixFormat fails.

Test results from test.winehq.org show that GetMixFormat consistently
fails on some configurations (usually for both capture and render,
sometimes only for capture).


---
 dlls/mmdevapi/tests/capture.c |   36 +++++++++++++++++++++---------------
 dlls/mmdevapi/tests/render.c  |   36 +++++++++++++++++++++---------------
 2 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/dlls/mmdevapi/tests/capture.c b/dlls/mmdevapi/tests/capture.c
index 1bedfc6..d387622 100644
--- a/dlls/mmdevapi/tests/capture.c
+++ b/dlls/mmdevapi/tests/capture.c
@@ -190,25 +190,31 @@ static void test_audioclient(IAudioClient *ac)
     hr = IAudioClient_GetMixFormat(ac, NULL);
     ok(hr == E_POINTER, "GetMixFormat returns %08x\n", hr);
 
+    pwfx = (void *)0xdeadbeef;
     hr = IAudioClient_GetMixFormat(ac, &pwfx);
     ok(hr == S_OK, "Valid GetMixFormat returns %08x\n", hr);
 
-    trace("Tag: %04x\n", pwfx->wFormatTag);
-    trace("bits: %u\n", pwfx->wBitsPerSample);
-    trace("chan: %u\n", pwfx->nChannels);
-    trace("rate: %u\n", pwfx->nSamplesPerSec);
-    trace("align: %u\n", pwfx->nBlockAlign);
-    trace("extra: %u\n", pwfx->cbSize);
-    ok(pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE, "wFormatTag is %x\n", pwfx->wFormatTag);
-    if (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
+    trace("pwfx: %p\n", pwfx);
+    if (pwfx == (void *)0xdeadbeef) pwfx = NULL;
+    if (pwfx)
     {
-        WAVEFORMATEXTENSIBLE *pwfxe = (void*)pwfx;
-        trace("Res: %u\n", pwfxe->Samples.wReserved);
-        trace("Mask: %x\n", pwfxe->dwChannelMask);
-        trace("Alg: %s\n",
-              IsEqualGUID(&pwfxe->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)?"PCM":
-              (IsEqualGUID(&pwfxe->SubFormat,
-                           &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)?"FLOAT":"Other"));
+        trace("Tag: %04x\n", pwfx->wFormatTag);
+        trace("bits: %u\n", pwfx->wBitsPerSample);
+        trace("chan: %u\n", pwfx->nChannels);
+        trace("rate: %u\n", pwfx->nSamplesPerSec);
+        trace("align: %u\n", pwfx->nBlockAlign);
+        trace("extra: %u\n", pwfx->cbSize);
+        ok(pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE, "wFormatTag is %x\n", pwfx->wFormatTag);
+        if (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
+        {
+            WAVEFORMATEXTENSIBLE *pwfxe = (void*)pwfx;
+            trace("Res: %u\n", pwfxe->Samples.wReserved);
+            trace("Mask: %x\n", pwfxe->dwChannelMask);
+            trace("Alg: %s\n",
+                  IsEqualGUID(&pwfxe->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)?"PCM":
+                  (IsEqualGUID(&pwfxe->SubFormat,
+                               &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)?"FLOAT":"Other"));
+        }
     }
 
     if (hr == S_OK)
diff --git a/dlls/mmdevapi/tests/render.c b/dlls/mmdevapi/tests/render.c
index 56fea02..ff4e0c0 100644
--- a/dlls/mmdevapi/tests/render.c
+++ b/dlls/mmdevapi/tests/render.c
@@ -123,25 +123,31 @@ static void test_audioclient(IAudioClient *ac)
     hr = IAudioClient_GetMixFormat(ac, NULL);
     ok(hr == E_POINTER, "GetMixFormat returns %08x\n", hr);
 
+    pwfx = (void *)0xdeadbeef;
     hr = IAudioClient_GetMixFormat(ac, &pwfx);
     ok(hr == S_OK, "Valid GetMixFormat returns %08x\n", hr);
 
-    trace("Tag: %04x\n", pwfx->wFormatTag);
-    trace("bits: %u\n", pwfx->wBitsPerSample);
-    trace("chan: %u\n", pwfx->nChannels);
-    trace("rate: %u\n", pwfx->nSamplesPerSec);
-    trace("align: %u\n", pwfx->nBlockAlign);
-    trace("extra: %u\n", pwfx->cbSize);
-    ok(pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE, "wFormatTag is %x\n", pwfx->wFormatTag);
-    if (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
+    trace("pwfx: %p\n", pwfx);
+    if (pwfx == (void *)0xdeadbeef) pwfx = NULL;
+    if (pwfx)
     {
-        WAVEFORMATEXTENSIBLE *pwfxe = (void*)pwfx;
-        trace("Res: %u\n", pwfxe->Samples.wReserved);
-        trace("Mask: %x\n", pwfxe->dwChannelMask);
-        trace("Alg: %s\n",
-              IsEqualGUID(&pwfxe->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)?"PCM":
-              (IsEqualGUID(&pwfxe->SubFormat,
-                           &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)?"FLOAT":"Other"));
+        trace("Tag: %04x\n", pwfx->wFormatTag);
+        trace("bits: %u\n", pwfx->wBitsPerSample);
+        trace("chan: %u\n", pwfx->nChannels);
+        trace("rate: %u\n", pwfx->nSamplesPerSec);
+        trace("align: %u\n", pwfx->nBlockAlign);
+        trace("extra: %u\n", pwfx->cbSize);
+        ok(pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE, "wFormatTag is %x\n", pwfx->wFormatTag);
+        if (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
+        {
+            WAVEFORMATEXTENSIBLE *pwfxe = (void*)pwfx;
+            trace("Res: %u\n", pwfxe->Samples.wReserved);
+            trace("Mask: %x\n", pwfxe->dwChannelMask);
+            trace("Alg: %s\n",
+                  IsEqualGUID(&pwfxe->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)?"PCM":
+                  (IsEqualGUID(&pwfxe->SubFormat,
+                               &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)?"FLOAT":"Other"));
+        }
     }
 
     if (hr == S_OK)
-- 
1.7.0.4




More information about the wine-patches mailing list