From 40df53aae273b47bf4b7db5d2d80664b2ea6fbfe Mon Sep 17 00:00:00 2001 From: Jeremy White Date: Thu, 17 Mar 2005 10:25:25 +0000 Subject: [PATCH] Do not fallback to defaults if a driver, mapper, or midi is specified in the registry; consolidate MMDRV_Init() into a single function. --- dlls/winmm/lolvldrv.c | 83 +++++++++++++++++-------------------------- dlls/winmm/winemm.h | 4 +++ 2 files changed, 36 insertions(+), 51 deletions(-) diff --git a/dlls/winmm/lolvldrv.c b/dlls/winmm/lolvldrv.c index 2c926b328e2..24bdd7c491a 100644 --- a/dlls/winmm/lolvldrv.c +++ b/dlls/winmm/lolvldrv.c @@ -715,73 +715,54 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper) } /************************************************************************** - * MMDRV_InitFromRegistry [internal] + * MMDRV_Init */ -static BOOL MMDRV_InitFromRegistry(void) +BOOL MMDRV_Init(void) { HKEY hKey; - char buffer[256]; + char driver_buffer[256]; + char mapper_buffer[256]; + char midi_buffer[256]; char* p1; char* p2; DWORD type, size; BOOL ret = FALSE; TRACE("()\n"); - if (RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\WinMM", &hKey)) { - TRACE("Cannot open WinMM config key\n"); - return FALSE; + strcpy(driver_buffer, WINE_DEFAULT_WINMM_DRIVER); + strcpy(mapper_buffer, WINE_DEFAULT_WINMM_MAPPER); + strcpy(midi_buffer, WINE_DEFAULT_WINMM_MIDI); + + if (! RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\WinMM", &hKey)) { + size = sizeof(driver_buffer); + if (RegQueryValueExA(hKey, "Drivers", 0, &type, (LPVOID)driver_buffer, &size)) + strcpy(driver_buffer, WINE_DEFAULT_WINMM_DRIVER); + + /* finish with mappers */ + size = sizeof(mapper_buffer); + if (RegQueryValueExA(hKey, "WaveMapper", 0, &type, (LPVOID)mapper_buffer, &size)) + strcpy(mapper_buffer, WINE_DEFAULT_WINMM_MAPPER); + + size = sizeof(midi_buffer); + if (RegQueryValueExA(hKey, "MidiMapper", 0, &type, (LPVOID)midi_buffer, &size)) + strcpy(midi_buffer, WINE_DEFAULT_WINMM_MIDI); + + RegCloseKey(hKey); } - size = sizeof(buffer); - if (!RegQueryValueExA(hKey, "Drivers", 0, &type, (LPVOID)buffer, &size)) { - p1 = buffer; - while (p1) { - p2 = strchr(p1, ';'); - if (p2) *p2++ = '\0'; - ret |= MMDRV_Install(p1, p1, FALSE); - p1 = p2; - } + p1 = driver_buffer; + while (p1) { + p2 = strchr(p1, ';'); + if (p2) *p2++ = '\0'; + ret |= MMDRV_Install(p1, p1, FALSE); + p1 = p2; } - /* finish with mappers */ - size = sizeof(buffer); - if (!RegQueryValueExA(hKey, "WaveMapper", 0, &type, (LPVOID)buffer, &size)) - ret |= MMDRV_Install("wavemapper", buffer, TRUE); - size = sizeof(buffer); - if (!RegQueryValueExA(hKey, "MidiMapper", 0, &type, (LPVOID)buffer, &size)) - ret |= MMDRV_Install("midimapper", buffer, TRUE); - - RegCloseKey(hKey); - + ret |= MMDRV_Install("wavemapper", mapper_buffer, TRUE); + ret |= MMDRV_Install("midimapper", midi_buffer, TRUE); return ret; } -/************************************************************************** - * MMDRV_InitHardcoded [internal] - */ -static BOOL MMDRV_InitHardcoded(void) -{ - TRACE("()\n"); - /* first load hardware drivers */ - MMDRV_Install("wineoss.drv", "wineoss.drv", FALSE); - - /* finish with mappers */ - MMDRV_Install("wavemapper", "msacm.drv", TRUE); - MMDRV_Install("midimapper", "midimap.drv", TRUE); - - return TRUE; -} - -/************************************************************************** - * MMDRV_Init [internal] - */ -BOOL MMDRV_Init(void) -{ - TRACE("()\n"); - /* FIXME: MMDRV_InitFromRegistry shall be MMDRV_Init in a near future */ - return MMDRV_InitFromRegistry() || MMDRV_InitHardcoded(); -} - /****************************************************************** * ExitPerType * diff --git a/dlls/winmm/winemm.h b/dlls/winmm/winemm.h index a558c76b7ba..72b78d7f1f2 100644 --- a/dlls/winmm/winemm.h +++ b/dlls/winmm/winemm.h @@ -28,6 +28,10 @@ #include "winbase.h" #include "mmddk.h" +#define WINE_DEFAULT_WINMM_DRIVER "wineoss.drv" +#define WINE_DEFAULT_WINMM_MAPPER "msacm.drv" +#define WINE_DEFAULT_WINMM_MIDI "midimap.drv" + typedef DWORD (WINAPI *MessageProc16)(UINT16 wDevID, UINT16 wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2); typedef DWORD (WINAPI *MessageProc32)(UINT wDevID, UINT wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2);