Commit be6d014f authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Add Unicode->ANSI MCI message mapping, implement mciSendCommandW, fix

a bug with a window creation belonging to another hInstance, add support for MCI_WINDOW command in mciavi.drv, add support for MCI_PLAY and MCI_STOP in the MCIWndClass implementation.
parent 042f8953
...@@ -60,7 +60,7 @@ typedef struct ...@@ -60,7 +60,7 @@ typedef struct
SendMessageW((info)->hwndOwner, MCIWNDM_NOTIFYMODE, (WPARAM)(info)->hWnd, (LPARAM)SendMessageW((info)->hWnd, MCIWNDM_GETMODEW, 0, 0)) SendMessageW((info)->hwndOwner, MCIWNDM_NOTIFYMODE, (WPARAM)(info)->hWnd, (LPARAM)SendMessageW((info)->hWnd, MCIWNDM_GETMODEW, 0, 0))
#define MCIWND_NOTIFY_SIZE(info) \ #define MCIWND_NOTIFY_SIZE(info) \
if (mwi->dwStyle & MCIWNDF_NOTIFYSIZE) \ if ((info)->dwStyle & MCIWNDF_NOTIFYSIZE) \
SendMessageW((info)->hwndOwner, MCIWNDM_NOTIFYSIZE, (WPARAM)(info)->hWnd, 0); SendMessageW((info)->hwndOwner, MCIWNDM_NOTIFYSIZE, (WPARAM)(info)->hWnd, 0);
#define MCIWND_NOTIFY_ERROR(info) \ #define MCIWND_NOTIFY_ERROR(info) \
...@@ -84,7 +84,13 @@ BOOL VFWAPIV MCIWndRegisterClass(HINSTANCE hInst) ...@@ -84,7 +84,13 @@ BOOL VFWAPIV MCIWndRegisterClass(HINSTANCE hInst)
{ {
WNDCLASSW wc; WNDCLASSW wc;
wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS | CS_OWNDC; /* Since we are going to register a class belonging to MSVFW32
* and later we will create windows with a different hInstance
* CS_GLOBALCLASS is needed. And because the second attempt
* to register a global class will fail we need to test whether
* the class was already registered.
*/
wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS | CS_OWNDC | CS_GLOBALCLASS;
wc.lpfnWndProc = MCIWndProc; wc.lpfnWndProc = MCIWndProc;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(MCIWndInfo*); wc.cbWndExtra = sizeof(MCIWndInfo*);
...@@ -95,7 +101,10 @@ BOOL VFWAPIV MCIWndRegisterClass(HINSTANCE hInst) ...@@ -95,7 +101,10 @@ BOOL VFWAPIV MCIWndRegisterClass(HINSTANCE hInst)
wc.lpszMenuName = NULL; wc.lpszMenuName = NULL;
wc.lpszClassName = mciWndClassW; wc.lpszClassName = mciWndClassW;
return RegisterClassW(&wc); if (RegisterClassW(&wc)) return TRUE;
if (GetLastError() == ERROR_CLASS_ALREADY_EXISTS) return TRUE;
return FALSE;
} }
/*********************************************************************** /***********************************************************************
...@@ -394,7 +403,6 @@ static LRESULT WINAPI MCIWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lPa ...@@ -394,7 +403,6 @@ static LRESULT WINAPI MCIWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lPa
MCIWND_NOTIFY_MODE(mwi); MCIWND_NOTIFY_MODE(mwi);
return 0; return 0;
case MCIWNDM_OPENA: case MCIWNDM_OPENA:
{ {
UNICODE_STRING nameW; UNICODE_STRING nameW;
...@@ -450,10 +458,6 @@ static LRESULT WINAPI MCIWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lPa ...@@ -450,10 +458,6 @@ static LRESULT WINAPI MCIWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lPa
(DWORD_PTR)&mci_devcaps); (DWORD_PTR)&mci_devcaps);
if (mwi->lasterror) if (mwi->lasterror)
{ {
WCHAR error_str[MAXERRORLENGTH];
mciGetErrorStringW(mwi->lasterror, error_str, MAXERRORLENGTH);
MCIWND_NOTIFY_ERROR(mwi); MCIWND_NOTIFY_ERROR(mwi);
goto end_of_mci_open; goto end_of_mci_open;
} }
...@@ -486,10 +490,8 @@ static LRESULT WINAPI MCIWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lPa ...@@ -486,10 +490,8 @@ static LRESULT WINAPI MCIWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lPa
if (!(mwi->dwStyle & MCIWNDF_NOPLAYBAR)) if (!(mwi->dwStyle & MCIWNDF_NOPLAYBAR))
rc.bottom += 32; /* add the height of the playbar */ rc.bottom += 32; /* add the height of the playbar */
SetWindowPos(hWnd, 0, 0, 0, rc.right - rc.left, SetWindowPos(hWnd, 0, 0, 0, rc.right - rc.left,
rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER); rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
if (mwi->dwStyle & MCIWNDF_NOOPEN)
ShowWindow(mwi->hWnd, SW_SHOW);
MCIWND_NOTIFY_MEDIA(mwi); MCIWND_NOTIFY_MEDIA(mwi);
SendDlgItemMessageW(hWnd, CTL_TRACKBAR, TBM_SETRANGEMIN, 0L, 0L); SendDlgItemMessageW(hWnd, CTL_TRACKBAR, TBM_SETRANGEMIN, 0L, 0L);
...@@ -670,6 +672,27 @@ end_of_mci_open: ...@@ -670,6 +672,27 @@ end_of_mci_open:
mwi->hwndOwner = (HWND)wParam; mwi->hwndOwner = (HWND)wParam;
return 0; return 0;
case MCI_PLAY:
{
LRESULT end = SendMessageW(hWnd, MCIWNDM_GETEND, 0, 0);
return SendMessageW(hWnd, MCIWNDM_PLAYTO, 0, end);
}
case MCI_STOP:
{
MCI_GENERIC_PARMS mci_generic;
mci_generic.dwCallback = 0;
mwi->lasterror = mciSendCommandW(mwi->mci, MCI_STOP, 0, (DWORD_PTR)&mci_generic);
if (mwi->lasterror)
{
MCIWND_NOTIFY_ERROR(mwi);
return mwi->lasterror;
}
return 0;
}
case MCI_SEEK: case MCI_SEEK:
{ {
MCI_SEEK_PARMS mci_seek; MCI_SEEK_PARMS mci_seek;
...@@ -697,16 +720,20 @@ end_of_mci_open: ...@@ -697,16 +720,20 @@ end_of_mci_open:
} }
case MCI_CLOSE: case MCI_CLOSE:
if (mwi->mci)
{ {
MCI_GENERIC_PARMS mci_generic; MCI_GENERIC_PARMS mci_generic;
mci_generic.dwCallback = 0; mci_generic.dwCallback = 0;
mciSendCommandW(mwi->mci, MCI_CLOSE, 0, (DWORD_PTR)&mci_generic); mwi->lasterror = mciSendCommandW(mwi->mci, MCI_CLOSE, 0, (DWORD_PTR)&mci_generic);
mwi->mci = 0;
if (mwi->lasterror)
{
MCIWND_NOTIFY_ERROR(mwi);
return mwi->lasterror;
} }
return 0; return 0;
} }
}
if ((wMsg >= WM_USER) && (wMsg < WM_APP)) if ((wMsg >= WM_USER) && (wMsg < WM_APP))
{ {
......
...@@ -1157,7 +1157,7 @@ BOOL WINAPI mciFreeCommandResource(UINT uTable) ...@@ -1157,7 +1157,7 @@ BOOL WINAPI mciFreeCommandResource(UINT uTable)
/************************************************************************** /**************************************************************************
* MCI_SendCommandFrom32 [internal] * MCI_SendCommandFrom32 [internal]
*/ */
DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2) DWORD MCI_SendCommandFrom32(MCIDEVICEID wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
{ {
DWORD dwRet = MCIERR_INVALID_DEVICE_ID; DWORD dwRet = MCIERR_INVALID_DEVICE_ID;
LPWINE_MCIDRIVER wmd = MCI_GetDriver(wDevID); LPWINE_MCIDRIVER wmd = MCI_GetDriver(wDevID);
...@@ -1192,7 +1192,7 @@ DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwPa ...@@ -1192,7 +1192,7 @@ DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwPa
/************************************************************************** /**************************************************************************
* MCI_SendCommandFrom16 [internal] * MCI_SendCommandFrom16 [internal]
*/ */
DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2) DWORD MCI_SendCommandFrom16(MCIDEVICEID wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
{ {
DWORD dwRet = MCIERR_INVALID_DEVICE_ID; DWORD dwRet = MCIERR_INVALID_DEVICE_ID;
LPWINE_MCIDRIVER wmd = MCI_GetDriver(wDevID); LPWINE_MCIDRIVER wmd = MCI_GetDriver(wDevID);
......
...@@ -401,8 +401,8 @@ DWORD MCIAVI_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_DGV_STATUS_PARMSA lpPar ...@@ -401,8 +401,8 @@ DWORD MCIAVI_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_DGV_STATUS_PARMSA lpPar
TRACE("MCI_DGV_STATUS_HPAL => %lx\n", lpParms->dwReturn); TRACE("MCI_DGV_STATUS_HPAL => %lx\n", lpParms->dwReturn);
break; break;
case MCI_DGV_STATUS_HWND: case MCI_DGV_STATUS_HWND:
lpParms->dwReturn = (DWORD)wma->hWnd; lpParms->dwReturn = (DWORD)wma->hWndPaint;
TRACE("MCI_DGV_STATUS_HWND => %p\n", wma->hWnd); TRACE("MCI_DGV_STATUS_HWND => %p\n", wma->hWndPaint);
break; break;
#if 0 #if 0
case MCI_DGV_STATUS_KEY_COLOR: case MCI_DGV_STATUS_KEY_COLOR:
......
...@@ -135,7 +135,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad) ...@@ -135,7 +135,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
static DWORD MCIAVI_drvOpen(LPSTR str, LPMCI_OPEN_DRIVER_PARMSA modp) static DWORD MCIAVI_drvOpen(LPSTR str, LPMCI_OPEN_DRIVER_PARMSA modp)
{ {
WINE_MCIAVI* wma; WINE_MCIAVI* wma;
static WCHAR mciAviWStr[] = {'M','C','I','A','V','I',0}; static const WCHAR mciAviWStr[] = {'M','C','I','A','V','I',0};
if (!modp) return 0xFFFFFFFF; if (!modp) return 0xFFFFFFFF;
...@@ -356,7 +356,7 @@ static DWORD MCIAVI_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms ...@@ -356,7 +356,7 @@ static DWORD MCIAVI_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms
if (wma == NULL) return MCIERR_INVALID_DEVICE_ID; if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
if (!wma->hFile) return MCIERR_FILE_NOT_FOUND; if (!wma->hFile) return MCIERR_FILE_NOT_FOUND;
if (!wma->hWnd) return MCIERR_NO_WINDOW; if (!wma->hWndPaint) return MCIERR_NO_WINDOW;
wma->dwStatus = MCI_MODE_PLAY; wma->dwStatus = MCI_MODE_PLAY;
...@@ -365,7 +365,7 @@ static DWORD MCIAVI_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms ...@@ -365,7 +365,7 @@ static DWORD MCIAVI_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms
(DWORD)lpParms, sizeof(MCI_PLAY_PARMS)); (DWORD)lpParms, sizeof(MCI_PLAY_PARMS));
} }
ShowWindow(wma->hWnd, SW_SHOW); ShowWindow(wma->hWndPaint, SW_SHOW);
dwFromFrame = wma->dwCurrVideoFrame; dwFromFrame = wma->dwCurrVideoFrame;
dwToFrame = wma->dwPlayableVideoFrames - 1; dwToFrame = wma->dwPlayableVideoFrames - 1;
......
...@@ -575,13 +575,12 @@ LRESULT MCIAVI_DrawFrame(WINE_MCIAVI* wma) ...@@ -575,13 +575,12 @@ LRESULT MCIAVI_DrawFrame(WINE_MCIAVI* wma)
return FALSE; return FALSE;
} }
if (IsWindowVisible(wma->hWnd) && (hDC = GetDC(wma->hWnd)) != 0) { if (IsWindowVisible(wma->hWndPaint) && (hDC = GetDC(wma->hWndPaint)) != 0) {
MCIAVI_PaintFrame(wma, hDC); MCIAVI_PaintFrame(wma, hDC);
ReleaseDC(wma->hWnd, hDC); ReleaseDC(wma->hWndPaint, hDC);
} }
LeaveCriticalSection(&wma->cs); LeaveCriticalSection(&wma->cs);
return TRUE; return TRUE;
} }
...@@ -72,7 +72,7 @@ typedef struct { ...@@ -72,7 +72,7 @@ typedef struct {
HANDLE hEvent; /* for synchronization */ HANDLE hEvent; /* for synchronization */
DWORD dwEventCount; /* for synchronization */ DWORD dwEventCount; /* for synchronization */
/* data for play back */ /* data for play back */
HWND hWnd; HWND hWnd, hWndPaint;
DWORD dwCurrVideoFrame; /* video frame to display and current position */ DWORD dwCurrVideoFrame; /* video frame to display and current position */
DWORD dwCurrAudioBlock; /* current audio block being played */ DWORD dwCurrAudioBlock; /* current audio block being played */
/* data for the background mechanism */ /* data for the background mechanism */
......
...@@ -87,6 +87,7 @@ BOOL MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARM ...@@ -87,6 +87,7 @@ BOOL MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARM
HWND hParent = 0; HWND hParent = 0;
DWORD dwStyle = WS_OVERLAPPEDWINDOW; DWORD dwStyle = WS_OVERLAPPEDWINDOW;
int p = CW_USEDEFAULT; int p = CW_USEDEFAULT;
RECT rc;
/* what should be done ? */ /* what should be done ? */
if (wma->hWnd) return TRUE; if (wma->hWnd) return TRUE;
...@@ -106,11 +107,17 @@ BOOL MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARM ...@@ -106,11 +107,17 @@ BOOL MCIAVI_CreateWindow(WINE_MCIAVI* wma, DWORD dwFlags, LPMCI_DGV_OPEN_PARM
if (dwFlags & MCI_DGV_OPEN_WS) dwStyle = lpOpenParms->dwStyle; if (dwFlags & MCI_DGV_OPEN_WS) dwStyle = lpOpenParms->dwStyle;
if (dwStyle & WS_CHILD) p = 0; if (dwStyle & WS_CHILD) p = 0;
rc.left = p;
rc.top = p;
rc.right = (wma->hic ? wma->outbih : wma->inbih)->biWidth;
rc.bottom = (wma->hic ? wma->outbih : wma->inbih)->biHeight;
AdjustWindowRect(&rc, dwStyle, FALSE);
wma->hWnd = CreateWindowA("MCIAVI", "Wine MCI-AVI player", wma->hWnd = CreateWindowA("MCIAVI", "Wine MCI-AVI player",
dwStyle, p, p, dwStyle, rc.left, rc.top,
(wma->hic ? wma->outbih : wma->inbih)->biWidth, rc.right, rc.bottom,
(wma->hic ? wma->outbih : wma->inbih)->biHeight,
hParent, 0, MCIAVI_hInstance, wma); hParent, 0, MCIAVI_hInstance, wma);
wma->hWndPaint = wma->hWnd;
return (BOOL)wma->hWnd; return (BOOL)wma->hWnd;
} }
...@@ -193,7 +200,7 @@ DWORD MCIAVI_mciWhere(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms) ...@@ -193,7 +200,7 @@ DWORD MCIAVI_mciWhere(UINT wDevID, DWORD dwFlags, LPMCI_DGV_RECT_PARMS lpParms)
} }
if (dwFlags & MCI_DGV_WHERE_WINDOW) { if (dwFlags & MCI_DGV_WHERE_WINDOW) {
x = "Window"; x = "Window";
GetClientRect(wma->hWnd, &lpParms->rc); GetClientRect(wma->hWndPaint, &lpParms->rc);
} }
TRACE("%s -> (%ld,%ld,%ld,%ld)\n", TRACE("%s -> (%ld,%ld,%ld,%ld)\n",
x, lpParms->rc.left, lpParms->rc.top, lpParms->rc.right, lpParms->rc.bottom); x, lpParms->rc.left, lpParms->rc.top, lpParms->rc.right, lpParms->rc.bottom);
...@@ -214,20 +221,18 @@ DWORD MCIAVI_mciWindow(UINT wDevID, DWORD dwFlags, LPMCI_DGV_WINDOW_PARMSA lpPar ...@@ -214,20 +221,18 @@ DWORD MCIAVI_mciWindow(UINT wDevID, DWORD dwFlags, LPMCI_DGV_WINDOW_PARMSA lpPar
if (wma == NULL) return MCIERR_INVALID_DEVICE_ID; if (wma == NULL) return MCIERR_INVALID_DEVICE_ID;
if (dwFlags & MCI_DGV_WINDOW_HWND) { if (dwFlags & MCI_DGV_WINDOW_HWND) {
FIXME("Setting hWnd to %08lx\n", (DWORD)lpParms->hWnd); TRACE("Setting hWnd to %p\n", lpParms->hWnd);
#if 0 if (wma->hWnd) ShowWindow(wma->hWnd, SW_HIDE);
if (wma->hWnd) DestroyWindow(wma->hWnd); wma->hWndPaint = (lpParms->hWnd == MCI_DGV_WINDOW_DEFAULT) ? wma->hWnd : lpParms->hWnd;
/* is the window to be subclassed ? */ InvalidateRect(wma->hWndPaint, NULL, FALSE);
wma->hWnd = lpParms->hWnd;
#endif
} }
if (dwFlags & MCI_DGV_WINDOW_STATE) { if (dwFlags & MCI_DGV_WINDOW_STATE) {
TRACE("Setting nCmdShow to %d\n", lpParms->nCmdShow); TRACE("Setting nCmdShow to %d\n", lpParms->nCmdShow);
ShowWindow(wma->hWnd, lpParms->nCmdShow); ShowWindow(wma->hWndPaint, lpParms->nCmdShow);
} }
if (dwFlags & MCI_DGV_WINDOW_TEXT) { if (dwFlags & MCI_DGV_WINDOW_TEXT) {
TRACE("Setting caption to '%s'\n", lpParms->lpstrText); TRACE("Setting caption to '%s'\n", lpParms->lpstrText);
SetWindowTextA(wma->hWnd, lpParms->lpstrText); SetWindowTextA(wma->hWndPaint, lpParms->lpstrText);
} }
return 0; return 0;
......
...@@ -707,20 +707,19 @@ UINT WINAPI auxOutMessage(UINT uDeviceID, UINT uMessage, DWORD dw1, DWORD dw2) ...@@ -707,20 +707,19 @@ UINT WINAPI auxOutMessage(UINT uDeviceID, UINT uMessage, DWORD dw1, DWORD dw2)
/************************************************************************** /**************************************************************************
* mciGetErrorStringW [WINMM.@] * mciGetErrorStringW [WINMM.@]
*/ */
BOOL WINAPI mciGetErrorStringW(DWORD wError, LPWSTR lpstrBuffer, UINT uLength) BOOL WINAPI mciGetErrorStringW(MCIERROR wError, LPWSTR lpstrBuffer, UINT uLength)
{ {
LPSTR bufstr = HeapAlloc(GetProcessHeap(), 0, uLength); char bufstr[MAXERRORLENGTH];
BOOL ret = mciGetErrorStringA(wError, bufstr, uLength); BOOL ret = mciGetErrorStringA(wError, bufstr, MAXERRORLENGTH);
MultiByteToWideChar( CP_ACP, 0, bufstr, -1, lpstrBuffer, uLength ); MultiByteToWideChar( CP_ACP, 0, bufstr, -1, lpstrBuffer, uLength );
HeapFree(GetProcessHeap(), 0, bufstr);
return ret; return ret;
} }
/************************************************************************** /**************************************************************************
* mciGetErrorStringA [WINMM.@] * mciGetErrorStringA [WINMM.@]
*/ */
BOOL WINAPI mciGetErrorStringA(DWORD dwError, LPSTR lpstrBuffer, UINT uLength) BOOL WINAPI mciGetErrorStringA(MCIERROR dwError, LPSTR lpstrBuffer, UINT uLength)
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
...@@ -738,18 +737,18 @@ BOOL WINAPI mciGetErrorStringA(DWORD dwError, LPSTR lpstrBuffer, UINT uLength) ...@@ -738,18 +737,18 @@ BOOL WINAPI mciGetErrorStringA(DWORD dwError, LPSTR lpstrBuffer, UINT uLength)
/************************************************************************** /**************************************************************************
* mciDriverNotify [WINMM.@] * mciDriverNotify [WINMM.@]
*/ */
BOOL WINAPI mciDriverNotify(HWND hWndCallBack, UINT wDevID, UINT wStatus) BOOL WINAPI mciDriverNotify(HWND hWndCallBack, MCIDEVICEID wDevID, UINT wStatus)
{ {
TRACE("(%p, %04x, %04X)\n", hWndCallBack, wDevID, wStatus); TRACE("(%p, %04x, %04X)\n", hWndCallBack, wDevID, wStatus);
return PostMessageA(hWndCallBack, MM_MCINOTIFY, wStatus, wDevID); return PostMessageW(hWndCallBack, MM_MCINOTIFY, wStatus, wDevID);
} }
/************************************************************************** /**************************************************************************
* mciGetDriverData [WINMM.@] * mciGetDriverData [WINMM.@]
*/ */
DWORD WINAPI mciGetDriverData(UINT uDeviceID) DWORD WINAPI mciGetDriverData(MCIDEVICEID uDeviceID)
{ {
LPWINE_MCIDRIVER wmd; LPWINE_MCIDRIVER wmd;
...@@ -768,7 +767,7 @@ DWORD WINAPI mciGetDriverData(UINT uDeviceID) ...@@ -768,7 +767,7 @@ DWORD WINAPI mciGetDriverData(UINT uDeviceID)
/************************************************************************** /**************************************************************************
* mciSetDriverData [WINMM.@] * mciSetDriverData [WINMM.@]
*/ */
BOOL WINAPI mciSetDriverData(UINT uDeviceID, DWORD data) BOOL WINAPI mciSetDriverData(MCIDEVICEID uDeviceID, DWORD data)
{ {
LPWINE_MCIDRIVER wmd; LPWINE_MCIDRIVER wmd;
...@@ -788,7 +787,7 @@ BOOL WINAPI mciSetDriverData(UINT uDeviceID, DWORD data) ...@@ -788,7 +787,7 @@ BOOL WINAPI mciSetDriverData(UINT uDeviceID, DWORD data)
/************************************************************************** /**************************************************************************
* mciSendCommandA [WINMM.@] * mciSendCommandA [WINMM.@]
*/ */
DWORD WINAPI mciSendCommandA(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2) DWORD WINAPI mciSendCommandA(MCIDEVICEID wDevID, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
{ {
DWORD dwRet; DWORD dwRet;
...@@ -801,14 +800,189 @@ DWORD WINAPI mciSendCommandA(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwPar ...@@ -801,14 +800,189 @@ DWORD WINAPI mciSendCommandA(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwPar
return dwRet; return dwRet;
} }
inline static LPSTR strdupWtoA( LPCWSTR str )
{
LPSTR ret;
INT len;
if (!str) return NULL;
len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
ret = HeapAlloc( GetProcessHeap(), 0, len );
if(ret) WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
return ret;
}
static int MCI_MapMsgWtoA(UINT msg, DWORD_PTR dwParam1, DWORD_PTR *dwParam2)
{
switch(msg)
{
case MCI_CLOSE:
case MCI_PLAY:
case MCI_SEEK:
case MCI_STOP:
case MCI_PAUSE:
case MCI_GETDEVCAPS:
case MCI_SPIN:
case MCI_SET:
case MCI_STEP:
case MCI_RECORD:
case MCI_BREAK:
case MCI_SOUND:
case MCI_STATUS:
case MCI_CUE:
case MCI_REALIZE:
case MCI_PUT:
case MCI_WHERE:
case MCI_FREEZE:
case MCI_UNFREEZE:
case MCI_CUT:
case MCI_COPY:
case MCI_PASTE:
case MCI_UPDATE:
case MCI_RESUME:
case MCI_DELETE:
return 0;
case MCI_OPEN:
{
MCI_OPEN_PARMSW *mci_openW = (MCI_OPEN_PARMSW *)*dwParam2;
MCI_OPEN_PARMSA *mci_openA;
DWORD_PTR *ptr;
ptr = HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_openA) + sizeof(DWORD_PTR));
if (!ptr) return -1;
*ptr++ = *dwParam2; /* save the previous pointer */
*dwParam2 = (DWORD_PTR)ptr;
mci_openA = (MCI_OPEN_PARMSA *)ptr;
if (dwParam1 & MCI_NOTIFY)
mci_openA->dwCallback = mci_openW->dwCallback;
if (dwParam1 & MCI_OPEN_TYPE)
{
if (dwParam1 & MCI_OPEN_TYPE_ID)
mci_openA->lpstrDeviceType = (LPSTR)mci_openW->lpstrDeviceType;
else
mci_openA->lpstrDeviceType = strdupWtoA(mci_openW->lpstrDeviceType);
}
if (dwParam1 & MCI_OPEN_ELEMENT)
{
if (dwParam1 & MCI_OPEN_ELEMENT_ID)
mci_openA->lpstrElementName = (LPSTR)mci_openW->lpstrElementName;
else
mci_openA->lpstrElementName = strdupWtoA(mci_openW->lpstrElementName);
}
if (dwParam1 & MCI_OPEN_ALIAS)
mci_openA->lpstrAlias = strdupWtoA(mci_openW->lpstrAlias);
}
return 1;
case MCI_WINDOW:
if (dwParam1 & MCI_ANIM_WINDOW_TEXT)
{
MCI_ANIM_WINDOW_PARMSW *mci_windowW = (MCI_ANIM_WINDOW_PARMSW *)*dwParam2;
MCI_ANIM_WINDOW_PARMSA *mci_windowA;
mci_windowA = HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_windowA));
if (!mci_windowA) return -1;
*dwParam2 = (DWORD_PTR)mci_windowA;
mci_windowA->lpstrText = strdupWtoA(mci_windowW->lpstrText);
if (dwParam1 & MCI_NOTIFY)
mci_windowA->dwCallback = mci_windowW->dwCallback;
if (dwParam1 & MCI_ANIM_WINDOW_HWND)
mci_windowA->hWnd = mci_windowW->hWnd;
if (dwParam1 & MCI_ANIM_WINDOW_STATE)
mci_windowA->nCmdShow = mci_windowW->nCmdShow;
return 1;
}
return 0;
case MCI_INFO:
case MCI_SYSINFO:
case MCI_SAVE:
case MCI_LOAD:
case MCI_ESCAPE:
default:
FIXME("Message 0x%04x needs translation\n", msg);
return -1;
}
return 0;
}
static void MCI_UnmapMsgWtoA(UINT msg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
{
switch(msg)
{
case MCI_OPEN:
{
DWORD_PTR *ptr = (DWORD_PTR *)dwParam2 - 1;
MCI_OPEN_PARMSW *mci_openW = (MCI_OPEN_PARMSW *)*ptr;
MCI_OPEN_PARMSA *mci_openA = (MCI_OPEN_PARMSA *)(ptr + 1);
mci_openW->wDeviceID = mci_openA->wDeviceID;
if (dwParam1 & MCI_OPEN_TYPE)
{
if (!(dwParam1 & MCI_OPEN_TYPE_ID))
HeapFree(GetProcessHeap(), 0, mci_openA->lpstrDeviceType);
}
if (dwParam1 & MCI_OPEN_ELEMENT)
{
if (!(dwParam1 & MCI_OPEN_ELEMENT_ID))
HeapFree(GetProcessHeap(), 0, mci_openA->lpstrElementName);
}
if (dwParam1 & MCI_OPEN_ALIAS)
HeapFree(GetProcessHeap(), 0, mci_openA->lpstrAlias);
HeapFree(GetProcessHeap(), 0, ptr);
}
break;
case MCI_WINDOW:
if (dwParam1 & MCI_ANIM_WINDOW_TEXT)
{
MCI_ANIM_WINDOW_PARMSA *mci_windowA = (MCI_ANIM_WINDOW_PARMSA *)dwParam2;
HeapFree(GetProcessHeap(), 0, (void *)mci_windowA->lpstrText);
HeapFree(GetProcessHeap(), 0, mci_windowA);
}
break;
default:
FIXME("Message 0x%04x needs unmapping\n", msg);
break;
}
}
/************************************************************************** /**************************************************************************
* mciSendCommandW [WINMM.@] * mciSendCommandW [WINMM.@]
*
* FIXME: we should do the things other way around, but since our
* MM subsystem is not unicode aware...
*/ */
DWORD WINAPI mciSendCommandW(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2) DWORD WINAPI mciSendCommandW(MCIDEVICEID wDevID, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
{ {
FIXME("(%08x, %s, %08lx, %08lx): stub\n", DWORD ret;
int mapped;
TRACE("(%08x, %s, %08lx, %08lx)\n",
wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2); wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2);
return MCIERR_UNSUPPORTED_FUNCTION;
mapped = MCI_MapMsgWtoA(wMsg, dwParam1, &dwParam2);
if (mapped == -1)
{
FIXME("message %04x mapping failed\n", wMsg);
return MMSYSERR_NOMEM;
}
ret = mciSendCommandA(wDevID, wMsg, dwParam1, dwParam2);
if (mapped)
MCI_UnmapMsgWtoA(wMsg, dwParam1, dwParam2);
return ret;
} }
/************************************************************************** /**************************************************************************
...@@ -864,7 +1038,7 @@ UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data) ...@@ -864,7 +1038,7 @@ UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data)
/************************************************************************** /**************************************************************************
* mciSetYieldProc [WINMM.@] * mciSetYieldProc [WINMM.@]
*/ */
BOOL WINAPI mciSetYieldProc(UINT uDeviceID, YIELDPROC fpYieldProc, DWORD dwYieldData) BOOL WINAPI mciSetYieldProc(MCIDEVICEID uDeviceID, YIELDPROC fpYieldProc, DWORD dwYieldData)
{ {
LPWINE_MCIDRIVER wmd; LPWINE_MCIDRIVER wmd;
...@@ -897,7 +1071,7 @@ UINT WINAPI mciGetDeviceIDFromElementIDW(DWORD dwElementID, LPCWSTR lpstrType) ...@@ -897,7 +1071,7 @@ UINT WINAPI mciGetDeviceIDFromElementIDW(DWORD dwElementID, LPCWSTR lpstrType)
/************************************************************************** /**************************************************************************
* mciGetYieldProc [WINMM.@] * mciGetYieldProc [WINMM.@]
*/ */
YIELDPROC WINAPI mciGetYieldProc(UINT uDeviceID, DWORD* lpdwYieldData) YIELDPROC WINAPI mciGetYieldProc(MCIDEVICEID uDeviceID, DWORD* lpdwYieldData)
{ {
LPWINE_MCIDRIVER wmd; LPWINE_MCIDRIVER wmd;
...@@ -921,7 +1095,7 @@ YIELDPROC WINAPI mciGetYieldProc(UINT uDeviceID, DWORD* lpdwYieldData) ...@@ -921,7 +1095,7 @@ YIELDPROC WINAPI mciGetYieldProc(UINT uDeviceID, DWORD* lpdwYieldData)
/************************************************************************** /**************************************************************************
* mciGetCreatorTask [WINMM.@] * mciGetCreatorTask [WINMM.@]
*/ */
HTASK WINAPI mciGetCreatorTask(UINT uDeviceID) HTASK WINAPI mciGetCreatorTask(MCIDEVICEID uDeviceID)
{ {
LPWINE_MCIDRIVER wmd; LPWINE_MCIDRIVER wmd;
HTASK ret = 0; HTASK ret = 0;
...@@ -935,7 +1109,7 @@ HTASK WINAPI mciGetCreatorTask(UINT uDeviceID) ...@@ -935,7 +1109,7 @@ HTASK WINAPI mciGetCreatorTask(UINT uDeviceID)
/************************************************************************** /**************************************************************************
* mciDriverYield [WINMM.@] * mciDriverYield [WINMM.@]
*/ */
UINT WINAPI mciDriverYield(UINT uDeviceID) UINT WINAPI mciDriverYield(MCIDEVICEID uDeviceID)
{ {
LPWINE_MCIDRIVER wmd; LPWINE_MCIDRIVER wmd;
UINT ret = 0; UINT ret = 0;
......
...@@ -1407,8 +1407,8 @@ MMRESULT WINAPI mmioCreateChunk(HMMIO,MMCKINFO*,UINT); ...@@ -1407,8 +1407,8 @@ MMRESULT WINAPI mmioCreateChunk(HMMIO,MMCKINFO*,UINT);
typedef UINT (CALLBACK *YIELDPROC)(MCIDEVICEID,DWORD); typedef UINT (CALLBACK *YIELDPROC)(MCIDEVICEID,DWORD);
DWORD WINAPI mciSendCommandA(UINT,UINT,DWORD,DWORD); DWORD WINAPI mciSendCommandA(MCIDEVICEID,UINT,DWORD_PTR,DWORD_PTR);
DWORD WINAPI mciSendCommandW(UINT,UINT,DWORD,DWORD); DWORD WINAPI mciSendCommandW(MCIDEVICEID,UINT,DWORD_PTR,DWORD_PTR);
#define mciSendCommand WINELIB_NAME_AW(mciSendCommand) #define mciSendCommand WINELIB_NAME_AW(mciSendCommand)
DWORD WINAPI mciSendStringA(LPCSTR,LPSTR,UINT,HWND); DWORD WINAPI mciSendStringA(LPCSTR,LPSTR,UINT,HWND);
DWORD WINAPI mciSendStringW(LPCWSTR,LPWSTR,UINT,HWND); DWORD WINAPI mciSendStringW(LPCWSTR,LPWSTR,UINT,HWND);
...@@ -1416,12 +1416,12 @@ DWORD WINAPI mciSendStringW(LPCWSTR,LPWSTR,UINT,HWND); ...@@ -1416,12 +1416,12 @@ DWORD WINAPI mciSendStringW(LPCWSTR,LPWSTR,UINT,HWND);
UINT WINAPI mciGetDeviceIDA(LPCSTR); UINT WINAPI mciGetDeviceIDA(LPCSTR);
UINT WINAPI mciGetDeviceIDW(LPCWSTR); UINT WINAPI mciGetDeviceIDW(LPCWSTR);
#define mciGetDeviceID WINELIB_NAME_AW(mciGetDeviceID) #define mciGetDeviceID WINELIB_NAME_AW(mciGetDeviceID)
BOOL WINAPI mciGetErrorStringA(DWORD,LPSTR,UINT); BOOL WINAPI mciGetErrorStringA(MCIERROR,LPSTR,UINT);
BOOL WINAPI mciGetErrorStringW(DWORD,LPWSTR,UINT); BOOL WINAPI mciGetErrorStringW(MCIERROR,LPWSTR,UINT);
#define mciGetErrorString WINELIB_NAME_AW(mciGetErrorString) #define mciGetErrorString WINELIB_NAME_AW(mciGetErrorString)
BOOL WINAPI mciSetYieldProc(UINT,YIELDPROC,DWORD); BOOL WINAPI mciSetYieldProc(MCIDEVICEID,YIELDPROC,DWORD);
HTASK WINAPI mciGetCreatorTask(UINT); HTASK WINAPI mciGetCreatorTask(MCIDEVICEID);
YIELDPROC WINAPI mciGetYieldProc(UINT,DWORD*); YIELDPROC WINAPI mciGetYieldProc(MCIDEVICEID,DWORD*);
#define MCIERR_INVALID_DEVICE_ID (MCIERR_BASE + 1) #define MCIERR_INVALID_DEVICE_ID (MCIERR_BASE + 1)
#define MCIERR_UNRECOGNIZED_KEYWORD (MCIERR_BASE + 3) #define MCIERR_UNRECOGNIZED_KEYWORD (MCIERR_BASE + 3)
......
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