From ca1a7c6badb8cd8eea67cbeedde0ebae48fda5e9 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Thu, 22 Oct 2009 22:11:15 +0200 Subject: [PATCH] winmm: Get rid of 16bit driver support. --- dlls/winmm/driver.c | 135 ++--- dlls/winmm/lolvldrv.c | 141 +---- dlls/winmm/message16.c | 1168 ---------------------------------------- dlls/winmm/mmsystem.c | 258 --------- dlls/winmm/winemm.h | 47 +- 5 files changed, 78 insertions(+), 1671 deletions(-) diff --git a/dlls/winmm/driver.c b/dlls/winmm/driver.c index 58afcba69c0..48152abaf17 100644 --- a/dlls/winmm/driver.c +++ b/dlls/winmm/driver.c @@ -53,10 +53,6 @@ static LPWINE_DRIVER lpDrvItemList /* = NULL */; static const WCHAR HKLM_BASE[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\', 'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',0}; -LPWINE_DRIVER (*pFnOpenDriver16)(LPCWSTR,LPCWSTR,LPARAM) /* = NULL */; -LRESULT (*pFnCloseDriver16)(UINT16,LPARAM,LPARAM) /* = NULL */; -LRESULT (*pFnSendMessage16)(UINT16,UINT,LPARAM,LPARAM) /* = NULL */; - static void DRIVER_Dump(const char *comment) { #if 0 @@ -90,7 +86,7 @@ static unsigned DRIVER_GetNumberOfModuleRefs(HMODULE hModule, WINE_DRIVER** foun if (found) *found = NULL; for (lpDrv = lpDrvItemList; lpDrv; lpDrv = lpDrv->lpNextItem) { - if (!(lpDrv->dwFlags & WINE_GDF_16BIT) && lpDrv->d.d32.hModule == hModule) + if (lpDrv->hModule == hModule) { if (found && !*found) *found = lpDrv; count++; @@ -121,7 +117,7 @@ LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr) } __ENDTRY; - if (d) TRACE("%p -> %p, %p\n", hDrvr, d->d.d32.lpDrvProc, (void *)d->d.d32.dwDriverID); + if (d) TRACE("%p -> %p, %p\n", hDrvr, d->lpDrvProc, (void *)d->dwDriverID); else TRACE("%p -> NULL\n", hDrvr); return d; @@ -135,18 +131,12 @@ static inline LRESULT DRIVER_SendMessage(LPWINE_DRIVER lpDrv, UINT msg, { LRESULT ret = 0; - if (lpDrv->dwFlags & WINE_GDF_16BIT) { - /* no need to check mmsystem presence: the driver must have been opened as a 16 bit one, - */ - if (pFnSendMessage16) - ret = pFnSendMessage16(lpDrv->d.d16.hDriver16, msg, lParam1, lParam2); - } else { - TRACE("Before call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx\n", - lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, lpDrv, msg, lParam1, lParam2); - ret = lpDrv->d.d32.lpDrvProc(lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2); - TRACE("After call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx => %08lx\n", - lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, lpDrv, msg, lParam1, lParam2, ret); - } + TRACE("Before call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx\n", + lpDrv->lpDrvProc, lpDrv->dwDriverID, lpDrv, msg, lParam1, lParam2); + ret = lpDrv->lpDrvProc(lpDrv->dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2); + TRACE("After call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx => %08lx\n", + lpDrv->lpDrvProc, lpDrv->dwDriverID, lpDrv, msg, lParam1, lParam2, ret); + return ret; } @@ -180,12 +170,10 @@ LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LPARAM lParam1, */ static BOOL DRIVER_RemoveFromList(LPWINE_DRIVER lpDrv) { - if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) { - /* last of this driver in list ? */ - if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, NULL) == 1) { - DRIVER_SendMessage(lpDrv, DRV_DISABLE, 0L, 0L); - DRIVER_SendMessage(lpDrv, DRV_FREE, 0L, 0L); - } + /* last of this driver in list ? */ + if (DRIVER_GetNumberOfModuleRefs(lpDrv->hModule, NULL) == 1) { + DRIVER_SendMessage(lpDrv, DRV_DISABLE, 0L, 0L); + DRIVER_SendMessage(lpDrv, DRV_FREE, 0L, 0L); } EnterCriticalSection( &mmdriver_lock ); @@ -198,9 +186,8 @@ static BOOL DRIVER_RemoveFromList(LPWINE_DRIVER lpDrv) lpDrv->lpNextItem->lpPrevItem = lpDrv->lpPrevItem; /* trash magic number */ lpDrv->dwMagic ^= 0xa5a5a5a5; - lpDrv->d.d32.lpDrvProc = NULL; - lpDrv->d.d32.dwDriverID = 0; - lpDrv->d.d16.hDriver16 = 0; + lpDrv->lpDrvProc = NULL; + lpDrv->dwDriverID = 0; LeaveCriticalSection( &mmdriver_lock ); @@ -217,25 +204,23 @@ static BOOL DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lPar { lpNewDrv->dwMagic = WINE_DI_MAGIC; /* First driver to be loaded for this module, need to load correctly the module */ - if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) { - /* first of this driver in list ? */ - if (DRIVER_GetNumberOfModuleRefs(lpNewDrv->d.d32.hModule, NULL) == 0) { - if (DRIVER_SendMessage(lpNewDrv, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) { - TRACE("DRV_LOAD failed on driver %p\n", lpNewDrv); - return FALSE; - } - /* returned value is not checked */ - DRIVER_SendMessage(lpNewDrv, DRV_ENABLE, 0L, 0L); - } + /* first of this driver in list ? */ + if (DRIVER_GetNumberOfModuleRefs(lpNewDrv->hModule, NULL) == 0) { + if (DRIVER_SendMessage(lpNewDrv, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) { + TRACE("DRV_LOAD failed on driver %p\n", lpNewDrv); + return FALSE; + } + /* returned value is not checked */ + DRIVER_SendMessage(lpNewDrv, DRV_ENABLE, 0L, 0L); + } - /* Now just open a new instance of a driver on this module */ - lpNewDrv->d.d32.dwDriverID = DRIVER_SendMessage(lpNewDrv, DRV_OPEN, lParam1, lParam2); + /* Now just open a new instance of a driver on this module */ + lpNewDrv->dwDriverID = DRIVER_SendMessage(lpNewDrv, DRV_OPEN, lParam1, lParam2); - if (lpNewDrv->d.d32.dwDriverID == 0) - { - TRACE("DRV_OPEN failed on driver %p\n", lpNewDrv); - return FALSE; - } + if (lpNewDrv->dwDriverID == 0) + { + TRACE("DRV_OPEN failed on driver %p\n", lpNewDrv); + return FALSE; } EnterCriticalSection( &mmdriver_lock ); @@ -313,18 +298,18 @@ LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2) if ((hModule = LoadLibraryW(fn)) == 0) {cause = "Not a 32 bit lib"; goto exit;} - lpDrv->d.d32.lpDrvProc = (DRIVERPROC)GetProcAddress(hModule, "DriverProc"); - if (lpDrv->d.d32.lpDrvProc == NULL) {cause = "no DriverProc"; goto exit;} + lpDrv->lpDrvProc = (DRIVERPROC)GetProcAddress(hModule, "DriverProc"); + if (lpDrv->lpDrvProc == NULL) {cause = "no DriverProc"; goto exit;} - lpDrv->dwFlags = 0; - lpDrv->d.d32.hModule = hModule; - lpDrv->d.d32.dwDriverID = 0; + lpDrv->dwFlags = 0; + lpDrv->hModule = hModule; + lpDrv->dwDriverID = 0; /* Win32 installable drivers must support a two phase opening scheme: * + first open with NULL as lParam2 (session instance), * + then do a second open with the real non null lParam2) */ - if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, NULL) == 0 && lParam2) + if (DRIVER_GetNumberOfModuleRefs(lpDrv->hModule, NULL) == 0 && lParam2) { LPWINE_DRIVER ret; @@ -421,17 +406,6 @@ HDRVR WINAPI OpenDriver(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lPar (lpDrv = DRIVER_TryOpenDriver32(libName, lParam))) goto the_end; - /* now we will try a 16 bit driver (and add all the glue to make it work... which - * is located in our mmsystem implementation) - * so ensure, we can load our mmsystem, otherwise just fail - */ - WINMM_CheckForMMSystem(); - if (pFnOpenDriver16 && - (lpDrv = pFnOpenDriver16(lpDriverName, lpSectionName, lParam))) - { - if (DRIVER_AddToList(lpDrv, 0, lParam)) goto the_end; - HeapFree(GetProcessHeap(), 0, lpDrv); - } TRACE("Failed to open driver %s from system.ini file, section %s\n", debugstr_w(lpDriverName), debugstr_w(lpSectionName)); @@ -458,33 +432,25 @@ LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2) if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) { - if (lpDrv->dwFlags & WINE_GDF_16BIT) - { - if (pFnCloseDriver16) - pFnCloseDriver16(lpDrv->d.d16.hDriver16, lParam1, lParam2); - } - else - DRIVER_SendMessage(lpDrv, DRV_CLOSE, lParam1, lParam2); + LPWINE_DRIVER lpDrv0; + + DRIVER_SendMessage(lpDrv, DRV_CLOSE, lParam1, lParam2); DRIVER_RemoveFromList(lpDrv); - if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) + if (lpDrv->dwFlags & WINE_GDF_SESSION) + FIXME("WINE_GDF_SESSION: Shouldn't happen (%p)\n", lpDrv); + /* if driver has an opened session instance, we have to close it too */ + if (DRIVER_GetNumberOfModuleRefs(lpDrv->hModule, &lpDrv0) == 1 && + (lpDrv0->dwFlags & WINE_GDF_SESSION)) { - LPWINE_DRIVER lpDrv0; - - if (lpDrv->dwFlags & WINE_GDF_SESSION) - FIXME("WINE_GDF_SESSION: Shouldn't happen (%p)\n", lpDrv); - /* if driver has an opened session instance, we have to close it too */ - if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, &lpDrv0) == 1 && - (lpDrv0->dwFlags & WINE_GDF_SESSION)) - { - DRIVER_SendMessage(lpDrv0, DRV_CLOSE, 0, 0); - DRIVER_RemoveFromList(lpDrv0); - FreeLibrary(lpDrv0->d.d32.hModule); - HeapFree(GetProcessHeap(), 0, lpDrv0); - } - FreeLibrary(lpDrv->d.d32.hModule); + DRIVER_SendMessage(lpDrv0, DRV_CLOSE, 0, 0); + DRIVER_RemoveFromList(lpDrv0); + FreeLibrary(lpDrv0->hModule); + HeapFree(GetProcessHeap(), 0, lpDrv0); } + FreeLibrary(lpDrv->hModule); + HeapFree(GetProcessHeap(), 0, lpDrv); ret = TRUE; } @@ -537,8 +503,7 @@ HMODULE WINAPI GetDriverModuleHandle(HDRVR hDrvr) TRACE("(%p);\n", hDrvr); if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) { - if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) - hModule = lpDrv->d.d32.hModule; + hModule = lpDrv->hModule; } TRACE("=> %p\n", hModule); return hModule; diff --git a/dlls/winmm/lolvldrv.c b/dlls/winmm/lolvldrv.c index ae95c910551..1c5e06b8b01 100644 --- a/dlls/winmm/lolvldrv.c +++ b/dlls/winmm/lolvldrv.c @@ -36,17 +36,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(winmm); -LRESULT (*pFnCallMMDrvFunc16)(DWORD,WORD,WORD,LONG,LONG,LONG) /* = NULL */; -unsigned (*pFnLoadMMDrvFunc16)(LPCSTR,LPWINE_DRIVER, LPWINE_MM_DRIVER) /* = NULL */; - /* each known type of driver has an instance of this structure */ typedef struct tagWINE_LLTYPE { /* those attributes depend on the specification of the type */ LPCSTR typestr; /* name (for debugging) */ BOOL bSupportMapper; /* if type is allowed to support mapper */ - MMDRV_MAPFUNC Map32WTo16; /* when hi-func (in mmsystem or winmm) and */ - MMDRV_UNMAPFUNC UnMap32WTo16; /* low-func (in .drv) do not match */ - LPDRVCALLBACK Callback; /* handles callback for a specified type */ /* those attributes reflect the loaded/current situation for the type */ UINT wMaxId; /* number of loaded devices (sum across all loaded drivers) */ LPWINE_MLD lpMlds; /* "static" mlds to access the part though device IDs */ @@ -58,7 +52,7 @@ static WINE_MM_DRIVER MMDrvs[8]; static LPWINE_MLD MM_MLDrvs[40]; #define MAX_MM_MLDRVS (sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) -#define A(_x,_y) {#_y, _x, NULL, NULL, NULL, 0, NULL, -1} +#define A(_x,_y) {#_y, _x, 0, NULL, -1} /* Note: the indices of this array must match the definitions * of the MMDRV_???? manifest constants */ @@ -72,31 +66,6 @@ static WINE_LLTYPE llTypes[MMDRV_MAX] = { }; #undef A -/****************************************************************** - * MMDRV_InstallMap - * - * - */ -void MMDRV_InstallMap(unsigned int drv, - MMDRV_MAPFUNC mp3216, MMDRV_UNMAPFUNC um3216, - LPDRVCALLBACK cb) -{ - assert(drv < MMDRV_MAX); - llTypes[drv].Map32WTo16 = mp3216; - llTypes[drv].UnMap32WTo16 = um3216; - llTypes[drv].Callback = cb; -} - -/****************************************************************** - * MMDRV_Is32 - * - */ -BOOL MMDRV_Is32(unsigned int idx) -{ - TRACE("(%d)\n", idx); - return MMDrvs[idx].bIs32; -} - /************************************************************************** * MMDRV_GetNum [internal] */ @@ -117,7 +86,6 @@ DWORD MMDRV_Message(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD ret; WINE_MM_DRIVER_PART* part; WINE_LLTYPE* llType = &llTypes[mld->type]; - WINMM_MapType map; int devID; TRACE("(%s %u %u 0x%08lx 0x%08lx 0x%08lx)\n", @@ -150,41 +118,13 @@ DWORD MMDRV_Message(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, ERR("!(devID(%d) < part->nIDMax(%d))\n", devID, part->nIDMax); #endif - if (lpDrv->bIs32) { - assert(part->u.fnMessage32); + assert(part->fnMessage32); - TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx)\n", - mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - ret = part->u.fnMessage32(mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - TRACE("=> %s\n", WINMM_ErrorToString(ret)); - } else { - assert(part->u.fnMessage16 && pFnCallMMDrvFunc16); + TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx)\n", + mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); + ret = part->fnMessage32(mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); + TRACE("=> %s\n", WINMM_ErrorToString(ret)); - map = llType->Map32WTo16(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); - switch (map) { - case WINMM_MAP_NOMEM: - ret = MMSYSERR_NOMEM; - break; - case WINMM_MAP_MSGERROR: - FIXME("NIY: no conversion yet 32->16 (%u)\n", wMsg); - ret = MMSYSERR_ERROR; - break; - case WINMM_MAP_OK: - case WINMM_MAP_OKMEM: - TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx)\n", - mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - ret = pFnCallMMDrvFunc16((DWORD)part->u.fnMessage16, mld->uDeviceID, wMsg, - mld->dwDriverInstance, dwParam1, dwParam2); - TRACE("=> %s\n", WINMM_ErrorToString(ret)); - if (map == WINMM_MAP_OKMEM) - llType->UnMap32WTo16(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2, ret); - break; - default: - FIXME("NIY\n"); - ret = MMSYSERR_NOTSUPPORTED; - break; - } - } return ret; } @@ -227,13 +167,6 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags, mld->dwCallback = *dwCallback; mld->dwClientInstance = *dwInstance; - if (llTypes[type].Callback) - { - *dwFlags = LOWORD(*dwFlags) | CALLBACK_FUNCTION; - *dwCallback = (DWORD_PTR)llTypes[type].Callback; - *dwInstance = (DWORD_PTR)mld; /* FIXME: wouldn't some 16 bit drivers only use the loword ? */ - } - return mld; } @@ -442,29 +375,16 @@ static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg) /* for DRVM_INIT and DRVM_ENABLE, dwParam2 should be PnP node */ /* the DRVM_ENABLE is only required when the PnP node is non zero */ - - if (lpDrv->bIs32 && part->u.fnMessage32) { - ret = part->u.fnMessage32(0, DRVM_INIT, 0L, 0L, 0L); - TRACE("DRVM_INIT => %s\n", WINMM_ErrorToString(ret)); + if (part->fnMessage32) { + ret = part->fnMessage32(0, DRVM_INIT, 0L, 0L, 0L); + TRACE("DRVM_INIT => %s\n", WINMM_ErrorToString(ret)); #if 0 - ret = part->u.fnMessage32(0, DRVM_ENABLE, 0L, 0L, 0L); - TRACE("DRVM_ENABLE => %08lx\n", ret); + ret = part->fnMessage32(0, DRVM_ENABLE, 0L, 0L, 0L); + TRACE("DRVM_ENABLE => %08lx\n", ret); #endif - count = part->u.fnMessage32(0, wMsg, 0L, 0L, 0L); - } else if (!lpDrv->bIs32 && part->u.fnMessage16 && pFnCallMMDrvFunc16) { - ret = pFnCallMMDrvFunc16((DWORD)part->u.fnMessage16, - 0, DRVM_INIT, 0L, 0L, 0L); - TRACE("DRVM_INIT => %s\n", WINMM_ErrorToString(ret)); -#if 0 - ret = pFnCallMMDrvFunc16((DWORD)part->u.fnMessage16, - 0, DRVM_ENABLE, 0L, 0L, 0L); - TRACE("DRVM_ENABLE => %08lx\n", ret); -#endif - count = pFnCallMMDrvFunc16((DWORD)part->u.fnMessage16, - 0, wMsg, 0L, 0L, 0L); - } else { - return FALSE; + count = part->fnMessage32(0, wMsg, 0L, 0L, 0L); } + else return FALSE; TRACE("Got %u dev for (%s:%s)\n", count, lpDrv->drvname, llTypes[type].typestr); @@ -529,6 +449,7 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper) int i, count = 0; LPWINE_MM_DRIVER lpDrv = &MMDrvs[MMDrvsHi]; LPWINE_DRIVER d; + WINEMM_msgFunc32 func; TRACE("('%s', '%s', mapper=%c);\n", drvRegName, drvFileName, bIsMapper ? 'Y' : 'N'); @@ -550,20 +471,16 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper) } d = DRIVER_FindFromHDrvr(lpDrv->hDriver); - lpDrv->bIs32 = (d->dwFlags & WINE_GDF_16BIT) ? FALSE : TRUE; /* Then look for xxxMessage functions */ #define AA(_h,_w,_x,_y,_z) \ func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \ if (func != NULL) \ - { lpDrv->parts[_w].u.fnMessage##_y = func; count++; \ + { lpDrv->parts[_w].fnMessage##_y = func; count++; \ TRACE("Got %d bit func '%s'\n", _y, #_x); } - if (lpDrv->bIs32) { - WINEMM_msgFunc32 func; - - if (d->d.d32.hModule) { -#define A(_x,_y) AA(d->d.d32.hModule,_x,_y,32,GetProcAddress) + if (d->hModule) { +#define A(_x,_y) AA(d->hModule,_x,_y,32,GetProcAddress) A(MMDRV_AUX, auxMessage); A(MMDRV_MIXER, mxdMessage); A(MMDRV_MIDIIN, midMessage); @@ -571,9 +488,6 @@ static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper) A(MMDRV_WAVEIN, widMessage); A(MMDRV_WAVEOUT, wodMessage); #undef A - } - } else if (WINMM_CheckForMMSystem() && pFnLoadMMDrvFunc16) { - count += pFnLoadMMDrvFunc16(drvFileName, d, lpDrv); } #undef AA @@ -664,24 +578,13 @@ static BOOL MMDRV_ExitPerType(LPWINE_MM_DRIVER lpDrv, UINT type) DWORD ret; TRACE("(%p, %04x)\n", lpDrv, type); - if (lpDrv->bIs32 && part->u.fnMessage32) { + if (part->fnMessage32) { #if 0 - ret = part->u.fnMessage32(0, DRVM_DISABLE, 0L, 0L, 0L); - TRACE("DRVM_DISABLE => %08lx\n", ret); + ret = part->fnMessage32(0, DRVM_DISABLE, 0L, 0L, 0L); + TRACE("DRVM_DISABLE => %08lx\n", ret); #endif - ret = part->u.fnMessage32(0, DRVM_EXIT, 0L, 0L, 0L); - TRACE("DRVM_EXIT => %s\n", WINMM_ErrorToString(ret)); - } else if (!lpDrv->bIs32 && part->u.fnMessage16 && pFnCallMMDrvFunc16) { -#if 0 - ret = pFnCallMMDrvFunc16((DWORD)part->u.fnMessage16, - 0, DRVM_DISABLE, 0L, 0L, 0L); - TRACE("DRVM_DISABLE => %08lx\n", ret); -#endif - ret = pFnCallMMDrvFunc16((DWORD)part->u.fnMessage16, - 0, DRVM_EXIT, 0L, 0L, 0L); - TRACE("DRVM_EXIT => %s\n", WINMM_ErrorToString(ret)); - } else { - return FALSE; + ret = part->fnMessage32(0, DRVM_EXIT, 0L, 0L, 0L); + TRACE("DRVM_EXIT => %s\n", WINMM_ErrorToString(ret)); } return TRUE; diff --git a/dlls/winmm/message16.c b/dlls/winmm/message16.c index be07d3c921a..a43c559d2c0 100644 --- a/dlls/winmm/message16.c +++ b/dlls/winmm/message16.c @@ -26,95 +26,16 @@ #include "windef.h" #include "winbase.h" #include "wownt32.h" -#include "winemm.h" #include "winemm16.h" #include "digitalv.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(winmm); -/****************************************************************** - * WINMM_MMTIME16to32 - */ -static void WINMM_MMTIME16to32(LPMMTIME mmt32, const MMTIME16* mmt16) -{ - mmt32->wType = mmt16->wType; - /* layout of rest is the same for 32/16, - * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding - */ - memcpy(&(mmt32->u), &(mmt16->u), sizeof(mmt16->u)); -} - - -/************************************************************************** - * MMDRV_Callback [internal] - */ -static void MMDRV_Callback(LPWINE_MLD mld, HDRVR hDev, UINT uMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2) -{ - TRACE("CB (*%08lx)(%p %08x %08lx %08lx %08lx\n", - mld->dwCallback, hDev, uMsg, mld->dwClientInstance, dwParam1, dwParam2); - - if ((mld->dwFlags & DCB_TYPEMASK) == DCB_FUNCTION) - { - WORD args[8]; - /* 16 bit func, call it */ - TRACE("Function (16 bit) !\n"); - - args[7] = HDRVR_16(hDev); - args[6] = uMsg; - args[5] = HIWORD(mld->dwClientInstance); - args[4] = LOWORD(mld->dwClientInstance); - args[3] = HIWORD(dwParam1); - args[2] = LOWORD(dwParam1); - args[1] = HIWORD(dwParam2); - args[0] = LOWORD(dwParam2); - WOWCallback16Ex( mld->dwCallback, WCB16_PASCAL, sizeof(args), args, NULL ); - } else { - DriverCallback(mld->dwCallback, mld->dwFlags, hDev, uMsg, - mld->dwClientInstance, dwParam1, dwParam2); - } -} - /* ================================= * A U X M A P P E R S * ================================= */ -/************************************************************************** - * MMDRV_Aux_Map32WTo16 [internal] - */ -static WINMM_MapType MMDRV_Aux_Map32WTo16 (UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_Aux_UnMap32WTo16 [internal] - */ -static WINMM_MapType MMDRV_Aux_UnMap32WTo16(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret) -{ -#if 0 - case AUXDM_GETDEVCAPS: - lpCaps->wMid = ac16.wMid; - lpCaps->wPid = ac16.wPid; - lpCaps->vDriverVersion = ac16.vDriverVersion; - strcpy(lpCaps->szPname, ac16.szPname); - lpCaps->wTechnology = ac16.wTechnology; - lpCaps->dwSupport = ac16.dwSupport; -#endif - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_Aux_Callback [internal] - */ -static void CALLBACK MMDRV_Aux_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) -{ - LPWINE_MLD mld = (LPWINE_MLD)dwInstance; - - FIXME("NIY\n"); - MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); -} - /* ================================= * M I X E R M A P P E R S * ================================= */ @@ -149,33 +70,6 @@ static MMSYSTEM_MapType MMSYSTDRV_Mixer_UnMap16To32W(UINT wMsg, DWORD_PTR* lpPa return MMSYSTEM_MAP_MSGERROR; } -/************************************************************************** - * MMDRV_Mixer_Map32WTo16 [internal] - */ -static WINMM_MapType MMDRV_Mixer_Map32WTo16 (UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_Mixer_UnMap32WTo16 [internal] - */ -static WINMM_MapType MMDRV_Mixer_UnMap32WTo16(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_Mixer_Callback [internal] - */ -static void CALLBACK MMDRV_Mixer_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) -{ - LPWINE_MLD mld = (LPWINE_MLD)dwInstance; - - FIXME("NIY\n"); - MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); -} - /************************************************************************** * MMSYSTDRV_Mixer_MapCB */ @@ -204,63 +98,6 @@ static MMSYSTEM_MapType MMSYSTDRV_MidiIn_UnMap16To32W(UINT wMsg, DWORD_PTR* lpP return MMSYSTEM_MAP_MSGERROR; } -/************************************************************************** - * MMDRV_MidiIn_Map32WTo16 [internal] - */ -static WINMM_MapType MMDRV_MidiIn_Map32WTo16 (UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_MidiIn_UnMap32WTo16 [internal] - */ -static WINMM_MapType MMDRV_MidiIn_UnMap32WTo16(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_MidiIn_Callback [internal] - */ -static void CALLBACK MMDRV_MidiIn_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) -{ - LPWINE_MLD mld = (LPWINE_MLD)dwInstance; - - switch (uMsg) { - case MIM_OPEN: - case MIM_CLOSE: - /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */ - - case MIM_DATA: - case MIM_MOREDATA: - case MIM_ERROR: - /* dwParam1 & dwParam2 are data, nothing to do */ - break; - case MIM_LONGDATA: - case MIM_LONGERROR: - /* dwParam1 points to a MidiHdr, work to be done !!! */ - if (!MMDRV_Is32(mld->mmdIndex)) { - /* initial map is: 32 => 16 */ - LPMIDIHDR mh16 = MapSL(dwParam1); - LPMIDIHDR mh32 = *(LPMIDIHDR*)((LPSTR)mh16 - sizeof(LPMIDIHDR)); - - dwParam1 = (DWORD)mh32; - mh32->dwFlags = mh16->dwFlags; - mh32->dwBytesRecorded = mh16->dwBytesRecorded; - if (mh32->reserved >= sizeof(MIDIHDR)) - mh32->dwOffset = mh16->dwOffset; - } - /* else { 32 => 32, nothing to do, same struct is kept }*/ - break; - /* case MOM_POSITIONCB: */ - default: - ERR("Unknown msg %u\n", uMsg); - } - - MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); -} - /************************************************************************** * MMSYSTDRV_MidiIn_MapCB [internal] */ @@ -464,257 +301,6 @@ static MMSYSTEM_MapType MMSYSTDRV_MidiOut_UnMap16To32W(UINT wMsg, DWORD_PTR* lp return ret; } -/************************************************************************** - * MMDRV_MidiOut_Map32WTo16 [internal] - */ -static WINMM_MapType MMDRV_MidiOut_Map32WTo16 (UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case MODM_CLOSE: - case MODM_GETNUMDEVS: - case MODM_DATA: - case MODM_RESET: - case MODM_SETVOLUME: - ret = WINMM_MAP_OK; - break; - case MODM_GETDEVCAPS: - { - LPMIDIOUTCAPSW moc32 = (LPMIDIOUTCAPSW)*lpParam1; - LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMIDIOUTCAPSW)+sizeof(MIDIOUTCAPS16)); - - if (ptr) { - *(LPMIDIOUTCAPSW*)ptr = moc32; - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - *lpParam1 = (DWORD)MapLS(ptr) + sizeof(LPMIDIOUTCAPSW); - *lpParam2 = sizeof(MIDIOUTCAPS16); - } - break; - case MODM_PREPARE: - { - LPMIDIHDR mh32 = (LPMIDIHDR)*lpParam1; - LPMIDIHDR mh16; - LPVOID ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPMIDIHDR) + sizeof(MIDIHDR) + mh32->dwBufferLength); - - if (ptr) { - *(LPMIDIHDR*)ptr = mh32; - mh16 = (LPMIDIHDR)((LPSTR)ptr + sizeof(LPMIDIHDR)); - *lpParam1 = MapLS(mh16); - mh16->lpData = (LPSTR)*lpParam1 + sizeof(MIDIHDR); - /* data will be copied on WODM_WRITE */ - mh16->dwBufferLength = mh32->dwBufferLength; - mh16->dwBytesRecorded = mh32->dwBytesRecorded; - mh16->dwUser = mh32->dwUser; - mh16->dwFlags = mh32->dwFlags; - /* FIXME: nothing on mh32->lpNext */ - /* could link the mh32->lpNext at this level for memory house keeping */ - mh16->dwOffset = (*lpParam2 >= sizeof(MIDIHDR)) ? mh32->dwOffset : 0; - - mh32->lpNext = mh16; /* for reuse in unprepare and write */ - mh32->reserved = *lpParam2; - - TRACE("mh16=%08lx mh16->lpData=%p mh32->buflen=%u mh32->lpData=%p\n", - *lpParam1, mh16->lpData, mh32->dwBufferLength, mh32->lpData); - *lpParam2 = sizeof(MIDIHDR); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case MODM_UNPREPARE: - case MODM_LONGDATA: - { - LPMIDIHDR mh32 = (LPMIDIHDR)(*lpParam1); - LPMIDIHDR mh16 = mh32->lpNext; - LPSTR ptr = (LPSTR)mh16 - sizeof(LPMIDIHDR); - - assert(*(LPMIDIHDR*)ptr == mh32); - - if (wMsg == MODM_LONGDATA) - memcpy((LPSTR)mh16 + sizeof(MIDIHDR), mh32->lpData, mh32->dwBufferLength); - - *lpParam1 = MapLS(mh16); - *lpParam2 = sizeof(MIDIHDR); - TRACE("mh16=%08lx mh16->lpData=%p mh32->buflen=%u mh32->lpData=%p\n", - *lpParam1, mh16->lpData, mh32->dwBufferLength, mh32->lpData); - - /* dwBufferLength can be reduced between prepare & write */ - if (wMsg == MODM_LONGDATA && mh16->dwBufferLength < mh32->dwBufferLength) { - ERR("Size of buffer has been increased from %d to %d, keeping initial value\n", - mh16->dwBufferLength, mh32->dwBufferLength); - } else - mh16->dwBufferLength = mh32->dwBufferLength; - ret = WINMM_MAP_OKMEM; - } - break; - case MODM_OPEN: - { - LPMIDIOPENDESC mod32 = (LPMIDIOPENDESC)*lpParam1; - LPVOID ptr; - LPMIDIOPENDESC16 mod16; - - /* allocated data are mapped as follows: - LPMIDIOPENDESC ptr to orig lParam1 - DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance - DWORD dwUser passed to driver - MIDIOPENDESC16 mod16: openDesc passed to driver - MIDIOPENSTRMID cIds - */ - ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPMIDIOPENDESC) + 2*sizeof(DWORD) + sizeof(MIDIOPENDESC16) + - mod32->cIds ? (mod32->cIds - 1) * sizeof(MIDIOPENSTRMID) : 0); - - if (ptr) { - SEGPTR segptr = MapLS(ptr); - *(LPMIDIOPENDESC*)ptr = mod32; - *(LPDWORD)((char*)ptr + sizeof(LPMIDIOPENDESC)) = *lpdwUser; - mod16 = (LPMIDIOPENDESC16)((LPSTR)ptr + sizeof(LPMIDIOPENDESC) + 2*sizeof(DWORD)); - - mod16->hMidi = HMIDI_16(mod32->hMidi); - mod16->dwCallback = mod32->dwCallback; - mod16->dwInstance = mod32->dwInstance; - mod16->dnDevNode = mod32->dnDevNode; - mod16->cIds = mod32->cIds; - memcpy(&mod16->rgIds, &mod32->rgIds, mod32->cIds * sizeof(MIDIOPENSTRMID)); - - *lpParam1 = (DWORD)segptr + sizeof(LPMIDIOPENDESC) + 2*sizeof(DWORD); - *lpdwUser = (DWORD)segptr + sizeof(LPMIDIOPENDESC) + sizeof(DWORD); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case MODM_GETVOLUME: - case MODM_CACHEPATCHES: - case MODM_CACHEDRUMPATCHES: - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_MidiOut_UnMap32WTo16 [internal] - */ -static WINMM_MapType MMDRV_MidiOut_UnMap32WTo16(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case MODM_CLOSE: - case MODM_GETNUMDEVS: - case MODM_DATA: - case MODM_RESET: - case MODM_SETVOLUME: - ret = WINMM_MAP_OK; - break; - case MODM_GETDEVCAPS: - { - LPMIDIOUTCAPS16 moc16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)moc16 - sizeof(LPMIDIOUTCAPSW); - LPMIDIOUTCAPSW moc32 = *(LPMIDIOUTCAPSW*)ptr; - - moc32->wMid = moc16->wMid; - moc32->wPid = moc16->wPid; - moc32->vDriverVersion = moc16->vDriverVersion; - WideCharToMultiByte( CP_ACP, 0, moc32->szPname, -1, moc16->szPname, - sizeof(moc16->szPname), NULL, NULL ); - moc32->wTechnology = moc16->wTechnology; - moc32->wVoices = moc16->wVoices; - moc32->wNotes = moc16->wNotes; - moc32->wChannelMask = moc16->wChannelMask; - moc32->dwSupport = moc16->dwSupport; - UnMapLS( *lpParam1 ); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case MODM_PREPARE: - case MODM_UNPREPARE: - case MODM_LONGDATA: - { - LPMIDIHDR mh16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)mh16 - sizeof(LPMIDIHDR); - LPMIDIHDR mh32 = *(LPMIDIHDR*)ptr; - - assert(mh32->lpNext == mh16); - UnMapLS( *lpParam1 ); - mh32->dwBytesRecorded = mh16->dwBytesRecorded; - mh32->dwUser = mh16->dwUser; - mh32->dwFlags = mh16->dwFlags; - - if (wMsg == MODM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) { - HeapFree( GetProcessHeap(), 0, ptr ); - mh32->lpNext = 0; - } - ret = WINMM_MAP_OK; - } - break; - case MODM_OPEN: - { - LPMIDIOPENDESC16 mod16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)mod16 - sizeof(LPMIDIOPENDESC) - 2*sizeof(DWORD); - UnMapLS( *lpParam1 ); - **(DWORD**)(ptr + sizeof(LPMIDIOPENDESC)) = *(LPDWORD)(ptr + sizeof(LPMIDIOPENDESC) + sizeof(DWORD)); - - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case MODM_GETVOLUME: - case MODM_CACHEPATCHES: - case MODM_CACHEDRUMPATCHES: - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_MidiOut_Callback [internal] - */ -static void CALLBACK MMDRV_MidiOut_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) -{ - LPWINE_MLD mld = (LPWINE_MLD)dwInstance; - - switch (uMsg) { - case MOM_OPEN: - case MOM_CLOSE: - /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */ - break; - case MOM_DONE: - if (!MMDRV_Is32(mld->mmdIndex)) { - /* initial map is: 32 => 16 */ - LPMIDIHDR mh16 = MapSL(dwParam1); - LPMIDIHDR mh32 = *(LPMIDIHDR*)((LPSTR)mh16 - sizeof(LPMIDIHDR)); - - dwParam1 = (DWORD)mh32; - mh32->dwFlags = mh16->dwFlags; - mh32->dwOffset = mh16->dwOffset; - if (mh32->reserved >= sizeof(MIDIHDR)) - mh32->dwOffset = mh16->dwOffset; - } - /* else { 32 => 32, nothing to do, same struct is kept }*/ - break; - /* case MOM_POSITIONCB: */ - default: - ERR("Unknown msg %u\n", uMsg); - } - - MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); -} - /****************************************************************** * MMSYSTDRV_MidiOut_MapCB */ @@ -934,300 +520,6 @@ static MMSYSTEM_MapType MMSYSTDRV_WaveIn_UnMap16To32W(UINT wMsg, DWORD_PTR* lpP return ret; } -/************************************************************************** - * MMDRV_WaveIn_Map32WTo16 [internal] - */ -static WINMM_MapType MMDRV_WaveIn_Map32WTo16 (UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case WIDM_CLOSE: - case WIDM_GETNUMDEVS: - case WIDM_RESET: - case WIDM_START: - case WIDM_STOP: - ret = WINMM_MAP_OK; - break; - - case WIDM_OPEN: - { - LPWAVEOPENDESC wod32 = (LPWAVEOPENDESC)*lpParam1; - int sz = sizeof(WAVEFORMATEX); - LPVOID ptr; - LPWAVEOPENDESC16 wod16; - - /* allocated data are mapped as follows: - LPWAVEOPENDESC ptr to orig lParam1 - DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance - DWORD dwUser passed to driver - WAVEOPENDESC16 wod16: openDesc passed to driver - WAVEFORMATEX openDesc->lpFormat passed to driver - xxx extra bytes to WAVEFORMATEX - */ - if (wod32->lpFormat->wFormatTag != WAVE_FORMAT_PCM) { - TRACE("Allocating %u extra bytes (%d)\n", wod32->lpFormat->cbSize, wod32->lpFormat->wFormatTag); - sz += wod32->lpFormat->cbSize; - } - - ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16) + sz); - - if (ptr) { - SEGPTR seg_ptr = MapLS( ptr ); - *(LPWAVEOPENDESC*)ptr = wod32; - *(LPDWORD)((char*)ptr + sizeof(LPWAVEOPENDESC)) = *lpdwUser; - wod16 = (LPWAVEOPENDESC16)((LPSTR)ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD)); - - wod16->hWave = HWAVE_16(wod32->hWave); - wod16->lpFormat = (LPWAVEFORMATEX)(seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16)); - memcpy(wod16 + 1, wod32->lpFormat, sz); - - wod16->dwCallback = wod32->dwCallback; - wod16->dwInstance = wod32->dwInstance; - wod16->uMappedDeviceID = wod32->uMappedDeviceID; - wod16->dnDevNode = wod32->dnDevNode; - - *lpParam1 = seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD); - *lpdwUser = seg_ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WIDM_PREPARE: - { - LPWAVEHDR wh32 = (LPWAVEHDR)*lpParam1; - LPWAVEHDR wh16; - LPVOID ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPWAVEHDR) + sizeof(WAVEHDR) + wh32->dwBufferLength); - - if (ptr) { - SEGPTR seg_ptr = MapLS( ptr ); - *(LPWAVEHDR*)ptr = wh32; - wh16 = (LPWAVEHDR)((LPSTR)ptr + sizeof(LPWAVEHDR)); - wh16->lpData = (LPSTR)seg_ptr + sizeof(LPWAVEHDR) + sizeof(WAVEHDR); - /* data will be copied on WODM_WRITE */ - wh16->dwBufferLength = wh32->dwBufferLength; - wh16->dwBytesRecorded = wh32->dwBytesRecorded; - wh16->dwUser = wh32->dwUser; - wh16->dwFlags = wh32->dwFlags; - wh16->dwLoops = wh32->dwLoops; - /* FIXME: nothing on wh32->lpNext */ - /* could link the wh32->lpNext at this level for memory house keeping */ - wh32->lpNext = wh16; /* for reuse in unprepare and write */ - *lpParam1 = seg_ptr + sizeof(LPWAVEHDR); - *lpParam2 = sizeof(WAVEHDR); - TRACE("wh16=%08lx wh16->lpData=%p wh32->buflen=%u wh32->lpData=%p\n", - *lpParam1, wh16->lpData, wh32->dwBufferLength, wh32->lpData); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WIDM_ADDBUFFER: - case WIDM_UNPREPARE: - { - LPWAVEHDR wh32 = (LPWAVEHDR)(*lpParam1); - LPWAVEHDR wh16 = wh32->lpNext; - LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR); - SEGPTR seg_ptr = MapLS( ptr ); - - assert(*(LPWAVEHDR*)ptr == wh32); - - if (wMsg == WIDM_ADDBUFFER) - memcpy((LPSTR)wh16 + sizeof(WAVEHDR), wh32->lpData, wh32->dwBufferLength); - - *lpParam1 = seg_ptr + sizeof(LPWAVEHDR); - *lpParam2 = sizeof(WAVEHDR); - TRACE("wh16=%08lx wh16->lpData=%p wh32->buflen=%u wh32->lpData=%p\n", - *lpParam1, wh16->lpData, wh32->dwBufferLength, wh32->lpData); - - /* dwBufferLength can be reduced between prepare & write */ - if (wMsg == WIDM_ADDBUFFER && wh16->dwBufferLength < wh32->dwBufferLength) { - ERR("Size of buffer has been increased from %d to %d, keeping initial value\n", - wh16->dwBufferLength, wh32->dwBufferLength); - } else - wh16->dwBufferLength = wh32->dwBufferLength; - ret = WINMM_MAP_OKMEM; - } - break; - case WIDM_GETDEVCAPS: - { - LPWAVEINCAPSW wic32 = (LPWAVEINCAPSW)*lpParam1; - LPSTR ptr = HeapAlloc( GetProcessHeap(), 0 ,sizeof(LPWAVEINCAPSW) + sizeof(WAVEINCAPS16)); - - if (ptr) { - *(LPWAVEINCAPSW*)ptr = wic32; - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - *lpParam1 = MapLS(ptr) + sizeof(LPWAVEINCAPSW); - *lpParam2 = sizeof(WAVEINCAPS16); - } - break; - case WIDM_GETPOS: - { - LPMMTIME mmt32 = (LPMMTIME)*lpParam1; - LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMMTIME) + sizeof(MMTIME16)); - LPMMTIME16 mmt16 = (LPMMTIME16)(ptr + sizeof(LPMMTIME)); - - if (ptr) { - *(LPMMTIME*)ptr = mmt32; - mmt16->wType = mmt32->wType; - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - *lpParam1 = MapLS(ptr) + sizeof(LPMMTIME); - *lpParam2 = sizeof(MMTIME16); - } - break; - case DRVM_MAPPER_STATUS: - { - LPDWORD p32 = (LPDWORD)*lpParam2; - *lpParam2 = MapLS(p32); - ret = WINMM_MAP_OKMEM; - } - break; - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_WaveIn_UnMap32WTo16 [internal] - */ -static WINMM_MapType MMDRV_WaveIn_UnMap32WTo16(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case WIDM_CLOSE: - case WIDM_GETNUMDEVS: - case WIDM_RESET: - case WIDM_START: - case WIDM_STOP: - ret = WINMM_MAP_OK; - break; - - case WIDM_OPEN: - { - LPWAVEOPENDESC16 wod16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)wod16 - sizeof(LPWAVEOPENDESC) - 2*sizeof(DWORD); - LPWAVEOPENDESC wod32 = *(LPWAVEOPENDESC*)ptr; - - UnMapLS( *lpParam1 ); - wod32->uMappedDeviceID = wod16->uMappedDeviceID; - **(DWORD**)(ptr + sizeof(LPWAVEOPENDESC)) = *(LPDWORD)(ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD)); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - - case WIDM_ADDBUFFER: - case WIDM_PREPARE: - case WIDM_UNPREPARE: - { - LPWAVEHDR wh16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR); - LPWAVEHDR wh32 = *(LPWAVEHDR*)ptr; - - assert(wh32->lpNext == wh16); - wh32->dwBytesRecorded = wh16->dwBytesRecorded; - wh32->dwUser = wh16->dwUser; - wh32->dwFlags = wh16->dwFlags; - wh32->dwLoops = wh16->dwLoops; - UnMapLS( *lpParam1 ); - - if (wMsg == WIDM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) { - HeapFree( GetProcessHeap(), 0, ptr ); - wh32->lpNext = 0; - } - ret = WINMM_MAP_OK; - } - break; - case WIDM_GETDEVCAPS: - { - LPWAVEINCAPS16 wic16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)wic16 - sizeof(LPWAVEINCAPSW); - LPWAVEINCAPSW wic32 = *(LPWAVEINCAPSW*)ptr; - - wic32->wMid = wic16->wMid; - wic32->wPid = wic16->wPid; - wic32->vDriverVersion = wic16->vDriverVersion; - WideCharToMultiByte( CP_ACP, 0, wic32->szPname, -1, wic16->szPname, - sizeof(wic16->szPname), NULL, NULL ); - wic32->dwFormats = wic16->dwFormats; - wic32->wChannels = wic16->wChannels; - UnMapLS( *lpParam1 ); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case WIDM_GETPOS: - { - LPMMTIME16 mmt16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)mmt16 - sizeof(LPMMTIME); - LPMMTIME mmt32 = *(LPMMTIME*)ptr; - - WINMM_MMTIME16to32(mmt32, mmt16); - UnMapLS( *lpParam1 ); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case DRVM_MAPPER_STATUS: - { - UnMapLS( *lpParam2 ); - ret = WINMM_MAP_OK; - } - break; - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_WaveIn_Callback [internal] - */ -static void CALLBACK MMDRV_WaveIn_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) -{ - LPWINE_MLD mld = (LPWINE_MLD)dwInstance; - - switch (uMsg) { - case WIM_OPEN: - case WIM_CLOSE: - /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */ - break; - case WIM_DATA: - if (!MMDRV_Is32(mld->mmdIndex)) { - /* initial map is: 32 => 16 */ - LPWAVEHDR wh16 = MapSL(dwParam1); - LPWAVEHDR wh32 = *(LPWAVEHDR*)((LPSTR)wh16 - sizeof(LPWAVEHDR)); - - dwParam1 = (DWORD)wh32; - wh32->dwFlags = wh16->dwFlags; - wh32->dwBytesRecorded = wh16->dwBytesRecorded; - } - /* else { 32 => 32, nothing to do, same struct is kept }*/ - break; - default: - ERR("Unknown msg %u\n", uMsg); - } - - MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); -} - /************************************************************************** * MMSYSTDRV_WaveIn_MapCB [internal] */ @@ -1461,336 +753,6 @@ static MMSYSTEM_MapType MMSYSTDRV_WaveOut_UnMap16To32W(UINT wMsg, DWORD_PTR* lp return ret; } -/************************************************************************** - * MMDRV_WaveOut_Map32WTo16 [internal] - */ -static WINMM_MapType MMDRV_WaveOut_Map32WTo16 (UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2) -{ - WINMM_MapType ret; - - switch (wMsg) { - /* nothing to do */ - case WODM_BREAKLOOP: - case WODM_CLOSE: - case WODM_GETNUMDEVS: - case WODM_PAUSE: - case WODM_RESET: - case WODM_RESTART: - case WODM_SETPITCH: - case WODM_SETPLAYBACKRATE: - case WODM_SETVOLUME: - ret = WINMM_MAP_OK; - break; - - case WODM_GETDEVCAPS: - { - LPWAVEOUTCAPSW woc32 = (LPWAVEOUTCAPSW)*lpParam1; - LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPWAVEOUTCAPSW) + sizeof(WAVEOUTCAPS16)); - - if (ptr) { - *(LPWAVEOUTCAPSW*)ptr = woc32; - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - *lpParam1 = MapLS(ptr) + sizeof(LPWAVEOUTCAPSW); - *lpParam2 = sizeof(WAVEOUTCAPS16); - } - break; - case WODM_GETPITCH: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - case WODM_GETPLAYBACKRATE: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - case WODM_GETPOS: - { - LPMMTIME mmt32 = (LPMMTIME)*lpParam1; - LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMMTIME) + sizeof(MMTIME16)); - LPMMTIME16 mmt16 = (LPMMTIME16)(ptr + sizeof(LPMMTIME)); - - if (ptr) { - *(LPMMTIME*)ptr = mmt32; - mmt16->wType = mmt32->wType; - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - *lpParam1 = MapLS(ptr) + sizeof(LPMMTIME); - *lpParam2 = sizeof(MMTIME16); - } - break; - case WODM_GETVOLUME: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - case WODM_OPEN: - { - LPWAVEOPENDESC wod32 = (LPWAVEOPENDESC)*lpParam1; - int sz = sizeof(WAVEFORMATEX); - LPVOID ptr; - LPWAVEOPENDESC16 wod16; - - /* allocated data are mapped as follows: - LPWAVEOPENDESC ptr to orig lParam1 - DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance - DWORD dwUser passed to driver - WAVEOPENDESC16 wod16: openDesc passed to driver - WAVEFORMATEX openDesc->lpFormat passed to driver - xxx extra bytes to WAVEFORMATEX - */ - if (wod32->lpFormat->wFormatTag != WAVE_FORMAT_PCM) { - TRACE("Allocating %u extra bytes (%d)\n", wod32->lpFormat->cbSize, wod32->lpFormat->wFormatTag); - sz += wod32->lpFormat->cbSize; - } - - ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16) + sz); - - if (ptr) { - SEGPTR seg_ptr = MapLS( ptr ); - *(LPWAVEOPENDESC*)ptr = wod32; - *(LPDWORD)((char*)ptr + sizeof(LPWAVEOPENDESC)) = *lpdwUser; - wod16 = (LPWAVEOPENDESC16)((LPSTR)ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD)); - - wod16->hWave = HWAVE_16(wod32->hWave); - wod16->lpFormat = (LPWAVEFORMATEX)(seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16)); - memcpy(wod16 + 1, wod32->lpFormat, sz); - - wod16->dwCallback = wod32->dwCallback; - wod16->dwInstance = wod32->dwInstance; - wod16->uMappedDeviceID = wod32->uMappedDeviceID; - wod16->dnDevNode = wod32->dnDevNode; - - *lpParam1 = seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD); - *lpdwUser = seg_ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WODM_PREPARE: - { - LPWAVEHDR wh32 = (LPWAVEHDR)*lpParam1; - LPWAVEHDR wh16; - LPVOID ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPWAVEHDR) + sizeof(WAVEHDR) + wh32->dwBufferLength); - - if (ptr) { - SEGPTR seg_ptr = MapLS( ptr ); - *(LPWAVEHDR*)ptr = wh32; - wh16 = (LPWAVEHDR)((LPSTR)ptr + sizeof(LPWAVEHDR)); - wh16->lpData = (LPSTR)seg_ptr + sizeof(LPWAVEHDR) + sizeof(WAVEHDR); - /* data will be copied on WODM_WRITE */ - wh16->dwBufferLength = wh32->dwBufferLength; - wh16->dwBytesRecorded = wh32->dwBytesRecorded; - wh16->dwUser = wh32->dwUser; - wh16->dwFlags = wh32->dwFlags; - wh16->dwLoops = wh32->dwLoops; - /* FIXME: nothing on wh32->lpNext */ - /* could link the wh32->lpNext at this level for memory house keeping */ - wh32->lpNext = wh16; /* for reuse in unprepare and write */ - *lpParam1 = seg_ptr + sizeof(LPWAVEHDR); - *lpParam2 = sizeof(WAVEHDR); - TRACE("wh16=%08lx wh16->lpData=%p wh32->buflen=%u wh32->lpData=%p\n", - *lpParam1, wh16->lpData, wh32->dwBufferLength, wh32->lpData); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WODM_UNPREPARE: - case WODM_WRITE: - { - LPWAVEHDR wh32 = (LPWAVEHDR)(*lpParam1); - LPWAVEHDR wh16 = wh32->lpNext; - LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR); - SEGPTR seg_ptr = MapLS( ptr ); - - assert(*(LPWAVEHDR*)ptr == wh32); - - if (wMsg == WODM_WRITE) - memcpy((LPSTR)wh16 + sizeof(WAVEHDR), wh32->lpData, wh32->dwBufferLength); - - *lpParam1 = seg_ptr + sizeof(LPWAVEHDR); - *lpParam2 = sizeof(WAVEHDR); - TRACE("wh16=%08lx wh16->lpData=%p wh32->buflen=%u wh32->lpData=%p\n", - *lpParam1, wh16->lpData, wh32->dwBufferLength, wh32->lpData); - - /* dwBufferLength can be reduced between prepare & write */ - if (wMsg == WODM_WRITE && wh16->dwBufferLength < wh32->dwBufferLength) { - ERR("Size of buffer has been increased from %d to %d, keeping initial value\n", - wh16->dwBufferLength, wh32->dwBufferLength); - } else - wh16->dwBufferLength = wh32->dwBufferLength; - ret = WINMM_MAP_OKMEM; - } - break; - case DRVM_MAPPER_STATUS: - { - LPDWORD p32 = (LPDWORD)*lpParam2; - *lpParam2 = MapLS(p32); - ret = WINMM_MAP_OKMEM; - } - break; - default: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_WaveOut_UnMap32WTo16 [internal] - */ -static WINMM_MapType MMDRV_WaveOut_UnMap32WTo16(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT fn_ret) -{ - WINMM_MapType ret; - - switch (wMsg) { - /* nothing to do */ - case WODM_BREAKLOOP: - case WODM_CLOSE: - case WODM_GETNUMDEVS: - case WODM_PAUSE: - case WODM_RESET: - case WODM_RESTART: - case WODM_SETPITCH: - case WODM_SETPLAYBACKRATE: - case WODM_SETVOLUME: - ret = WINMM_MAP_OK; - break; - - case WODM_GETDEVCAPS: - { - LPWAVEOUTCAPS16 woc16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)woc16 - sizeof(LPWAVEOUTCAPSW); - LPWAVEOUTCAPSW woc32 = *(LPWAVEOUTCAPSW*)ptr; - - woc32->wMid = woc16->wMid; - woc32->wPid = woc16->wPid; - woc32->vDriverVersion = woc16->vDriverVersion; - WideCharToMultiByte( CP_ACP, 0, woc32->szPname, -1, woc16->szPname, - sizeof(woc16->szPname), NULL, NULL ); - woc32->dwFormats = woc16->dwFormats; - woc32->wChannels = woc16->wChannels; - woc32->dwSupport = woc16->dwSupport; - UnMapLS( *lpParam1 ); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case WODM_GETPITCH: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - case WODM_GETPLAYBACKRATE: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - case WODM_GETPOS: - { - LPMMTIME16 mmt16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)mmt16 - sizeof(LPMMTIME); - LPMMTIME mmt32 = *(LPMMTIME*)ptr; - - WINMM_MMTIME16to32(mmt32, mmt16); - UnMapLS( *lpParam1 ); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case WODM_OPEN: - { - LPWAVEOPENDESC16 wod16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)wod16 - sizeof(LPWAVEOPENDESC) - 2*sizeof(DWORD); - LPWAVEOPENDESC wod32 = *(LPWAVEOPENDESC*)ptr; - - wod32->uMappedDeviceID = wod16->uMappedDeviceID; - **(DWORD**)(ptr + sizeof(LPWAVEOPENDESC)) = *(LPDWORD)(ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD)); - UnMapLS( *lpParam1 ); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case WODM_PREPARE: - case WODM_UNPREPARE: - case WODM_WRITE: - { - LPWAVEHDR wh16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR); - LPWAVEHDR wh32 = *(LPWAVEHDR*)ptr; - - assert(wh32->lpNext == wh16); - wh32->dwBytesRecorded = wh16->dwBytesRecorded; - wh32->dwUser = wh16->dwUser; - wh32->dwFlags = wh16->dwFlags; - wh32->dwLoops = wh16->dwLoops; - - UnMapLS( *lpParam1 ); - if (wMsg == WODM_UNPREPARE && fn_ret == MMSYSERR_NOERROR) { - HeapFree( GetProcessHeap(), 0, ptr ); - wh32->lpNext = 0; - } - ret = WINMM_MAP_OK; - } - break; - case WODM_GETVOLUME: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - case DRVM_MAPPER_STATUS: - { - UnMapLS( *lpParam2 ); - ret = WINMM_MAP_OK; - } - break; - default: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_WaveOut_Callback [internal] - */ -static void CALLBACK MMDRV_WaveOut_Callback(HDRVR hDev, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) -{ - LPWINE_MLD mld = (LPWINE_MLD)dwInstance; - - switch (uMsg) { - case WOM_OPEN: - case WOM_CLOSE: - /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */ - break; - case WOM_DONE: - if (!MMDRV_Is32(mld->mmdIndex)) { - /* initial map is: 32 => 16 */ - LPWAVEHDR wh16 = MapSL(dwParam1); - LPWAVEHDR wh32 = *(LPWAVEHDR*)((LPSTR)wh16 - sizeof(LPWAVEHDR)); - - dwParam1 = (DWORD)wh32; - wh32->dwFlags = wh16->dwFlags; - } - /* else { 32 => 32, nothing to do, same struct is kept }*/ - break; - default: - ERR("Unknown msg %u\n", uMsg); - } - - MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); -} - /************************************************************************** * MMDRV_WaveOut_Callback [internal] */ @@ -1817,136 +779,6 @@ static void MMSYSTDRV_WaveOut_MapCB(UINT uMsg, DWORD_PTR* dwUser, DWORD_PTR* dw } } -/* ================================= - * M A P P E R S H A N D L I N G - * ================================= */ - -static LRESULT MMDRV_CallMMDrvFunc16(DWORD fp16, WORD dev, WORD msg, LONG instance, - LONG lp1, LONG lp2) -{ - WORD args[8]; - DWORD ret; - - args[7] = dev; - args[6] = msg; - args[5] = HIWORD(instance); - args[4] = LOWORD(instance); - args[3] = HIWORD(lp1); - args[2] = LOWORD(lp1); - args[1] = HIWORD(lp2); - args[0] = LOWORD(lp2); - WOWCallback16Ex( fp16, WCB16_PASCAL, sizeof(args), args, &ret ); - return LOWORD(ret); -} - -/************************************************************************** - * MMDRV_GetDescription16 [internal] - */ -static BOOL MMDRV_GetDescription16(const char* fname, char* buf, int buflen) -{ - OFSTRUCT ofs; - HFILE hFile; - WORD w; - DWORD dw; - BOOL ret = FALSE; - - if ((hFile = OpenFile(fname, &ofs, OF_READ | OF_SHARE_DENY_WRITE)) == HFILE_ERROR) { - ERR("Can't open file %s (builtin driver ?)\n", fname); - return FALSE; - } - -#define E(_x) do {TRACE _x;goto theEnd;} while(0) - - if (_lread(hFile, &w, 2) != 2) E(("Can't read sig\n")); - if (w != ('Z' * 256 + 'M')) E(("Bad sig %04x\n", w)); - if (_llseek(hFile, 0x3C, SEEK_SET) < 0) E(("Can't seek to ext header offset\n")); - if (_lread(hFile, &dw, 4) != 4) E(("Can't read ext header offset\n")); - if (_llseek(hFile, dw + 0x2C, SEEK_SET) < 0) E(("Can't seek to ext header.nr table %u\n", dw+0x2C)); - if (_lread(hFile, &dw, 4) != 4) E(("Can't read nr table offset\n")); - if (_llseek(hFile, dw, SEEK_SET) < 0) E(("Can't seek to nr table %u\n", dw)); - if (_lread(hFile, buf, 1) != 1) E(("Can't read descr length\n")); - buflen = min((int)(unsigned)(BYTE)buf[0], buflen - 1); - if (_lread(hFile, buf, buflen) != buflen) E(("Can't read descr (%d)\n", buflen)); - buf[buflen] = '\0'; - ret = TRUE; - TRACE("Got '%s' [%d]\n", buf, buflen); -theEnd: - _lclose(hFile); - return ret; -} - -/****************************************************************** - * MMDRV_LoadMMDrvFunc16 - * - */ -static unsigned MMDRV_LoadMMDrvFunc16(LPCSTR drvName, LPWINE_DRIVER d, - LPWINE_MM_DRIVER lpDrv) -{ - WINEMM_msgFunc16 func; - unsigned count = 0; - char buffer[128]; - /* - * DESCRIPTION 'wave,aux,mixer:Creative Labs Sound Blaster 16 Driver' - * The beginning of the module description indicates the driver supports - * waveform, auxiliary, and mixer devices. Use one of the following - * device-type names, followed by a colon (:) to indicate the type of - * device your driver supports. If the driver supports more than one - * type of device, separate each device-type name with a comma (,). - * - * wave for waveform audio devices - * wavemapper for wave mappers - * midi for MIDI audio devices - * midimapper for midi mappers - * aux for auxiliary audio devices - * mixer for mixer devices - */ - - if (d->d.d16.hDriver16) { - HMODULE16 hMod16 = GetDriverModuleHandle16(d->d.d16.hDriver16); - -#define AA(_h,_w,_x,_y,_z) \ - func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \ - if (func != NULL) \ - { lpDrv->parts[_w].u.fnMessage##_y = func; count++; \ - TRACE("Got %d bit func '%s'\n", _y, #_x); } - -#define A(_x,_y) AA(hMod16,_x,_y,16,GetProcAddress16) - A(MMDRV_AUX, auxMessage); - A(MMDRV_MIXER, mxdMessage); - A(MMDRV_MIDIIN, midMessage); - A(MMDRV_MIDIOUT,modMessage); - A(MMDRV_WAVEIN, widMessage); - A(MMDRV_WAVEOUT,wodMessage); -#undef A -#undef AA - } - if (TRACE_ON(winmm)) { - if (MMDRV_GetDescription16(drvName, buffer, sizeof(buffer))) - TRACE("%s => %s\n", drvName, buffer); - else - TRACE("%s => No description\n", drvName); - } - - return count; -} - -void MMDRV_Init16(void) -{ -#define A(_x,_y) MMDRV_InstallMap(_x, \ -MMDRV_##_y##_Map32WTo16, MMDRV_##_y##_UnMap32WTo16, \ -MMDRV_##_y##_Callback) - A(MMDRV_AUX, Aux); - A(MMDRV_MIXER, Mixer); - A(MMDRV_MIDIIN, MidiIn); - A(MMDRV_MIDIOUT, MidiOut); - A(MMDRV_WAVEIN, WaveIn); - A(MMDRV_WAVEOUT, WaveOut); -#undef A - - pFnCallMMDrvFunc16 = MMDRV_CallMMDrvFunc16; - pFnLoadMMDrvFunc16 = MMDRV_LoadMMDrvFunc16; -} - /* ################################################### * # DRIVER THUNKING # * ################################################### diff --git a/dlls/winmm/mmsystem.c b/dlls/winmm/mmsystem.c index ce26192126b..f258feedc76 100644 --- a/dlls/winmm/mmsystem.c +++ b/dlls/winmm/mmsystem.c @@ -40,7 +40,6 @@ #include "wine/list.h" #include "wine/winuser16.h" -#include "winemm.h" #include "winemm16.h" #include "wine/debug.h" @@ -48,9 +47,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mmsys); static WINE_MMTHREAD* WINMM_GetmmThread(HANDLE16); -static LPWINE_DRIVER DRIVER_OpenDriver16(LPCWSTR, LPCWSTR, LPARAM); -static LRESULT DRIVER_CloseDriver16(HDRVR16, LPARAM, LPARAM); -static LRESULT DRIVER_SendMessage16(HDRVR16, UINT, LPARAM, LPARAM); static CRITICAL_SECTION_DEBUG mmdrv_critsect_debug = { @@ -76,32 +72,6 @@ BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds, { TRACE("%p 0x%x\n", hinstDLL, fdwReason); - switch (fdwReason) { - case DLL_PROCESS_ATTACH: - /* need to load WinMM in order to: - * - initiate correctly shared variables (WINMM_Init()) - */ - if (!GetModuleHandleA("WINMM.DLL")) - { - ERR("Could not load sibling WinMM.dll\n"); - return FALSE; - } - /* hook in our 16 bit function pointers */ - pFnOpenDriver16 = DRIVER_OpenDriver16; - pFnCloseDriver16 = DRIVER_CloseDriver16; - pFnSendMessage16 = DRIVER_SendMessage16; - MMDRV_Init16(); - break; - case DLL_PROCESS_DETACH: - pFnOpenDriver16 = NULL; - pFnCloseDriver16 = NULL; - pFnSendMessage16 = NULL; - /* FIXME: add equivalent for MMDRV_Init16() */ - break; - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - break; - } return TRUE; } @@ -2069,234 +2039,6 @@ void WINAPI WMMMidiRunOnce16(void) FIXME("(), stub!\n"); } -/* ################################################### - * # DRIVER # - * ################################################### - */ - -/************************************************************************** - * DRIVER_MapMsg32To16 [internal] - * - * Map a 32 bit driver message to a 16 bit driver message. - */ -static WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, LPARAM *lParam1, LPARAM *lParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case DRV_LOAD: - case DRV_ENABLE: - case DRV_DISABLE: - case DRV_FREE: - case DRV_QUERYCONFIGURE: - case DRV_REMOVE: - case DRV_EXITSESSION: - case DRV_EXITAPPLICATION: - case DRV_POWER: - case DRV_CLOSE: /* should be 0/0 */ - case DRV_OPEN: /* pass through */ - /* lParam1 and lParam2 are not used */ - ret = WINMM_MAP_OK; - break; - case DRV_CONFIGURE: - case DRV_INSTALL: - /* lParam1 is a handle to a window (conf) or to a driver (inst) or not used, - * lParam2 is a pointer to DRVCONFIGINFO - */ - if (*lParam2) { - LPDRVCONFIGINFO16 dci16 = HeapAlloc( GetProcessHeap(), 0, sizeof(*dci16) ); - LPDRVCONFIGINFO dci32 = (LPDRVCONFIGINFO)(*lParam2); - - if (dci16) { - LPSTR str1 = NULL,str2; - INT len; - dci16->dwDCISize = sizeof(DRVCONFIGINFO16); - - if (dci32->lpszDCISectionName) { - len = WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCISectionName, -1, NULL, 0, NULL, NULL ); - str1 = HeapAlloc( GetProcessHeap(), 0, len ); - if (str1) { - WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCISectionName, -1, str1, len, NULL, NULL ); - dci16->lpszDCISectionName = MapLS( str1 ); - } else { - HeapFree( GetProcessHeap(), 0, dci16); - return WINMM_MAP_NOMEM; - } - } else { - dci16->lpszDCISectionName = 0L; - } - if (dci32->lpszDCIAliasName) { - len = WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCIAliasName, -1, NULL, 0, NULL, NULL ); - str2 = HeapAlloc( GetProcessHeap(), 0, len ); - if (str2) { - WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCIAliasName, -1, str2, len, NULL, NULL ); - dci16->lpszDCIAliasName = MapLS( str2 ); - } else { - HeapFree( GetProcessHeap(), 0, str1); - HeapFree( GetProcessHeap(), 0, dci16); - return WINMM_MAP_NOMEM; - } - } else { - dci16->lpszDCISectionName = 0L; - } - } else { - return WINMM_MAP_NOMEM; - } - *lParam2 = MapLS( dci16 ); - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_OK; - } - break; - default: - if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) { - FIXME("Unknown message 0x%04x\n", wMsg); - } - ret = WINMM_MAP_OK; - } - return ret; -} - -/************************************************************************** - * DRIVER_UnMapMsg32To16 [internal] - * - * UnMap a 32 bit driver message to a 16 bit driver message. - */ -static WINMM_MapType DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case DRV_LOAD: - case DRV_ENABLE: - case DRV_DISABLE: - case DRV_FREE: - case DRV_QUERYCONFIGURE: - case DRV_REMOVE: - case DRV_EXITSESSION: - case DRV_EXITAPPLICATION: - case DRV_POWER: - case DRV_OPEN: - case DRV_CLOSE: - /* lParam1 and lParam2 are not used */ - break; - case DRV_CONFIGURE: - case DRV_INSTALL: - /* lParam1 is a handle to a window (or not used), lParam2 is a pointer to DRVCONFIGINFO, lParam2 */ - if (lParam2) { - LPDRVCONFIGINFO16 dci16 = MapSL(lParam2); - HeapFree( GetProcessHeap(), 0, MapSL(dci16->lpszDCISectionName) ); - HeapFree( GetProcessHeap(), 0, MapSL(dci16->lpszDCIAliasName) ); - UnMapLS( lParam2 ); - UnMapLS( dci16->lpszDCISectionName ); - UnMapLS( dci16->lpszDCIAliasName ); - HeapFree( GetProcessHeap(), 0, dci16 ); - } - ret = WINMM_MAP_OK; - break; - default: - if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) { - FIXME("Unknown message 0x%04x\n", wMsg); - } - ret = WINMM_MAP_OK; - } - return ret; -} - -/************************************************************************** - * DRIVER_TryOpenDriver16 [internal] - * - * Tries to load a 16 bit driver whose DLL's (module) name is lpFileName. - */ -static LPWINE_DRIVER DRIVER_OpenDriver16(LPCWSTR fn, LPCWSTR sn, LPARAM lParam2) -{ - LPWINE_DRIVER lpDrv = NULL; - LPCSTR cause = NULL; - LPSTR fnA = NULL, snA = NULL; - unsigned len; - - TRACE("(%s, %s, %08lX);\n", debugstr_w(fn), debugstr_w(sn), lParam2); - - lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER)); - if (lpDrv == NULL) {cause = "OOM"; goto exit;} - - if (fn) - { - len = WideCharToMultiByte( CP_ACP, 0, fn, -1, NULL, 0, NULL, NULL ); - fnA = HeapAlloc(GetProcessHeap(), 0, len); - if (fnA == NULL) {cause = "OOM"; goto exit;} - WideCharToMultiByte( CP_ACP, 0, fn, -1, fnA, len, NULL, NULL ); - } - - if (sn) - { - len = WideCharToMultiByte( CP_ACP, 0, sn, -1, NULL, 0, NULL, NULL ); - snA = HeapAlloc(GetProcessHeap(), 0, len); - if (snA == NULL) {cause = "OOM"; goto exit;} - WideCharToMultiByte( CP_ACP, 0, sn, -1, snA, len, NULL, NULL ); - } - - /* FIXME: shall we do some black magic here on sn ? - * drivers32 => drivers - * mci32 => mci - * ... - */ - lpDrv->d.d16.hDriver16 = OpenDriver16(fnA, snA, lParam2); - if (lpDrv->d.d16.hDriver16 == 0) {cause = "Not a 16 bit driver"; goto exit;} - lpDrv->dwFlags = WINE_GDF_16BIT; - -exit: - HeapFree(GetProcessHeap(), 0, fnA); - HeapFree(GetProcessHeap(), 0, snA); - - if (cause) - { - TRACE("Unable to load 16 bit module %s[%s]: %s\n", - debugstr_w(fn), debugstr_w(sn), cause); - HeapFree(GetProcessHeap(), 0, lpDrv); - return NULL; - } - - TRACE("=> %p\n", lpDrv); - return lpDrv; -} - -/****************************************************************** - * DRIVER_SendMessage16 - * - * - */ -static LRESULT DRIVER_SendMessage16(HDRVR16 hDrv16, UINT msg, - LPARAM lParam1, LPARAM lParam2) -{ - LRESULT ret = 0; - WINMM_MapType map; - - TRACE("Before sdm16 call hDrv=%04x wMsg=%04x p1=%08lx p2=%08lx\n", - hDrv16, msg, lParam1, lParam2); - - switch (map = DRIVER_MapMsg32To16(msg, &lParam1, &lParam2)) { - case WINMM_MAP_OKMEM: - case WINMM_MAP_OK: - ret = SendDriverMessage16(hDrv16, msg, lParam1, lParam2); - if (map == WINMM_MAP_OKMEM) - DRIVER_UnMapMsg32To16(msg, lParam1, lParam2); - default: - break; - } - return ret; -} - -/****************************************************************** - * DRIVER_CloseDriver16 - * - * - */ -static LRESULT DRIVER_CloseDriver16(HDRVR16 hDrv16, LPARAM lParam1, LPARAM lParam2) -{ - return CloseDriver16(hDrv16, lParam1, lParam2); -} - /************************************************************************** * DrvOpen [MMSYSTEM.1100] */ diff --git a/dlls/winmm/winemm.h b/dlls/winmm/winemm.h index 4c864166200..7920e2eb2b7 100644 --- a/dlls/winmm/winemm.h +++ b/dlls/winmm/winemm.h @@ -29,13 +29,6 @@ #define WINE_DEFAULT_WINMM_MAPPER "msacm32.drv" #define WINE_DEFAULT_WINMM_MIDI "midimap.dll" -typedef enum { - WINMM_MAP_NOMEM, /* ko, memory problem */ - WINMM_MAP_MSGERROR, /* ko, unknown message */ - WINMM_MAP_OK, /* ok, no memory allocated. to be sent to the proc. */ - WINMM_MAP_OKMEM, /* ok, some memory allocated, need to call UnMapMsg. to be sent to the proc. */ -} WINMM_MapType; - /* Who said goofy boy ? */ #define WINE_DI_MAGIC 0x900F1B01 @@ -44,22 +37,14 @@ typedef struct tagWINE_DRIVER DWORD dwMagic; /* as usual LPWINE_DRIVER == hDriver32 */ DWORD dwFlags; - union { - struct { - HMODULE hModule; - DRIVERPROC lpDrvProc; - DWORD_PTR dwDriverID; - } d32; - struct { - UINT16 hDriver16; - } d16; - } d; + HMODULE hModule; + DRIVERPROC lpDrvProc; + DWORD_PTR dwDriverID; struct tagWINE_DRIVER* lpPrevItem; struct tagWINE_DRIVER* lpNextItem; } WINE_DRIVER, *LPWINE_DRIVER; -typedef DWORD (CALLBACK *WINEMM_msgFunc16)(UINT16, WORD, DWORD, DWORD, DWORD); -typedef DWORD (CALLBACK *WINEMM_msgFunc32)(UINT , UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR); +typedef DWORD (CALLBACK *WINEMM_msgFunc32)(UINT, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR); /* for each loaded driver and each known type of driver, this structure contains * the information needed to access it @@ -67,10 +52,7 @@ typedef DWORD (CALLBACK *WINEMM_msgFunc32)(UINT , UINT, DWORD_PTR, DWORD_PTR, D typedef struct tagWINE_MM_DRIVER_PART { int nIDMin; /* lower bound of global indexes for this type */ int nIDMax; /* hhigher bound of global indexes for this type */ - union { - WINEMM_msgFunc32 fnMessage32; /* pointer to function */ - WINEMM_msgFunc16 fnMessage16; - } u; + WINEMM_msgFunc32 fnMessage32; /* pointer to function */ } WINE_MM_DRIVER_PART; #define MMDRV_AUX 0 @@ -85,8 +67,7 @@ typedef struct tagWINE_MM_DRIVER_PART { typedef struct tagWINE_MM_DRIVER { HDRVR hDriver; LPSTR drvname; /* name of the driver */ - unsigned bIs32 : 1, /* TRUE if 32 bit driver, FALSE for 16 */ - bIsMapper : 1; /* TRUE if mapper */ + unsigned bIsMapper : 1; /* TRUE if mapper */ WINE_MM_DRIVER_PART parts[MMDRV_MAX];/* Information for all known types */ } WINE_MM_DRIVER, *LPWINE_MM_DRIVER; @@ -151,9 +132,6 @@ typedef struct tagWINE_MMIO { /* function prototypes */ -typedef WINMM_MapType (*MMDRV_MAPFUNC)(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2); -typedef WINMM_MapType (*MMDRV_UNMAPFUNC)(UINT wMsg, DWORD_PTR *lpdwUser, DWORD_PTR* lpParam1, DWORD_PTR* lpParam2, MMRESULT ret); - LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr); BOOL DRIVER_GetLibName(LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz); LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2); @@ -171,15 +149,12 @@ LPWINE_MLD MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID); LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType, BOOL bSrcCanBeID, UINT dstTyped); DWORD MMDRV_Message(LPWINE_MLD mld, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2); UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2); -BOOL MMDRV_Is32(unsigned int); -void MMDRV_InstallMap(unsigned int, MMDRV_MAPFUNC, MMDRV_UNMAPFUNC, LPDRVCALLBACK); const char* MCI_MessageToString(UINT wMsg); DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2); LPWSTR MCI_strdupAtoW(LPCSTR str); LPSTR MCI_strdupWtoA(LPCWSTR str); -BOOL WINMM_CheckForMMSystem(void); const char* WINMM_ErrorToString(MMRESULT error); void TIME_MMTimeStop(void); @@ -190,19 +165,9 @@ extern HINSTANCE hWinMM32Instance; extern HANDLE psLastEvent; extern HANDLE psStopEvent; -/* pointers to 16 bit functions (if sibling MMSYSTEM.DLL is loaded - * NULL otherwise - */ -extern LPWINE_DRIVER (*pFnOpenDriver16)(LPCWSTR,LPCWSTR,LPARAM); -extern LRESULT (*pFnCloseDriver16)(UINT16,LPARAM,LPARAM); -extern LRESULT (*pFnSendMessage16)(UINT16,UINT,LPARAM,LPARAM); -extern LRESULT (*pFnCallMMDrvFunc16)(DWORD /* in fact FARPROC16 */,WORD,WORD,LONG,LONG,LONG); -extern unsigned (*pFnLoadMMDrvFunc16)(LPCSTR,LPWINE_DRIVER, LPWINE_MM_DRIVER); - /* GetDriverFlags() returned bits is not documented (nor the call itself) * Here are Wine only definitions of the bits */ #define WINE_GDF_EXIST 0x80000000 -#define WINE_GDF_16BIT 0x10000000 #define WINE_GDF_EXTERNAL_MASK 0xF0000000 #define WINE_GDF_SESSION 0x00000001