winmm/tests: Don't test the non-default Midi devices if the 'PreferredOnly' Windows setting is set.

Francois Gouget fgouget at free.fr
Mon Oct 4 11:19:56 CDT 2010


---

This patch is really from Paul Vriens (but I hesitate to fake the 
email's From address which probably means Git will think I wrote it).


So here's the situation:

 * The winmm:midi tests get stuck on my Windows XP VM due to VMware not 
   emulating the Midi hardware.

 * I tried disabling the AudioPCI Midi device as decribed in this email 
   but to no avail (I also find hacking inf files behing XP's back quite 
   ugly).
   http://www.winehq.org/pipermail/wine-devel/2010-March/082116.html

 * There's also Windows' Midi synthesizer device which is the default. 
   So the patch below would let me just flip a switch in XP so the tests 
   skip the broken AudioPCI Midi device. Is that ok?


 dlls/winmm/tests/Makefile.in |    2 +-
 dlls/winmm/tests/midi.c      |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/dlls/winmm/tests/Makefile.in b/dlls/winmm/tests/Makefile.in
index 4a74bdf..31c854f 100644
--- a/dlls/winmm/tests/Makefile.in
+++ b/dlls/winmm/tests/Makefile.in
@@ -1,5 +1,5 @@
 TESTDLL   = winmm.dll
-IMPORTS   = winmm user32
+IMPORTS   = winmm advapi32 user32
 
 C_SRCS = \
 	capture.c \
diff --git a/dlls/winmm/tests/midi.c b/dlls/winmm/tests/midi.c
index 972899e..5d1f39d 100644
--- a/dlls/winmm/tests/midi.c
+++ b/dlls/winmm/tests/midi.c
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <stddef.h>
 #include "windows.h"
+#include "winreg.h"
 #include "mmsystem.h"
 #include "wine/test.h"
 
@@ -201,6 +202,39 @@ static void test_midi_mci(HWND hwnd)
     if (!err) trace("Found %s MCI sequencer devices\n", buf);
 }
 
+static BOOL skip_device(UINT udev)
+{
+    MMRESULT rc;
+    MIDIOUTCAPSA capsA;
+    HKEY hkey;
+    LONG ret;
+
+    rc = midiOutGetDevCapsA(udev, &capsA, sizeof(capsA));
+
+    /* Skip the tests if the user told us to only use the default device */
+    ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\MultiMedia\\Sound Mapper", &hkey);
+    if (ret == ERROR_SUCCESS) {
+        DWORD pref = 0;
+        DWORD size = sizeof(DWORD);
+        RegQueryValueExA(hkey, "PreferredOnly", NULL, NULL, (LPBYTE)&pref, &size);
+        RegCloseKey(hkey);
+        if (pref == 1) {
+            ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Multimedia\\MIDIMap", &hkey);
+            if (ret == ERROR_SUCCESS) {
+                char name[MAX_PATH];
+                name[0] = 0;
+                size = MAX_PATH;
+                RegQueryValueExA(hkey, "szPname", NULL, NULL, (LPBYTE)name, &size);
+                RegCloseKey(hkey);
+                if (lstrcmpA(name, capsA.szPname)) {
+                    win_skip("'%s' is not the preferred device\n", capsA.szPname);
+                    return TRUE;
+                }
+            }
+        }
+    }
+    return FALSE;
+}
 
 static void test_midiOut_device(UINT udev, HWND hwnd)
 {
@@ -224,6 +258,10 @@ static void test_midiOut_device(UINT udev, HWND hwnd)
         }
     }
 
+    if (udev != MIDIMAPPER && skip_device(udev)) {
+        return;
+    }
+
     if (hwnd)
         rc = midiOutOpen(&hm, udev, (DWORD_PTR)hwnd, (DWORD_PTR)MYCBINST, CALLBACK_WINDOW);
     else
@@ -385,6 +423,10 @@ static void test_midiStream(UINT udev, HWND hwnd)
         MIDIPROPTIMEDIV tdiv;
     } midiprop;
 
+    if (udev != MIDIMAPPER && skip_device(udev)) {
+        return;
+    }
+
     if (hwnd)
         rc = midiStreamOpen(&hm, &udev, 1, (DWORD_PTR)hwnd, (DWORD_PTR)MYCBINST, CALLBACK_WINDOW);
     else
-- 
1.7.1



More information about the wine-patches mailing list