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_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE
138 * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO
141 /* case MCI_CAPTURE */
143 case MCI_CLOSE_DRIVER
:
150 /* case MCI_INDEX: */
152 /* case MCI_MONITOR: */
161 /* case MCI_SETTIMECODE:*/
162 /* case MCI_SIGNAL:*/
168 *lParam
= (DWORD
)MapSL(*lParam
);
169 return MMSYSTEM_MAP_OK
;
175 LPMCI_DGV_RECT_PARMS mdrp32
= HeapAlloc(GetProcessHeap(), 0,
176 sizeof(LPMCI_DGV_RECT_PARMS16
) + sizeof(MCI_DGV_RECT_PARMS
));
177 LPMCI_DGV_RECT_PARMS16 mdrp16
= MapSL(*lParam
);
179 *(LPMCI_DGV_RECT_PARMS16
*)(mdrp32
) = mdrp16
;
180 mdrp32
= (LPMCI_DGV_RECT_PARMS
)((char*)mdrp32
+ sizeof(LPMCI_DGV_RECT_PARMS16
));
181 mdrp32
->dwCallback
= mdrp16
->dwCallback
;
182 mdrp32
->rc
.left
= mdrp16
->rc
.left
;
183 mdrp32
->rc
.top
= mdrp16
->rc
.top
;
184 mdrp32
->rc
.right
= mdrp16
->rc
.right
;
185 mdrp32
->rc
.bottom
= mdrp16
->rc
.bottom
;
187 return MMSYSTEM_MAP_NOMEM
;
189 *lParam
= (DWORD
)mdrp32
;
191 return MMSYSTEM_MAP_OKMEM
;
194 if (dwFlags
& (MCI_DGV_STATUS_REFERENCE
| MCI_DGV_STATUS_DISKSPACE
)) {
195 LPMCI_DGV_STATUS_PARMSW mdsp32w
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
196 sizeof(LPMCI_DGV_STATUS_PARMS16
) + sizeof(MCI_DGV_STATUS_PARMSW
));
197 LPMCI_DGV_STATUS_PARMS16 mdsp16
= MapSL(*lParam
);
199 *(LPMCI_DGV_STATUS_PARMS16
*)(mdsp32w
) = mdsp16
;
200 mdsp32w
= (LPMCI_DGV_STATUS_PARMSW
)((char*)mdsp32w
+ sizeof(LPMCI_DGV_STATUS_PARMS16
));
201 mdsp32w
->dwCallback
= mdsp16
->dwCallback
;
202 mdsp32w
->dwReturn
= mdsp16
->dwReturn
;
203 mdsp32w
->dwItem
= mdsp16
->dwItem
;
204 mdsp32w
->dwTrack
= mdsp16
->dwTrack
;
205 if (dwFlags
& MCI_DGV_STATUS_DISKSPACE
)
206 mdsp32w
->lpstrDrive
= MCI_strdupAtoW(MapSL(mdsp16
->lpstrDrive
));
207 if (dwFlags
& MCI_DGV_STATUS_REFERENCE
)
208 mdsp32w
->dwReference
= mdsp16
->dwReference
;
209 *lParam
= (DWORD
)mdsp32w
;
211 return MMSYSTEM_MAP_NOMEM
;
214 *lParam
= (DWORD
)MapSL(*lParam
);
215 return MMSYSTEM_MAP_OK
;
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_DGV_INFO_PARMSW mip32w
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_DGV_INFO_PARMS16
) + sizeof(MCI_DGV_INFO_PARMSW
));
267 LPMCI_DGV_INFO_PARMS16 mip16
= MapSL(*lParam
);
270 *(LPMCI_DGV_INFO_PARMS16
*)(mip32w
) = mip16
;
271 mip32w
= (LPMCI_DGV_INFO_PARMSW
)((char*)mip32w
+ sizeof(LPMCI_DGV_INFO_PARMS16
));
272 mip32w
->dwCallback
= mip16
->dwCallback
;
273 mip32w
->lpstrReturn
= HeapAlloc(GetProcessHeap(), 0, mip16
->dwRetSize
* sizeof(WCHAR
));
274 mip32w
->dwRetSize
= mip16
->dwRetSize
;
275 if (dwFlags
& MCI_DGV_INFO_ITEM
)
276 mip32w
->dwItem
= mip16
->dwItem
;
278 return MMSYSTEM_MAP_NOMEM
;
280 *lParam
= (DWORD
)mip32w
;
282 return MMSYSTEM_MAP_OKMEM
;
284 case MCI_OPEN_DRIVER
:
286 LPMCI_OPEN_PARMSW mop32w
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16
) + sizeof(MCI_ANIM_OPEN_PARMSW
));
287 LPMCI_OPEN_PARMS16 mop16
= MapSL(*lParam
);
290 *(LPMCI_OPEN_PARMS16
*)(mop32w
) = mop16
;
291 mop32w
= (LPMCI_OPEN_PARMSW
)((char*)mop32w
+ sizeof(LPMCI_OPEN_PARMS16
));
292 mop32w
->dwCallback
= mop16
->dwCallback
;
293 mop32w
->wDeviceID
= mop16
->wDeviceID
;
294 if( ( dwFlags
& ( MCI_OPEN_TYPE
| MCI_OPEN_TYPE_ID
)) == MCI_OPEN_TYPE
)
295 mop32w
->lpstrDeviceType
= MCI_strdupAtoW(MapSL(mop16
->lpstrDeviceType
));
297 mop32w
->lpstrDeviceType
= (LPWSTR
) mop16
->lpstrDeviceType
;
298 if( ( dwFlags
& ( MCI_OPEN_ELEMENT
| MCI_OPEN_ELEMENT_ID
)) == MCI_OPEN_ELEMENT
)
299 mop32w
->lpstrElementName
= MCI_strdupAtoW(MapSL(mop16
->lpstrElementName
));
301 mop32w
->lpstrElementName
= (LPWSTR
) mop16
->lpstrElementName
;
302 if( ( dwFlags
& MCI_OPEN_ALIAS
))
303 mop32w
->lpstrAlias
= MCI_strdupAtoW(MapSL(mop16
->lpstrAlias
));
305 mop32w
->lpstrAlias
= (LPWSTR
) mop16
->lpstrAlias
;
306 /* copy extended information if any...
307 * FIXME: this may seg fault if initial structure does not contain them and
308 * the reads after msip16 fail under LDT limits...
309 * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and
310 * should not take care of extended parameters, and should be used by MCI_Open
311 * to fetch uDevType. When, this is known, the mapping for sending the
312 * MCI_OPEN_DRIVER shall be done depending on uDevType.
315 memcpy(mop32w
+ 1, mop16
+ 1, sizeof(MCI_ANIM_OPEN_PARMS16
) - sizeof(MCI_OPEN_PARMS16
));
317 return MMSYSTEM_MAP_NOMEM
;
319 *lParam
= (DWORD
)mop32w
;
321 return MMSYSTEM_MAP_OKMEM
;
324 MCI_SYSINFO_PARMSW
*origmsip32w
;
325 MCI_SYSINFO_PARMSW
*msip32w
= HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_OPEN_PARMS16
*) + sizeof(MCI_SYSINFO_PARMSW
));
326 MCI_SYSINFO_PARMS16
*msip16
= MapSL(*lParam
);
329 return MMSYSTEM_MAP_NOMEM
;
331 origmsip32w
= msip32w
;
332 *(MCI_SYSINFO_PARMS16
**)msip32w
= msip16
;
333 msip32w
= (MCI_SYSINFO_PARMSW
*)((char *)msip32w
+ sizeof(MCI_OPEN_PARMS16
*));
334 msip32w
->dwCallback
= msip16
->dwCallback
;
335 msip32w
->lpstrReturn
= HeapAlloc(GetProcessHeap(), 0, (dwFlags
& MCI_SYSINFO_QUANTITY
) ?
337 msip16
->dwRetSize
* sizeof(WCHAR
));
338 if (!msip32w
->lpstrReturn
)
340 HeapFree(GetProcessHeap(), 0, origmsip32w
);
341 return MMSYSTEM_MAP_NOMEM
;
343 msip32w
->dwRetSize
= (dwFlags
& MCI_SYSINFO_QUANTITY
) ? sizeof(DWORD
) : msip16
->dwRetSize
;
344 msip32w
->dwNumber
= msip16
->dwNumber
;
345 msip32w
->wDeviceType
= msip16
->wDeviceType
;
347 *lParam
= (DWORD
)msip32w
;
349 return MMSYSTEM_MAP_OKMEM
;
352 LPMCI_SOUND_PARMSW mbp32
= HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_SOUND_PARMSW
));
353 LPMCI_SOUND_PARMS16 mbp16
= MapSL(*lParam
);
356 mbp32
->dwCallback
= mbp16
->dwCallback
;
357 mbp32
->lpstrSoundName
= MCI_strdupAtoW(MapSL(mbp16
->lpstrSoundName
));
359 return MMSYSTEM_MAP_NOMEM
;
361 *lParam
= (DWORD
)mbp32
;
363 return MMSYSTEM_MAP_OKMEM
;
371 case DRV_QUERYCONFIGURE
:
374 case DRV_EXITSESSION
:
375 case DRV_EXITAPPLICATION
:
377 FIXME("This is a hack\n");
378 return MMSYSTEM_MAP_OK
;
380 FIXME("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg
));
382 return MMSYSTEM_MAP_MSGERROR
;
385 /**************************************************************************
386 * MCI_UnMapMsg16To32W [internal]
388 static void MCI_UnMapMsg16To32W(WORD wMsg
, DWORD dwFlags
, DWORD_PTR lParam
, DWORD result
)
396 LPMCI_DGV_RECT_PARMS mdrp32
= (LPMCI_DGV_RECT_PARMS
)lParam
;
397 char *base
= (char*)lParam
- sizeof(LPMCI_DGV_RECT_PARMS16
);
398 LPMCI_DGV_RECT_PARMS16 mdrp16
= *(LPMCI_DGV_RECT_PARMS16
*)base
;
399 mdrp16
->rc
.left
= mdrp32
->rc
.left
;
400 mdrp16
->rc
.top
= mdrp32
->rc
.top
;
401 mdrp16
->rc
.right
= mdrp32
->rc
.right
;
402 mdrp16
->rc
.bottom
= mdrp32
->rc
.bottom
;
403 HeapFree(GetProcessHeap(), 0, base
);
408 LPMCI_DGV_STATUS_PARMSW mdsp32w
= (LPMCI_DGV_STATUS_PARMSW
)lParam
;
409 char *base
= (char*)lParam
- sizeof(LPMCI_DGV_STATUS_PARMS16
);
410 LPMCI_DGV_STATUS_PARMS16 mdsp16
= *(LPMCI_DGV_STATUS_PARMS16
*)base
;
411 mdsp16
->dwReturn
= mdsp32w
->dwReturn
;
412 HeapFree(GetProcessHeap(), 0, (LPVOID
)mdsp32w
->lpstrDrive
);
413 HeapFree(GetProcessHeap(), 0, base
);
418 LPMCI_OVLY_WINDOW_PARMSW mowp32w
= (LPMCI_OVLY_WINDOW_PARMSW
)lParam
;
419 HeapFree(GetProcessHeap(), 0, (LPVOID
)mowp32w
->lpstrText
);
420 HeapFree(GetProcessHeap(), 0, mowp32w
);
424 HeapFree(GetProcessHeap(), 0, (LPVOID
)lParam
);
428 LPMCI_VD_ESCAPE_PARMSW mvep32W
= (LPMCI_VD_ESCAPE_PARMSW
)lParam
;
429 HeapFree(GetProcessHeap(), 0, (LPVOID
)mvep32W
->lpstrCommand
);
430 HeapFree(GetProcessHeap(), 0, (LPVOID
)lParam
);
435 LPMCI_INFO_PARMSW mip32w
= (LPMCI_INFO_PARMSW
)lParam
;
436 char *base
= (char*)lParam
- sizeof(LPMCI_INFO_PARMS16
);
437 LPMCI_INFO_PARMS16 mip16
= *(LPMCI_INFO_PARMS16
*)base
;
439 if (result
== MMSYSERR_NOERROR
)
440 WideCharToMultiByte(CP_ACP
, 0,
441 mip32w
->lpstrReturn
, mip32w
->dwRetSize
,
442 MapSL(mip16
->lpstrReturn
), mip16
->dwRetSize
,
444 mip16
->dwRetSize
= mip32w
->dwRetSize
; /* never update prior to NT? */
445 HeapFree(GetProcessHeap(), 0, mip32w
->lpstrReturn
);
446 HeapFree(GetProcessHeap(), 0, base
);
451 MCI_SYSINFO_PARMSW
*msip32w
= (MCI_SYSINFO_PARMSW
*)lParam
;
452 char *base
= (char*)lParam
- sizeof(MCI_SYSINFO_PARMS16
*);
453 MCI_SYSINFO_PARMS16
*msip16
= *(MCI_SYSINFO_PARMS16
**)base
;
455 if (dwFlags
& MCI_SYSINFO_QUANTITY
) {
456 DWORD
*quantity
= MapSL(msip16
->lpstrReturn
);
458 *quantity
= *(DWORD
*)msip32w
->lpstrReturn
;
460 else if (result
== MMSYSERR_NOERROR
) {
461 WideCharToMultiByte(CP_ACP
, 0,
462 msip32w
->lpstrReturn
, msip32w
->dwRetSize
,
463 MapSL(msip16
->lpstrReturn
), msip16
->dwRetSize
,
467 HeapFree(GetProcessHeap(), 0, msip32w
->lpstrReturn
);
468 HeapFree(GetProcessHeap(), 0, base
);
473 LPMCI_SOUND_PARMSW msp32W
= (LPMCI_SOUND_PARMSW
)lParam
;
474 HeapFree(GetProcessHeap(), 0, (LPVOID
)msp32W
->lpstrSoundName
);
475 HeapFree(GetProcessHeap(), 0, (LPVOID
)lParam
);
479 case MCI_OPEN_DRIVER
:
481 LPMCI_OPEN_PARMSW mop32w
= (LPMCI_OPEN_PARMSW
)lParam
;
482 char *base
= (char*)lParam
- sizeof(LPMCI_OPEN_PARMS16
);
483 LPMCI_OPEN_PARMS16 mop16
= *(LPMCI_OPEN_PARMS16
*)base
;
485 mop16
->wDeviceID
= mop32w
->wDeviceID
;
486 if( ( dwFlags
& ( MCI_OPEN_TYPE
| MCI_OPEN_TYPE_ID
)) == MCI_OPEN_TYPE
)
487 HeapFree(GetProcessHeap(), 0, (LPWSTR
)mop32w
->lpstrDeviceType
);
488 if( ( dwFlags
& ( MCI_OPEN_ELEMENT
| MCI_OPEN_ELEMENT_ID
)) == MCI_OPEN_ELEMENT
)
489 HeapFree(GetProcessHeap(), 0, (LPWSTR
)mop32w
->lpstrElementName
);
490 if( ( dwFlags
& MCI_OPEN_ALIAS
))
491 HeapFree(GetProcessHeap(), 0, (LPWSTR
)mop32w
->lpstrAlias
);
492 HeapFree(GetProcessHeap(), 0, base
);
496 FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg
));
500 /* ###################################################
502 * ###################################################
505 #include <pshpack1.h>
506 #define MCI_MAX_THUNKS 32
508 static struct mci_thunk
510 BYTE popl_eax
; /* popl %eax (return address) */
511 BYTE pushl_func
; /* pushl $pfn16 (16bit callback function) */
513 BYTE pushl_eax
; /* pushl %eax */
514 BYTE jmp
; /* ljmp MCI_Yield1632 */
521 static CRITICAL_SECTION mci_cs
;
522 static CRITICAL_SECTION_DEBUG mci_critsect_debug
=
525 { &mci_critsect_debug
.ProcessLocksList
, &mci_critsect_debug
.ProcessLocksList
},
526 0, 0, { (DWORD_PTR
)(__FILE__
": mmsystem_mci_cs") }
528 static CRITICAL_SECTION mci_cs
= { &mci_critsect_debug
, -1, 0, 0, 0, 0 };
530 static UINT
MCI_Yield1632(DWORD pfn16
, MCIDEVICEID id
, DWORD yield_data
)
537 PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
);
541 /* 16 bit func, call it */
542 TRACE("Function (16 bit) !\n");
544 args
[2] = (MCIDEVICEID16
)id
;
545 args
[1] = HIWORD(yield_data
);
546 args
[0] = LOWORD(yield_data
);
547 return WOWCallback16Ex(pfn16
, WCB16_PASCAL
, sizeof(args
), args
, NULL
);
550 /******************************************************************
554 static struct mci_thunk
* MCI_AddThunk(MCIDEVICEID id
, YIELDPROC16 pfn16
)
556 struct mci_thunk
* thunk
;
560 MCI_Thunks
= VirtualAlloc(NULL
, MCI_MAX_THUNKS
* sizeof(*MCI_Thunks
), MEM_COMMIT
,
561 PAGE_EXECUTE_READWRITE
);
562 if (!MCI_Thunks
) return NULL
;
563 for (thunk
= MCI_Thunks
; thunk
< &MCI_Thunks
[MCI_MAX_THUNKS
]; thunk
++)
565 thunk
->popl_eax
= 0x58; /* popl %eax */
566 thunk
->pushl_func
= 0x68; /* pushl $pfn16 */
568 thunk
->pushl_eax
= 0x50; /* pushl %eax */
569 thunk
->jmp
= 0xe9; /* jmp MCI_Yield1632 */
570 thunk
->callback
= (char *)MCI_Yield1632
- (char *)(&thunk
->callback
+ 1);
574 for (thunk
= MCI_Thunks
; thunk
< &MCI_Thunks
[MCI_MAX_THUNKS
]; thunk
++)
576 if (thunk
->yield16
== 0)
578 thunk
->yield16
= pfn16
;
583 FIXME("Out of mci-thunks. Bump MCI_MAX_THUNKS\n");
587 /******************************************************************
591 static struct mci_thunk
* MCI_HasThunk(YIELDPROC pfn
)
593 struct mci_thunk
* thunk
;
595 if (!MCI_Thunks
) return NULL
;
596 for (thunk
= MCI_Thunks
; thunk
< &MCI_Thunks
[MCI_MAX_THUNKS
]; thunk
++)
598 if ((YIELDPROC
)thunk
== pfn
) return thunk
;
603 /**************************************************************************
604 * mciSetYieldProc [MMSYSTEM.714]
606 BOOL16 WINAPI
mciSetYieldProc16(UINT16 uDeviceID
, YIELDPROC16 fpYieldProc
, DWORD dwYieldData
)
608 struct mci_thunk
* thunk
;
611 TRACE("(%u, %p, %08x)\n", uDeviceID
, fpYieldProc
, dwYieldData
);
613 if (!(thunk
= MCI_AddThunk(uDeviceID
, fpYieldProc
)))
615 ret
= mciSetYieldProc(uDeviceID
, (YIELDPROC
)thunk
, dwYieldData
);
616 if (!ret
) thunk
->yield16
= NULL
;
620 /**************************************************************************
621 * mciGetYieldProc [MMSYSTEM.716]
623 YIELDPROC16 WINAPI
mciGetYieldProc16(UINT16 uDeviceID
, DWORD
* lpdwYieldData
)
627 struct mci_thunk
* thunk
;
629 TRACE("(%u, %p)\n", uDeviceID
, lpdwYieldData
);
631 yield
= mciGetYieldProc(uDeviceID
, &data
);
632 if (!yield
|| !(thunk
= MCI_HasThunk(yield
))) return NULL
;
634 if (lpdwYieldData
) *lpdwYieldData
= data
;
635 return thunk
->yield16
;
638 /**************************************************************************
639 * mciGetErrorString [MMSYSTEM.706]
641 BOOL16 WINAPI
mciGetErrorString16(DWORD wError
, LPSTR lpstrBuffer
, UINT16 uLength
)
643 return mciGetErrorStringA(wError
, lpstrBuffer
, uLength
);
646 /**************************************************************************
647 * mciDriverNotify [MMSYSTEM.711]
649 BOOL16 WINAPI
mciDriverNotify16(HWND16 hWndCallBack
, UINT16 wDevID
, UINT16 wStatus
)
651 TRACE("(%04X, %04x, %04X)\n", hWndCallBack
, wDevID
, wStatus
);
653 return PostMessageA(HWND_32(hWndCallBack
), MM_MCINOTIFY
, wStatus
, wDevID
);
656 /**************************************************************************
657 * mciGetDriverData [MMSYSTEM.708]
659 DWORD WINAPI
mciGetDriverData16(UINT16 uDeviceID
)
661 return mciGetDriverData(uDeviceID
);
664 /**************************************************************************
665 * mciSetDriverData [MMSYSTEM.707]
667 BOOL16 WINAPI
mciSetDriverData16(UINT16 uDeviceID
, DWORD data
)
669 return mciSetDriverData(uDeviceID
, data
);
672 /**************************************************************************
673 * mciSendCommand [MMSYSTEM.701]
675 DWORD WINAPI
mciSendCommand16(UINT16 wDevID
, UINT16 wMsg
, DWORD dwParam1
, DWORD p2
)
679 DWORD_PTR dwParam2
= p2
;
681 TRACE("(%04X, %s, %08X, %08lX)\n", wDevID
, MCI_MessageToString(wMsg
), dwParam1
, dwParam2
);
692 /* FIXME: this is suboptimal. If MCI driver is a 16bit one, we'll be
693 * doing 16=>32W, then 32W=>16 conversions.
694 * We could directly call the 16bit driver if we had the information.
699 MMSYSTEM_MapType res
;
701 dwRet
= MCIERR_INVALID_DEVICE_ID
;
703 switch (res
= MCI_MapMsg16To32W(wMsg
, dwParam1
, &dwParam2
)) {
704 case MMSYSTEM_MAP_MSGERROR
:
705 dwRet
= MCIERR_DRIVER_INTERNAL
;
707 case MMSYSTEM_MAP_NOMEM
:
708 TRACE("Problem mapping %s from 16 to 32\n", MCI_MessageToString(wMsg
));
709 dwRet
= MCIERR_OUT_OF_MEMORY
;
711 case MMSYSTEM_MAP_OK
:
712 case MMSYSTEM_MAP_OKMEM
:
713 dwRet
= mciSendCommandW(wDevID
, wMsg
, dwParam1
, dwParam2
);
714 if (res
== MMSYSTEM_MAP_OKMEM
)
715 MCI_UnMapMsg16To32W(wMsg
, dwParam1
, dwParam2
, dwRet
);
722 if (wDevID
== MCI_ALL_DEVICE_ID
) {
723 FIXME("unhandled MCI_ALL_DEVICE_ID\n");
724 dwRet
= MCIERR_CANNOT_USE_ALL
;
726 dwRet
= SendDriverMessage(hdrv
, wMsg
, dwParam1
, dwParam2
);
730 if (wMsg
== MCI_CLOSE
&& dwRet
== 0 && MCI_Thunks
)
732 /* free yield thunks, if any */
734 for (i
= 0; i
< MCI_MAX_THUNKS
; i
++)
736 if (MCI_Thunks
[i
].id
== wDevID
)
737 MCI_Thunks
[i
].yield16
= NULL
;
743 /**************************************************************************
744 * mciGetDeviceID [MMSYSTEM.703]
746 UINT16 WINAPI
mciGetDeviceID16(LPCSTR lpstrName
)
748 TRACE("(\"%s\")\n", lpstrName
);
750 return mciGetDeviceIDA(lpstrName
);
753 /**************************************************************************
754 * mciGetDeviceIDFromElementID [MMSYSTEM.715]
756 UINT16 WINAPI
mciGetDeviceIDFromElementID16(DWORD dwElementID
, LPCSTR lpstrType
)
758 return mciGetDeviceIDFromElementIDA(dwElementID
, lpstrType
);
761 /**************************************************************************
762 * mciGetCreatorTask [MMSYSTEM.717]
764 HTASK16 WINAPI
mciGetCreatorTask16(UINT16 uDeviceID
)
766 return HTASK_16(mciGetCreatorTask(uDeviceID
));
769 /**************************************************************************
770 * mciDriverYield [MMSYSTEM.710]
772 UINT16 WINAPI
mciDriverYield16(UINT16 uDeviceID
)
774 return mciDriverYield(uDeviceID
);
777 /**************************************************************************
778 * mciSendString [MMSYSTEM.702]
780 DWORD WINAPI
mciSendString16(LPCSTR lpstrCommand
, LPSTR lpstrRet
,
781 UINT16 uRetLen
, HWND16 hwndCallback
)
783 return mciSendStringA(lpstrCommand
, lpstrRet
, uRetLen
, HWND_32(hwndCallback
));
786 /**************************************************************************
787 * mciLoadCommandResource [MMSYSTEM.705]
789 UINT16 WINAPI
mciLoadCommandResource16(HINSTANCE16 hInst
, LPCSTR resname
, UINT16 type
)
791 TRACE("(%04x, %s, %x)!\n", hInst
, resname
, type
);
792 return MCI_NO_COMMAND_TABLE
;
795 /**************************************************************************
796 * mciFreeCommandResource [MMSYSTEM.713]
798 BOOL16 WINAPI
mciFreeCommandResource16(UINT16 uTable
)
800 TRACE("(%04x)!\n", uTable
);
805 /**************************************************************************
806 * mciExecute [MMSYSTEM.712]
808 BOOL16 WINAPI
mciExecute16(LPCSTR lpstrCommand
)
810 return mciExecute(lpstrCommand
);