Do more tests in non-interactive mode

Francois Gouget fgouget at codeweavers.com
Fri Jul 23 13:43:47 CDT 2004


This patch is based on the following email:
http://www.winehq.org/hypermail/wine-devel/2004/07/0287.html

As pointed out in the above email, if not in interactive mode we can 
make the test tones/captures much shorter so that the test does not take 
too long to run. Here is some more details about what we do:
   * test tones are always played
   * if not in interactive mode we only play silence
   * if not in interactive mode tones/captures last only 0.1 (resp. 0.5) 
seconds
   * if not in interactive mode we don't touch the volume
   * if in interactive mode nothing is changed

The difference is that the patch now applies the technique to the 
following tests:
  * dsound - wave
  * winmm  - wave
  * winmm  - capture

This way we exercise almost as much of the API as in interactive mode 
without disturbing users, and the tests still run fast. The slowest one 
is the winmm test which takes 16 seconds on my machine which supports 
all the tested sound formats (but has only one sound card). Given that 
winetest's timeout is two minutes this gives a wide margin.

Changelog:

  * dlls/dsound/tests/ds3d.c
    dlls/dsound/tests/dsound.c
    dlls/dsound/tests/dsound_test.h
    dlls/winmm/tests/capture.c
    dlls/winmm/tests/wave.c

    Francois Gouget <fgouget at codeweavers.com>
    Do more tests in non-interactive mode by playing silence instead of 
the 440Hz test tone, not touching the volume settings, shortening the 
test tones/captures.
    Shorten the dsound TIME_SLICE to reduce the granularity of the tone 
duration check.


-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/dsound/tests/ds3d.c
===================================================================
RCS file: /var/cvs/wine/dlls/dsound/tests/ds3d.c,v
retrieving revision 1.4
diff -u -r1.4 ds3d.c
--- dlls/dsound/tests/ds3d.c	19 Jul 2004 21:20:38 -0000	1.4
+++ dlls/dsound/tests/ds3d.c	23 Jul 2004 13:48:40 -0000
@@ -34,6 +34,7 @@
 #include "windef.h"
 #include "wingdi.h"
 #include "dsound.h"
+#include "dxerr8.h"
 
 #include "dsound_test.h"
 
@@ -71,6 +72,21 @@
     return buf;
 }
 
+static char* wave_generate_silence(WAVEFORMATEX* wfx, double duration, DWORD* size)
+{
+    DWORD nb_samples;
+    char* buf;
+
+    nb_samples=(DWORD)(duration*wfx->nSamplesPerSec);
+    *size=nb_samples*wfx->nBlockAlign;
+    buf=malloc(*size);
+    if (wfx->wBitsPerSample==8)
+        memset(buf,0x80,*size);
+    else
+        memset(buf,0,*size);
+    return buf;
+}
+
 HWND get_hwnd()
 {
     HWND hwnd=GetForegroundWindow();
@@ -347,7 +363,8 @@
         DS3DBUFFER buffer_param;
         DWORD start_time,now;
 
-        trace("    Playing %g second 440Hz tone at %ldx%dx%d\n", duration,
+        trace("    Playing %g second %s at %ldx%dx%d\n", duration,
+              winetest_interactive?"440Hz tone":"of silence",
               wfx.nSamplesPerSec, wfx.wBitsPerSample,wfx.nChannels);
 
         if (is_primary) {
@@ -409,8 +426,11 @@
                 rc=IDirectSoundBuffer_GetVolume(dsbo,&val);
                 ok(rc==DS_OK,"GetVolume failed: 0x%lx\n",rc);
 
-                rc=IDirectSoundBuffer_SetVolume(dsbo,volume);
-                ok(rc==DS_OK,"SetVolume failed: 0x%lx\n",rc);
+                if (winetest_interactive || !is_primary)
+                {
+                    rc=IDirectSoundBuffer_SetVolume(dsbo,volume);
+                    ok(rc==DS_OK,"SetVolume failed: 0x%lx\n",rc);
+                }
             } else {
                 /* DSOUND: Error: Buffer does not have CTRLVOLUME */
                 rc=IDirectSoundBuffer_GetVolume(dsbo,&volume);
@@ -424,8 +444,11 @@
                 rc=IDirectSoundBuffer_GetPan(dsbo,&val);
                 ok(rc==DS_OK,"GetPan failed: 0x%lx\n",rc);
 
-                rc=IDirectSoundBuffer_SetPan(dsbo,pan);
-                ok(rc==DS_OK,"SetPan failed: 0x%lx\n",rc);
+                if (winetest_interactive || !is_primary)
+                {
+                    rc=IDirectSoundBuffer_SetPan(dsbo,pan);
+                    ok(rc==DS_OK,"SetPan failed: 0x%lx\n",rc);
+                }
             } else {
                 /* DSOUND: Error: Buffer does not have CTRLPAN */
                 rc=IDirectSoundBuffer_GetPan(dsbo,&pan);
@@ -433,7 +456,10 @@
             }
         }
 
-        state.wave=wave_generate_la(&wfx,duration,&state.wave_len);
+        if (winetest_interactive)
+            state.wave=wave_generate_la(&wfx,duration,&state.wave_len);
+        else
+            state.wave=wave_generate_silence(&wfx,duration,&state.wave_len);
 
         state.dsbo=dsbo;
         state.wfx=&wfx;
@@ -492,9 +518,15 @@
                 ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition failed 0x%lx\n",rc);
             }
         }
-        /* Check the sound duration was within 10% of the expected value */
+        /* Check the sound duration was within 10% of the expected value.
+         * Skip the test for short durations as the timer/TIME_SLICE/scheduler
+         * granularity is too big to get meaningful results.
+         */
         now=GetTickCount();
-        ok(fabs(1000*duration-now+start_time)<=100*duration,"The sound played for %ld ms instead of %g ms\n",now-start_time,1000*duration);
+        if (duration>=0.4)
+        {
+            ok(fabs(duration*1000.0-now+start_time)<=TIME_SLICE+100*duration,"The sound played for %ld ms instead of %g ms\n",now-start_time,1000*duration);
+        }
 
         free(state.wave);
         if (is_primary) {
@@ -510,7 +542,7 @@
     }
 }
 
-static HRESULT test_secondary(LPGUID lpGuid, int play,
+static HRESULT test_secondary(LPGUID lpGuid,
                               int has_3d, int has_3dbuffer,
                               int has_listener, int has_duplicate,
                               int move_listener, int move_sound)
@@ -622,7 +697,9 @@
             if (rc==DS_OK && secondary!=NULL) {
                 double duration;
                 duration=(move_listener || move_sound?4.0:1.0);
-                test_buffer(dso,secondary,0,FALSE,0,FALSE,0,winetest_interactive,duration,has_3dbuffer,listener,move_listener,move_sound);
+                if (!winetest_interactive)
+                    duration=duration/10.0;
+                test_buffer(dso,secondary,0,FALSE,0,FALSE,0,1,duration,has_3dbuffer,listener,move_listener,move_sound);
                 ref=IDirectSoundBuffer_Release(secondary);
                 ok(ref==0,"IDirectSoundBuffer_Release %s has %d references, should have 0\n",has_duplicate?"duplicated":"secondary",ref);
             }
@@ -732,19 +809,20 @@
     rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
     ok(rc==DS_OK && primary!=NULL,"CreateSoundBuffer failed to create a primary buffer: 0x%lx\n",rc);
     if (rc==DS_OK && primary!=NULL) {
-        test_buffer(dso,primary,1,TRUE,0,TRUE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,NULL,0,0);
+        double duration=(winetest_interactive?1.0:0.1);
+        test_buffer(dso,primary,1,TRUE,0,TRUE,0,!(dscaps.dwFlags & DSCAPS_EMULDRIVER),duration,0,NULL,0,0);
         if (winetest_interactive) {
             LONG volume,pan;
 
             volume = DSBVOLUME_MAX;
             for (i = 0; i < 6; i++) {
-                test_buffer(dso,primary,1,TRUE,volume,TRUE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,NULL,0,0);
+                test_buffer(dso,primary,1,TRUE,volume,TRUE,0,!(dscaps.dwFlags & DSCAPS_EMULDRIVER),duration,0,NULL,0,0);
                 volume -= ((DSBVOLUME_MAX-DSBVOLUME_MIN) / 40);
             }
 
             pan = DSBPAN_LEFT;
             for (i = 0; i < 7; i++) {
-                test_buffer(dso,primary,1,TRUE,0,TRUE,pan,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0);
+                test_buffer(dso,primary,1,TRUE,0,TRUE,pan,!(dscaps.dwFlags & DSCAPS_EMULDRIVER),duration,0,0,0,0);
                 pan += ((DSBPAN_RIGHT-DSBPAN_LEFT) / 6);
             }
         }
@@ -812,7 +890,8 @@
         rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
         ok(rc==DS_OK && primary!=NULL,"CreateSoundBuffer failed to create a 3D primary buffer: 0x%lx\n",rc);
         if (rc==DS_OK && primary!=NULL) {
-            test_buffer(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0);
+            double duration=(winetest_interactive?1.0:0.1);
+            test_buffer(dso,primary,1,FALSE,0,FALSE,0,!(dscaps.dwFlags & DSCAPS_EMULDRIVER),duration,0,0,0,0);
             ref=IDirectSoundBuffer_Release(primary);
             ok(ref==0,"IDirectSoundBuffer_Release primary has %d references, should have 0\n",ref);
         }
@@ -872,6 +951,7 @@
         ok(rc==DS_OK && listener!=NULL,"IDirectSoundBuffer_QueryInterface failed to get a 3D listener 0x%lx\n",rc);
         if (rc==DS_OK && listener!=NULL) {
             LPDIRECTSOUNDBUFFER temp_buffer=NULL;
+            double duration;
 
             /* Checking the COM interface */
             rc=IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer);
@@ -889,7 +969,8 @@
                 ok(ref==1,"IDirectSoundBuffer_Release has %d references, should have 1\n",ref);
 
                 /* Testing the buffer */
-                test_buffer(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,listener,0,0);
+                duration=(winetest_interactive?1.0:0.1);
+                test_buffer(dso,primary,1,FALSE,0,FALSE,0,!(dscaps.dwFlags & DSCAPS_EMULDRIVER),duration,0,listener,0,0);
             }
 
             /* Testing the reference counting */
@@ -927,20 +1008,20 @@
     test_primary_3d_with_listener(lpGuid);
 
     /* Testing secondary buffers */
-    test_secondary(lpGuid,winetest_interactive,0,0,0,0,0,0);
-    test_secondary(lpGuid,winetest_interactive,0,0,0,1,0,0);
+    test_secondary(lpGuid,0,0,0,0,0,0);
+    test_secondary(lpGuid,0,0,0,1,0,0);
 
     /* Testing 3D secondary buffers */
-    test_secondary(lpGuid,winetest_interactive,1,0,0,0,0,0);
-    test_secondary(lpGuid,winetest_interactive,1,1,0,0,0,0);
-    test_secondary(lpGuid,winetest_interactive,1,1,0,1,0,0);
-    test_secondary(lpGuid,winetest_interactive,1,0,1,0,0,0);
-    test_secondary(lpGuid,winetest_interactive,1,0,1,1,0,0);
-    test_secondary(lpGuid,winetest_interactive,1,1,1,0,0,0);
-    test_secondary(lpGuid,winetest_interactive,1,1,1,1,0,0);
-    test_secondary(lpGuid,winetest_interactive,1,1,1,0,1,0);
-    test_secondary(lpGuid,winetest_interactive,1,1,1,0,0,1);
-    test_secondary(lpGuid,winetest_interactive,1,1,1,0,1,1);
+    test_secondary(lpGuid,1,0,0,0,0,0);
+    test_secondary(lpGuid,1,1,0,0,0,0);
+    test_secondary(lpGuid,1,1,0,1,0,0);
+    test_secondary(lpGuid,1,0,1,0,0,0);
+    test_secondary(lpGuid,1,0,1,1,0,0);
+    test_secondary(lpGuid,1,1,1,0,0,0);
+    test_secondary(lpGuid,1,1,1,1,0,0);
+    test_secondary(lpGuid,1,1,1,0,1,0);
+    test_secondary(lpGuid,1,1,1,0,0,1);
+    test_secondary(lpGuid,1,1,1,0,1,1);
 
     return 1;
 }
Index: dlls/dsound/tests/dsound.c
===================================================================
RCS file: /var/cvs/wine/dlls/dsound/tests/dsound.c,v
retrieving revision 1.31
diff -u -r1.31 dsound.c
--- dlls/dsound/tests/dsound.c	22 Jul 2004 20:35:36 -0000	1.31
+++ dlls/dsound/tests/dsound.c	23 Jul 2004 13:35:37 -0000
@@ -750,6 +750,7 @@
     ok(rc==DS_OK && primary!=NULL,"CreateSoundBuffer failed to create a primary buffer: 0x%lx\n",rc);
     if (rc==DS_OK && primary!=NULL) {
         LONG vol;
+        double duration;
 
         /* Try to create a second primary buffer */
         /* DSOUND: Error: The primary buffer already exists.  Any changes made to the buffer description will be ignored. */
@@ -765,17 +766,15 @@
         ok(rc!=DS_OK,"IDirectSound_DuplicateSoundBuffer primary buffer should have failed 0x%lx\n",rc);
 
         rc=IDirectSoundBuffer_GetVolume(primary,&vol);
-        ok(rc==DS_OK,"GetVolume failed: 0x%lx\n",rc);
+        ok(rc==DS_OK,"GetVolume failed: %s\n",DXGetErrorString8(rc));
 
-        if (winetest_interactive)
-        {
-            trace("Playing a 5 seconds reference tone at the current volume.\n");
-            if (rc==DS_OK)
-                trace("(the current volume is %ld according to DirectSound)\n",vol);
-            trace("All subsequent tones should be identical to this one.\n");
-            trace("Listen for stutter, changes in pitch, volume, etc.\n");
-        }
-        test_buffer(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),5.0,0,0,0,0);
+        duration=(winetest_interactive?5.0:0.5);
+        trace("Playing a %g seconds reference tone at the current volume.\n",duration);
+        if (rc==DS_OK)
+            trace("(the current volume is %ld according to DirectSound)\n",vol);
+        trace("All subsequent tones should be identical to this one.\n");
+        trace("Listen for stutter, changes in pitch, volume, etc.\n");
+        test_buffer(dso,primary,1,FALSE,0,FALSE,0,!(dscaps.dwFlags & DSCAPS_EMULDRIVER),duration,0,0,0,0);
 
         ref=IDirectSoundBuffer_Release(primary);
         ok(ref==0,"IDirectSoundBuffer_Release primary has %d references, should have 0\n",ref);
@@ -847,7 +846,8 @@
             ok(rc==DS_OK && secondary!=NULL,"CreateSoundBuffer failed to create a secondary buffer 0x%lx\n",rc);
 
             if (rc==DS_OK && secondary!=NULL) {
-                test_buffer(dso,secondary,0,FALSE,0,FALSE,0,winetest_interactive,1.0,0,NULL,0,0);
+                double duration=(winetest_interactive?1.0:0.1);
+                test_buffer(dso,secondary,0,FALSE,0,FALSE,0,1,duration,0,NULL,0,0);
 
                 ref=IDirectSoundBuffer_Release(secondary);
                 ok(ref==0,"IDirectSoundBuffer_Release has %d references, should have 0\n",ref);
Index: dlls/dsound/tests/dsound_test.h
===================================================================
RCS file: /var/cvs/wine/dlls/dsound/tests/dsound_test.h,v
retrieving revision 1.2
diff -u -r1.2 dsound_test.h
--- dlls/dsound/tests/dsound_test.h	16 Jul 2004 23:42:32 -0000	1.2
+++ dlls/dsound/tests/dsound_test.h	23 Jul 2004 13:47:30 -0000
@@ -47,7 +47,7 @@
 #define NB_FORMATS (sizeof(formats)/sizeof(*formats))
 
 /* The time slice determines how often we will service the buffer */
-#define TIME_SLICE     31
+#define TIME_SLICE     17
 #define BUFFER_LEN    400
 
 
Index: dlls/winmm/tests/capture.c
===================================================================
RCS file: /var/cvs/wine/dlls/winmm/tests/capture.c,v
retrieving revision 1.6
diff -u -r1.6 capture.c
--- dlls/winmm/tests/capture.c	14 Jun 2004 17:54:45 -0000	1.6
+++ dlls/winmm/tests/capture.c	23 Jul 2004 10:32:48 -0000
@@ -56,6 +56,7 @@
     WORD nChannels = pwfx->nChannels;
     WORD wBitsPerSample = pwfx->wBitsPerSample;
     DWORD nSamplesPerSec = pwfx->nSamplesPerSec;
+    double duration;
 
     hevent=CreateEvent(NULL,FALSE,FALSE,NULL);
     ok(hevent!=NULL,"CreateEvent: error=%ld\n",GetLastError());
@@ -98,8 +103,9 @@
        pwfx->nSamplesPerSec, pwfx->wBitsPerSample,
        pwfx->nChannels, nSamplesPerSec, wBitsPerSample, nChannels);
 
-    frag.lpData=malloc(pwfx->nAvgBytesPerSec);
-    frag.dwBufferLength=pwfx->nAvgBytesPerSec;
+    duration=winetest_interactive?1.0:0.1;
+    frag.dwBufferLength=((DWORD)(duration*pwfx->nSamplesPerSec))*pwfx->nBlockAlign;
+    frag.lpData=malloc(frag.dwBufferLength);
     frag.dwBytesRecorded=0;
     frag.dwUser=0;
     frag.dwFlags=0;
@@ -110,9 +116,10 @@
     ok(rc==MMSYSERR_NOERROR, "waveInPrepareHeader: device=%s rc=%s\n",dev_name(device),wave_in_error(rc));
     ok(frag.dwFlags&WHDR_PREPARED,"waveInPrepareHeader: prepared flag not set\n");
 
-    if (winetest_interactive && rc==MMSYSERR_NOERROR) {
-        trace("Recording for 1 second at %5ldx%2dx%d %s\n",
-              pwfx->nSamplesPerSec, pwfx->wBitsPerSample,pwfx->nChannels,
+    if (rc==MMSYSERR_NOERROR) {
+        trace("Recording for %g second at %5ldx%2dx%d %s\n",
+              duration, pwfx->nSamplesPerSec, pwfx->wBitsPerSample,
+              pwfx->nChannels,
               flags & WAVE_FORMAT_DIRECT ? "WAVE_FORMAT_DIRECT" :
               flags & WAVE_MAPPED ? "WAVE_MAPPED" : "");
         rc=waveInAddBuffer(win, &frag, sizeof(frag));
@@ -121,11 +128,12 @@
         rc=waveInStart(win);
         ok(rc==MMSYSERR_NOERROR,"waveInStart: device=%s rc=%s\n",dev_name(device),wave_in_error(rc));
 
-        res = WaitForSingleObject(hevent,1200);
+        res = WaitForSingleObject(hevent,duration*1200.0);
         ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for header\n");
         ok(frag.dwFlags&WHDR_DONE,"WHDR_DONE not set in frag.dwFlags\n");
-        ok(frag.dwBytesRecorded==pwfx->nAvgBytesPerSec,"frag.dwBytesRecorded=%ld, should=%ld\n",
-           frag.dwBytesRecorded,pwfx->nAvgBytesPerSec);
+        ok(frag.dwBytesRecorded==frag.dwBufferLength,
+           "frag.dwBytesRecorded=%ld, should=%ld\n",
+           frag.dwBytesRecorded,frag.dwBufferLength);
         /* stop playing on error */
         if (res!=WAIT_OBJECT_0) {
             rc=waveInStop(win);
@@ -226,7 +327,7 @@
             wave_in_test_deviceIn(device,&format,win_formats[f][0],WAVE_MAPPED, &caps);
     }
 
-    /* Try a PCMWAVEFORMAT aligned next to an unaccessable page for bounds checking */
+    /* Try a PCMWAVEFORMAT aligned next to an unaccessible page for bounds checking */
     twoPages = VirtualAlloc(NULL, 2 * dwPageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
     ok(twoPages!=NULL,"Failed to allocate 2 pages of memory\n");
     if (twoPages) {
Index: dlls/winmm/tests/wave.c
===================================================================
RCS file: /var/cvs/wine/dlls/winmm/tests/wave.c,v
retrieving revision 1.36
diff -u -r1.36 wave.c
--- dlls/winmm/tests/wave.c	21 Jul 2004 03:23:29 -0000	1.36
+++ dlls/winmm/tests/wave.c	22 Jul 2004 10:46:37 -0000
@@ -75,6 +75,21 @@
     return buf;
 }
 
+static char* wave_generate_silence(WAVEFORMATEX* wfx, double duration, DWORD* size)
+{
+    DWORD nb_samples;
+    char* buf;
+
+    nb_samples=(DWORD)(duration*wfx->nSamplesPerSec);
+    *size=nb_samples*wfx->nBlockAlign;
+    buf=malloc(*size);
+    if (wfx->wBitsPerSample==8)
+        memset(buf,0x80,*size);
+    else
+        memset(buf,0,*size);
+    return buf;
+}
+
 const char * dev_name(int device)
 {
     static char name[16];
@@ -286,6 +302,7 @@
     WORD nChannels = pwfx->nChannels;
     WORD wBitsPerSample = pwfx->wBitsPerSample;
     DWORD nSamplesPerSec = pwfx->nSamplesPerSec;
+    char* wave_desc;
 
     hevent=CreateEvent(NULL,FALSE,FALSE,NULL);
     ok(hevent!=NULL,"CreateEvent: error=%ld\n",GetLastError());
@@ -327,7 +344,16 @@
        pwfx->nSamplesPerSec, pwfx->wBitsPerSample,
        pwfx->nChannels, nSamplesPerSec, wBitsPerSample, nChannels);
 
-    frag.lpData=wave_generate_la(pwfx,duration,&frag.dwBufferLength);
+    if (winetest_interactive)
+    {
+        wave_desc="440Hz tone";
+        frag.lpData=wave_generate_la(pwfx,duration,&frag.dwBufferLength);
+    }
+    else
+    {
+        wave_desc="of silence";
+        frag.lpData=wave_generate_silence(pwfx,duration,&frag.dwBufferLength);
+    }
     frag.dwFlags=0;
     frag.dwLoops=0;
 
@@ -338,32 +364,40 @@
     ok(rc==MMSYSERR_NOERROR,
        "waveOutPrepareHeader: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
 
-    if (winetest_interactive && rc==MMSYSERR_NOERROR) {
+    if (rc==MMSYSERR_NOERROR) {
         DWORD start,end;
-        trace("Playing %g second 440Hz tone at %5ldx%2dx%d %s\n",duration,
+        double tolerance;
+
+        trace("Playing %g second %s at %5ldx%2dx%d %s\n",duration,wave_desc,
               pwfx->nSamplesPerSec, pwfx->wBitsPerSample,pwfx->nChannels,
               flags & WAVE_FORMAT_DIRECT ? "WAVE_FORMAT_DIRECT" :
               flags & WAVE_MAPPED ? "WAVE_MAPPED" : "");
 
         /* Check that the position is 0 at start */
-        check_position(device, wout, 0.0, pwfx);
+        check_position(device, wout, 0, pwfx);
 
-        rc=waveOutSetVolume(wout,0x20002000);
-        ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
-        WaitForSingleObject(hevent,INFINITE);
+        if (winetest_interactive)
+        {
+            rc=waveOutSetVolume(wout,0x20002000);
+            ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
+        }
 
+        WaitForSingleObject(hevent,INFINITE);
         start=GetTickCount();
         rc=waveOutWrite(wout, &frag, sizeof(frag));
         ok(rc==MMSYSERR_NOERROR,"waveOutWrite: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
         WaitForSingleObject(hevent,INFINITE);
 
-        /* Check the sound duration was within 10% of the expected value */
+        /* Check that the tone duration was about right */
         end=GetTickCount();
-        trace("sound duration=%ld\n",end-start);
-        ok(fabs(1000*duration-end+start)<=100*duration,"The sound played for %ld ms instead of %g ms\n",end-start,1000*duration);
+        tolerance=duration<1.0?0.2:0.1;
+        ok(fabs(1000*duration-end+start)<=10.0+tolerance*1000.0*duration,"The sound played for %ld ms instead of %g ms\n",end-start,1000*duration);
 
-        rc=waveOutSetVolume(wout,volume);
-        ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
+        if (winetest_interactive)
+        {
+            rc=waveOutSetVolume(wout,volume);
+            ok(rc==MMSYSERR_NOERROR,"waveOutSetVolume: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
+        }
 
         check_position(device, wout, frag.dwBufferLength, pwfx);
     }
@@ -393,6 +427,7 @@
     BYTE * twoPages;
     SYSTEM_INFO sSysInfo;
     DWORD flOldProtect;
+    double duration;
     BOOL res;
 
     GetSystemInfo(&sSysInfo);
@@ -460,9 +495,10 @@
           capsA.wChannels,capsA.dwFormats,capsA.dwSupport,wave_out_caps(capsA.dwSupport));
     free(nameA);
 
-    if (winetest_interactive && (device != WAVE_MAPPER))
+    duration=winetest_interactive?1.0:0.1;
+    if (device != WAVE_MAPPER)
     {
-        trace("Playing a 5 seconds reference tone.\n");
+        trace("Playing a %g seconds reference tone.\n",5*duration);
         trace("All subsequent tones should be identical to this one.\n");
         trace("Listen for stutter, changes in pitch, volume, etc.\n");
         format.wFormatTag=WAVE_FORMAT_PCM;
@@ -472,7 +508,7 @@
         format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
         format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
         format.cbSize=0;
-        wave_out_test_deviceOut(device,5.0,&format,WAVE_FORMAT_2M08,0,&capsA);
+        wave_out_test_deviceOut(device,5*duration,&format,WAVE_FORMAT_2M08,0,&capsA);
     }
 
     for (f=0;f<NB_WIN_FORMATS;f++) {
@@ -483,13 +519,14 @@
         format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
         format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
         format.cbSize=0;
-        wave_out_test_deviceOut(device,1.0,&format,win_formats[f][0],0,&capsA);
-        wave_out_test_deviceOut(device,1.0,&format,win_formats[f][0],WAVE_FORMAT_DIRECT,&capsA);
+        wave_out_test_deviceOut(device,duration,&format,win_formats[f][0],0,&capsA);
+        wave_out_test_deviceOut(device,duration,&format,win_formats[f][0],0,&capsA);
+        wave_out_test_deviceOut(device,duration,&format,win_formats[f][0],WAVE_FORMAT_DIRECT,&capsA);
         if (device != WAVE_MAPPER)
-            wave_out_test_deviceOut(device,1.0,&format,win_formats[f][0],WAVE_MAPPED,&capsA);
+            wave_out_test_deviceOut(device,duration,&format,win_formats[f][0],WAVE_MAPPED,&capsA);
     }
 
-    /* Try a PCMWAVEFORMAT aligned next to an unaccessable page for bounds checking */
+    /* Try a PCMWAVEFORMAT aligned next to an unaccessible page for bounds checking */
     twoPages = VirtualAlloc(NULL, 2 * dwPageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
     ok(twoPages!=NULL,"Failed to allocate 2 pages of memory\n");
     if (twoPages) {
@@ -503,10 +540,10 @@
             pwfx->nSamplesPerSec=22050;
             pwfx->nBlockAlign=pwfx->nChannels*pwfx->wBitsPerSample/8;
             pwfx->nAvgBytesPerSec=pwfx->nSamplesPerSec*pwfx->nBlockAlign;
-            wave_out_test_deviceOut(device,1.0,pwfx,WAVE_FORMAT_2M08,0,&capsA);
-            wave_out_test_deviceOut(device,1.0,pwfx,WAVE_FORMAT_2M08,WAVE_FORMAT_DIRECT,&capsA);
+            wave_out_test_deviceOut(device,duration,pwfx,WAVE_FORMAT_2M08,0,&capsA);
+            wave_out_test_deviceOut(device,duration,pwfx,WAVE_FORMAT_2M08,WAVE_FORMAT_DIRECT,&capsA);
             if (device != WAVE_MAPPER)
-                wave_out_test_deviceOut(device,1.0,pwfx,WAVE_FORMAT_2M08,WAVE_MAPPED,&capsA);
+                wave_out_test_deviceOut(device,duration,pwfx,WAVE_FORMAT_2M08,WAVE_MAPPED,&capsA);
         }
         VirtualFree(twoPages, 2 * dwPageSize, MEM_RELEASE);
     }


More information about the wine-patches mailing list