Commit 9becf85a authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

All MCI functions are now cleanly separated.

parent b4df16b3
......@@ -32,9 +32,8 @@
#include "wingdi.h"
#include "winreg.h"
#include "winuser.h"
#include "winnls.h"
#include "wine/mmsystem16.h"
#include "wine/winbase16.h"
#include "digitalv.h"
#include "winemm.h"
......@@ -43,7 +42,12 @@
WINE_DEFAULT_DEBUG_CHANNEL(mci);
static int MCI_InstalledCount;
static LPSTR MCI_lpInstallNames = NULL;
static LPSTR MCI_lpInstallNames /* = NULL */;
WINMM_MapType (*pFnMciMapMsg16To32A) (WORD,WORD,DWORD*) /* = NULL */;
WINMM_MapType (*pFnMciUnMapMsg16To32A)(WORD,WORD,DWORD) /* = NULL */;
WINMM_MapType (*pFnMciMapMsg32ATo16) (WORD,WORD,DWORD,DWORD*) /* = NULL */;
WINMM_MapType (*pFnMciUnMapMsg32ATo16)(WORD,WORD,DWORD,DWORD) /* = NULL */;
/* First MCI valid device ID (0 means error) */
#define MCI_MAGIC 0x0001
......@@ -450,10 +454,10 @@ static BOOL MCI_OpenMciDriver(LPWINE_MCIDRIVER wmd, LPCSTR drvTyp, LPARAM lp)
/* First load driver */
if ((wmd->hDriver = (HDRVR)DRIVER_TryOpenDriver32(libName, lp))) {
wmd->bIs32 = TRUE;
} else {
} else if (WINMM_CheckForMMSystem() && pFnMciMapMsg32ATo16) {
WINMM_MapType res;
switch (res = MCI_MapMsg32ATo16(0, DRV_OPEN, 0, &lp)) {
switch (res = pFnMciMapMsg32ATo16(0, DRV_OPEN, 0, &lp)) {
case WINMM_MAP_MSGERROR:
TRACE("Not handled yet (DRV_OPEN)\n");
break;
......@@ -465,7 +469,7 @@ static BOOL MCI_OpenMciDriver(LPWINE_MCIDRIVER wmd, LPCSTR drvTyp, LPARAM lp)
if ((wmd->hDriver = OpenDriverA(drvTyp, "mci", lp)))
wmd->bIs32 = FALSE;
if (res == WINMM_MAP_OKMEM)
MCI_UnMapMsg32ATo16(0, DRV_OPEN, 0, lp);
pFnMciUnMapMsg32ATo16(0, DRV_OPEN, 0, lp);
break;
}
}
......@@ -1151,10 +1155,10 @@ DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwPa
if (wmd) {
if (wmd->bIs32) {
dwRet = SendDriverMessage(wmd->hDriver, wMsg, dwParam1, dwParam2);
} else {
} else if (pFnMciMapMsg32ATo16) {
WINMM_MapType res;
switch (res = MCI_MapMsg32ATo16(wmd->wType, wMsg, dwParam1, &dwParam2)) {
switch (res = pFnMciMapMsg32ATo16(wmd->wType, wMsg, dwParam1, &dwParam2)) {
case WINMM_MAP_MSGERROR:
TRACE("Not handled yet (%s)\n", MCI_MessageToString(wMsg));
dwRet = MCIERR_DRIVER_INTERNAL;
......@@ -1167,7 +1171,7 @@ DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwPa
case WINMM_MAP_OKMEM:
dwRet = SendDriverMessage(wmd->hDriver, wMsg, dwParam1, dwParam2);
if (res == WINMM_MAP_OKMEM)
MCI_UnMapMsg32ATo16(wmd->wType, wMsg, dwParam1, dwParam2);
pFnMciUnMapMsg32ATo16(wmd->wType, wMsg, dwParam1, dwParam2);
break;
}
}
......@@ -1186,10 +1190,10 @@ DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwPa
if (wmd) {
dwRet = MCIERR_INVALID_DEVICE_ID;
if (wmd->bIs32) {
if (wmd->bIs32 && pFnMciMapMsg16To32A) {
WINMM_MapType res;
switch (res = MCI_MapMsg16To32A(wmd->wType, wMsg, &dwParam2)) {
switch (res = pFnMciMapMsg16To32A(wmd->wType, wMsg, &dwParam2)) {
case WINMM_MAP_MSGERROR:
TRACE("Not handled yet (%s)\n", MCI_MessageToString(wMsg));
dwRet = MCIERR_DRIVER_INTERNAL;
......@@ -1202,7 +1206,7 @@ DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwPa
case WINMM_MAP_OKMEM:
dwRet = SendDriverMessage(wmd->hDriver, wMsg, dwParam1, dwParam2);
if (res == WINMM_MAP_OKMEM)
MCI_UnMapMsg16To32A(wmd->wType, wMsg, dwParam2);
pFnMciUnMapMsg16To32A(wmd->wType, wMsg, dwParam2);
break;
}
} else {
......@@ -1517,12 +1521,12 @@ DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1,
case MCI_OPEN:
if (bFrom32) {
dwRet = MCI_Open(dwParam1, (LPMCI_OPEN_PARMSA)dwParam2);
} else {
switch (MCI_MapMsg16To32A(0, wMsg, &dwParam2)) {
} else if (pFnMciMapMsg16To32A) {
switch (pFnMciMapMsg16To32A(0, wMsg, &dwParam2)) {
case WINMM_MAP_OK:
case WINMM_MAP_OKMEM:
dwRet = MCI_Open(dwParam1, (LPMCI_OPEN_PARMSA)dwParam2);
MCI_UnMapMsg16To32A(0, wMsg, dwParam2);
pFnMciUnMapMsg16To32A(0, wMsg, dwParam2);
break;
default: break; /* so that gcc does not bark */
}
......@@ -1531,12 +1535,12 @@ DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1,
case MCI_CLOSE:
if (bFrom32) {
dwRet = MCI_Close(wDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
} else {
switch (MCI_MapMsg16To32A(0, wMsg, &dwParam2)) {
} else if (pFnMciMapMsg16To32A) {
switch (pFnMciMapMsg16To32A(0, wMsg, &dwParam2)) {
case WINMM_MAP_OK:
case WINMM_MAP_OKMEM:
dwRet = MCI_Close(wDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
MCI_UnMapMsg16To32A(0, wMsg, dwParam2);
pFnMciUnMapMsg16To32A(0, wMsg, dwParam2);
break;
default: break; /* so that gcc does not bark */
}
......@@ -1545,12 +1549,12 @@ DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1,
case MCI_SYSINFO:
if (bFrom32) {
dwRet = MCI_SysInfo(wDevID, dwParam1, (LPMCI_SYSINFO_PARMSA)dwParam2);
} else {
switch (MCI_MapMsg16To32A(0, wMsg, &dwParam2)) {
} else if (pFnMciMapMsg16To32A) {
switch (pFnMciMapMsg16To32A(0, wMsg, &dwParam2)) {
case WINMM_MAP_OK:
case WINMM_MAP_OKMEM:
dwRet = MCI_SysInfo(wDevID, dwParam1, (LPMCI_SYSINFO_PARMSA)dwParam2);
MCI_UnMapMsg16To32A(0, wMsg, dwParam2);
pFnMciUnMapMsg16To32A(0, wMsg, dwParam2);
break;
default: break; /* so that gcc doesnot bark */
}
......@@ -1559,12 +1563,12 @@ DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1,
case MCI_BREAK:
if (bFrom32) {
dwRet = MCI_Break(wDevID, dwParam1, (LPMCI_BREAK_PARMS)dwParam2);
} else {
switch (MCI_MapMsg16To32A(0, wMsg, &dwParam2)) {
} else if (pFnMciMapMsg16To32A) {
switch (pFnMciMapMsg16To32A(0, wMsg, &dwParam2)) {
case WINMM_MAP_OK:
case WINMM_MAP_OKMEM:
dwRet = MCI_Break(wDevID, dwParam1, (LPMCI_BREAK_PARMS)dwParam2);
MCI_UnMapMsg16To32A(0, wMsg, dwParam2);
pFnMciUnMapMsg16To32A(0, wMsg, dwParam2);
break;
default: break; /* so that gcc does not bark */
}
......@@ -1596,7 +1600,7 @@ DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD 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 dwParam2, BOOL bIs32)
LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2)
{
if (LOWORD(dwRet))
return LOWORD(dwRet);
......@@ -1615,7 +1619,7 @@ LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2, BOOL bIs32)
{
LPMCI_GETDEVCAPS_PARMS lmgp;
lmgp = (LPMCI_GETDEVCAPS_PARMS)(bIs32 ? (void*)dwParam2 : MapSL(dwParam2));
lmgp = (LPMCI_GETDEVCAPS_PARMS)(void*)dwParam2;
TRACE("Changing %08lx to %08lx\n", lmgp->dwReturn, (DWORD)LOWORD(lmgp->dwReturn));
lmgp->dwReturn = LOWORD(lmgp->dwReturn);
}
......@@ -1638,7 +1642,7 @@ LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2, BOOL bIs32)
{
LPMCI_STATUS_PARMS lsp;
lsp = (LPMCI_STATUS_PARMS)(bIs32 ? (void*)dwParam2 : MapSL(dwParam2));
lsp = (LPMCI_STATUS_PARMS)(void*)dwParam2;
TRACE("Changing %08lx to %08lx\n", lsp->dwReturn, (DWORD)LOWORD(lsp->dwReturn));
lsp->dwReturn = LOWORD(lsp->dwReturn);
}
......@@ -1669,12 +1673,12 @@ LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2, BOOL bIs32)
}
/**************************************************************************
* MULTIMEDIA_MciInit [internal]
* MCI_Init [internal]
*
* Initializes the MCI internal variables.
*
*/
BOOL MULTIMEDIA_MciInit(void)
BOOL MCI_Init(void)
{
LPSTR ptr1, ptr2;
HKEY hWineConf;
......
......@@ -1765,7 +1765,7 @@ theEnd:
/**************************************************************************
* MCI_MapMsg16To32A [internal]
*/
WINMM_MapType MCI_MapMsg16To32A(WORD uDevType, WORD wMsg, DWORD* lParam)
static WINMM_MapType MCI_MapMsg16To32A(WORD uDevType, WORD wMsg, DWORD* lParam)
{
if (*lParam == 0)
return WINMM_MAP_OK;
......@@ -1933,7 +1933,7 @@ WINMM_MapType MCI_MapMsg16To32A(WORD uDevType, WORD wMsg, DWORD* lParam)
/**************************************************************************
* MCI_UnMapMsg16To32A [internal]
*/
WINMM_MapType MCI_UnMapMsg16To32A(WORD uDevType, WORD wMsg, DWORD lParam)
static WINMM_MapType MCI_UnMapMsg16To32A(WORD uDevType, WORD wMsg, DWORD lParam)
{
switch (wMsg) {
/* case MCI_CAPTURE */
......@@ -2180,7 +2180,7 @@ static WINMM_MapType MCI_MsgMapper32To16_Destroy(void* ptr, int size16, DWORD ma
*
* Map a 32-A bit MCI message to a 16 bit MCI message.
*/
WINMM_MapType MCI_MapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD* lParam)
static WINMM_MapType MCI_MapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD* lParam)
{
int size;
BOOLEAN keep = FALSE;
......@@ -2487,7 +2487,7 @@ WINMM_MapType MCI_MapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD*
/**************************************************************************
* MCI_UnMapMsg32ATo16 [internal]
*/
WINMM_MapType MCI_UnMapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD lParam)
static WINMM_MapType MCI_UnMapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD lParam)
{
int size = 0;
BOOLEAN kept = FALSE; /* there is no need to compute size when kept is FALSE */
......@@ -2667,3 +2667,10 @@ WINMM_MapType MCI_UnMapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD
return MCI_MsgMapper32To16_Destroy((void*)lParam, size, map, kept);
}
void MMDRV_Init16(void)
{
pFnMciMapMsg16To32A = MCI_MapMsg16To32A;
pFnMciUnMapMsg16To32A = MCI_UnMapMsg16To32A;
pFnMciMapMsg32ATo16 = MCI_MapMsg32ATo16;
pFnMciUnMapMsg32ATo16 = MCI_UnMapMsg32ATo16;
}
......@@ -88,6 +88,7 @@ BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
pFnCloseDriver16 = DRIVER_CloseDriver16;
pFnSendMessage16 = DRIVER_SendMessage16;
pFnMmioCallback16 = MMIO_Callback16;
MMDRV_Init16();
break;
case DLL_PROCESS_DETACH:
WINMM_IData->hWinMM16Instance = 0;
......@@ -96,6 +97,7 @@ BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
pFnCloseDriver16 = NULL;
pFnSendMessage16 = NULL;
pFnMmioCallback16 = NULL;
/* FIXME: add equivalent for MMDRV_Init16() */
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
......@@ -555,7 +557,7 @@ DWORD WINAPI mciSendCommand16(UINT16 wDevID, UINT16 wMsg, DWORD dwParam1, DWORD
wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2);
dwRet = MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2, FALSE);
dwRet = MCI_CleanUp(dwRet, wMsg, dwParam2, FALSE);
dwRet = MCI_CleanUp(dwRet, wMsg, (DWORD)MapSL(dwParam2));
TRACE("=> %ld\n", dwRet);
return dwRet;
}
......
......@@ -244,12 +244,13 @@ DWORD MMDRV_Message(LPWINE_MLD mld, WORD wMsg, DWORD dwParam1, DWORD dwParam2,
UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD dwParam1, DWORD dwParam2);
BOOL MMDRV_Is32(unsigned int);
BOOL MCI_Init(void);
WINE_MCIDRIVER* MCI_GetDriver(UINT16 uDevID);
UINT MCI_GetDriverFromString(LPCSTR str);
DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr);
const char* MCI_MessageToString(UINT16 wMsg);
UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data);
LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2, BOOL bIs32);
LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2);
DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32);
DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2);
DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2);
......@@ -283,17 +284,12 @@ LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1,
LPARAM lParam2, enum mmioProcType type);
LPWINE_MMIO MMIO_Get(HMMIO h);
BOOL MULTIMEDIA_MciInit(void);
BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode);
void TIME_MMTimeStart(void);
void TIME_MMTimeStop(void);
/* temporary definitions */
WINMM_MapType MCI_MapMsg16To32A (WORD uDevType, WORD wMsg, DWORD* lParam);
WINMM_MapType MCI_UnMapMsg16To32A(WORD uDevType, WORD wMsg, DWORD lParam);
WINMM_MapType MCI_MapMsg32ATo16 (WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD* lParam);
WINMM_MapType MCI_UnMapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD lParam);
void MMDRV_Callback(LPWINE_MLD mld, HDRVR hDev, UINT uMsg, DWORD dwParam1, DWORD dwParam2);
WINMM_MapType MMDRV_Aux_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2);
......@@ -340,11 +336,18 @@ extern LPWINE_MM_IDATA WINMM_IData;
/* pointers to 16 bit functions (if sibling MMSYSTEM.DLL is loaded
* NULL otherwise
*/
extern LRESULT (*pFnMmioCallback16)(SEGPTR,LPMMIOINFO,UINT,LPARAM,LPARAM);
extern WINE_MMTHREAD* (*pFnGetMMThread16)(HANDLE16);
extern LPWINE_DRIVER (*pFnOpenDriver16)(LPCSTR,LPCSTR,LPARAM);
extern LRESULT (*pFnCloseDriver16)(HDRVR16,LPARAM,LPARAM);
extern LRESULT (*pFnSendMessage16)(HDRVR16,UINT,LPARAM,LPARAM);
extern WINE_MMTHREAD* (*pFnGetMMThread16)(HANDLE16);
extern WINMM_MapType (*pFnMciMapMsg16To32A)(WORD,WORD,DWORD*);
extern WINMM_MapType (*pFnMciUnMapMsg16To32A)(WORD,WORD,DWORD);
extern WINMM_MapType (*pFnMciMapMsg32ATo16)(WORD,WORD,DWORD,DWORD*);
extern WINMM_MapType (*pFnMciUnMapMsg32ATo16)(WORD,WORD,DWORD,DWORD);
extern LRESULT (*pFnMmioCallback16)(SEGPTR,LPMMIOINFO,UINT,LPARAM,LPARAM);
/* mmsystem only functions */
void MMDRV_Init16(void);
/* HANDLE16 -> HANDLE conversions */
#define HDRVR_32(h16) ((HDRVR)(ULONG_PTR)(h16))
......
......@@ -148,7 +148,7 @@ BOOL WINAPI WINMM_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
case DLL_PROCESS_ATTACH:
if (!WINMM_CreateIData(hInstDLL))
return FALSE;
if (!MULTIMEDIA_MciInit() || !MMDRV_Init()) {
if (!MCI_Init() || !MMDRV_Init()) {
WINMM_DeleteIData();
return FALSE;
}
......@@ -781,7 +781,7 @@ DWORD WINAPI mciSendCommandA(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwPar
wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2);
dwRet = MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2, TRUE);
dwRet = MCI_CleanUp(dwRet, wMsg, dwParam2, TRUE);
dwRet = MCI_CleanUp(dwRet, wMsg, dwParam2);
TRACE("=> %08lx\n", dwRet);
return dwRet;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment