4 * Copyright 1993 Martin Ayotte
5 * 1998-2003,2009 Eric Pouech
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
35 #include "wine/winuser16.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(mmsys);
43 /**************************************************************************
44 * MCI_MessageToString [internal]
46 static const char* MCI_MessageToString(UINT wMsg)
48 static char buffer[100];
50 #define CASE(s) case (s): return #s
60 CASE(DRV_QUERYCONFIGURE);
63 CASE(DRV_EXITSESSION);
64 CASE(DRV_EXITAPPLICATION);
68 CASE(MCI_CLOSE_DRIVER);
81 CASE(MCI_OPEN_DRIVER);
100 /* constants for digital video */
114 sprintf(buffer, "MCI_<<%04X>>", wMsg);
119 static LPWSTR MCI_strdupAtoW( LPCSTR str )
124 if (!str) return NULL;
125 len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
126 ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
127 if (ret) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
131 /**************************************************************************
132 * MCI_MapMsg16To32W [internal]
134 static MMSYSTEM_MapType MCI_MapMsg16To32W(WORD wMsg, DWORD dwFlags, DWORD_PTR* lParam)
137 return MMSYSTEM_MAP_OK;
138 /* FIXME: to add also (with seg/linear modifications to do):
139 * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE
140 * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO
143 /* case MCI_CAPTURE */
145 case MCI_CLOSE_DRIVER:
152 /* case MCI_INDEX: */
154 /* case MCI_MONITOR: */
163 /* case MCI_SETTIMECODE:*/
164 /* case MCI_SIGNAL:*/
170 *lParam = (DWORD)MapSL(*lParam);
171 return MMSYSTEM_MAP_OK;
177 LPMCI_DGV_RECT_PARMS mdrp32 = HeapAlloc(GetProcessHeap(), 0,
178 sizeof(LPMCI_DGV_RECT_PARMS16) + sizeof(MCI_DGV_RECT_PARMS));
179 LPMCI_DGV_RECT_PARMS16 mdrp16 = MapSL(*lParam);
181 *(LPMCI_DGV_RECT_PARMS16*)(mdrp32) = mdrp16;
182 mdrp32 = (LPMCI_DGV_RECT_PARMS)((char*)mdrp32 + sizeof(LPMCI_DGV_RECT_PARMS16));
183 mdrp32->dwCallback = mdrp16->dwCallback;
184 mdrp32->rc.left = mdrp16->rc.left;
185 mdrp32->rc.top = mdrp16->rc.top;
186 mdrp32->rc.right = mdrp16->rc.right;
187 mdrp32->rc.bottom = mdrp16->rc.bottom;
189 return MMSYSTEM_MAP_NOMEM;
191 *lParam = (DWORD)mdrp32;
193 return MMSYSTEM_MAP_OKMEM;
196 if (dwFlags & (MCI_DGV_STATUS_REFERENCE | MCI_DGV_STATUS_DISKSPACE)) {
197 LPMCI_DGV_STATUS_PARMSW mdsp32w = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
198 sizeof(LPMCI_DGV_STATUS_PARMS16) + sizeof(MCI_DGV_STATUS_PARMSW));
199 LPMCI_DGV_STATUS_PARMS16 mdsp16 = MapSL(*lParam);
201 *(LPMCI_DGV_STATUS_PARMS16*)(mdsp32w) = mdsp16;
202 mdsp32w = (LPMCI_DGV_STATUS_PARMSW)((char*)mdsp32w + sizeof(LPMCI_DGV_STATUS_PARMS16));
203 mdsp32w->dwCallback = mdsp16->dwCallback;
204 mdsp32w->dwReturn = mdsp16->dwReturn;
205 mdsp32w->dwItem = mdsp16->dwItem;
206 mdsp32w->dwTrack = mdsp16->dwTrack;
207 if (dwFlags & MCI_DGV_STATUS_DISKSPACE)
208 mdsp32w->lpstrDrive = MCI_strdupAtoW(MapSL(mdsp16->lpstrDrive));
209 mdsp32w->dwReference = mdsp16->dwReference;
210 *lParam = (DWORD)mdsp32w;
212 return MMSYSTEM_MAP_NOMEM;
215 *lParam = (DWORD)MapSL(*lParam);
218 return MMSYSTEM_MAP_OKMEM;
221 LPMCI_OVLY_WINDOW_PARMSW mowp32w = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MCI_OVLY_WINDOW_PARMSW));
222 LPMCI_OVLY_WINDOW_PARMS16 mowp16 = MapSL(*lParam);
224 mowp32w->dwCallback = mowp16->dwCallback;
225 mowp32w->hWnd = HWND_32(mowp16->hWnd);
226 mowp32w->nCmdShow = mowp16->nCmdShow;
227 if (dwFlags & (MCI_DGV_WINDOW_TEXT | MCI_OVLY_WINDOW_TEXT))
228 mowp32w->lpstrText = MCI_strdupAtoW(MapSL(mowp16->lpstrText));
230 return MMSYSTEM_MAP_NOMEM;
232 *lParam = (DWORD)mowp32w;
234 return MMSYSTEM_MAP_OKMEM;
237 LPMCI_BREAK_PARMS mbp32 = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_BREAK_PARMS));
238 LPMCI_BREAK_PARMS16 mbp16 = MapSL(*lParam);
241 mbp32->dwCallback = mbp16->dwCallback;
242 mbp32->nVirtKey = mbp16->nVirtKey;
243 mbp32->hwndBreak = HWND_32(mbp16->hwndBreak);
245 return MMSYSTEM_MAP_NOMEM;
247 *lParam = (DWORD)mbp32;
249 return MMSYSTEM_MAP_OKMEM;
252 LPMCI_VD_ESCAPE_PARMSW mvep32w = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_VD_ESCAPE_PARMSW));
253 LPMCI_VD_ESCAPE_PARMS16 mvep16 = MapSL(*lParam);
256 mvep32w->dwCallback = mvep16->dwCallback;
257 mvep32w->lpstrCommand = MCI_strdupAtoW(MapSL(mvep16->lpstrCommand));
259 return MMSYSTEM_MAP_NOMEM;
261 *lParam = (DWORD)mvep32w;
263 return MMSYSTEM_MAP_OKMEM;
266 LPMCI_INFO_PARMSW mip32w = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16) + sizeof(MCI_INFO_PARMSW));
267 LPMCI_INFO_PARMS16 mip16 = MapSL(*lParam);
269 /* FIXME this is wrong if device is of type
270 * MCI_DEVTYPE_DIGITAL_VIDEO, some members are not mapped
273 *(LPMCI_INFO_PARMS16*)(mip32w) = mip16;
274 mip32w = (LPMCI_INFO_PARMSW)((char*)mip32w + sizeof(LPMCI_INFO_PARMS16));
275 mip32w->dwCallback = mip16->dwCallback;
276 mip32w->lpstrReturn = HeapAlloc(GetProcessHeap(), 0, mip16->dwRetSize * sizeof(WCHAR));
277 mip32w->dwRetSize = mip16->dwRetSize * sizeof(WCHAR);
279 return MMSYSTEM_MAP_NOMEM;
281 *lParam = (DWORD)mip32w;
283 return MMSYSTEM_MAP_OKMEM;
285 case MCI_OPEN_DRIVER:
287 LPMCI_OPEN_PARMSW mop32w = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16) + sizeof(MCI_OPEN_PARMSW) + 2 * sizeof(DWORD));
288 LPMCI_OPEN_PARMS16 mop16 = MapSL(*lParam);
291 *(LPMCI_OPEN_PARMS16*)(mop32w) = mop16;
292 mop32w = (LPMCI_OPEN_PARMSW)((char*)mop32w + sizeof(LPMCI_OPEN_PARMS16));
293 mop32w->dwCallback = mop16->dwCallback;
294 mop32w->wDeviceID = mop16->wDeviceID;
295 if( ( dwFlags & ( MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID)) == MCI_OPEN_TYPE)
296 mop32w->lpstrDeviceType = MCI_strdupAtoW(MapSL(mop16->lpstrDeviceType));
298 mop32w->lpstrDeviceType = (LPWSTR) mop16->lpstrDeviceType;
299 if( ( dwFlags & ( MCI_OPEN_ELEMENT | MCI_OPEN_ELEMENT_ID)) == MCI_OPEN_ELEMENT)
300 mop32w->lpstrElementName = MCI_strdupAtoW(MapSL(mop16->lpstrElementName));
302 mop32w->lpstrElementName = (LPWSTR) mop16->lpstrElementName;
303 if( ( dwFlags & MCI_OPEN_ALIAS))
304 mop32w->lpstrAlias = MCI_strdupAtoW(MapSL(mop16->lpstrAlias));
306 mop32w->lpstrAlias = (LPWSTR) mop16->lpstrAlias;
307 /* copy extended information if any...
308 * FIXME: this may seg fault if initial structure does not contain them and
309 * the reads after msip16 fail under LDT limits...
310 * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and
311 * should not take care of extended parameters, and should be used by MCI_Open
312 * to fetch uDevType. When, this is known, the mapping for sending the
313 * MCI_OPEN_DRIVER shall be done depending on uDevType.
315 memcpy(mop32w + 1, mop16 + 1, 2 * sizeof(DWORD));
317 return MMSYSTEM_MAP_NOMEM;
319 *lParam = (DWORD)mop32w;
321 return MMSYSTEM_MAP_OKMEM;
324 MCI_SYSINFO_PARMSW *msip32w = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_OPEN_PARMS16 *) + sizeof(MCI_SYSINFO_PARMSW));
325 MCI_SYSINFO_PARMS16 *msip16 = MapSL(*lParam);
328 return MMSYSTEM_MAP_NOMEM;
330 *(MCI_SYSINFO_PARMS16 **)msip32w = msip16;
331 msip32w = (MCI_SYSINFO_PARMSW *)((char *)msip32w + sizeof(MCI_OPEN_PARMS16 *));
332 msip32w->dwCallback = msip16->dwCallback;
333 msip32w->lpstrReturn = HeapAlloc(GetProcessHeap(), 0, (dwFlags & MCI_SYSINFO_QUANTITY) ?
335 msip16->dwRetSize * sizeof(WCHAR));
336 if (!msip32w->lpstrReturn)
338 HeapFree(GetProcessHeap(), 0, msip32w);
339 return MMSYSTEM_MAP_NOMEM;
341 msip32w->dwRetSize = (dwFlags & MCI_SYSINFO_QUANTITY) ? sizeof(DWORD) : msip16->dwRetSize;
342 msip32w->dwNumber = msip16->dwNumber;
343 msip32w->wDeviceType = msip16->wDeviceType;
345 *lParam = (DWORD)msip32w;
347 return MMSYSTEM_MAP_OKMEM;
350 LPMCI_SOUND_PARMSW mbp32 = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_SOUND_PARMSW));
351 LPMCI_SOUND_PARMS16 mbp16 = MapSL(*lParam);
354 mbp32->dwCallback = mbp16->dwCallback;
355 mbp32->lpstrSoundName = MCI_strdupAtoW(MapSL(mbp16->lpstrSoundName));
357 return MMSYSTEM_MAP_NOMEM;
359 *lParam = (DWORD)mbp32;
361 return MMSYSTEM_MAP_OKMEM;
369 case DRV_QUERYCONFIGURE:
372 case DRV_EXITSESSION:
373 case DRV_EXITAPPLICATION:
375 FIXME("This is a hack\n");
376 return MMSYSTEM_MAP_OK;
378 FIXME("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg));
380 return MMSYSTEM_MAP_MSGERROR;
383 /**************************************************************************
384 * MCI_UnMapMsg16To32W [internal]
386 static MMSYSTEM_MapType MCI_UnMapMsg16To32W(WORD wMsg, DWORD dwFlags, DWORD_PTR lParam)
389 /* case MCI_CAPTURE */
391 case MCI_CLOSE_DRIVER:
398 /* case MCI_INDEX: */
400 /* case MCI_MONITOR: */
409 /* case MCI_SETTIMECODE:*/
410 /* case MCI_SIGNAL:*/
416 return MMSYSTEM_MAP_OK;
423 LPMCI_DGV_RECT_PARMS mdrp32 = (LPMCI_DGV_RECT_PARMS)lParam;
424 char *base = (char*)lParam - sizeof(LPMCI_DGV_RECT_PARMS16);
425 LPMCI_DGV_RECT_PARMS16 mdrp16 = *(LPMCI_DGV_RECT_PARMS16*)base;
426 mdrp16->dwCallback = mdrp32->dwCallback;
427 mdrp16->rc.left = mdrp32->rc.left;
428 mdrp16->rc.top = mdrp32->rc.top;
429 mdrp16->rc.right = mdrp32->rc.right;
430 mdrp16->rc.bottom = mdrp32->rc.bottom;
431 HeapFree(GetProcessHeap(), 0, base);
433 return MMSYSTEM_MAP_OK;
435 if (lParam && (dwFlags & (MCI_DGV_STATUS_REFERENCE | MCI_DGV_STATUS_DISKSPACE))) {
436 LPMCI_DGV_STATUS_PARMSW mdsp32w = (LPMCI_DGV_STATUS_PARMSW)lParam;
437 char *base = (char*)lParam - sizeof(LPMCI_DGV_STATUS_PARMS16);
438 LPMCI_DGV_STATUS_PARMS16 mdsp16 = *(LPMCI_DGV_STATUS_PARMS16*)base;
439 mdsp16->dwCallback = mdsp32w->dwCallback;
440 mdsp16->dwReturn = mdsp32w->dwReturn;
441 mdsp16->dwItem = mdsp32w->dwItem;
442 mdsp16->dwTrack = mdsp32w->dwTrack;
443 mdsp16->dwReference = mdsp32w->dwReference;
444 HeapFree(GetProcessHeap(), 0, (LPVOID)mdsp32w->lpstrDrive);
445 HeapFree(GetProcessHeap(), 0, base);
447 return MMSYSTEM_MAP_OK;
450 LPMCI_OVLY_WINDOW_PARMSW mowp32w = (LPMCI_OVLY_WINDOW_PARMSW)lParam;
451 HeapFree(GetProcessHeap(), 0, (LPVOID)mowp32w->lpstrText);
452 HeapFree(GetProcessHeap(), 0, mowp32w);
454 return MMSYSTEM_MAP_OK;
457 HeapFree(GetProcessHeap(), 0, (LPVOID)lParam);
458 return MMSYSTEM_MAP_OK;
461 LPMCI_VD_ESCAPE_PARMSW mvep32W = (LPMCI_VD_ESCAPE_PARMSW)lParam;
462 HeapFree(GetProcessHeap(), 0, (LPVOID)mvep32W->lpstrCommand);
463 HeapFree(GetProcessHeap(), 0, (LPVOID)lParam);
465 return MMSYSTEM_MAP_OK;
468 LPMCI_INFO_PARMSW mip32w = (LPMCI_INFO_PARMSW)lParam;
469 char *base = (char*)lParam - sizeof(LPMCI_INFO_PARMS16);
470 LPMCI_INFO_PARMS16 mip16 = *(LPMCI_INFO_PARMS16*)base;
472 WideCharToMultiByte(CP_ACP, 0,
473 mip32w->lpstrReturn, mip32w->dwRetSize / sizeof(WCHAR),
474 MapSL(mip16->lpstrReturn), mip16->dwRetSize,
476 HeapFree(GetProcessHeap(), 0, mip32w->lpstrReturn);
477 HeapFree(GetProcessHeap(), 0, base);
479 return MMSYSTEM_MAP_OK;
482 MCI_SYSINFO_PARMSW *msip32w = (MCI_SYSINFO_PARMSW *)lParam;
483 char *base = (char*)lParam - sizeof(MCI_SYSINFO_PARMS16 *);
484 MCI_SYSINFO_PARMS16 *msip16 = *(MCI_SYSINFO_PARMS16 **)base;
486 if (dwFlags & MCI_SYSINFO_QUANTITY) {
487 DWORD *quantity = MapSL(msip16->lpstrReturn);
489 *quantity = *(DWORD *)msip32w->lpstrReturn;
492 WideCharToMultiByte(CP_ACP, 0,
493 msip32w->lpstrReturn, msip32w->dwRetSize,
494 MapSL(msip16->lpstrReturn), msip16->dwRetSize,
498 HeapFree(GetProcessHeap(), 0, msip32w->lpstrReturn);
499 HeapFree(GetProcessHeap(), 0, base);
501 return MMSYSTEM_MAP_OK;
504 LPMCI_SOUND_PARMSW msp32W = (LPMCI_SOUND_PARMSW)lParam;
505 HeapFree(GetProcessHeap(), 0, (LPVOID)msp32W->lpstrSoundName);
506 HeapFree(GetProcessHeap(), 0, (LPVOID)lParam);
508 return MMSYSTEM_MAP_OK;
510 case MCI_OPEN_DRIVER:
512 LPMCI_OPEN_PARMSW mop32w = (LPMCI_OPEN_PARMSW)lParam;
513 char *base = (char*)lParam - sizeof(LPMCI_OPEN_PARMS16);
514 LPMCI_OPEN_PARMS16 mop16 = *(LPMCI_OPEN_PARMS16*)base;
516 mop16->wDeviceID = mop32w->wDeviceID;
517 if( ( dwFlags & ( MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID)) == MCI_OPEN_TYPE)
518 HeapFree(GetProcessHeap(), 0, (LPWSTR)mop32w->lpstrDeviceType);
519 if( ( dwFlags & ( MCI_OPEN_ELEMENT | MCI_OPEN_ELEMENT_ID)) == MCI_OPEN_ELEMENT)
520 HeapFree(GetProcessHeap(), 0, (LPWSTR)mop32w->lpstrElementName);
521 if( ( dwFlags & MCI_OPEN_ALIAS))
522 HeapFree(GetProcessHeap(), 0, (LPWSTR)mop32w->lpstrAlias);
523 if (!HeapFree(GetProcessHeap(), 0, base))
524 FIXME("bad free line=%d\n", __LINE__);
526 return MMSYSTEM_MAP_OK;
534 case DRV_QUERYCONFIGURE:
537 case DRV_EXITSESSION:
538 case DRV_EXITAPPLICATION:
540 FIXME("This is a hack\n");
541 return MMSYSTEM_MAP_OK;
543 FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg));
545 return MMSYSTEM_MAP_MSGERROR;
548 /* ###################################################
550 * ###################################################
553 #include <pshpack1.h>
554 #define MCI_MAX_THUNKS 32
556 static struct mci_thunk
558 BYTE popl_eax; /* popl %eax (return address) */
559 BYTE pushl_func; /* pushl $pfn16 (16bit callback function) */
561 BYTE pushl_eax; /* pushl %eax */
562 BYTE jmp; /* ljmp MCI_Yield1632 */
569 static CRITICAL_SECTION mci_cs;
570 static CRITICAL_SECTION_DEBUG mci_critsect_debug =
573 { &mci_critsect_debug.ProcessLocksList, &mci_critsect_debug.ProcessLocksList },
574 0, 0, { (DWORD_PTR)(__FILE__ ": mmsystem_mci_cs") }
576 static CRITICAL_SECTION mci_cs = { &mci_critsect_debug, -1, 0, 0, 0, 0 };
578 static UINT MCI_Yield1632(DWORD pfn16, MCIDEVICEID id, DWORD yield_data)
585 PeekMessageW( &msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE );
589 /* 16 bit func, call it */
590 TRACE("Function (16 bit) !\n");
592 args[2] = (MCIDEVICEID16)id;
593 args[1] = HIWORD(yield_data);
594 args[0] = LOWORD(yield_data);
595 return WOWCallback16Ex(pfn16, WCB16_PASCAL, sizeof(args), args, NULL);
598 /******************************************************************
602 static struct mci_thunk* MCI_AddThunk(MCIDEVICEID id, YIELDPROC16 pfn16)
604 struct mci_thunk* thunk;
608 MCI_Thunks = VirtualAlloc(NULL, MCI_MAX_THUNKS * sizeof(*MCI_Thunks), MEM_COMMIT,
609 PAGE_EXECUTE_READWRITE);
610 if (!MCI_Thunks) return NULL;
611 for (thunk = MCI_Thunks; thunk < &MCI_Thunks[MCI_MAX_THUNKS]; thunk++)
613 thunk->popl_eax = 0x58; /* popl %eax */
614 thunk->pushl_func = 0x68; /* pushl $pfn16 */
616 thunk->pushl_eax = 0x50; /* pushl %eax */
617 thunk->jmp = 0xe9; /* jmp MCI_Yield1632 */
618 thunk->callback = (char *)MCI_Yield1632 - (char *)(&thunk->callback + 1);
622 for (thunk = MCI_Thunks; thunk < &MCI_Thunks[MCI_MAX_THUNKS]; thunk++)
624 if (thunk->yield16 == 0)
626 thunk->yield16 = pfn16;
631 FIXME("Out of mci-thunks. Bump MCI_MAX_THUNKS\n");
635 /******************************************************************
639 static struct mci_thunk* MCI_HasThunk(YIELDPROC pfn)
641 struct mci_thunk* thunk;
643 if (!MCI_Thunks) return NULL;
644 for (thunk = MCI_Thunks; thunk < &MCI_Thunks[MCI_MAX_THUNKS]; thunk++)
646 if ((YIELDPROC)thunk == pfn) return thunk;
651 /**************************************************************************
652 * mciSetYieldProc [MMSYSTEM.714]
654 BOOL16 WINAPI mciSetYieldProc16(UINT16 uDeviceID, YIELDPROC16 fpYieldProc, DWORD dwYieldData)
656 struct mci_thunk* thunk;
659 TRACE("(%u, %p, %08x)\n", uDeviceID, fpYieldProc, dwYieldData);
661 if (!(thunk = MCI_AddThunk(uDeviceID, fpYieldProc)))
663 ret = mciSetYieldProc(uDeviceID, (YIELDPROC)thunk, dwYieldData);
664 if (!ret) thunk->yield16 = NULL;
668 /**************************************************************************
669 * mciGetYieldProc [MMSYSTEM.716]
671 YIELDPROC16 WINAPI mciGetYieldProc16(UINT16 uDeviceID, DWORD* lpdwYieldData)
675 struct mci_thunk* thunk;
677 TRACE("(%u, %p)\n", uDeviceID, lpdwYieldData);
679 yield = mciGetYieldProc(uDeviceID, &data);
680 if (!yield || !(thunk = MCI_HasThunk(yield))) return NULL;
682 if (lpdwYieldData) *lpdwYieldData = data;
683 return thunk->yield16;
686 /**************************************************************************
687 * mciGetErrorString [MMSYSTEM.706]
689 BOOL16 WINAPI mciGetErrorString16(DWORD wError, LPSTR lpstrBuffer, UINT16 uLength)
691 return mciGetErrorStringA(wError, lpstrBuffer, uLength);
694 /**************************************************************************
695 * mciDriverNotify [MMSYSTEM.711]
697 BOOL16 WINAPI mciDriverNotify16(HWND16 hWndCallBack, UINT16 wDevID, UINT16 wStatus)
699 TRACE("(%04X, %04x, %04X)\n", hWndCallBack, wDevID, wStatus);
701 return PostMessageA(HWND_32(hWndCallBack), MM_MCINOTIFY, wStatus, wDevID);
704 /**************************************************************************
705 * mciGetDriverData [MMSYSTEM.708]
707 DWORD WINAPI mciGetDriverData16(UINT16 uDeviceID)
709 return mciGetDriverData(uDeviceID);
712 /**************************************************************************
713 * mciSetDriverData [MMSYSTEM.707]
715 BOOL16 WINAPI mciSetDriverData16(UINT16 uDeviceID, DWORD data)
717 return mciSetDriverData(uDeviceID, data);
720 /**************************************************************************
721 * mciSendCommand [MMSYSTEM.701]
723 DWORD WINAPI mciSendCommand16(UINT16 wDevID, UINT16 wMsg, DWORD dwParam1, DWORD p2)
727 DWORD_PTR dwParam2 = p2;
729 TRACE("(%04X, %s, %08X, %08lX)\n", wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2);
740 /* FIXME: this is suboptimal. If MCI driver is a 16bit one, we'll be
741 * doing 16=>32W, then 32W=>16 conversions.
742 * We could directly call the 16bit driver if we had the information.
747 MMSYSTEM_MapType res;
749 dwRet = MCIERR_INVALID_DEVICE_ID;
751 switch (res = MCI_MapMsg16To32W(wMsg, dwParam1, &dwParam2)) {
752 case MMSYSTEM_MAP_MSGERROR:
753 TRACE("%s not handled yet\n", MCI_MessageToString(wMsg));
754 dwRet = MCIERR_DRIVER_INTERNAL;
756 case MMSYSTEM_MAP_NOMEM:
757 TRACE("Problem mapping %s from 16 to 32a\n", MCI_MessageToString(wMsg));
758 dwRet = MCIERR_OUT_OF_MEMORY;
760 case MMSYSTEM_MAP_OK:
761 case MMSYSTEM_MAP_OKMEM:
762 dwRet = mciSendCommandW(wDevID, wMsg, dwParam1, dwParam2);
763 if (res == MMSYSTEM_MAP_OKMEM)
764 MCI_UnMapMsg16To32W(wMsg, dwParam1, dwParam2);
771 if (wDevID == MCI_ALL_DEVICE_ID) {
772 FIXME("unhandled MCI_ALL_DEVICE_ID\n");
773 dwRet = MCIERR_CANNOT_USE_ALL;
775 dwRet = SendDriverMessage(hdrv, wMsg, dwParam1, dwParam2);
779 if (wMsg == MCI_CLOSE && dwRet == 0 && MCI_Thunks)
781 /* free yield thunks, if any */
783 for (i = 0; i < MCI_MAX_THUNKS; i++)
785 if (MCI_Thunks[i].id == wDevID)
786 MCI_Thunks[i].yield16 = NULL;
792 /**************************************************************************
793 * mciGetDeviceID [MMSYSTEM.703]
795 UINT16 WINAPI mciGetDeviceID16(LPCSTR lpstrName)
797 TRACE("(\"%s\")\n", lpstrName);
799 return mciGetDeviceIDA(lpstrName);
802 /**************************************************************************
803 * mciGetDeviceIDFromElementID [MMSYSTEM.715]
805 UINT16 WINAPI mciGetDeviceIDFromElementID16(DWORD dwElementID, LPCSTR lpstrType)
807 return mciGetDeviceIDFromElementIDA(dwElementID, lpstrType);
810 /**************************************************************************
811 * mciGetCreatorTask [MMSYSTEM.717]
813 HTASK16 WINAPI mciGetCreatorTask16(UINT16 uDeviceID)
815 return HTASK_16(mciGetCreatorTask(uDeviceID));
818 /**************************************************************************
819 * mciDriverYield [MMSYSTEM.710]
821 UINT16 WINAPI mciDriverYield16(UINT16 uDeviceID)
823 return mciDriverYield(uDeviceID);
826 /**************************************************************************
827 * mciSendString [MMSYSTEM.702]
829 DWORD WINAPI mciSendString16(LPCSTR lpstrCommand, LPSTR lpstrRet,
830 UINT16 uRetLen, HWND16 hwndCallback)
832 return mciSendStringA(lpstrCommand, lpstrRet, uRetLen, HWND_32(hwndCallback));
835 /**************************************************************************
836 * mciLoadCommandResource [MMSYSTEM.705]
838 UINT16 WINAPI mciLoadCommandResource16(HINSTANCE16 hInst, LPCSTR resname, UINT16 type)
840 TRACE("(%04x, %s, %x)!\n", hInst, resname, type);
841 return MCI_NO_COMMAND_TABLE;
844 /**************************************************************************
845 * mciFreeCommandResource [MMSYSTEM.713]
847 BOOL16 WINAPI mciFreeCommandResource16(UINT16 uTable)
849 TRACE("(%04x)!\n", uTable);
854 /**************************************************************************
855 * mciExecute [MMSYSTEM.712]
857 BOOL16 WINAPI mciExecute16(LPCSTR lpstrCommand)
859 return mciExecute(lpstrCommand);