winmm: Defer loading drivers until they are requested.

This commit is contained in:
Maarten Lankhorst 2010-03-31 20:19:35 +02:00 committed by Alexandre Julliard
parent 39208d4d60
commit 4f4dd855c4
3 changed files with 14 additions and 10 deletions

View File

@ -47,7 +47,7 @@ typedef struct tagWINE_LLTYPE {
int nMapper; /* index to mapper */
} WINE_LLTYPE;
static int MMDrvsHi /* = 0 */;
static int drivers_loaded, MMDrvsHi;
static WINE_MM_DRIVER MMDrvs[8];
static LPWINE_MLD MM_MLDrvs[40];
#define MAX_MM_MLDRVS (sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]))
@ -66,6 +66,15 @@ static WINE_LLTYPE llTypes[MMDRV_MAX] = {
};
#undef A
static void MMDRV_Init(void);
static void MMDRV_InitSingleType(UINT type) {
if (!drivers_loaded) {
drivers_loaded = 1;
MMDRV_Init();
}
}
/**************************************************************************
* MMDRV_GetNum [internal]
*/
@ -73,6 +82,7 @@ UINT MMDRV_GetNum(UINT type)
{
TRACE("(%04x)\n", type);
assert(type < MMDRV_MAX);
MMDRV_InitSingleType(type);
return llTypes[type].wMaxId;
}
@ -109,7 +119,6 @@ DWORD MMDRV_Message(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1,
lpDrv = &MMDrvs[mld->mmdIndex];
part = &lpDrv->parts[mld->type];
#if 0
/* some sanity checks */
if (!(part->nIDMin <= devID))
@ -265,6 +274,7 @@ LPWINE_MLD MMDRV_Get(HANDLE _hndl, UINT type, BOOL bCanBeID)
TRACE("(%p, %04x, %c)\n", _hndl, type, bCanBeID ? 'Y' : 'N');
assert(type < MMDRV_MAX);
MMDRV_InitSingleType(type);
if (hndl >= llTypes[type].wMaxId &&
hndl != (UINT16)-1 && hndl != (UINT)-1) {
@ -528,7 +538,7 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper)
/**************************************************************************
* MMDRV_Init
*/
BOOL MMDRV_Init(void)
static void MMDRV_Init(void)
{
HKEY hKey;
char driver_buffer[256];
@ -564,7 +574,6 @@ BOOL MMDRV_Init(void)
ret |= MMDRV_Install("wavemapper", WINE_DEFAULT_WINMM_MAPPER, TRUE);
ret |= MMDRV_Install("midimapper", WINE_DEFAULT_WINMM_MIDI, TRUE);
return ret;
}
/******************************************************************

View File

@ -137,7 +137,6 @@ BOOL DRIVER_GetLibName(LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz);
LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2);
void DRIVER_UnloadAll(void);
BOOL MMDRV_Init(void);
void MMDRV_Exit(void);
UINT MMDRV_GetNum(UINT);
LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,

View File

@ -155,10 +155,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
if (!WINMM_CreateIData(hInstDLL))
return FALSE;
if (!MMDRV_Init()) {
WINMM_DeleteIData();
return FALSE;
}
break;
case DLL_PROCESS_DETACH:
/* close all opened MCI drivers */