Replay recorded sound for control

Francois Gouget fgouget at codeweavers.com
Fri Jul 23 18:35:51 CDT 2004


Currently, when in interactive mode, the winmm capture test records 
sounds. But it never plays what it has recorded so there's no point for 
a human being to be present since there is nothing to verify. I.e. it's 
not very interactive after all.

This patch modifies the test so that after recording our 1 second of 
sound, we replay it for the user to verify that it is correct: i.e. as 
usual check for stutter, pitch, balance, pan, etc.

One more word on testing how to really run this test in interactive 
mode: what do you record?

  * One way is to hook up a microphone to the soundcard, start the test 
and say something while the test is recording and then listen to it 
being played back. That as interactive as you get but it can be a bit 
boring after the first few seconds.
  * So what I'm doing now is configure Alsa to record from the CD player 
without playing back the CD player sound so all I hear is what is played 
by the test program. Because I know the CD I know if the sound is 
correct or not. Also this works with both winealsa and wineoss because 
OSS records from wherever Alsa records from. Here's how I do that:

     # To prevent the CD output from going straight to the speakers
     amixer cset numid=20,iface=MIXER,name='CD Playback Switch' off

     # Set the CD as the capture input
     amixer cset numid=28,iface=MIXER,name='Capture Source' 1

     # Enable sound capture
     amixer cset numid=29,iface=MIXER,name='Capture Switch' on
     amixer cset numid=30,iface=MIXER,name='Capture Volume' 15

    That's for my VIA 8235 / ALC650E sound card. The exact mixer 
settings are probably different on other soundcards but it's probably 
possible to play the same kind of trick.


Changelog:

  * dlls/winmm/tests/capture.c
    dlls/winmm/tests/wave.c
    dlls/winmm/tests/winmm_test.h

    Francois Gouget <fgouget at codeweavers.com>
    Play back what has been recorded when in interactive mode so that 
the user can verify that the recording is correct.

-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
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
@@ -121,6 +128,47 @@
        "waveInClose: device=%s rc=%s\n",dev_name(device),wave_in_error(rc));
     res=WaitForSingleObject(hevent,1000);
     ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for close\n");
+
+    if (winetest_interactive)
+    {
+        /*
+         * Now play back what we recorded
+         */
+        HWAVEOUT wout;
+
+        trace("Playing back recorded sound\n");
+        rc=waveOutOpen(&wout,WAVE_MAPPER,pwfx,(DWORD)hevent,0,CALLBACK_EVENT);
+        ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID ||
+           rc==MMSYSERR_NOTENABLED || rc==MMSYSERR_NODRIVER || rc==MMSYSERR_ALLOCATED ||
+           ((rc==WAVERR_BADFORMAT || rc==MMSYSERR_NOTSUPPORTED) &&
+            !(pcaps->dwFormats & format)),
+           "waveOutOpen: device=%s format=%ldx%2dx%d flags=%lx(%s) rc=%s\n",dev_name(device),
+           pwfx->nSamplesPerSec,pwfx->wBitsPerSample,pwfx->nChannels,CALLBACK_EVENT|flags,
+           wave_open_flags(CALLBACK_EVENT),wave_out_error(rc));
+        if (rc==MMSYSERR_NOERROR)
+        {
+            rc=waveOutPrepareHeader(wout, &frag, sizeof(frag));
+            ok(rc==MMSYSERR_NOERROR,
+               "waveOutPrepareHeader: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
+
+            if (rc==MMSYSERR_NOERROR)
+            {
+                WaitForSingleObject(hevent,INFINITE);
+                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);
+
+                rc=waveOutUnprepareHeader(wout, &frag, sizeof(frag));
+                ok(rc==MMSYSERR_NOERROR,
+                   "waveOutUnprepareHeader: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
+            }
+            rc=waveOutClose(wout);
+            ok(rc==MMSYSERR_NOERROR,"waveOutClose: device=%s rc=%s\n",dev_name(device),wave_out_error(rc));
+        }
+        else
+            trace("Unable to play back the recorded sound\n");
+    }
+
     free(frag.lpData);
     CloseHandle(hevent);
 }
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
@@ -111,7 +126,7 @@
 #undef ERR_TO_STR
 }
 
-static const char * wave_out_error(MMRESULT error)
+const char* wave_out_error(MMRESULT error)
 {
     static char msg[1024];
     static char long_msg[1100];
Index: dlls/winmm/tests/winmm_test.h
===================================================================
RCS file: /var/cvs/wine/dlls/winmm/tests/winmm_test.h,v
retrieving revision 1.4
diff -u -r1.4 winmm_test.h
--- dlls/winmm/tests/winmm_test.h	4 Jun 2004 17:58:00 -0000	1.4
+++ dlls/winmm/tests/winmm_test.h	22 Jul 2004 10:33:30 -0000
@@ -63,3 +65,4 @@
 extern const char* dev_name(int);
 extern const char* wave_open_flags(DWORD);
 extern const char* mmsys_error(MMRESULT);
+extern const char* wave_out_error(MMRESULT);


More information about the wine-patches mailing list