=?UTF-8?Q?J=C3=B6rg=20H=C3=B6hle=20?=: mmdevapi/tests: Produce audible output.

Alexandre Julliard julliard at winehq.org
Thu Feb 9 15:21:48 CST 2012


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

Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date:   Wed Feb  1 06:53:31 2012 +0100

mmdevapi/tests: Produce audible output.

---

 dlls/mmdevapi/tests/render.c |   40 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/dlls/mmdevapi/tests/render.c b/dlls/mmdevapi/tests/render.c
index 2427be7..928d93e 100644
--- a/dlls/mmdevapi/tests/render.c
+++ b/dlls/mmdevapi/tests/render.c
@@ -66,6 +66,32 @@ static inline const char *dbgstr_guid( const GUID *id )
     return ret;
 }
 
+#define PI 3.14159265358979323846L
+static DWORD wave_generate_tone(PWAVEFORMATEX pwfx, BYTE* data, UINT32 frames)
+{
+    static double phase = 0.; /* normalized to unit, not 2*PI */
+    PWAVEFORMATEXTENSIBLE wfxe = (PWAVEFORMATEXTENSIBLE)pwfx;
+    DWORD cn, i;
+    double delta, y;
+
+    if(!winetest_interactive || wfxe->Format.wFormatTag != WAVE_FORMAT_EXTENSIBLE ||
+       !IsEqualGUID(&wfxe->SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT))
+        return AUDCLNT_BUFFERFLAGS_SILENT;
+
+    for(delta = phase, cn = 0; cn < wfxe->Format.nChannels;
+        delta += .5/wfxe->Format.nChannels, cn++){
+        for(i = 0; i < frames; i++){
+            y = sin(2*PI*(440.* i / wfxe->Format.nSamplesPerSec + delta));
+            /* assume alignment is granted */
+            ((float*)data)[cn+i*wfxe->Format.nChannels] = y;
+            /* fixme: 16bit for exclusive mode */
+        }
+    }
+    phase += 440.* frames / wfxe->Format.nSamplesPerSec;
+    phase -= floor(phase);
+    return 0;
+}
+
 static void test_uninitialized(IAudioClient *ac)
 {
     HRESULT hr;
@@ -1590,7 +1616,15 @@ static void test_worst_case(void)
         hr = IAudioClock_GetPosition(acl, &pos, &pcpos0);
         ok(hr == S_OK, "GetPosition failed: %08x\n", hr);
 
-        /* XAudio2 prefills one period, we don't */
+        /* XAudio2 prefills one period, play without it */
+        if(winetest_debug>2){
+            hr = IAudioRenderClient_GetBuffer(arc, fragment, &data);
+            ok(hr == S_OK, "GetBuffer failed: %08x\n", hr);
+
+            hr = IAudioRenderClient_ReleaseBuffer(arc, fragment, AUDCLNT_BUFFERFLAGS_SILENT);
+            ok(hr == S_OK, "ReleaseBuffer failed: %08x\n", hr);
+        }
+
         hr = IAudioClient_Start(ac);
         ok(hr == S_OK, "Start failed: %08x\n", hr);
 
@@ -1609,8 +1643,8 @@ static void test_worst_case(void)
                 hr = IAudioRenderClient_GetBuffer(arc, fragment, &data);
                 ok(hr == S_OK, "GetBuffer failed: %08x\n", hr);
 
-                /* fixme: produce audible output */
-                hr = IAudioRenderClient_ReleaseBuffer(arc, fragment, AUDCLNT_BUFFERFLAGS_SILENT);
+                hr = IAudioRenderClient_ReleaseBuffer(arc, fragment,
+                       wave_generate_tone(pwfx, data, fragment));
                 ok(hr == S_OK, "ReleaseBuffer failed: %08x\n", hr);
                 if(hr == S_OK)
                     sum += fragment;




More information about the wine-cvs mailing list