diff --git a/dlls/winmm/mci.c b/dlls/winmm/mci.c index b133ffcd8f1..53908155257 100644 --- a/dlls/winmm/mci.c +++ b/dlls/winmm/mci.c @@ -67,8 +67,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mci); -WINMM_MapType (*pFnMciMapMsg16To32W) (WORD,WORD,DWORD,DWORD_PTR*) = NULL; -WINMM_MapType (*pFnMciUnMapMsg16To32W)(WORD,WORD,DWORD,DWORD_PTR) = NULL; WINMM_MapType (*pFnMciMapMsg32WTo16) (WORD,WORD,DWORD,DWORD_PTR*) = NULL; WINMM_MapType (*pFnMciUnMapMsg32WTo16)(WORD,WORD,DWORD,DWORD_PTR) = NULL; @@ -103,7 +101,7 @@ static inline LPWSTR str_dup_upper( LPCWSTR str ) /************************************************************************** * MCI_GetDriver [internal] */ -LPWINE_MCIDRIVER MCI_GetDriver(UINT16 wDevID) +static LPWINE_MCIDRIVER MCI_GetDriver(UINT16 wDevID) { LPWINE_MCIDRIVER wmd = 0; @@ -1469,7 +1467,7 @@ DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet, MCI_UnLoadMciDriver(wmd); /* FIXME: notification is not properly shared across two opens */ } else { - dwRet = MCI_SendCommand(wmd->wDeviceID, MCI_GetMessage(lpCmd), dwFlags, (DWORD_PTR)data, TRUE); + dwRet = MCI_SendCommand(wmd->wDeviceID, MCI_GetMessage(lpCmd), dwFlags, (DWORD_PTR)data); } TRACE("=> 1/ %x (%s)\n", dwRet, debugstr_w(lpstrRet)); dwRet = MCI_HandleReturnValues(dwRet, wmd, retType, data, lpstrRet, uRetLen); @@ -1586,43 +1584,6 @@ BOOL WINAPI mciFreeCommandResource(UINT uTable) return MCI_DeleteCommandTable(uTable, FALSE); } -/************************************************************************** - * MCI_SendCommandFrom16 [internal] - */ -static DWORD MCI_SendCommandFrom16(MCIDEVICEID wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2) -{ - DWORD dwRet = MCIERR_INVALID_DEVICE_ID; - LPWINE_MCIDRIVER wmd = MCI_GetDriver(wDevID); - - if (wmd) { - dwRet = MCIERR_INVALID_DEVICE_ID; - - if (wmd->bIs32 && pFnMciMapMsg16To32W) { - WINMM_MapType res; - - switch (res = pFnMciMapMsg16To32W(wmd->wType, wMsg, dwParam1, &dwParam2)) { - case WINMM_MAP_MSGERROR: - TRACE("Not handled yet (%s)\n", MCI_MessageToString(wMsg)); - dwRet = MCIERR_DRIVER_INTERNAL; - break; - case WINMM_MAP_NOMEM: - TRACE("Problem mapping msg=%s from 16 to 32a\n", MCI_MessageToString(wMsg)); - dwRet = MCIERR_OUT_OF_MEMORY; - break; - case WINMM_MAP_OK: - case WINMM_MAP_OKMEM: - dwRet = SendDriverMessage(wmd->hDriver, wMsg, dwParam1, dwParam2); - if (res == WINMM_MAP_OKMEM) - pFnMciUnMapMsg16To32W(wmd->wType, wMsg, dwParam1, dwParam2); - break; - } - } else { - dwRet = SendDriverMessage(wmd->hDriver, wMsg, dwParam1, dwParam2); - } - } - return dwRet; -} - /************************************************************************** * MCI_Open [internal] */ @@ -1969,90 +1930,32 @@ static DWORD MCI_Sound(UINT wDevID, DWORD dwFlags, LPMCI_SOUND_PARMSW lpParms) /************************************************************************** * MCI_SendCommand [internal] */ -DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, - DWORD_PTR dwParam2, BOOL bFrom32) +DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2) { DWORD dwRet = MCIERR_UNRECOGNIZED_COMMAND; switch (wMsg) { case MCI_OPEN: - if (bFrom32) { - dwRet = MCI_Open(dwParam1, (LPMCI_OPEN_PARMSW)dwParam2); - } else if (pFnMciMapMsg16To32W) { - switch (pFnMciMapMsg16To32W(0, wMsg, dwParam1, &dwParam2)) { - case WINMM_MAP_OK: - case WINMM_MAP_OKMEM: - dwRet = MCI_Open(dwParam1, (LPMCI_OPEN_PARMSW)dwParam2); - pFnMciUnMapMsg16To32W(0, wMsg, dwParam1, dwParam2); - break; - default: break; /* so that gcc does not bark */ - } - } + dwRet = MCI_Open(dwParam1, (LPMCI_OPEN_PARMSW)dwParam2); break; case MCI_CLOSE: - if (bFrom32) { - dwRet = MCI_Close(wDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2); - } else if (pFnMciMapMsg16To32W) { - switch (pFnMciMapMsg16To32W(0, wMsg, dwParam1, &dwParam2)) { - case WINMM_MAP_OK: - case WINMM_MAP_OKMEM: - dwRet = MCI_Close(wDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2); - pFnMciUnMapMsg16To32W(0, wMsg, dwParam1, dwParam2); - break; - default: break; /* so that gcc does not bark */ - } - } + dwRet = MCI_Close(wDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2); break; case MCI_SYSINFO: - if (bFrom32) { - dwRet = MCI_SysInfo(wDevID, dwParam1, (LPMCI_SYSINFO_PARMSW)dwParam2); - } else if (pFnMciMapMsg16To32W) { - switch (pFnMciMapMsg16To32W(0, wMsg, dwParam1, &dwParam2)) { - case WINMM_MAP_OK: - case WINMM_MAP_OKMEM: - dwRet = MCI_SysInfo(wDevID, dwParam1, (LPMCI_SYSINFO_PARMSW)dwParam2); - pFnMciUnMapMsg16To32W(0, wMsg, dwParam1, dwParam2); - break; - default: break; /* so that gcc does not bark */ - } - } + dwRet = MCI_SysInfo(wDevID, dwParam1, (LPMCI_SYSINFO_PARMSW)dwParam2); break; case MCI_BREAK: - if (bFrom32) { - dwRet = MCI_Break(wDevID, dwParam1, (LPMCI_BREAK_PARMS)dwParam2); - } else if (pFnMciMapMsg16To32W) { - switch (pFnMciMapMsg16To32W(0, wMsg, dwParam1, &dwParam2)) { - case WINMM_MAP_OK: - case WINMM_MAP_OKMEM: - dwRet = MCI_Break(wDevID, dwParam1, (LPMCI_BREAK_PARMS)dwParam2); - pFnMciUnMapMsg16To32W(0, wMsg, dwParam1, dwParam2); - break; - default: break; /* so that gcc does not bark */ - } - } + dwRet = MCI_Break(wDevID, dwParam1, (LPMCI_BREAK_PARMS)dwParam2); break; case MCI_SOUND: - if (bFrom32) { - dwRet = MCI_Sound(wDevID, dwParam1, (LPMCI_SOUND_PARMSW)dwParam2); - } else if (pFnMciMapMsg16To32W) { - switch (pFnMciMapMsg16To32W(0, wMsg, dwParam1, &dwParam2)) { - case WINMM_MAP_OK: - case WINMM_MAP_OKMEM: - dwRet = MCI_Sound(wDevID, dwParam1, (LPMCI_SOUND_PARMSW)dwParam2); - pFnMciUnMapMsg16To32W(0, wMsg, dwParam1, dwParam2); - break; - default: break; /* so that gcc does not bark */ - } - } + dwRet = MCI_Sound(wDevID, dwParam1, (LPMCI_SOUND_PARMSW)dwParam2); break; default: if (wDevID == MCI_ALL_DEVICE_ID) { FIXME("unhandled MCI_ALL_DEVICE_ID\n"); dwRet = MCIERR_CANNOT_USE_ALL; } else { - dwRet = (bFrom32) ? - MCI_SendCommandFrom32(wDevID, wMsg, dwParam1, dwParam2) : - MCI_SendCommandFrom16(wDevID, wMsg, dwParam1, dwParam2); + dwRet = MCI_SendCommandFrom32(wDevID, wMsg, dwParam1, dwParam2); } break; } @@ -2066,7 +1969,7 @@ DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, * mciSendString), because MCI drivers return extra information for string * transformation. This function gets rid of them. */ -LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD_PTR dwParam2) +static LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD_PTR dwParam2) { if (LOWORD(dwRet)) return LOWORD(dwRet); @@ -2232,7 +2135,7 @@ DWORD WINAPI mciSendCommandW(MCIDEVICEID wDevID, UINT wMsg, DWORD_PTR dwParam1, TRACE("(%08x, %s, %08lx, %08lx)\n", wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2); - dwRet = MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2, TRUE); + dwRet = MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2); dwRet = MCI_CleanUp(dwRet, wMsg, dwParam2); TRACE("=> %08x\n", dwRet); return dwRet; @@ -2339,7 +2242,6 @@ BOOL WINAPI mciSetYieldProc(MCIDEVICEID uDeviceID, YIELDPROC fpYieldProc, DWORD wmd->lpfnYieldProc = fpYieldProc; wmd->dwYieldData = dwYieldData; - wmd->bIs32 = TRUE; return TRUE; } @@ -2389,10 +2291,6 @@ YIELDPROC WINAPI mciGetYieldProc(MCIDEVICEID uDeviceID, DWORD* lpdwYieldData) WARN("No proc set\n"); return NULL; } - if (!wmd->bIs32) { - WARN("Proc is 32 bit\n"); - return NULL; - } if (lpdwYieldData) *lpdwYieldData = wmd->dwYieldData; return wmd->lpfnYieldProc; } @@ -2421,7 +2319,7 @@ UINT WINAPI mciDriverYield(MCIDEVICEID uDeviceID) TRACE("(%04x)\n", uDeviceID); - if (!(wmd = MCI_GetDriver(uDeviceID)) || !wmd->lpfnYieldProc || !wmd->bIs32) { + if (!(wmd = MCI_GetDriver(uDeviceID)) || !wmd->lpfnYieldProc) { MyUserYield(); } else { ret = wmd->lpfnYieldProc(uDeviceID, wmd->dwYieldData); diff --git a/dlls/winmm/mci16.c b/dlls/winmm/mci16.c index 5214afc0615..6155bdbe9b8 100644 --- a/dlls/winmm/mci16.c +++ b/dlls/winmm/mci16.c @@ -33,7 +33,6 @@ #include "wine/winuser16.h" #include "winemm16.h" -#include "winemm.h" #include "wine/debug.h" @@ -44,25 +43,118 @@ WINE_DEFAULT_DEBUG_CHANNEL(mmsys); * ################################################### */ +#include +#define MCI_MAX_THUNKS 32 + +static struct mci_thunk +{ + BYTE popl_eax; /* popl %eax (return address) */ + BYTE pushl_func; /* pushl $pfn16 (16bit callback function) */ + YIELDPROC16 yield16; + BYTE pushl_eax; /* pushl %eax */ + BYTE jmp; /* ljmp MCI_Yield1632 */ + DWORD callback; + MCIDEVICEID id; +} *MCI_Thunks; + +#include + +static CRITICAL_SECTION mci_cs; +static CRITICAL_SECTION_DEBUG mci_critsect_debug = +{ + 0, 0, &mci_cs, + { &mci_critsect_debug.ProcessLocksList, &mci_critsect_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": mmsystem_mci_cs") } +}; +static CRITICAL_SECTION mci_cs = { &mci_critsect_debug, -1, 0, 0, 0, 0 }; + +static UINT MCI_Yield1632(DWORD pfn16, MCIDEVICEID id, DWORD yield_data) +{ + WORD args[8]; + + if (!pfn16) + { + UserYield16(); + return 0; + } + + /* 16 bit func, call it */ + TRACE("Function (16 bit) !\n"); + + args[2] = (MCIDEVICEID16)id; + args[1] = HIWORD(yield_data); + args[0] = LOWORD(yield_data); + return WOWCallback16Ex(pfn16, WCB16_PASCAL, sizeof(args), args, NULL); +} + +/****************************************************************** + * MCI_AddThunk + * + */ +static struct mci_thunk* MCI_AddThunk(MCIDEVICEID id, YIELDPROC16 pfn16) +{ + struct mci_thunk* thunk; + + if (!MCI_Thunks) + { + MCI_Thunks = VirtualAlloc(NULL, MCI_MAX_THUNKS * sizeof(*MCI_Thunks), MEM_COMMIT, + PAGE_EXECUTE_READWRITE); + if (!MCI_Thunks) return NULL; + for (thunk = MCI_Thunks; thunk < &MCI_Thunks[MCI_MAX_THUNKS]; thunk++) + { + thunk->popl_eax = 0x58; /* popl %eax */ + thunk->pushl_func = 0x68; /* pushl $pfn16 */ + thunk->yield16 = 0; + thunk->pushl_eax = 0x50; /* pushl %eax */ + thunk->jmp = 0xe9; /* jmp MCI_Yield1632 */ + thunk->callback = (char *)MCI_Yield1632 - (char *)(&thunk->callback + 1); + thunk->id = 0; + } + } + for (thunk = MCI_Thunks; thunk < &MCI_Thunks[MCI_MAX_THUNKS]; thunk++) + { + if (thunk->yield16 == 0) + { + thunk->yield16 = pfn16; + thunk->id = id; + return thunk; + } + } + FIXME("Out of mci-thunks. Bump MCI_MAX_THUNKS\n"); + return NULL; +} + +/****************************************************************** + * MCI_HasThunk + * + */ +static struct mci_thunk* MCI_HasThunk(YIELDPROC pfn) +{ + struct mci_thunk* thunk; + + if (!MCI_Thunks) return NULL; + for (thunk = MCI_Thunks; thunk < &MCI_Thunks[MCI_MAX_THUNKS]; thunk++) + { + if ((YIELDPROC)thunk == pfn) return thunk; + } + return NULL; +} + /************************************************************************** * mciSetYieldProc [MMSYSTEM.714] */ BOOL16 WINAPI mciSetYieldProc16(UINT16 uDeviceID, YIELDPROC16 fpYieldProc, DWORD dwYieldData) { - LPWINE_MCIDRIVER wmd; + struct mci_thunk* thunk; + BOOL ret; TRACE("(%u, %p, %08x)\n", uDeviceID, fpYieldProc, dwYieldData); - if (!(wmd = MCI_GetDriver(uDeviceID))) { - WARN("Bad uDeviceID\n"); - return FALSE; - } - - wmd->lpfnYieldProc = (YIELDPROC)fpYieldProc; - wmd->dwYieldData = dwYieldData; - wmd->bIs32 = FALSE; - - return TRUE; + if (!(thunk = MCI_AddThunk(uDeviceID, fpYieldProc))) + return FALSE; + ret = mciSetYieldProc(uDeviceID, (YIELDPROC)thunk, dwYieldData); + if (!ret) thunk->yield16 = NULL; + return ret; } /************************************************************************** @@ -70,24 +162,17 @@ BOOL16 WINAPI mciSetYieldProc16(UINT16 uDeviceID, YIELDPROC16 fpYieldProc, DWORD */ YIELDPROC16 WINAPI mciGetYieldProc16(UINT16 uDeviceID, DWORD* lpdwYieldData) { - LPWINE_MCIDRIVER wmd; + YIELDPROC yield; + DWORD data; + struct mci_thunk* thunk; TRACE("(%u, %p)\n", uDeviceID, lpdwYieldData); - if (!(wmd = MCI_GetDriver(uDeviceID))) { - WARN("Bad uDeviceID\n"); - return NULL; - } - if (!wmd->lpfnYieldProc) { - WARN("No proc set\n"); - return NULL; - } - if (wmd->bIs32) { - WARN("Proc is 32 bit\n"); - return NULL; - } - if (lpdwYieldData) *lpdwYieldData = wmd->dwYieldData; - return (YIELDPROC16)wmd->lpfnYieldProc; + yield = mciGetYieldProc(uDeviceID, &data); + if (!yield || !(thunk = MCI_HasThunk(yield))) return NULL; + + if (lpdwYieldData) *lpdwYieldData = data; + return thunk->yield16; } /************************************************************************** @@ -127,16 +212,72 @@ BOOL16 WINAPI mciSetDriverData16(UINT16 uDeviceID, DWORD data) /************************************************************************** * mciSendCommand [MMSYSTEM.701] */ -DWORD WINAPI mciSendCommand16(UINT16 wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2) +DWORD WINAPI mciSendCommand16(UINT16 wDevID, UINT16 wMsg, DWORD dwParam1, DWORD p2) { DWORD dwRet; + BOOL to32; + DWORD_PTR dwParam2 = p2; - TRACE("(%04X, %s, %08X, %08X)\n", - wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2); + TRACE("(%04X, %u, %08X, %08lX)\n", wDevID, wMsg, dwParam1, dwParam2); - dwRet = MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2, FALSE); - dwRet = MCI_CleanUp(dwRet, wMsg, (DWORD)MapSL(dwParam2)); - TRACE("=> %d\n", dwRet); + switch (wMsg) { + case MCI_CLOSE: + case MCI_OPEN: + case MCI_SYSINFO: + case MCI_BREAK: + case MCI_SOUND: + to32 = TRUE; + break; + default: + /* FIXME: this is suboptimal. If MCI driver is a 16bit one, we'll be + * doing 16=>32W, then 32W=>16 conversions. + * We could directly call the 16bit driver if we had the information. + */ + to32 = TRUE; + } + if (to32) { + MMSYSTEM_MapType res; + + dwRet = MCIERR_INVALID_DEVICE_ID; + + switch (res = MCI_MapMsg16To32W(wMsg, dwParam1, &dwParam2)) { + case MMSYSTEM_MAP_MSGERROR: + TRACE("Not handled yet (%u)\n", wMsg); + dwRet = MCIERR_DRIVER_INTERNAL; + break; + case MMSYSTEM_MAP_NOMEM: + TRACE("Problem mapping msg=%u from 16 to 32a\n", wMsg); + dwRet = MCIERR_OUT_OF_MEMORY; + break; + case MMSYSTEM_MAP_OK: + case MMSYSTEM_MAP_OKMEM: + dwRet = mciSendCommandW(wDevID, wMsg, dwParam1, dwParam2); + if (res == MMSYSTEM_MAP_OKMEM) + MCI_UnMapMsg16To32W(wMsg, dwParam1, dwParam2); + break; + } + } + else + { +#if 0 + if (wDevID == MCI_ALL_DEVICE_ID) { + FIXME("unhandled MCI_ALL_DEVICE_ID\n"); + dwRet = MCIERR_CANNOT_USE_ALL; + } else { + dwRet = SendDriverMessage(hdrv, wMsg, dwParam1, dwParam2); + } +#endif + } + if (wMsg == MCI_CLOSE && dwRet == 0 && MCI_Thunks) + { + /* free yield thunks, if any */ + unsigned i; + for (i = 0; i < MCI_MAX_THUNKS; i++) + { + if (MCI_Thunks[i].id == wDevID) + MCI_Thunks[i].yield16 = NULL; + } + } return dwRet; } @@ -155,8 +296,7 @@ UINT16 WINAPI mciGetDeviceID16(LPCSTR lpstrName) */ UINT16 WINAPI mciGetDeviceIDFromElementID16(DWORD dwElementID, LPCSTR lpstrType) { - FIXME("(%u, %s) stub\n", dwElementID, lpstrType); - return 0; + return mciGetDeviceIDFromElementIDA(dwElementID, lpstrType); } /************************************************************************** @@ -172,18 +312,7 @@ HTASK16 WINAPI mciGetCreatorTask16(UINT16 uDeviceID) */ UINT16 WINAPI mciDriverYield16(UINT16 uDeviceID) { - LPWINE_MCIDRIVER wmd; - UINT16 ret = 0; - - /* TRACE("(%04x)\n", uDeviceID); */ - - if (!(wmd = MCI_GetDriver(uDeviceID)) || !wmd->lpfnYieldProc || wmd->bIs32) { - UserYield16(); - } else { - ret = wmd->lpfnYieldProc(uDeviceID, wmd->dwYieldData); - } - - return ret; + return mciDriverYield(uDeviceID); } /************************************************************************** diff --git a/dlls/winmm/message16.c b/dlls/winmm/message16.c index 0bbc14afc50..4fc34809fb4 100644 --- a/dlls/winmm/message16.c +++ b/dlls/winmm/message16.c @@ -1850,10 +1850,10 @@ static unsigned MMDRV_LoadMMDrvFunc16(LPCSTR drvName, LPWINE_DRIVER d, /************************************************************************** * MCI_MapMsg16To32W [internal] */ -static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD_PTR* lParam) +MMSYSTEM_MapType MCI_MapMsg16To32W(WORD wMsg, DWORD dwFlags, DWORD_PTR* lParam) { if (*lParam == 0) - return WINMM_MAP_OK; + return MMSYSTEM_MAP_OK; /* FIXME: to add also (with seg/linear modifications to do): * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO @@ -1892,7 +1892,7 @@ static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, case MCI_UPDATE: case MCI_WHERE: *lParam = (DWORD)MapSL(*lParam); - return WINMM_MAP_OK; + return MMSYSTEM_MAP_OK; case MCI_WINDOW: /* in fact, I would also need the dwFlags... to see * which members of lParam are effectively used @@ -1910,11 +1910,11 @@ static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, mbp32->nVirtKey = mbp16->nVirtKey; mbp32->hwndBreak = HWND_32(mbp16->hwndBreak); } else { - return WINMM_MAP_NOMEM; + return MMSYSTEM_MAP_NOMEM; } *lParam = (DWORD)mbp32; } - return WINMM_MAP_OKMEM; + return MMSYSTEM_MAP_OKMEM; case MCI_ESCAPE: { LPMCI_VD_ESCAPE_PARMSW mvep32w = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_VD_ESCAPE_PARMSW)); @@ -1924,11 +1924,11 @@ static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, mvep32w->dwCallback = mvep16->dwCallback; mvep32w->lpstrCommand = MCI_strdupAtoW(MapSL(mvep16->lpstrCommand)); } else { - return WINMM_MAP_NOMEM; + return MMSYSTEM_MAP_NOMEM; } *lParam = (DWORD)mvep32w; } - return WINMM_MAP_OKMEM; + return MMSYSTEM_MAP_OKMEM; case MCI_INFO: { LPMCI_INFO_PARMSW mip32w = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16) + sizeof(MCI_INFO_PARMSW)); @@ -1944,11 +1944,11 @@ static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, mip32w->lpstrReturn = HeapAlloc(GetProcessHeap(), 0, mip16->dwRetSize * sizeof(WCHAR)); mip32w->dwRetSize = mip16->dwRetSize * sizeof(WCHAR); } else { - return WINMM_MAP_NOMEM; + return MMSYSTEM_MAP_NOMEM; } *lParam = (DWORD)mip32w; } - return WINMM_MAP_OKMEM; + return MMSYSTEM_MAP_OKMEM; case MCI_OPEN: case MCI_OPEN_DRIVER: { @@ -1982,11 +1982,11 @@ static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, */ memcpy(mop32w + 1, mop16 + 1, 2 * sizeof(DWORD)); } else { - return WINMM_MAP_NOMEM; + return MMSYSTEM_MAP_NOMEM; } *lParam = (DWORD)mop32w; } - return WINMM_MAP_OKMEM; + return MMSYSTEM_MAP_OKMEM; case MCI_SYSINFO: { LPMCI_SYSINFO_PARMSW msip32w = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16) + sizeof(MCI_SYSINFO_PARMSW)); @@ -2001,11 +2001,11 @@ static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, msip32w->dwNumber = msip16->dwNumber; msip32w->wDeviceType = msip16->wDeviceType; } else { - return WINMM_MAP_NOMEM; + return MMSYSTEM_MAP_NOMEM; } *lParam = (DWORD)msip32w; } - return WINMM_MAP_OKMEM; + return MMSYSTEM_MAP_OKMEM; case MCI_SOUND: { LPMCI_SOUND_PARMSW mbp32 = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_SOUND_PARMSW)); @@ -2015,11 +2015,11 @@ static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, mbp32->dwCallback = mbp16->dwCallback; mbp32->lpstrSoundName = MCI_strdupAtoW(MapSL(mbp16->lpstrSoundName)); } else { - return WINMM_MAP_NOMEM; + return MMSYSTEM_MAP_NOMEM; } *lParam = (DWORD)mbp32; } - return WINMM_MAP_OKMEM; + return MMSYSTEM_MAP_OKMEM; case DRV_LOAD: case DRV_ENABLE: case DRV_OPEN: @@ -2034,17 +2034,17 @@ static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, case DRV_EXITAPPLICATION: case DRV_POWER: FIXME("This is a hack\n"); - return WINMM_MAP_OK; + return MMSYSTEM_MAP_OK; default: FIXME("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg)); } - return WINMM_MAP_MSGERROR; + return MMSYSTEM_MAP_MSGERROR; } /************************************************************************** * MCI_UnMapMsg16To32W [internal] */ -static WINMM_MapType MCI_UnMapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD_PTR lParam) +MMSYSTEM_MapType MCI_UnMapMsg16To32W(WORD wMsg, DWORD dwFlags, DWORD_PTR lParam) { switch (wMsg) { /* case MCI_CAPTURE */ @@ -2079,22 +2079,22 @@ static WINMM_MapType MCI_UnMapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlag case MCI_UNFREEZE: case MCI_UPDATE: case MCI_WHERE: - return WINMM_MAP_OK; + return MMSYSTEM_MAP_OK; case MCI_WINDOW: /* FIXME ?? see Map function */ - return WINMM_MAP_OK; + return MMSYSTEM_MAP_OK; case MCI_BREAK: HeapFree(GetProcessHeap(), 0, (LPVOID)lParam); - return WINMM_MAP_OK; + return MMSYSTEM_MAP_OK; case MCI_ESCAPE: if (lParam) { LPMCI_VD_ESCAPE_PARMSW mvep32W = (LPMCI_VD_ESCAPE_PARMSW)lParam; HeapFree(GetProcessHeap(), 0, (LPVOID)mvep32W->lpstrCommand); HeapFree(GetProcessHeap(), 0, (LPVOID)lParam); } - return WINMM_MAP_OK; + return MMSYSTEM_MAP_OK; case MCI_INFO: if (lParam) { LPMCI_INFO_PARMSW mip32w = (LPMCI_INFO_PARMSW)lParam; @@ -2107,7 +2107,7 @@ static WINMM_MapType MCI_UnMapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlag HeapFree(GetProcessHeap(), 0, mip32w->lpstrReturn); HeapFree(GetProcessHeap(), 0, (LPVOID)lParam); } - return WINMM_MAP_OK; + return MMSYSTEM_MAP_OK; case MCI_SYSINFO: if (lParam) { LPMCI_SYSINFO_PARMSW msip32w = (LPMCI_SYSINFO_PARMSW)lParam; @@ -2120,14 +2120,14 @@ static WINMM_MapType MCI_UnMapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlag HeapFree(GetProcessHeap(), 0, msip32w->lpstrReturn); HeapFree(GetProcessHeap(), 0, (LPVOID)lParam); } - return WINMM_MAP_OK; + return MMSYSTEM_MAP_OK; case MCI_SOUND: if (lParam) { LPMCI_SOUND_PARMSW msp32W = (LPMCI_SOUND_PARMSW)lParam; HeapFree(GetProcessHeap(), 0, (LPVOID)msp32W->lpstrSoundName); HeapFree(GetProcessHeap(), 0, (LPVOID)lParam); } - return WINMM_MAP_OK; + return MMSYSTEM_MAP_OK; case MCI_OPEN: case MCI_OPEN_DRIVER: if (lParam) { @@ -2144,7 +2144,7 @@ static WINMM_MapType MCI_UnMapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlag if (!HeapFree(GetProcessHeap(), 0, (LPVOID)(lParam - sizeof(LPMCI_OPEN_PARMS16)))) FIXME("bad free line=%d\n", __LINE__); } - return WINMM_MAP_OK; + return MMSYSTEM_MAP_OK; case DRV_LOAD: case DRV_ENABLE: case DRV_OPEN: @@ -2159,11 +2159,11 @@ static WINMM_MapType MCI_UnMapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlag case DRV_EXITAPPLICATION: case DRV_POWER: FIXME("This is a hack\n"); - return WINMM_MAP_OK; + return MMSYSTEM_MAP_OK; default: FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg)); } - return WINMM_MAP_MSGERROR; + return MMSYSTEM_MAP_MSGERROR; } /* @@ -2861,8 +2861,6 @@ MMDRV_##_y##_Callback) pFnCallMMDrvFunc16 = MMDRV_CallMMDrvFunc16; pFnLoadMMDrvFunc16 = MMDRV_LoadMMDrvFunc16; - pFnMciMapMsg16To32W = MCI_MapMsg16To32W; - pFnMciUnMapMsg16To32W = MCI_UnMapMsg16To32W; pFnMciMapMsg32WTo16 = MCI_MapMsg32WTo16; pFnMciUnMapMsg32WTo16 = MCI_UnMapMsg32WTo16; } diff --git a/dlls/winmm/winemm.h b/dlls/winmm/winemm.h index 50edb721126..22bf222bea3 100644 --- a/dlls/winmm/winemm.h +++ b/dlls/winmm/winemm.h @@ -197,11 +197,9 @@ BOOL MMDRV_Is32(unsigned int); void MMDRV_InstallMap(unsigned int, MMDRV_MAPFUNC, MMDRV_UNMAPFUNC, MMDRV_MAPFUNC, MMDRV_UNMAPFUNC, LPDRVCALLBACK); -WINE_MCIDRIVER* MCI_GetDriver(UINT16 uDevID); const char* MCI_MessageToString(UINT wMsg); -LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD_PTR dwParam2); -DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2, BOOL bFrom32); -UINT MCI_SetCommandTable(void *table, UINT uDevType); +DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2); +UINT MCI_SetCommandTable(void *table, UINT uDevType); BOOL MCI_DeleteCommandTable(UINT uTbl, BOOL delete); LPWSTR MCI_strdupAtoW(LPCSTR str); LPSTR MCI_strdupWtoA(LPCWSTR str); @@ -239,8 +237,6 @@ extern WINE_MMTHREAD* (*pFnGetMMThread16)(UINT16); extern LPWINE_DRIVER (*pFnOpenDriver16)(LPCWSTR,LPCWSTR,LPARAM); extern LRESULT (*pFnCloseDriver16)(UINT16,LPARAM,LPARAM); extern LRESULT (*pFnSendMessage16)(UINT16,UINT,LPARAM,LPARAM); -extern WINMM_MapType (*pFnMciMapMsg16To32W)(WORD,WORD,DWORD,DWORD_PTR*); -extern WINMM_MapType (*pFnMciUnMapMsg16To32W)(WORD,WORD,DWORD,DWORD_PTR); extern WINMM_MapType (*pFnMciMapMsg32WTo16)(WORD,WORD,DWORD,DWORD_PTR*); extern WINMM_MapType (*pFnMciUnMapMsg32WTo16)(WORD,WORD,DWORD,DWORD_PTR); extern LRESULT (*pFnCallMMDrvFunc16)(DWORD /* in fact FARPROC16 */,WORD,WORD,LONG,LONG,LONG); diff --git a/dlls/winmm/winemm16.h b/dlls/winmm/winemm16.h index a64e28c0f11..a4f9254780f 100644 --- a/dlls/winmm/winemm16.h +++ b/dlls/winmm/winemm16.h @@ -54,3 +54,13 @@ typedef LONG (*MCIPROC16)(DWORD, HDRVR16, WORD, DWORD, DWORD); #define HWAVE_16(h32) (LOWORD(h32)) #define HWAVEIN_16(h32) (LOWORD(h32)) #define HWAVEOUT_16(h32) (LOWORD(h32)) + +typedef enum { + MMSYSTEM_MAP_NOMEM, /* ko, memory problem */ + MMSYSTEM_MAP_MSGERROR, /* ko, unknown message */ + MMSYSTEM_MAP_OK, /* ok, no memory allocated. to be sent to the proc. */ + MMSYSTEM_MAP_OKMEM, /* ok, some memory allocated, need to call UnMapMsg. to be sent to the proc. */ +} MMSYSTEM_MapType; + +extern MMSYSTEM_MapType MCI_MapMsg16To32W(WORD,DWORD,DWORD_PTR*); +extern MMSYSTEM_MapType MCI_UnMapMsg16To32W(WORD,DWORD,DWORD_PTR); diff --git a/dlls/winmm/winmm.c b/dlls/winmm/winmm.c index de043c1f4de..0e42df71e7d 100644 --- a/dlls/winmm/winmm.c +++ b/dlls/winmm/winmm.c @@ -191,7 +191,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad) break; case DLL_PROCESS_DETACH: /* close all opened MCI drivers */ - MCI_SendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_WAIT, 0L, TRUE); + MCI_SendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_WAIT, 0L); MMDRV_Exit(); /* There's no guarantee the drivers haven't already been unloaded on * process shutdown.