James Hawkins wrote:
Changelog: * take audio autodetection out of winecfg and put it in winmm * if driver is not found in the registry or the driver fails to load, then autodetect driver
Thanks for another cool patch. It lessens the burden on the user. CC'ing ros-kernel as explained below.
Index: dlls/winmm/lolvldrv.c =================================================================== RCS file: /home/wine/wine/dlls/winmm/lolvldrv.c,v retrieving revision 1.58 diff -u -r1.58 lolvldrv.c --- dlls/winmm/lolvldrv.c 1 Jun 2004 19:40:48 -0000 1.58 +++ dlls/winmm/lolvldrv.c 25 Jul 2004 22:05:54 -0000 @@ -30,6 +30,8 @@ #include "winver.h" #include "winemm.h" #include "wine/debug.h" +#include "config.h" +#include "wine/port.h"
WINE_DEFAULT_DEBUG_CHANNEL(winmm);
@@ -711,6 +713,80 @@ }
/************************************************************************** + * MMDRV_AutoDetectDriver [internal] + * + * modified from programs/winecfg/audio.c + */ +BOOL MMDRV_AutoDetectDriver(void) +{ + struct stat buf; + const char *argv_new[4]; + int fd; + + char *driversFound[10]; + char *name[10]; + int numFound = 0; + + argv_new[0] = "/bin/sh";
I think the ReactOS people may have a few comments to make on this, now that they are using this DLL in ReactOS.
+ argv_new[1] = "-c"; + argv_new[3] = NULL; + + /* try to detect arts */ + argv_new[2] = "ps awx|grep artsd|grep -v grep|grep artsd > /dev/null"; + if(!spawnvp(_P_WAIT, "/bin/sh", argv_new)) + { + driversFound[numFound] = "winearts.drv"; + name[numFound] = "aRts"; + numFound++; + } + + /* try to detect jack */ + argv_new[2] = "ps awx|grep jackd|grep -v grep|grep jackd > /dev/null"; + if(!spawnvp(_P_WAIT, "/bin/sh", argv_new)) + { + driversFound[numFound] = "winejack.drv"; + name[numFound] = "jack"; + numFound++; + } + + /* try to detect nas */ + /* TODO */ + + /* try to detect audioIO (solaris) */ + /* TODO */ + + /* try to detect alsa */ + if(!stat("/proc/asound", &buf)) + { + driversFound[numFound] = "winealsa.drv"; + name[numFound] = "Alsa"; + numFound++; + } + + /* try to detect oss */ + fd = open("/dev/dsp", O_WRONLY | O_NONBLOCK); + if(fd) + { + close(fd); + driversFound[numFound] = "wineoss.drv"; + name[numFound] = "OSS"; + numFound++; + } + + + if (numFound == 0) + { + TRACE("Could not detect any audio devices/servers"); + return FALSE; + } + + /* TODO: possibly smarter handling of multiple drivers? */ + TRACE("Found driver %s\n", name[0]); + + return MMDRV_Install(driversFound[0], driversFound[0], FALSE); +} + +/************************************************************************** * MMDRV_InitFromRegistry [internal] */ static BOOL MMDRV_InitFromRegistry(void) @@ -729,7 +805,9 @@ }
size = sizeof(buffer); - if (!RegQueryValueExA(hKey, "Drivers", 0, &type, (LPVOID)buffer, &size)) { + BOOL keyQueried = !RegQueryValueExA(hKey, "Drivers", 0, &type, + (LPVOID)buffer, &size);
This is only available in C99. We try to make Wine compile with as many C compilers as possible, including gcc 2.95, which doesn't allow this sort of thing.
+ if (keyQueried) { p1 = buffer; while (p1) { p2 = strchr(p1, ';'); @@ -738,7 +816,11 @@ p1 = p2; } } - + + /* if no driver specified in reg or driver fails to load then autodetect */ + if (!keyQueried || !ret) + ret |= MMDRV_AutoDetectDriver(); + /* finish with mappers */ size = sizeof(buffer); if (!RegQueryValueExA(hKey, "WaveMapper", 0, &type, (LPVOID)buffer, &size))
Rob