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
33 #include "wine/winuser16.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mmsys
);
41 /**************************************************************************
42 * MCI_MessageToString [internal]
44 static const char* MCI_MessageToString(UINT wMsg
)
46 static char buffer
[100];
48 #define CASE(s) case (s): return #s
58 CASE(DRV_QUERYCONFIGURE
);
61 CASE(DRV_EXITSESSION
);
62 CASE(DRV_EXITAPPLICATION
);
66 CASE(MCI_CLOSE_DRIVER
);
79 CASE(MCI_OPEN_DRIVER
);
98 /* constants for digital video */
112 sprintf(buffer
, "MCI_<<%04X>>", wMsg
);
117 static LPWSTR
MCI_strdupAtoW( LPCSTR str
)
122 if (!str
) return NULL
;
123 len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0 );
124 ret
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
125 if (ret
) MultiByteToWideChar( CP_ACP
, 0, str
, -1, ret
, len
);
129 /**************************************************************************
130 * MCI_MapMsg16To32W [internal]
132 static MMSYSTEM_MapType
MCI_MapMsg16To32W(WORD wMsg
, DWORD dwFlags
, DWORD_PTR
* lParam
)
135 return MMSYSTEM_MAP_OK
;
136 /* FIXME: to add also (with seg/linear modifications to do):
137 * MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE, MCI_SETTUNER
140 /* case MCI_CAPTURE */
142 case MCI_CLOSE_DRIVER
:
149 /* case MCI_INDEX: */
152 /* 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 if (dwFlags
& MCI_DGV_STATUS_REFERENCE
)
210 mdsp32w
->dwReference
= mdsp16
->dwReference
;
211 *lParam
= (DWORD
)mdsp32w
;
213 return MMSYSTEM_MAP_NOMEM
;
216 *lParam
= (DWORD
)MapSL(*lParam
);
217 return MMSYSTEM_MAP_OK
;
220 return MMSYSTEM_MAP_OKMEM
;
223 LPMCI_OVLY_WINDOW_PARMSW mowp32w
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(MCI_OVLY_WINDOW_PARMSW
));
224 LPMCI_OVLY_WINDOW_PARMS16 mowp16
= MapSL(*lParam
);
226 mowp32w
->dwCallback
= mowp16
->dwCallback
;
227 mowp32w
->hWnd
= HWND_32(mowp16
->hWnd
);
228 mowp32w
->nCmdShow
= mowp16
->nCmdShow
;
229 if (dwFlags
& (MCI_DGV_WINDOW_TEXT
| MCI_OVLY_WINDOW_TEXT
))
230 mowp32w
->lpstrText
= MCI_strdupAtoW(MapSL(mowp16
->lpstrText
));
232 return MMSYSTEM_MAP_NOMEM
;
234 *lParam
= (DWORD
)mowp32w
;
236 return MMSYSTEM_MAP_OKMEM
;
239 LPMCI_BREAK_PARMS mbp32
= HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_BREAK_PARMS
));
240 LPMCI_BREAK_PARMS16 mbp16
= MapSL(*lParam
);
243 mbp32
->dwCallback
= mbp16
->dwCallback
;
244 mbp32
->nVirtKey
= mbp16
->nVirtKey
;
245 mbp32
->hwndBreak
= HWND_32(mbp16
->hwndBreak
);
247 return MMSYSTEM_MAP_NOMEM
;
249 *lParam
= (DWORD
)mbp32
;
251 return MMSYSTEM_MAP_OKMEM
;
254 LPMCI_VD_ESCAPE_PARMSW mvep32w
= HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_VD_ESCAPE_PARMSW
));
255 LPMCI_VD_ESCAPE_PARMS16 mvep16
= MapSL(*lParam
);
258 mvep32w
->dwCallback
= mvep16
->dwCallback
;
259 mvep32w
->lpstrCommand
= MCI_strdupAtoW(MapSL(mvep16
->lpstrCommand
));
261 return MMSYSTEM_MAP_NOMEM
;
263 *lParam
= (DWORD
)mvep32w
;
265 return MMSYSTEM_MAP_OKMEM
;
268 LPMCI_DGV_INFO_PARMSW mip32w
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_DGV_INFO_PARMS16
) + sizeof(MCI_DGV_INFO_PARMSW
));
269 LPMCI_DGV_INFO_PARMS16 mip16
= MapSL(*lParam
);
272 *(LPMCI_DGV_INFO_PARMS16
*)(mip32w
) = mip16
;
273 mip32w
= (LPMCI_DGV_INFO_PARMSW
)((char*)mip32w
+ sizeof(LPMCI_DGV_INFO_PARMS16
));
274 mip32w
->dwCallback
= mip16
->dwCallback
;
275 mip32w
->lpstrReturn
= HeapAlloc(GetProcessHeap(), 0, mip16
->dwRetSize
* sizeof(WCHAR
));
276 mip32w
->dwRetSize
= mip16
->dwRetSize
;
277 if (dwFlags
& MCI_DGV_INFO_ITEM
)
278 mip32w
->dwItem
= mip16
->dwItem
;
280 return MMSYSTEM_MAP_NOMEM
;
282 *lParam
= (DWORD
)mip32w
;
284 return MMSYSTEM_MAP_OKMEM
;
286 case MCI_OPEN_DRIVER
:
288 LPMCI_OPEN_PARMSW mop32w
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16
) + sizeof(MCI_ANIM_OPEN_PARMSW
));
289 LPMCI_OPEN_PARMS16 mop16
= MapSL(*lParam
);
292 *(LPMCI_OPEN_PARMS16
*)(mop32w
) = mop16
;
293 mop32w
= (LPMCI_OPEN_PARMSW
)((char*)mop32w
+ sizeof(LPMCI_OPEN_PARMS16
));
294 mop32w
->dwCallback
= mop16
->dwCallback
;
295 mop32w
->wDeviceID
= mop16
->wDeviceID
;
296 if( ( dwFlags
& ( MCI_OPEN_TYPE
| MCI_OPEN_TYPE_ID
)) == MCI_OPEN_TYPE
)
297 mop32w
->lpstrDeviceType
= MCI_strdupAtoW(MapSL(mop16
->lpstrDeviceType
));
299 mop32w
->lpstrDeviceType
= (LPWSTR
) mop16
->lpstrDeviceType
;
300 if( ( dwFlags
& ( MCI_OPEN_ELEMENT
| MCI_OPEN_ELEMENT_ID
)) == MCI_OPEN_ELEMENT
)
301 mop32w
->lpstrElementName
= MCI_strdupAtoW(MapSL(mop16
->lpstrElementName
));
303 mop32w
->lpstrElementName
= (LPWSTR
) mop16
->lpstrElementName
;
304 if( ( dwFlags
& MCI_OPEN_ALIAS
))
305 mop32w
->lpstrAlias
= MCI_strdupAtoW(MapSL(mop16
->lpstrAlias
));
307 mop32w
->lpstrAlias
= (LPWSTR
) mop16
->lpstrAlias
;
308 /* copy extended information if any...
309 * FIXME: this may seg fault if initial structure does not contain them and
310 * the reads after msip16 fail under LDT limits...
311 * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and
312 * should not take care of extended parameters, and should be used by MCI_Open
313 * to fetch uDevType. When, this is known, the mapping for sending the
314 * MCI_OPEN_DRIVER shall be done depending on uDevType.
317 memcpy(mop32w
+ 1, mop16
+ 1, sizeof(MCI_ANIM_OPEN_PARMS16
) - sizeof(MCI_OPEN_PARMS16
));
319 return MMSYSTEM_MAP_NOMEM
;
321 *lParam
= (DWORD
)mop32w
;
323 return MMSYSTEM_MAP_OKMEM
;
326 MCI_SYSINFO_PARMSW
*origmsip32w
;
327 MCI_SYSINFO_PARMSW
*msip32w
= HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_OPEN_PARMS16
*) + sizeof(MCI_SYSINFO_PARMSW
));
328 MCI_SYSINFO_PARMS16
*msip16
= MapSL(*lParam
);
331 return MMSYSTEM_MAP_NOMEM
;
333 origmsip32w
= msip32w
;
334 *(MCI_SYSINFO_PARMS16
**)msip32w
= msip16
;
335 msip32w
= (MCI_SYSINFO_PARMSW
*)((char *)msip32w
+ sizeof(MCI_OPEN_PARMS16
*));
336 msip32w
->dwCallback
= msip16
->dwCallback
;
337 msip32w
->lpstrReturn
= HeapAlloc(GetProcessHeap(), 0, (dwFlags
& MCI_SYSINFO_QUANTITY
) ?
339 msip16
->dwRetSize
* sizeof(WCHAR
));
340 if (!msip32w
->lpstrReturn
)
342 HeapFree(GetProcessHeap(), 0, origmsip32w
);
343 return MMSYSTEM_MAP_NOMEM
;
345 msip32w
->dwRetSize
= (dwFlags
& MCI_SYSINFO_QUANTITY
) ? sizeof(DWORD
) : msip16
->dwRetSize
;
346 msip32w
->dwNumber
= msip16
->dwNumber
;
347 msip32w
->wDeviceType
= msip16
->wDeviceType
;
349 *lParam
= (DWORD
)msip32w
;
351 return MMSYSTEM_MAP_OKMEM
;
354 LPMCI_SOUND_PARMSW mbp32
= HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_SOUND_PARMSW
));
355 LPMCI_SOUND_PARMS16 mbp16
= MapSL(*lParam
);
358 mbp32
->dwCallback
= mbp16
->dwCallback
;
359 mbp32
->lpstrSoundName
= MCI_strdupAtoW(MapSL(mbp16
->lpstrSoundName
));
361 return MMSYSTEM_MAP_NOMEM
;
363 *lParam
= (DWORD
)mbp32
;
365 return MMSYSTEM_MAP_OKMEM
;
373 case DRV_QUERYCONFIGURE
:
376 case DRV_EXITSESSION
:
377 case DRV_EXITAPPLICATION
:
379 FIXME("This is a hack\n");
380 return MMSYSTEM_MAP_OK
;
382 FIXME("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg
));
384 return MMSYSTEM_MAP_MSGERROR
;
387 /**************************************************************************
388 * MCI_UnMapMsg16To32W [internal]
390 static void MCI_UnMapMsg16To32W(WORD wMsg
, DWORD dwFlags
, DWORD_PTR lParam
, DWORD result
)
398 LPMCI_DGV_RECT_PARMS mdrp32
= (LPMCI_DGV_RECT_PARMS
)lParam
;
399 char *base
= (char*)lParam
- sizeof(LPMCI_DGV_RECT_PARMS16
);
400 LPMCI_DGV_RECT_PARMS16 mdrp16
= *(LPMCI_DGV_RECT_PARMS16
*)base
;
401 mdrp16
->rc
.left
= mdrp32
->rc
.left
;
402 mdrp16
->rc
.top
= mdrp32
->rc
.top
;
403 mdrp16
->rc
.right
= mdrp32
->rc
.right
;
404 mdrp16
->rc
.bottom
= mdrp32
->rc
.bottom
;
405 HeapFree(GetProcessHeap(), 0, base
);
410 LPMCI_DGV_STATUS_PARMSW mdsp32w
= (LPMCI_DGV_STATUS_PARMSW
)lParam
;
411 char *base
= (char*)lParam
- sizeof(LPMCI_DGV_STATUS_PARMS16
);
412 LPMCI_DGV_STATUS_PARMS16 mdsp16
= *(LPMCI_DGV_STATUS_PARMS16
*)base
;
413 mdsp16
->dwReturn
= mdsp32w
->dwReturn
;
414 HeapFree(GetProcessHeap(), 0, (LPVOID
)mdsp32w
->lpstrDrive
);
415 HeapFree(GetProcessHeap(), 0, base
);
420 LPMCI_OVLY_WINDOW_PARMSW mowp32w
= (LPMCI_OVLY_WINDOW_PARMSW
)lParam
;
421 HeapFree(GetProcessHeap(), 0, (LPVOID
)mowp32w
->lpstrText
);
422 HeapFree(GetProcessHeap(), 0, mowp32w
);
426 HeapFree(GetProcessHeap(), 0, (LPVOID
)lParam
);
430 LPMCI_VD_ESCAPE_PARMSW mvep32W
= (LPMCI_VD_ESCAPE_PARMSW
)lParam
;
431 HeapFree(GetProcessHeap(), 0, (LPVOID
)mvep32W
->lpstrCommand
);
432 HeapFree(GetProcessHeap(), 0, (LPVOID
)lParam
);
437 LPMCI_INFO_PARMSW mip32w
= (LPMCI_INFO_PARMSW
)lParam
;
438 char *base
= (char*)lParam
- sizeof(LPMCI_INFO_PARMS16
);
439 LPMCI_INFO_PARMS16 mip16
= *(LPMCI_INFO_PARMS16
*)base
;
441 if (result
== MMSYSERR_NOERROR
)
442 WideCharToMultiByte(CP_ACP
, 0,
443 mip32w
->lpstrReturn
, mip32w
->dwRetSize
,
444 MapSL(mip16
->lpstrReturn
), mip16
->dwRetSize
,
446 mip16
->dwRetSize
= mip32w
->dwRetSize
; /* never update prior to NT? */
447 HeapFree(GetProcessHeap(), 0, mip32w
->lpstrReturn
);
448 HeapFree(GetProcessHeap(), 0, base
);
453 MCI_SYSINFO_PARMSW
*msip32w
= (MCI_SYSINFO_PARMSW
*)lParam
;
454 char *base
= (char*)lParam
- sizeof(MCI_SYSINFO_PARMS16
*);
455 MCI_SYSINFO_PARMS16
*msip16
= *(MCI_SYSINFO_PARMS16
**)base
;
457 if (dwFlags
& MCI_SYSINFO_QUANTITY
) {
458 DWORD
*quantity
= MapSL(msip16
->lpstrReturn
);
460 *quantity
= *(DWORD
*)msip32w
->lpstrReturn
;
462 else if (result
== MMSYSERR_NOERROR
) {
463 WideCharToMultiByte(CP_ACP
, 0,
464 msip32w
->lpstrReturn
, msip32w
->dwRetSize
,
465 MapSL(msip16
->lpstrReturn
), msip16
->dwRetSize
,
469 HeapFree(GetProcessHeap(), 0, msip32w
->lpstrReturn
);
470 HeapFree(GetProcessHeap(), 0, base
);
475 LPMCI_SOUND_PARMSW msp32W
= (LPMCI_SOUND_PARMSW
)lParam
;
476 HeapFree(GetProcessHeap(), 0, (LPVOID
)msp32W
->lpstrSoundName
);
477 HeapFree(GetProcessHeap(), 0, (LPVOID
)lParam
);
481 case MCI_OPEN_DRIVER
:
483 LPMCI_OPEN_PARMSW mop32w
= (LPMCI_OPEN_PARMSW
)lParam
;
484 char *base
= (char*)lParam
- sizeof(LPMCI_OPEN_PARMS16
);
485 LPMCI_OPEN_PARMS16 mop16
= *(LPMCI_OPEN_PARMS16
*)base
;
487 mop16
->wDeviceID
= mop32w
->wDeviceID
;
488 if( ( dwFlags
& ( MCI_OPEN_TYPE
| MCI_OPEN_TYPE_ID
)) == MCI_OPEN_TYPE
)
489 HeapFree(GetProcessHeap(), 0, (LPWSTR
)mop32w
->lpstrDeviceType
);
490 if( ( dwFlags
& ( MCI_OPEN_ELEMENT
| MCI_OPEN_ELEMENT_ID
)) == MCI_OPEN_ELEMENT
)
491 HeapFree(GetProcessHeap(), 0, (LPWSTR
)mop32w
->lpstrElementName
);
492 if( ( dwFlags
& MCI_OPEN_ALIAS
))
493 HeapFree(GetProcessHeap(), 0, (LPWSTR
)mop32w
->lpstrAlias
);
494 HeapFree(GetProcessHeap(), 0, base
);
498 FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg
));
502 /* ###################################################
504 * ###################################################
507 #include <pshpack1.h>
508 #define MCI_MAX_THUNKS 32
510 static struct mci_thunk
512 BYTE popl_eax
; /* popl %eax (return address) */
513 BYTE pushl_func
; /* pushl $pfn16 (16bit callback function) */
515 BYTE pushl_eax
; /* pushl %eax */
516 BYTE jmp
; /* ljmp MCI_Yield1632 */
523 static CRITICAL_SECTION mci_cs
;
524 static CRITICAL_SECTION_DEBUG mci_critsect_debug
=
527 { &mci_critsect_debug
.ProcessLocksList
, &mci_critsect_debug
.ProcessLocksList
},
528 0, 0, { (DWORD_PTR
)(__FILE__
": mmsystem_mci_cs") }
530 static CRITICAL_SECTION mci_cs
= { &mci_critsect_debug
, -1, 0, 0, 0, 0 };
532 static UINT
MCI_Yield1632(DWORD pfn16
, MCIDEVICEID id
, DWORD yield_data
)
539 PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
543 /* 16 bit func, call it */
544 TRACE("Function (16 bit) !\n");
546 args
[2] = (MCIDEVICEID16
)id
;
547 args
[1] = HIWORD(yield_data
);
548 args
[0] = LOWORD(yield_data
);
549 return WOWCallback16Ex(pfn16
, WCB16_PASCAL
, sizeof(args
), args
, NULL
);
552 /******************************************************************
556 static struct mci_thunk
* MCI_AddThunk(MCIDEVICEID id
, YIELDPROC16 pfn16
)
558 struct mci_thunk
* thunk
;
562 MCI_Thunks
= VirtualAlloc(NULL
, MCI_MAX_THUNKS
* sizeof(*MCI_Thunks
), MEM_COMMIT
,
563 PAGE_EXECUTE_READWRITE
);
564 if (!MCI_Thunks
) return NULL
;
565 for (thunk
= MCI_Thunks
; thunk
< &MCI_Thunks
[MCI_MAX_THUNKS
]; thunk
++)
567 thunk
->popl_eax
= 0x58; /* popl %eax */
568 thunk
->pushl_func
= 0x68; /* pushl $pfn16 */
570 thunk
->pushl_eax
= 0x50; /* pushl %eax */
571 thunk
->jmp
= 0xe9; /* jmp MCI_Yield1632 */
572 thunk
->callback
= (char *)MCI_Yield1632
- (char *)(&thunk
->callback
+ 1);
576 for (thunk
= MCI_Thunks
; thunk
< &MCI_Thunks
[MCI_MAX_THUNKS
]; thunk
++)
578 if (thunk
->yield16
== 0)
580 thunk
->yield16
= pfn16
;
585 FIXME("Out of mci-thunks. Bump MCI_MAX_THUNKS\n");
589 /******************************************************************
593 static struct mci_thunk
* MCI_HasThunk(YIELDPROC pfn
)
595 struct mci_thunk
* thunk
;
597 if (!MCI_Thunks
) return NULL
;
598 for (thunk
= MCI_Thunks
; thunk
< &MCI_Thunks
[MCI_MAX_THUNKS
]; thunk
++)
600 if ((YIELDPROC
)thunk
== pfn
) return thunk
;
605 /**************************************************************************
606 * mciSetYieldProc [MMSYSTEM.714]
608 BOOL16 WINAPI
mciSetYieldProc16(UINT16 uDeviceID
, YIELDPROC16 fpYieldProc
, DWORD dwYieldData
)
610 struct mci_thunk
* thunk
;
613 TRACE("(%u, %p, %08x)\n", uDeviceID
, fpYieldProc
, dwYieldData
);
615 if (!(thunk
= MCI_AddThunk(uDeviceID
, fpYieldProc
)))
617 ret
= mciSetYieldProc(uDeviceID
, (YIELDPROC
)thunk
, dwYieldData
);
618 if (!ret
) thunk
->yield16
= NULL
;
622 /**************************************************************************
623 * mciGetYieldProc [MMSYSTEM.716]
625 YIELDPROC16 WINAPI
mciGetYieldProc16(UINT16 uDeviceID
, DWORD
* lpdwYieldData
)
629 struct mci_thunk
* thunk
;
631 TRACE("(%u, %p)\n", uDeviceID
, lpdwYieldData
);
633 yield
= mciGetYieldProc(uDeviceID
, &data
);
634 if (!yield
|| !(thunk
= MCI_HasThunk(yield
))) return NULL
;
636 if (lpdwYieldData
) *lpdwYieldData
= data
;
637 return thunk
->yield16
;
640 /**************************************************************************
641 * mciGetErrorString [MMSYSTEM.706]
643 BOOL16 WINAPI
mciGetErrorString16(DWORD wError
, LPSTR lpstrBuffer
, UINT16 uLength
)
645 return mciGetErrorStringA(wError
, lpstrBuffer
, uLength
);
648 /**************************************************************************
649 * mciDriverNotify [MMSYSTEM.711]
651 BOOL16 WINAPI
mciDriverNotify16(HWND16 hWndCallBack
, UINT16 wDevID
, UINT16 wStatus
)
653 TRACE("(%04X, %04x, %04X)\n", hWndCallBack
, wDevID
, wStatus
);
655 return PostMessageA(HWND_32(hWndCallBack
), MM_MCINOTIFY
, wStatus
, wDevID
);
658 /**************************************************************************
659 * mciGetDriverData [MMSYSTEM.708]
661 DWORD WINAPI
mciGetDriverData16(UINT16 uDeviceID
)
663 return mciGetDriverData(uDeviceID
);
666 /**************************************************************************
667 * mciSetDriverData [MMSYSTEM.707]
669 BOOL16 WINAPI
mciSetDriverData16(UINT16 uDeviceID
, DWORD data
)
671 return mciSetDriverData(uDeviceID
, data
);
674 /**************************************************************************
675 * mciSendCommand [MMSYSTEM.701]
677 DWORD WINAPI
mciSendCommand16(UINT16 wDevID
, UINT16 wMsg
, DWORD dwParam1
, DWORD p2
)
681 DWORD_PTR dwParam2
= p2
;
683 TRACE("(%04X, %s, %08X, %08lX)\n", wDevID
, MCI_MessageToString(wMsg
), dwParam1
, dwParam2
);
694 /* FIXME: this is suboptimal. If MCI driver is a 16bit one, we'll be
695 * doing 16=>32W, then 32W=>16 conversions.
696 * We could directly call the 16bit driver if we had the information.
701 MMSYSTEM_MapType res
;
703 dwRet
= MCIERR_INVALID_DEVICE_ID
;
705 switch (res
= MCI_MapMsg16To32W(wMsg
, dwParam1
, &dwParam2
)) {
706 case MMSYSTEM_MAP_MSGERROR
:
707 dwRet
= MCIERR_DRIVER_INTERNAL
;
709 case MMSYSTEM_MAP_NOMEM
:
710 TRACE("Problem mapping %s from 16 to 32\n", MCI_MessageToString(wMsg
));
711 dwRet
= MCIERR_OUT_OF_MEMORY
;
713 case MMSYSTEM_MAP_OK
:
714 case MMSYSTEM_MAP_OKMEM
:
715 dwRet
= mciSendCommandW(wDevID
, wMsg
, dwParam1
, dwParam2
);
716 if (res
== MMSYSTEM_MAP_OKMEM
)
717 MCI_UnMapMsg16To32W(wMsg
, dwParam1
, dwParam2
, dwRet
);
724 if (wDevID
== MCI_ALL_DEVICE_ID
) {
725 FIXME("unhandled MCI_ALL_DEVICE_ID\n");
726 dwRet
= MCIERR_CANNOT_USE_ALL
;
728 dwRet
= SendDriverMessage(hdrv
, wMsg
, dwParam1
, dwParam2
);
732 if (wMsg
== MCI_CLOSE
&& dwRet
== 0 && MCI_Thunks
)
734 /* free yield thunks, if any */
736 for (i
= 0; i
< MCI_MAX_THUNKS
; i
++)
738 if (MCI_Thunks
[i
].id
== wDevID
)
739 MCI_Thunks
[i
].yield16
= NULL
;
745 /**************************************************************************
746 * mciGetDeviceID [MMSYSTEM.703]
748 UINT16 WINAPI
mciGetDeviceID16(LPCSTR lpstrName
)
750 TRACE("(\"%s\")\n", lpstrName
);
752 return mciGetDeviceIDA(lpstrName
);
755 /**************************************************************************
756 * mciGetDeviceIDFromElementID [MMSYSTEM.715]
758 UINT16 WINAPI
mciGetDeviceIDFromElementID16(DWORD dwElementID
, LPCSTR lpstrType
)
760 return mciGetDeviceIDFromElementIDA(dwElementID
, lpstrType
);
763 /**************************************************************************
764 * mciGetCreatorTask [MMSYSTEM.717]
766 HTASK16 WINAPI
mciGetCreatorTask16(UINT16 uDeviceID
)
768 return HTASK_16(mciGetCreatorTask(uDeviceID
));
771 /**************************************************************************
772 * mciDriverYield [MMSYSTEM.710]
774 UINT16 WINAPI
mciDriverYield16(UINT16 uDeviceID
)
776 return mciDriverYield(uDeviceID
);
779 /**************************************************************************
780 * mciSendString [MMSYSTEM.702]
782 DWORD WINAPI
mciSendString16(LPCSTR lpstrCommand
, LPSTR lpstrRet
,
783 UINT16 uRetLen
, HWND16 hwndCallback
)
785 return mciSendStringA(lpstrCommand
, lpstrRet
, uRetLen
, HWND_32(hwndCallback
));
788 /**************************************************************************
789 * mciLoadCommandResource [MMSYSTEM.705]
791 UINT16 WINAPI
mciLoadCommandResource16(HINSTANCE16 hInst
, LPCSTR resname
, UINT16 type
)
793 TRACE("(%04x, %s, %x)!\n", hInst
, resname
, type
);
794 return MCI_NO_COMMAND_TABLE
;
797 /**************************************************************************
798 * mciFreeCommandResource [MMSYSTEM.713]
800 BOOL16 WINAPI
mciFreeCommandResource16(UINT16 uTable
)
802 TRACE("(%04x)!\n", uTable
);
807 /**************************************************************************
808 * mciExecute [MMSYSTEM.712]
810 BOOL16 WINAPI
mciExecute16(LPCSTR lpstrCommand
)
812 return mciExecute(lpstrCommand
);