1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1993 Martin Ayotte
7 * 1998-2003 Eric Pouech
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 * 99/4 added mmTask and mmThread functions support
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
43 #include "wine/winuser16.h"
46 #include "wine/debug.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(mmsys);
50 static WINE_MMTHREAD* WINMM_GetmmThread(HANDLE16);
51 static LPWINE_DRIVER DRIVER_OpenDriver16(LPCSTR, LPCSTR, LPARAM);
52 static LRESULT DRIVER_CloseDriver16(HDRVR16, LPARAM, LPARAM);
53 static LRESULT DRIVER_SendMessage16(HDRVR16, UINT, LPARAM, LPARAM);
54 static LRESULT MMIO_Callback16(SEGPTR, LPMMIOINFO, UINT, LPARAM, LPARAM);
57 /* ###################################################
59 * ###################################################
62 /**************************************************************************
63 * DllEntryPoint (MMSYSTEM.2046)
65 * MMSYSTEM DLL entry point
68 BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
69 WORD wHeapSize, DWORD dwReserved1, WORD wReserved2)
71 TRACE("%p 0x%lx\n", hinstDLL, fdwReason);
74 case DLL_PROCESS_ATTACH:
75 /* need to load WinMM in order to:
76 * - initiate correctly shared variables (WINMM_Init())
78 if (!GetModuleHandleA("WINMM.DLL") && !LoadLibraryA("WINMM.DLL"))
80 ERR("Could not load sibling WinMM.dll\n");
83 WINMM_IData->hWinMM16Instance = hinstDLL;
84 /* hook in our 16 bit function pointers */
85 pFnGetMMThread16 = WINMM_GetmmThread;
86 pFnOpenDriver16 = DRIVER_OpenDriver16;
87 pFnCloseDriver16 = DRIVER_CloseDriver16;
88 pFnSendMessage16 = DRIVER_SendMessage16;
89 pFnMmioCallback16 = MMIO_Callback16;
92 case DLL_PROCESS_DETACH:
93 WINMM_IData->hWinMM16Instance = 0;
94 pFnGetMMThread16 = NULL;
95 pFnOpenDriver16 = NULL;
96 pFnCloseDriver16 = NULL;
97 pFnSendMessage16 = NULL;
98 pFnMmioCallback16 = NULL;
99 /* FIXME: add equivalent for MMDRV_Init16() */
101 case DLL_THREAD_ATTACH:
102 case DLL_THREAD_DETACH:
108 /**************************************************************************
109 * MMSYSTEM_WEP [MMSYSTEM.1]
111 int WINAPI MMSYSTEM_WEP(HINSTANCE16 hInstance, WORD wDataSeg,
112 WORD cbHeapSize, LPSTR lpCmdLine)
114 FIXME("STUB: Unloading MMSystem DLL ... hInst=%04X \n", hInstance);
118 /* ###################################################
120 * ###################################################
123 /**************************************************************************
124 * PlaySound [MMSYSTEM.3]
126 BOOL16 WINAPI PlaySound16(LPCSTR pszSound, HMODULE16 hmod, DWORD fdwSound)
131 if ((fdwSound & SND_RESOURCE) == SND_RESOURCE)
136 if (!(res = FindResource16( hmod, pszSound, "WAVE" ))) return FALSE;
137 if (!(handle = LoadResource16( hmod, res ))) return FALSE;
138 pszSound = LockResource16(handle);
139 fdwSound = (fdwSound & ~SND_RESOURCE) | SND_MEMORY;
140 /* FIXME: FreeResource16 */
143 ReleaseThunkLock(&lc);
144 retv = PlaySoundA(pszSound, 0, fdwSound);
145 RestoreThunkLock(lc);
150 /**************************************************************************
151 * sndPlaySound [MMSYSTEM.2]
153 BOOL16 WINAPI sndPlaySound16(LPCSTR lpszSoundName, UINT16 uFlags)
158 ReleaseThunkLock(&lc);
159 retv = sndPlaySoundA(lpszSoundName, uFlags);
160 RestoreThunkLock(lc);
165 /* ###################################################
167 * ###################################################
170 /**************************************************************************
171 * mmsystemGetVersion [MMSYSTEM.5]
174 UINT16 WINAPI mmsystemGetVersion16(void)
176 return mmsystemGetVersion();
179 /**************************************************************************
180 * DriverCallback [MMSYSTEM.31]
182 BOOL16 WINAPI DriverCallback16(DWORD dwCallBack, UINT16 uFlags, HDRVR16 hDev,
183 WORD wMsg, DWORD dwUser, DWORD dwParam1,
186 return DriverCallback(dwCallBack, uFlags, HDRVR_32(hDev), wMsg, dwUser, dwParam1, dwParam2);
189 /**************************************************************************
190 * OutputDebugStr [MMSYSTEM.30]
192 void WINAPI OutputDebugStr16(LPCSTR str)
194 OutputDebugStringA( str );
198 /* ###################################################
200 * ###################################################
203 /**************************************************************************
204 * Mixer devices. New to Win95
207 /**************************************************************************
208 * mixerGetNumDevs [MMSYSTEM.800]
210 UINT16 WINAPI mixerGetNumDevs16(void)
212 return MMDRV_GetNum(MMDRV_MIXER);
215 /**************************************************************************
216 * mixerGetDevCaps [MMSYSTEM.801]
218 UINT16 WINAPI mixerGetDevCaps16(UINT16 devid, LPMIXERCAPS16 mixcaps,
222 UINT ret = mixerGetDevCapsA(devid, &micA, sizeof(micA));
224 if (ret == MMSYSERR_NOERROR) {
225 mixcaps->wMid = micA.wMid;
226 mixcaps->wPid = micA.wPid;
227 mixcaps->vDriverVersion = micA.vDriverVersion;
228 strcpy(mixcaps->szPname, micA.szPname);
229 mixcaps->fdwSupport = micA.fdwSupport;
230 mixcaps->cDestinations = micA.cDestinations;
235 /**************************************************************************
236 * mixerOpen [MMSYSTEM.802]
238 UINT16 WINAPI mixerOpen16(LPHMIXER16 lphmix, UINT16 uDeviceID, DWORD dwCallback,
239 DWORD dwInstance, DWORD fdwOpen)
244 ret = MIXER_Open(&hmix, uDeviceID, dwCallback, dwInstance, fdwOpen, FALSE);
245 if (lphmix) *lphmix = HMIXER_16(hmix);
249 /**************************************************************************
250 * mixerClose [MMSYSTEM.803]
252 UINT16 WINAPI mixerClose16(HMIXER16 hMix)
254 return mixerClose(HMIXER_32(hMix));
257 /**************************************************************************
258 * mixerGetID (MMSYSTEM.806)
260 UINT16 WINAPI mixerGetID16(HMIXEROBJ16 hmix, LPUINT16 lpid, DWORD fdwID)
263 UINT ret = mixerGetID(HMIXEROBJ_32(hmix), &xid, fdwID);
270 /**************************************************************************
271 * mixerGetControlDetails [MMSYSTEM.808]
273 UINT16 WINAPI mixerGetControlDetails16(HMIXEROBJ16 hmix,
274 LPMIXERCONTROLDETAILS16 lpmcd,
277 DWORD ret = MMSYSERR_NOTENABLED;
280 TRACE("(%04x, %p, %08lx)\n", hmix, lpmcd, fdwDetails);
282 if (lpmcd == NULL || lpmcd->cbStruct != sizeof(*lpmcd))
283 return MMSYSERR_INVALPARAM;
285 sppaDetails = (SEGPTR)lpmcd->paDetails;
286 lpmcd->paDetails = MapSL(sppaDetails);
287 ret = mixerGetControlDetailsA(HMIXEROBJ_32(hmix),
288 (LPMIXERCONTROLDETAILS)lpmcd, fdwDetails);
289 lpmcd->paDetails = (LPVOID)sppaDetails;
294 /**************************************************************************
295 * mixerGetLineControls [MMSYSTEM.807]
297 UINT16 WINAPI mixerGetLineControls16(HMIXEROBJ16 hmix,
298 LPMIXERLINECONTROLS16 lpmlc16,
301 MIXERLINECONTROLSA mlcA;
304 LPMIXERCONTROL16 lpmc16;
306 TRACE("(%04x, %p, %08lx)\n", hmix, lpmlc16, fdwControls);
308 if (lpmlc16 == NULL || lpmlc16->cbStruct != sizeof(*lpmlc16) ||
309 lpmlc16->cbmxctrl != sizeof(MIXERCONTROL16))
310 return MMSYSERR_INVALPARAM;
312 mlcA.cbStruct = sizeof(mlcA);
313 mlcA.dwLineID = lpmlc16->dwLineID;
314 mlcA.u.dwControlID = lpmlc16->u.dwControlID;
315 mlcA.u.dwControlType = lpmlc16->u.dwControlType;
316 mlcA.cControls = lpmlc16->cControls;
317 mlcA.cbmxctrl = sizeof(MIXERCONTROLA);
318 mlcA.pamxctrl = HeapAlloc(GetProcessHeap(), 0,
319 mlcA.cControls * mlcA.cbmxctrl);
321 ret = mixerGetLineControlsA(HMIXEROBJ_32(hmix), &mlcA, fdwControls);
323 if (ret == MMSYSERR_NOERROR) {
324 lpmlc16->dwLineID = mlcA.dwLineID;
325 lpmlc16->u.dwControlID = mlcA.u.dwControlID;
326 lpmlc16->u.dwControlType = mlcA.u.dwControlType;
327 lpmlc16->cControls = mlcA.cControls;
329 lpmc16 = MapSL(lpmlc16->pamxctrl);
331 for (i = 0; i < mlcA.cControls; i++) {
332 lpmc16[i].cbStruct = sizeof(MIXERCONTROL16);
333 lpmc16[i].dwControlID = mlcA.pamxctrl[i].dwControlID;
334 lpmc16[i].dwControlType = mlcA.pamxctrl[i].dwControlType;
335 lpmc16[i].fdwControl = mlcA.pamxctrl[i].fdwControl;
336 lpmc16[i].cMultipleItems = mlcA.pamxctrl[i].cMultipleItems;
337 strcpy(lpmc16[i].szShortName, mlcA.pamxctrl[i].szShortName);
338 strcpy(lpmc16[i].szName, mlcA.pamxctrl[i].szName);
339 /* sizeof(lpmc16[i].Bounds) == sizeof(mlcA.pamxctrl[i].Bounds) */
340 memcpy(&lpmc16[i].Bounds, &mlcA.pamxctrl[i].Bounds,
341 sizeof(mlcA.pamxctrl[i].Bounds));
342 /* sizeof(lpmc16[i].Metrics) == sizeof(mlcA.pamxctrl[i].Metrics) */
343 memcpy(&lpmc16[i].Metrics, &mlcA.pamxctrl[i].Metrics,
344 sizeof(mlcA.pamxctrl[i].Metrics));
348 HeapFree(GetProcessHeap(), 0, mlcA.pamxctrl);
353 /**************************************************************************
354 * mixerGetLineInfo [MMSYSTEM.805]
356 UINT16 WINAPI mixerGetLineInfo16(HMIXEROBJ16 hmix, LPMIXERLINE16 lpmli16,
362 TRACE("(%04x, %p, %08lx)\n", hmix, lpmli16, fdwInfo);
364 if (lpmli16 == NULL || lpmli16->cbStruct != sizeof(*lpmli16))
365 return MMSYSERR_INVALPARAM;
367 mliA.cbStruct = sizeof(mliA);
368 switch (fdwInfo & MIXER_GETLINEINFOF_QUERYMASK) {
369 case MIXER_GETLINEINFOF_COMPONENTTYPE:
370 mliA.dwComponentType = lpmli16->dwComponentType;
372 case MIXER_GETLINEINFOF_DESTINATION:
373 mliA.dwDestination = lpmli16->dwDestination;
375 case MIXER_GETLINEINFOF_LINEID:
376 mliA.dwLineID = lpmli16->dwLineID;
378 case MIXER_GETLINEINFOF_SOURCE:
379 mliA.dwDestination = lpmli16->dwDestination;
380 mliA.dwSource = lpmli16->dwSource;
382 case MIXER_GETLINEINFOF_TARGETTYPE:
383 mliA.Target.dwType = lpmli16->Target.dwType;
384 mliA.Target.wMid = lpmli16->Target.wMid;
385 mliA.Target.wPid = lpmli16->Target.wPid;
386 mliA.Target.vDriverVersion = lpmli16->Target.vDriverVersion;
387 strcpy(mliA.Target.szPname, lpmli16->Target.szPname);
390 FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo);
393 ret = mixerGetLineInfoA(HMIXEROBJ_32(hmix), &mliA, fdwInfo);
395 lpmli16->dwDestination = mliA.dwDestination;
396 lpmli16->dwSource = mliA.dwSource;
397 lpmli16->dwLineID = mliA.dwLineID;
398 lpmli16->fdwLine = mliA.fdwLine;
399 lpmli16->dwUser = mliA.dwUser;
400 lpmli16->dwComponentType = mliA.dwComponentType;
401 lpmli16->cChannels = mliA.cChannels;
402 lpmli16->cConnections = mliA.cConnections;
403 lpmli16->cControls = mliA.cControls;
404 strcpy(lpmli16->szShortName, mliA.szShortName);
405 strcpy(lpmli16->szName, mliA.szName);
406 lpmli16->Target.dwType = mliA.Target.dwType;
407 lpmli16->Target.dwDeviceID = mliA.Target.dwDeviceID;
408 lpmli16->Target.wMid = mliA.Target.wMid;
409 lpmli16->Target.wPid = mliA.Target.wPid;
410 lpmli16->Target.vDriverVersion = mliA.Target.vDriverVersion;
411 strcpy(lpmli16->Target.szPname, mliA.Target.szPname);
416 /**************************************************************************
417 * mixerSetControlDetails [MMSYSTEM.809]
419 UINT16 WINAPI mixerSetControlDetails16(HMIXEROBJ16 hmix,
420 LPMIXERCONTROLDETAILS16 lpmcd,
423 TRACE("(%04x, %p, %08lx)\n", hmix, lpmcd, fdwDetails);
424 return MMSYSERR_NOTENABLED;
427 /**************************************************************************
428 * mixerMessage [MMSYSTEM.804]
430 DWORD WINAPI mixerMessage16(HMIXER16 hmix, UINT16 uMsg, DWORD dwParam1,
433 return mixerMessage(HMIXER_32(hmix), uMsg, dwParam1, dwParam2);
436 /**************************************************************************
437 * auxGetNumDevs [MMSYSTEM.350]
439 UINT16 WINAPI auxGetNumDevs16(void)
441 return MMDRV_GetNum(MMDRV_AUX);
444 /* ###################################################
446 * ###################################################
449 /**************************************************************************
450 * auxGetDevCaps [MMSYSTEM.351]
452 UINT16 WINAPI auxGetDevCaps16(UINT16 uDeviceID, LPAUXCAPS16 lpCaps, UINT16 uSize)
456 TRACE("(%04X, %p, %d) !\n", uDeviceID, lpCaps, uSize);
458 if ((wmld = MMDRV_Get((HANDLE)(ULONG_PTR)uDeviceID, MMDRV_AUX, TRUE)) == NULL)
459 return MMSYSERR_INVALHANDLE;
460 return MMDRV_Message(wmld, AUXDM_GETDEVCAPS, (DWORD)lpCaps, uSize, TRUE);
463 /**************************************************************************
464 * auxGetVolume [MMSYSTEM.352]
466 UINT16 WINAPI auxGetVolume16(UINT16 uDeviceID, LPDWORD lpdwVolume)
470 TRACE("(%04X, %p) !\n", uDeviceID, lpdwVolume);
472 if ((wmld = MMDRV_Get((HANDLE)(ULONG_PTR)uDeviceID, MMDRV_AUX, TRUE)) == NULL)
473 return MMSYSERR_INVALHANDLE;
474 return MMDRV_Message(wmld, AUXDM_GETVOLUME, (DWORD)lpdwVolume, 0L, TRUE);
477 /**************************************************************************
478 * auxSetVolume [MMSYSTEM.353]
480 UINT16 WINAPI auxSetVolume16(UINT16 uDeviceID, DWORD dwVolume)
484 TRACE("(%04X, %lu) !\n", uDeviceID, dwVolume);
486 if ((wmld = MMDRV_Get((HANDLE)(ULONG_PTR)uDeviceID, MMDRV_AUX, TRUE)) == NULL)
487 return MMSYSERR_INVALHANDLE;
488 return MMDRV_Message(wmld, AUXDM_SETVOLUME, dwVolume, 0L, TRUE);
491 /**************************************************************************
492 * auxOutMessage [MMSYSTEM.354]
494 DWORD WINAPI auxOutMessage16(UINT16 uDeviceID, UINT16 uMessage, DWORD dw1, DWORD dw2)
498 TRACE("(%04X, %04X, %08lX, %08lX)\n", uDeviceID, uMessage, dw1, dw2);
501 case AUXDM_GETNUMDEVS:
502 case AUXDM_SETVOLUME:
503 /* no argument conversion needed */
505 case AUXDM_GETVOLUME:
506 return auxGetVolume16(uDeviceID, MapSL(dw1));
507 case AUXDM_GETDEVCAPS:
508 return auxGetDevCaps16(uDeviceID, MapSL(dw1), dw2);
510 TRACE("(%04x, %04x, %08lx, %08lx): unhandled message\n",
511 uDeviceID, uMessage, dw1, dw2);
514 if ((wmld = MMDRV_Get((HANDLE)(ULONG_PTR)uDeviceID, MMDRV_AUX, TRUE)) == NULL)
515 return MMSYSERR_INVALHANDLE;
517 return MMDRV_Message(wmld, uMessage, dw1, dw2, TRUE);
520 /* ###################################################
522 * ###################################################
525 /**************************************************************************
526 * mciGetErrorString [MMSYSTEM.706]
528 BOOL16 WINAPI mciGetErrorString16(DWORD wError, LPSTR lpstrBuffer, UINT16 uLength)
530 return mciGetErrorStringA(wError, lpstrBuffer, uLength);
533 /**************************************************************************
534 * mciDriverNotify [MMSYSTEM.711]
536 BOOL16 WINAPI mciDriverNotify16(HWND16 hWndCallBack, UINT16 wDevID, UINT16 wStatus)
538 TRACE("(%04X, %04x, %04X)\n", hWndCallBack, wDevID, wStatus);
540 return PostMessageA(HWND_32(hWndCallBack), MM_MCINOTIFY, wStatus, wDevID);
543 /**************************************************************************
544 * mciGetDriverData [MMSYSTEM.708]
546 DWORD WINAPI mciGetDriverData16(UINT16 uDeviceID)
548 return mciGetDriverData(uDeviceID);
551 /**************************************************************************
552 * mciSetDriverData [MMSYSTEM.707]
554 BOOL16 WINAPI mciSetDriverData16(UINT16 uDeviceID, DWORD data)
556 return mciSetDriverData(uDeviceID, data);
559 /**************************************************************************
560 * mciSendCommand [MMSYSTEM.701]
562 DWORD WINAPI mciSendCommand16(UINT16 wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2)
566 TRACE("(%04X, %s, %08lX, %08lX)\n",
567 wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2);
569 dwRet = MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2, FALSE);
570 dwRet = MCI_CleanUp(dwRet, wMsg, (DWORD)MapSL(dwParam2));
571 TRACE("=> %ld\n", dwRet);
575 /**************************************************************************
576 * mciGetDeviceID [MMSYSTEM.703]
578 UINT16 WINAPI mciGetDeviceID16(LPCSTR lpstrName)
580 TRACE("(\"%s\")\n", lpstrName);
582 return MCI_GetDriverFromString(lpstrName);
585 /**************************************************************************
586 * mciSetYieldProc [MMSYSTEM.714]
588 BOOL16 WINAPI mciSetYieldProc16(UINT16 uDeviceID, YIELDPROC16 fpYieldProc, DWORD dwYieldData)
590 LPWINE_MCIDRIVER wmd;
592 TRACE("(%u, %p, %08lx)\n", uDeviceID, fpYieldProc, dwYieldData);
594 if (!(wmd = MCI_GetDriver(uDeviceID))) {
595 WARN("Bad uDeviceID\n");
599 wmd->lpfnYieldProc = (YIELDPROC)fpYieldProc;
600 wmd->dwYieldData = dwYieldData;
606 /**************************************************************************
607 * mciGetDeviceIDFromElementID [MMSYSTEM.715]
609 UINT16 WINAPI mciGetDeviceIDFromElementID16(DWORD dwElementID, LPCSTR lpstrType)
611 FIXME("(%lu, %s) stub\n", dwElementID, lpstrType);
615 /**************************************************************************
616 * mciGetYieldProc [MMSYSTEM.716]
618 YIELDPROC16 WINAPI mciGetYieldProc16(UINT16 uDeviceID, DWORD* lpdwYieldData)
620 LPWINE_MCIDRIVER wmd;
622 TRACE("(%u, %p)\n", uDeviceID, lpdwYieldData);
624 if (!(wmd = MCI_GetDriver(uDeviceID))) {
625 WARN("Bad uDeviceID\n");
628 if (!wmd->lpfnYieldProc) {
629 WARN("No proc set\n");
633 WARN("Proc is 32 bit\n");
636 return (YIELDPROC16)wmd->lpfnYieldProc;
639 /**************************************************************************
640 * mciGetCreatorTask [MMSYSTEM.717]
642 HTASK16 WINAPI mciGetCreatorTask16(UINT16 uDeviceID)
644 LPWINE_MCIDRIVER wmd;
647 if ((wmd = MCI_GetDriver(uDeviceID)))
648 ret = HTASK_16(wmd->CreatorThread);
650 TRACE("(%u) => %04x\n", uDeviceID, ret);
654 /**************************************************************************
655 * mciDriverYield [MMSYSTEM.710]
657 UINT16 WINAPI mciDriverYield16(UINT16 uDeviceID)
659 LPWINE_MCIDRIVER wmd;
662 /* TRACE("(%04x)\n", uDeviceID); */
664 if (!(wmd = MCI_GetDriver(uDeviceID)) || !wmd->lpfnYieldProc || wmd->bIs32) {
667 ret = wmd->lpfnYieldProc(uDeviceID, wmd->dwYieldData);
673 /* ###################################################
675 * ###################################################
678 /**************************************************************************
679 * midiOutGetNumDevs [MMSYSTEM.201]
681 UINT16 WINAPI midiOutGetNumDevs16(void)
683 return MMDRV_GetNum(MMDRV_MIDIOUT);
686 /**************************************************************************
687 * midiOutGetDevCaps [MMSYSTEM.202]
689 UINT16 WINAPI midiOutGetDevCaps16(UINT16 uDeviceID, LPMIDIOUTCAPS16 lpCaps,
695 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
697 dwRet = midiOutGetDevCapsA(uDeviceID, &capsA, sizeof(capsA));
698 if (dwRet == MMSYSERR_NOERROR) {
699 lpCaps->wMid = capsA.wMid;
700 lpCaps->wPid = capsA.wPid;
701 lpCaps->vDriverVersion = capsA.vDriverVersion;
702 strcpy(lpCaps->szPname, capsA.szPname);
703 lpCaps->wTechnology = capsA.wTechnology;
704 lpCaps->wVoices = capsA.wVoices;
705 lpCaps->wNotes = capsA.wNotes;
706 lpCaps->wChannelMask = capsA.wChannelMask;
707 lpCaps->dwSupport = capsA.dwSupport;
712 /**************************************************************************
713 * midiOutGetErrorText [MMSYSTEM.203]
715 UINT16 WINAPI midiOutGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
717 return midiOutGetErrorTextA(uError, lpText, uSize);
720 /**************************************************************************
721 * midiOutOpen [MMSYSTEM.204]
723 UINT16 WINAPI midiOutOpen16(HMIDIOUT16* lphMidiOut, UINT16 uDeviceID,
724 DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
729 ret = MIDI_OutOpen(&hmo, uDeviceID, dwCallback, dwInstance, dwFlags, FALSE);
731 if (lphMidiOut != NULL) *lphMidiOut = HMIDIOUT_16(hmo);
735 /**************************************************************************
736 * midiOutClose [MMSYSTEM.205]
738 UINT16 WINAPI midiOutClose16(HMIDIOUT16 hMidiOut)
740 return midiOutClose(HMIDIOUT_32(hMidiOut));
743 /**************************************************************************
744 * midiOutPrepareHeader [MMSYSTEM.206]
746 UINT16 WINAPI midiOutPrepareHeader16(HMIDIOUT16 hMidiOut, /* [in] */
747 SEGPTR lpsegMidiOutHdr, /* [???] */
748 UINT16 uSize) /* [in] */
752 TRACE("(%04X, %08lx, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
754 if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
755 return MMSYSERR_INVALHANDLE;
757 return MMDRV_Message(wmld, MODM_PREPARE, lpsegMidiOutHdr, uSize, FALSE);
760 /**************************************************************************
761 * midiOutUnprepareHeader [MMSYSTEM.207]
763 UINT16 WINAPI midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut, /* [in] */
764 SEGPTR lpsegMidiOutHdr, /* [???] */
765 UINT16 uSize) /* [in] */
768 LPMIDIHDR16 lpMidiOutHdr = MapSL(lpsegMidiOutHdr);
770 TRACE("(%04X, %08lx, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
772 if (!(lpMidiOutHdr->dwFlags & MHDR_PREPARED)) {
773 return MMSYSERR_NOERROR;
776 if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
777 return MMSYSERR_INVALHANDLE;
779 return MMDRV_Message(wmld, MODM_UNPREPARE, (DWORD)lpsegMidiOutHdr, uSize, FALSE);
782 /**************************************************************************
783 * midiOutShortMsg [MMSYSTEM.208]
785 UINT16 WINAPI midiOutShortMsg16(HMIDIOUT16 hMidiOut, DWORD dwMsg)
787 return midiOutShortMsg(HMIDIOUT_32(hMidiOut), dwMsg);
790 /**************************************************************************
791 * midiOutLongMsg [MMSYSTEM.209]
793 UINT16 WINAPI midiOutLongMsg16(HMIDIOUT16 hMidiOut, /* [in] */
794 LPMIDIHDR16 lpsegMidiOutHdr, /* [???] NOTE: SEGPTR */
795 UINT16 uSize) /* [in] */
799 TRACE("(%04X, %p, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
801 if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
802 return MMSYSERR_INVALHANDLE;
804 return MMDRV_Message(wmld, MODM_LONGDATA, (DWORD)lpsegMidiOutHdr, uSize, FALSE);
807 /**************************************************************************
808 * midiOutReset [MMSYSTEM.210]
810 UINT16 WINAPI midiOutReset16(HMIDIOUT16 hMidiOut)
812 return midiOutReset(HMIDIOUT_32(hMidiOut));
815 /**************************************************************************
816 * midiOutGetVolume [MMSYSTEM.211]
818 UINT16 WINAPI midiOutGetVolume16(UINT16 uDeviceID, DWORD* lpdwVolume)
820 return midiOutGetVolume(HMIDIOUT_32(uDeviceID), lpdwVolume);
823 /**************************************************************************
824 * midiOutSetVolume [MMSYSTEM.212]
826 UINT16 WINAPI midiOutSetVolume16(UINT16 uDeviceID, DWORD dwVolume)
828 return midiOutSetVolume(HMIDIOUT_32(uDeviceID), dwVolume);
831 /**************************************************************************
832 * midiOutCachePatches [MMSYSTEM.213]
834 UINT16 WINAPI midiOutCachePatches16(HMIDIOUT16 hMidiOut, UINT16 uBank,
835 WORD* lpwPatchArray, UINT16 uFlags)
837 return midiOutCachePatches(HMIDIOUT_32(hMidiOut), uBank, lpwPatchArray,
841 /**************************************************************************
842 * midiOutCacheDrumPatches [MMSYSTEM.214]
844 UINT16 WINAPI midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut, UINT16 uPatch,
845 WORD* lpwKeyArray, UINT16 uFlags)
847 return midiOutCacheDrumPatches(HMIDIOUT_32(hMidiOut), uPatch, lpwKeyArray, uFlags);
850 /**************************************************************************
851 * midiOutGetID [MMSYSTEM.215]
853 UINT16 WINAPI midiOutGetID16(HMIDIOUT16 hMidiOut, UINT16* lpuDeviceID)
857 TRACE("(%04X, %p)\n", hMidiOut, lpuDeviceID);
859 if (lpuDeviceID == NULL) return MMSYSERR_INVALPARAM;
860 if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
861 return MMSYSERR_INVALHANDLE;
863 *lpuDeviceID = wmld->uDeviceID;
864 return MMSYSERR_NOERROR;
867 /**************************************************************************
868 * midiOutMessage [MMSYSTEM.216]
870 DWORD WINAPI midiOutMessage16(HMIDIOUT16 hMidiOut, UINT16 uMessage,
871 DWORD dwParam1, DWORD dwParam2)
875 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiOut, uMessage, dwParam1, dwParam2);
877 if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
878 return MMSYSERR_INVALHANDLE;
883 FIXME("can't handle OPEN or CLOSE message!\n");
884 return MMSYSERR_NOTSUPPORTED;
887 return midiOutGetVolume16(hMidiOut, MapSL(dwParam1));
889 return midiOutLongMsg16(hMidiOut, MapSL(dwParam1), dwParam2);
891 /* lpMidiOutHdr is still a segmented pointer for this function */
892 return midiOutPrepareHeader16(hMidiOut, dwParam1, dwParam2);
894 return midiOutUnprepareHeader16(hMidiOut, dwParam1, dwParam2);
896 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
899 /**************************************************************************
900 * midiInGetNumDevs [MMSYSTEM.301]
902 UINT16 WINAPI midiInGetNumDevs16(void)
904 return MMDRV_GetNum(MMDRV_MIDIIN);
907 /**************************************************************************
908 * midiInGetDevCaps [MMSYSTEM.302]
910 UINT16 WINAPI midiInGetDevCaps16(UINT16 uDeviceID, LPMIDIINCAPS16 lpCaps,
914 UINT ret = midiInGetDevCapsA(uDeviceID, &micA, uSize);
916 if (ret == MMSYSERR_NOERROR) {
917 lpCaps->wMid = micA.wMid;
918 lpCaps->wPid = micA.wPid;
919 lpCaps->vDriverVersion = micA.vDriverVersion;
920 strcpy(lpCaps->szPname, micA.szPname);
921 lpCaps->dwSupport = micA.dwSupport;
927 /**************************************************************************
928 * midiInGetErrorText [MMSYSTEM.303]
930 UINT16 WINAPI midiInGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
932 return midiInGetErrorTextA(uError, lpText, uSize);
935 /**************************************************************************
936 * midiInOpen [MMSYSTEM.304]
938 UINT16 WINAPI midiInOpen16(HMIDIIN16* lphMidiIn, UINT16 uDeviceID,
939 DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
944 ret = MIDI_InOpen(&xhmid, uDeviceID, dwCallback, dwInstance, dwFlags, FALSE);
946 if (lphMidiIn) *lphMidiIn = HMIDIIN_16(xhmid);
950 /**************************************************************************
951 * midiInClose [MMSYSTEM.305]
953 UINT16 WINAPI midiInClose16(HMIDIIN16 hMidiIn)
955 return midiInClose(HMIDIIN_32(hMidiIn));
958 /**************************************************************************
959 * midiInPrepareHeader [MMSYSTEM.306]
961 UINT16 WINAPI midiInPrepareHeader16(HMIDIIN16 hMidiIn, /* [in] */
962 SEGPTR lpsegMidiInHdr, /* [???] */
963 UINT16 uSize) /* [in] */
967 TRACE("(%04X, %08lx, %d)\n", hMidiIn, lpsegMidiInHdr, uSize);
969 if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL)
970 return MMSYSERR_INVALHANDLE;
972 return MMDRV_Message(wmld, MIDM_PREPARE, (DWORD)lpsegMidiInHdr, uSize, FALSE);
975 /**************************************************************************
976 * midiInUnprepareHeader [MMSYSTEM.307]
978 UINT16 WINAPI midiInUnprepareHeader16(HMIDIIN16 hMidiIn, /* [in] */
979 SEGPTR lpsegMidiInHdr, /* [???] */
980 UINT16 uSize) /* [in] */
983 LPMIDIHDR16 lpMidiInHdr = MapSL(lpsegMidiInHdr);
985 TRACE("(%04X, %08lx, %d)\n", hMidiIn, lpsegMidiInHdr, uSize);
987 if (!(lpMidiInHdr->dwFlags & MHDR_PREPARED)) {
988 return MMSYSERR_NOERROR;
991 if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL)
992 return MMSYSERR_INVALHANDLE;
994 return MMDRV_Message(wmld, MIDM_UNPREPARE, (DWORD)lpsegMidiInHdr, uSize, FALSE);
997 /**************************************************************************
998 * midiInAddBuffer [MMSYSTEM.308]
1000 UINT16 WINAPI midiInAddBuffer16(HMIDIIN16 hMidiIn, /* [in] */
1001 MIDIHDR16* lpsegMidiInHdr, /* [???] NOTE: SEGPTR */
1002 UINT16 uSize) /* [in] */
1006 TRACE("(%04X, %p, %d)\n", hMidiIn, lpsegMidiInHdr, uSize);
1008 if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL)
1009 return MMSYSERR_INVALHANDLE;
1011 return MMDRV_Message(wmld, MIDM_ADDBUFFER, (DWORD)lpsegMidiInHdr, uSize, FALSE);
1014 /**************************************************************************
1015 * midiInStart [MMSYSTEM.309]
1017 UINT16 WINAPI midiInStart16(HMIDIIN16 hMidiIn)
1019 return midiInStart(HMIDIIN_32(hMidiIn));
1022 /**************************************************************************
1023 * midiInStop [MMSYSTEM.310]
1025 UINT16 WINAPI midiInStop16(HMIDIIN16 hMidiIn)
1027 return midiInStop(HMIDIIN_32(hMidiIn));
1030 /**************************************************************************
1031 * midiInReset [MMSYSTEM.311]
1033 UINT16 WINAPI midiInReset16(HMIDIIN16 hMidiIn)
1035 return midiInReset(HMIDIIN_32(hMidiIn));
1038 /**************************************************************************
1039 * midiInGetID [MMSYSTEM.312]
1041 UINT16 WINAPI midiInGetID16(HMIDIIN16 hMidiIn, UINT16* lpuDeviceID)
1045 TRACE("(%04X, %p)\n", hMidiIn, lpuDeviceID);
1047 if (lpuDeviceID == NULL) return MMSYSERR_INVALPARAM;
1049 if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, TRUE)) == NULL)
1050 return MMSYSERR_INVALHANDLE;
1052 *lpuDeviceID = wmld->uDeviceID;
1054 return MMSYSERR_NOERROR;
1057 /**************************************************************************
1058 * midiInMessage [MMSYSTEM.313]
1060 DWORD WINAPI midiInMessage16(HMIDIIN16 hMidiIn, UINT16 uMessage,
1061 DWORD dwParam1, DWORD dwParam2)
1065 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn, uMessage, dwParam1, dwParam2);
1070 FIXME("can't handle OPEN or CLOSE message!\n");
1071 return MMSYSERR_NOTSUPPORTED;
1073 case MIDM_GETDEVCAPS:
1074 return midiInGetDevCaps16(hMidiIn, MapSL(dwParam1), dwParam2);
1076 return midiInPrepareHeader16(hMidiIn, dwParam1, dwParam2);
1077 case MIDM_UNPREPARE:
1078 return midiInUnprepareHeader16(hMidiIn, dwParam1, dwParam2);
1079 case MIDM_ADDBUFFER:
1080 return midiInAddBuffer16(hMidiIn, MapSL(dwParam1), dwParam2);
1083 if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL)
1084 return MMSYSERR_INVALHANDLE;
1086 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, FALSE);
1089 /**************************************************************************
1090 * midiStreamClose [MMSYSTEM.252]
1092 MMRESULT16 WINAPI midiStreamClose16(HMIDISTRM16 hMidiStrm)
1094 return midiStreamClose(HMIDISTRM_32(hMidiStrm));
1097 /**************************************************************************
1098 * midiStreamOpen [MMSYSTEM.251]
1100 MMRESULT16 WINAPI midiStreamOpen16(HMIDISTRM16* phMidiStrm, LPUINT16 devid,
1101 DWORD cMidi, DWORD dwCallback,
1102 DWORD dwInstance, DWORD fdwOpen)
1104 HMIDISTRM hMidiStrm32;
1108 if (!phMidiStrm || !devid)
1109 return MMSYSERR_INVALPARAM;
1111 ret = MIDI_StreamOpen(&hMidiStrm32, &devid32, cMidi, dwCallback,
1112 dwInstance, fdwOpen, FALSE);
1113 *phMidiStrm = HMIDISTRM_16(hMidiStrm32);
1118 /**************************************************************************
1119 * midiStreamOut [MMSYSTEM.254]
1121 MMRESULT16 WINAPI midiStreamOut16(HMIDISTRM16 hMidiStrm, LPMIDIHDR16 lpMidiHdr, UINT16 cbMidiHdr)
1123 return midiStreamOut(HMIDISTRM_32(hMidiStrm), (LPMIDIHDR)lpMidiHdr,
1127 /**************************************************************************
1128 * midiStreamPause [MMSYSTEM.255]
1130 MMRESULT16 WINAPI midiStreamPause16(HMIDISTRM16 hMidiStrm)
1132 return midiStreamPause(HMIDISTRM_32(hMidiStrm));
1135 /**************************************************************************
1136 * midiStreamPosition [MMSYSTEM.253]
1138 MMRESULT16 WINAPI midiStreamPosition16(HMIDISTRM16 hMidiStrm, LPMMTIME16 lpmmt16, UINT16 cbmmt)
1144 return MMSYSERR_INVALPARAM;
1145 MMSYSTEM_MMTIME16to32(&mmt32, lpmmt16);
1146 ret = midiStreamPosition(HMIDISTRM_32(hMidiStrm), &mmt32, sizeof(MMTIME));
1147 MMSYSTEM_MMTIME32to16(lpmmt16, &mmt32);
1151 /**************************************************************************
1152 * midiStreamProperty [MMSYSTEM.250]
1154 MMRESULT16 WINAPI midiStreamProperty16(HMIDISTRM16 hMidiStrm, LPBYTE lpPropData, DWORD dwProperty)
1156 return midiStreamProperty(HMIDISTRM_32(hMidiStrm), lpPropData, dwProperty);
1159 /**************************************************************************
1160 * midiStreamRestart [MMSYSTEM.256]
1162 MMRESULT16 WINAPI midiStreamRestart16(HMIDISTRM16 hMidiStrm)
1164 return midiStreamRestart(HMIDISTRM_32(hMidiStrm));
1167 /**************************************************************************
1168 * midiStreamStop [MMSYSTEM.257]
1170 MMRESULT16 WINAPI midiStreamStop16(HMIDISTRM16 hMidiStrm)
1172 return midiStreamStop(HMIDISTRM_32(hMidiStrm));
1175 /* ###################################################
1177 * ###################################################
1180 /**************************************************************************
1181 * waveOutGetNumDevs [MMSYSTEM.401]
1183 UINT16 WINAPI waveOutGetNumDevs16(void)
1185 return MMDRV_GetNum(MMDRV_WAVEOUT);
1188 /**************************************************************************
1189 * waveOutGetDevCaps [MMSYSTEM.402]
1191 UINT16 WINAPI waveOutGetDevCaps16(UINT16 uDeviceID,
1192 LPWAVEOUTCAPS16 lpCaps, UINT16 uSize)
1197 TRACE("(%u %p %u)!\n", uDeviceID, lpCaps, uSize);
1198 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
1200 ret = waveOutGetDevCapsA(uDeviceID, &wocA, sizeof(wocA));
1202 if (ret == MMSYSERR_NOERROR) {
1203 lpCaps->wMid = wocA.wMid;
1204 lpCaps->wPid = wocA.wPid;
1205 lpCaps->vDriverVersion = wocA.vDriverVersion;
1206 strcpy(lpCaps->szPname, wocA.szPname);
1207 lpCaps->dwFormats = wocA.dwFormats;
1208 lpCaps->wChannels = wocA.wChannels;
1209 lpCaps->dwSupport = wocA.dwSupport;
1214 /**************************************************************************
1215 * waveOutGetErrorText [MMSYSTEM.403]
1217 UINT16 WINAPI waveOutGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
1219 return waveOutGetErrorTextA(uError, lpText, uSize);
1222 /**************************************************************************
1223 * waveOutOpen [MMSYSTEM.404]
1225 UINT16 WINAPI waveOutOpen16(HWAVEOUT16* lphWaveOut, UINT16 uDeviceID,
1226 const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
1227 DWORD dwInstance, DWORD dwFlags)
1232 /* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
1233 * call the 32 bit version
1234 * however, we need to promote correctly the wave mapper id
1235 * (0xFFFFFFFF and not 0x0000FFFF)
1237 ret = WAVE_Open(&hWaveOut, (uDeviceID == (UINT16)-1) ? (UINT)-1 : uDeviceID,
1238 MMDRV_WAVEOUT, lpFormat, dwCallback, dwInstance, dwFlags, FALSE);
1240 if (lphWaveOut != NULL) *lphWaveOut = HWAVEOUT_16(hWaveOut);
1244 /**************************************************************************
1245 * waveOutClose [MMSYSTEM.405]
1247 UINT16 WINAPI waveOutClose16(HWAVEOUT16 hWaveOut)
1252 ReleaseThunkLock(&level);
1253 ret = waveOutClose(HWAVEOUT_32(hWaveOut));
1254 RestoreThunkLock(level);
1258 /**************************************************************************
1259 * waveOutPrepareHeader [MMSYSTEM.406]
1261 UINT16 WINAPI waveOutPrepareHeader16(HWAVEOUT16 hWaveOut, /* [in] */
1262 SEGPTR lpsegWaveOutHdr, /* [???] */
1263 UINT16 uSize) /* [in] */
1266 LPWAVEHDR lpWaveOutHdr = MapSL(lpsegWaveOutHdr);
1268 TRACE("(%04X, %08lx, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
1270 if (lpWaveOutHdr == NULL) return MMSYSERR_INVALPARAM;
1272 if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
1273 return MMSYSERR_INVALHANDLE;
1275 return MMDRV_Message(wmld, WODM_PREPARE, (DWORD)lpsegWaveOutHdr, uSize, FALSE);
1278 /**************************************************************************
1279 * waveOutUnprepareHeader [MMSYSTEM.407]
1281 UINT16 WINAPI waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut, /* [in] */
1282 SEGPTR lpsegWaveOutHdr, /* [???] */
1283 UINT16 uSize) /* [in] */
1286 LPWAVEHDR lpWaveOutHdr = MapSL(lpsegWaveOutHdr);
1288 TRACE("(%04X, %08lx, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
1290 if (!(lpWaveOutHdr->dwFlags & WHDR_PREPARED)) {
1291 return MMSYSERR_NOERROR;
1294 if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
1295 return MMSYSERR_INVALHANDLE;
1297 return MMDRV_Message(wmld, WODM_UNPREPARE, (DWORD)lpsegWaveOutHdr, uSize, FALSE);
1300 /**************************************************************************
1301 * waveOutWrite [MMSYSTEM.408]
1303 UINT16 WINAPI waveOutWrite16(HWAVEOUT16 hWaveOut, /* [in] */
1304 LPWAVEHDR lpsegWaveOutHdr, /* [???] NOTE: SEGPTR */
1305 UINT16 uSize) /* [in] */
1309 TRACE("(%04X, %p, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
1311 if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
1312 return MMSYSERR_INVALHANDLE;
1314 return MMDRV_Message(wmld, WODM_WRITE, (DWORD)lpsegWaveOutHdr, uSize, FALSE);
1317 /**************************************************************************
1318 * waveOutBreakLoop [MMSYSTEM.419]
1320 UINT16 WINAPI waveOutBreakLoop16(HWAVEOUT16 hWaveOut16)
1325 ReleaseThunkLock(&level);
1326 ret = waveOutBreakLoop(HWAVEOUT_32(hWaveOut16));
1327 RestoreThunkLock(level);
1331 /**************************************************************************
1332 * waveOutPause [MMSYSTEM.409]
1334 UINT16 WINAPI waveOutPause16(HWAVEOUT16 hWaveOut16)
1339 ReleaseThunkLock(&level);
1340 ret = waveOutPause(HWAVEOUT_32(hWaveOut16));
1341 RestoreThunkLock(level);
1345 /**************************************************************************
1346 * waveOutReset [MMSYSTEM.411]
1348 UINT16 WINAPI waveOutReset16(HWAVEOUT16 hWaveOut16)
1353 ReleaseThunkLock(&level);
1354 ret = waveOutReset(HWAVEOUT_32(hWaveOut16));
1355 RestoreThunkLock(level);
1359 /**************************************************************************
1360 * waveOutRestart [MMSYSTEM.410]
1362 UINT16 WINAPI waveOutRestart16(HWAVEOUT16 hWaveOut16)
1367 ReleaseThunkLock(&level);
1368 ret = waveOutRestart(HWAVEOUT_32(hWaveOut16));
1369 RestoreThunkLock(level);
1373 /**************************************************************************
1374 * waveOutGetPosition [MMSYSTEM.412]
1376 UINT16 WINAPI waveOutGetPosition16(HWAVEOUT16 hWaveOut, LPMMTIME16 lpTime,
1382 mmt.wType = lpTime->wType;
1383 ret = waveOutGetPosition(HWAVEOUT_32(hWaveOut), &mmt, sizeof(mmt));
1384 MMSYSTEM_MMTIME32to16(lpTime, &mmt);
1388 /**************************************************************************
1389 * waveOutGetPitch [MMSYSTEM.413]
1391 UINT16 WINAPI waveOutGetPitch16(HWAVEOUT16 hWaveOut16, LPDWORD lpdw)
1393 return waveOutGetPitch(HWAVEOUT_32(hWaveOut16), lpdw);
1396 /**************************************************************************
1397 * waveOutSetPitch [MMSYSTEM.414]
1399 UINT16 WINAPI waveOutSetPitch16(HWAVEOUT16 hWaveOut16, DWORD dw)
1401 return waveOutSetPitch(HWAVEOUT_32(hWaveOut16), dw);
1404 /**************************************************************************
1405 * waveOutGetPlaybackRate [MMSYSTEM.417]
1407 UINT16 WINAPI waveOutGetPlaybackRate16(HWAVEOUT16 hWaveOut16, LPDWORD lpdw)
1409 return waveOutGetPlaybackRate(HWAVEOUT_32(hWaveOut16), lpdw);
1412 /**************************************************************************
1413 * waveOutSetPlaybackRate [MMSYSTEM.418]
1415 UINT16 WINAPI waveOutSetPlaybackRate16(HWAVEOUT16 hWaveOut16, DWORD dw)
1417 return waveOutSetPlaybackRate(HWAVEOUT_32(hWaveOut16), dw);
1420 /**************************************************************************
1421 * waveOutGetVolume [MMSYSTEM.415]
1423 UINT16 WINAPI waveOutGetVolume16(UINT16 devid, LPDWORD lpdw)
1425 return waveOutGetVolume(HWAVEOUT_32(devid), lpdw);
1428 /**************************************************************************
1429 * waveOutSetVolume [MMSYSTEM.416]
1431 UINT16 WINAPI waveOutSetVolume16(UINT16 devid, DWORD dw)
1433 return waveOutSetVolume(HWAVEOUT_32(devid), dw);
1436 /**************************************************************************
1437 * waveOutGetID [MMSYSTEM.420]
1439 UINT16 WINAPI waveOutGetID16(HWAVEOUT16 hWaveOut, UINT16* lpuDeviceID)
1443 TRACE("(%04X, %p);\n", hWaveOut, lpuDeviceID);
1445 if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
1447 if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
1448 return MMSYSERR_INVALHANDLE;
1450 *lpuDeviceID = wmld->uDeviceID;
1454 /**************************************************************************
1455 * waveOutMessage [MMSYSTEM.421]
1457 DWORD WINAPI waveOutMessage16(HWAVEOUT16 hWaveOut, UINT16 uMessage,
1458 DWORD dwParam1, DWORD dwParam2)
1462 TRACE("(%04x, %u, %ld, %ld)\n", hWaveOut, uMessage, dwParam1, dwParam2);
1464 if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL) {
1465 if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, TRUE)) != NULL) {
1466 return MMDRV_PhysicalFeatures(wmld, uMessage, dwParam1, dwParam2);
1468 return MMSYSERR_INVALHANDLE;
1472 if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
1473 return MMSYSERR_INVALPARAM;
1475 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, FALSE);
1478 /**************************************************************************
1479 * waveInGetNumDevs [MMSYSTEM.501]
1481 UINT16 WINAPI waveInGetNumDevs16(void)
1483 return MMDRV_GetNum(MMDRV_WAVEIN);
1486 /**************************************************************************
1487 * waveInGetDevCaps [MMSYSTEM.502]
1489 UINT16 WINAPI waveInGetDevCaps16(UINT16 uDeviceID, LPWAVEINCAPS16 lpCaps,
1493 UINT ret = waveInGetDevCapsA(uDeviceID, &wicA, sizeof(wicA));
1495 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
1497 if (ret == MMSYSERR_NOERROR) {
1498 lpCaps->wMid = wicA.wMid;
1499 lpCaps->wPid = wicA.wPid;
1500 lpCaps->vDriverVersion = wicA.vDriverVersion;
1501 strcpy(lpCaps->szPname, wicA.szPname);
1502 lpCaps->dwFormats = wicA.dwFormats;
1503 lpCaps->wChannels = wicA.wChannels;
1508 /**************************************************************************
1509 * waveInGetErrorText [MMSYSTEM.503]
1511 UINT16 WINAPI waveInGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
1513 return waveInGetErrorTextA(uError, lpText, uSize);
1516 /**************************************************************************
1517 * waveInOpen [MMSYSTEM.504]
1519 UINT16 WINAPI waveInOpen16(HWAVEIN16* lphWaveIn, UINT16 uDeviceID,
1520 const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
1521 DWORD dwInstance, DWORD dwFlags)
1526 /* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
1527 * call the 32 bit version
1528 * however, we need to promote correctly the wave mapper id
1529 * (0xFFFFFFFF and not 0x0000FFFF)
1531 ret = WAVE_Open(&hWaveIn, (uDeviceID == (UINT16)-1) ? (UINT)-1 : uDeviceID,
1532 MMDRV_WAVEIN, lpFormat, dwCallback, dwInstance, dwFlags, FALSE);
1534 if (lphWaveIn != NULL) *lphWaveIn = HWAVEIN_16(hWaveIn);
1538 /**************************************************************************
1539 * waveInClose [MMSYSTEM.505]
1541 UINT16 WINAPI waveInClose16(HWAVEIN16 hWaveIn)
1546 ReleaseThunkLock(&level);
1547 ret = waveInClose(HWAVEIN_32(hWaveIn));
1548 RestoreThunkLock(level);
1552 /**************************************************************************
1553 * waveInPrepareHeader [MMSYSTEM.506]
1555 UINT16 WINAPI waveInPrepareHeader16(HWAVEIN16 hWaveIn, /* [in] */
1556 SEGPTR lpsegWaveInHdr, /* [???] */
1557 UINT16 uSize) /* [in] */
1560 LPWAVEHDR lpWaveInHdr = MapSL(lpsegWaveInHdr);
1563 TRACE("(%04X, %p, %u);\n", hWaveIn, lpWaveInHdr, uSize);
1565 if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
1566 if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
1567 return MMSYSERR_INVALHANDLE;
1569 lpWaveInHdr->dwBytesRecorded = 0;
1571 ret = MMDRV_Message(wmld, WIDM_PREPARE, (DWORD)lpsegWaveInHdr, uSize, FALSE);
1575 /**************************************************************************
1576 * waveInUnprepareHeader [MMSYSTEM.507]
1578 UINT16 WINAPI waveInUnprepareHeader16(HWAVEIN16 hWaveIn, /* [in] */
1579 SEGPTR lpsegWaveInHdr, /* [???] */
1580 UINT16 uSize) /* [in] */
1583 LPWAVEHDR lpWaveInHdr = MapSL(lpsegWaveInHdr);
1585 TRACE("(%04X, %08lx, %u);\n", hWaveIn, lpsegWaveInHdr, uSize);
1587 if (lpWaveInHdr == NULL) return MMSYSERR_INVALPARAM;
1589 if (!(lpWaveInHdr->dwFlags & WHDR_PREPARED)) {
1590 return MMSYSERR_NOERROR;
1593 if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
1594 return MMSYSERR_INVALHANDLE;
1596 return MMDRV_Message(wmld, WIDM_UNPREPARE, (DWORD)lpsegWaveInHdr, uSize, FALSE);
1599 /**************************************************************************
1600 * waveInAddBuffer [MMSYSTEM.508]
1602 UINT16 WINAPI waveInAddBuffer16(HWAVEIN16 hWaveIn, /* [in] */
1603 WAVEHDR* lpsegWaveInHdr, /* [???] NOTE: SEGPTR */
1604 UINT16 uSize) /* [in] */
1608 TRACE("(%04X, %p, %u);\n", hWaveIn, lpsegWaveInHdr, uSize);
1610 if (lpsegWaveInHdr == NULL) return MMSYSERR_INVALPARAM;
1611 if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
1612 return MMSYSERR_INVALHANDLE;
1614 return MMDRV_Message(wmld, WIDM_ADDBUFFER, (DWORD)lpsegWaveInHdr, uSize, FALSE);
1617 /**************************************************************************
1618 * waveInReset [MMSYSTEM.511]
1620 UINT16 WINAPI waveInReset16(HWAVEIN16 hWaveIn16)
1625 ReleaseThunkLock(&level);
1626 ret = waveInReset(HWAVEIN_32(hWaveIn16));
1627 RestoreThunkLock(level);
1631 /**************************************************************************
1632 * waveInStart [MMSYSTEM.509]
1634 UINT16 WINAPI waveInStart16(HWAVEIN16 hWaveIn16)
1639 ReleaseThunkLock(&level);
1640 ret = waveInStart(HWAVEIN_32(hWaveIn16));
1641 RestoreThunkLock(level);
1645 /**************************************************************************
1646 * waveInStop [MMSYSTEM.510]
1648 UINT16 WINAPI waveInStop16(HWAVEIN16 hWaveIn16)
1653 ReleaseThunkLock(&level);
1654 ret = waveInStop(HWAVEIN_32(hWaveIn16));
1655 RestoreThunkLock(level);
1659 /**************************************************************************
1660 * waveInGetPosition [MMSYSTEM.512]
1662 UINT16 WINAPI waveInGetPosition16(HWAVEIN16 hWaveIn, LPMMTIME16 lpTime,
1668 mmt.wType = lpTime->wType;
1669 ret = waveInGetPosition(HWAVEIN_32(hWaveIn), &mmt, sizeof(mmt));
1670 MMSYSTEM_MMTIME32to16(lpTime, &mmt);
1674 /**************************************************************************
1675 * waveInGetID [MMSYSTEM.513]
1677 UINT16 WINAPI waveInGetID16(HWAVEIN16 hWaveIn, UINT16* lpuDeviceID)
1681 TRACE("(%04X, %p);\n", hWaveIn, lpuDeviceID);
1683 if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
1685 if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
1686 return MMSYSERR_INVALHANDLE;
1688 *lpuDeviceID = wmld->uDeviceID;
1689 return MMSYSERR_NOERROR;
1692 /**************************************************************************
1693 * waveInMessage [MMSYSTEM.514]
1695 DWORD WINAPI waveInMessage16(HWAVEIN16 hWaveIn, UINT16 uMessage,
1696 DWORD dwParam1, DWORD dwParam2)
1700 TRACE("(%04x, %u, %ld, %ld)\n", hWaveIn, uMessage, dwParam1, dwParam2);
1703 if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
1704 return MMSYSERR_INVALPARAM;
1706 if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
1707 return MMSYSERR_INVALHANDLE;
1709 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
1712 /* ###################################################
1714 * ###################################################
1717 /*#define USE_MM_TSK_WINE*/
1719 /**************************************************************************
1720 * mmTaskCreate [MMSYSTEM.900]
1722 * Creates a 16 bit MM task. It's entry point is lpFunc, and it should be
1723 * called upon creation with dwPmt as parameter.
1725 HINSTANCE16 WINAPI mmTaskCreate16(SEGPTR spProc, HINSTANCE16 *lphMmTask, DWORD dwPmt)
1730 DWORD showCmd = 0x40002;
1733 TRACE("(%08lx, %p, %08lx);\n", spProc, lphMmTask, dwPmt);
1734 /* This to work requires NE modules to be started with a binary command line
1735 * which is not currently the case. A patch exists but has never been committed.
1736 * A workaround would be to integrate code for mmtask.tsk into Wine, but
1737 * this requires tremendous work (starting with patching tools/build to
1738 * create NE executables (and not only DLLs) for builtins modules.
1741 FIXME("This is currently broken. It will fail\n");
1744 *(LPDWORD)(cmdline + 1) = (DWORD)spProc;
1745 *(LPDWORD)(cmdline + 5) = dwPmt;
1746 *(LPDWORD)(cmdline + 9) = 0;
1748 lp.hEnvironment = 0;
1749 lp.cmdLine = MapLS(cmdline);
1750 lp.showCmd = MapLS(&showCmd);
1753 #ifndef USE_MM_TSK_WINE
1754 handle = LoadModule16("c:\\windows\\system\\mmtask.tsk", &lp);
1756 handle = LoadModule16("mmtask.tsk", &lp);
1759 ret = (handle) ? 1 : 2;
1765 *lphMmTask = handle;
1767 UnMapLS( lp.cmdLine );
1768 UnMapLS( lp.showCmd );
1769 TRACE("=> 0x%04x/%d\n", handle, ret);
1773 #ifdef USE_MM_TSK_WINE
1774 /* C equivalent to mmtask.tsk binary content */
1775 void mmTaskEntryPoint16(LPSTR cmdLine, WORD di, WORD si)
1777 int len = cmdLine[0x80];
1780 void (*fpProc)(DWORD) = MapSL(*((DWORD*)(cmdLine + 1)));
1781 DWORD dwPmt = *((DWORD*)(cmdLine + 5));
1784 InitTask16(); /* FIXME: pmts / from context ? */
1787 if (SetMessageQueue16(0x40)) {
1789 if (HIWORD(fpProc)) {
1791 /* EPP StackEnter16(); */
1803 /**************************************************************************
1804 * mmTaskBlock [MMSYSTEM.902]
1806 void WINAPI mmTaskBlock16(HINSTANCE16 WINE_UNUSED hInst)
1811 GetMessageA(&msg, 0, 0, 0);
1813 TranslateMessage(&msg);
1814 DispatchMessageA(&msg);
1816 } while (msg.message < 0x3A0);
1819 /**************************************************************************
1820 * mmTaskSignal [MMSYSTEM.903]
1822 LRESULT WINAPI mmTaskSignal16(HTASK16 ht)
1824 TRACE("(%04x);\n", ht);
1825 return PostThreadMessageW( HTASK_32(ht), WM_USER, 0, 0 );
1828 /**************************************************************************
1829 * mmGetCurrentTask [MMSYSTEM.904]
1831 HTASK16 WINAPI mmGetCurrentTask16(void)
1833 return GetCurrentTask();
1836 /**************************************************************************
1837 * mmTaskYield [MMSYSTEM.905]
1839 void WINAPI mmTaskYield16(void)
1843 if (PeekMessageA(&msg, 0, 0, 0, 0)) {
1848 extern DWORD WINAPI GetProcessFlags(DWORD);
1850 /******************************************************************
1855 static WINE_MMTHREAD* WINMM_GetmmThread(HANDLE16 h)
1857 return (WINE_MMTHREAD*)MapSL( MAKESEGPTR(h, 0) );
1860 void WINAPI WINE_mmThreadEntryPoint(DWORD);
1862 /**************************************************************************
1863 * mmThreadCreate [MMSYSTEM.1120]
1866 * Creates a MM thread, calling fpThreadAddr(dwPmt).
1868 * bit.0 set means create a 16 bit task instead of thread calling a 16 bit proc
1869 * bit.1 set means to open a VxD for this thread (unsupported)
1871 LRESULT WINAPI mmThreadCreate16(FARPROC16 fpThreadAddr, LPHANDLE16 lpHndl, DWORD dwPmt, DWORD dwFlags)
1876 TRACE("(%p, %p, %08lx, %08lx)!\n", fpThreadAddr, lpHndl, dwPmt, dwFlags);
1878 hndl = GlobalAlloc16(sizeof(WINE_MMTHREAD), GMEM_SHARE|GMEM_ZEROINIT);
1883 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
1886 /* force mmtask routines even if mmthread is required */
1887 /* this will work only if the patch about binary cmd line and NE tasks
1893 lpMMThd->dwSignature = WINE_MMTHREAD_CREATED;
1894 lpMMThd->dwCounter = 0;
1895 lpMMThd->hThread = 0;
1896 lpMMThd->dwThreadID = 0;
1897 lpMMThd->fpThread = fpThreadAddr;
1898 lpMMThd->dwThreadPmt = dwPmt;
1899 lpMMThd->dwSignalCount = 0;
1900 lpMMThd->hEvent = 0;
1902 lpMMThd->dwStatus = 0;
1903 lpMMThd->dwFlags = dwFlags;
1906 if ((dwFlags & 1) == 0 && (GetProcessFlags(GetCurrentThreadId()) & 8) == 0) {
1907 lpMMThd->hEvent = CreateEventA(0, 0, 1, 0);
1909 TRACE("Let's go crazy... trying new MM thread. lpMMThd=%p\n", lpMMThd);
1910 if (lpMMThd->dwFlags & 2) {
1911 /* as long as we don't support MM VxD in wine, we don't need
1912 * to care about this flag
1914 /* FIXME("Don't know how to properly open VxD handles\n"); */
1915 /* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */
1918 lpMMThd->hThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)WINE_mmThreadEntryPoint,
1919 (LPVOID)(DWORD)hndl, CREATE_SUSPENDED, &lpMMThd->dwThreadID);
1920 if (lpMMThd->hThread == 0) {
1921 WARN("Couldn't create thread\n");
1922 /* clean-up(VxDhandle...); devicedirectio... */
1923 if (lpMMThd->hEvent != 0)
1924 CloseHandle(lpMMThd->hEvent);
1927 TRACE("Got a nice thread hndl=%p id=0x%08lx\n", lpMMThd->hThread, lpMMThd->dwThreadID);
1931 /* get WINE_mmThreadEntryPoint()
1932 * 2047 is its ordinal in mmsystem.spec
1934 FARPROC16 fp = GetProcAddress16(GetModuleHandle16("MMSYSTEM"), (LPCSTR)2047);
1936 TRACE("farproc seg=0x%08lx lin=%p\n", (DWORD)fp, MapSL((SEGPTR)fp));
1938 ret = (fp == 0) ? 2 : mmTaskCreate16((DWORD)fp, 0, hndl);
1942 if (lpMMThd->hThread && !ResumeThread(lpMMThd->hThread))
1943 WARN("Couldn't resume thread\n");
1945 while (lpMMThd->dwStatus != 0x10) { /* test also HIWORD of dwStatus */
1959 TRACE("ok => %ld\n", ret);
1963 /**************************************************************************
1964 * mmThreadSignal [MMSYSTEM.1121]
1966 void WINAPI mmThreadSignal16(HANDLE16 hndl)
1968 TRACE("(%04x)!\n", hndl);
1971 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
1973 lpMMThd->dwCounter++;
1974 if (lpMMThd->hThread != 0) {
1975 InterlockedIncrement(&lpMMThd->dwSignalCount);
1976 SetEvent(lpMMThd->hEvent);
1978 mmTaskSignal16(lpMMThd->hTask);
1980 lpMMThd->dwCounter--;
1984 static void MMSYSTEM_ThreadBlock(WINE_MMTHREAD* lpMMThd)
1989 if (lpMMThd->dwThreadID != GetCurrentThreadId())
1990 ERR("Not called by thread itself\n");
1993 ResetEvent(lpMMThd->hEvent);
1994 if (InterlockedDecrement(&lpMMThd->dwSignalCount) >= 0)
1996 InterlockedIncrement(&lpMMThd->dwSignalCount);
2000 ret = MsgWaitForMultipleObjects(1, &lpMMThd->hEvent, FALSE, INFINITE, QS_ALLINPUT);
2002 case WAIT_OBJECT_0: /* Event */
2005 case WAIT_OBJECT_0 + 1: /* Msg */
2007 if (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) {
2008 TranslateMessage(&msg);
2009 DispatchMessageA(&msg);
2013 WARN("S2.x unsupported ret val 0x%08lx\n", ret);
2019 /**************************************************************************
2020 * mmThreadBlock [MMSYSTEM.1122]
2022 void WINAPI mmThreadBlock16(HANDLE16 hndl)
2024 TRACE("(%04x)!\n", hndl);
2027 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
2029 if (lpMMThd->hThread != 0) {
2032 ReleaseThunkLock(&lc);
2033 MMSYSTEM_ThreadBlock(lpMMThd);
2034 RestoreThunkLock(lc);
2036 mmTaskBlock16(lpMMThd->hTask);
2042 /**************************************************************************
2043 * mmThreadIsCurrent [MMSYSTEM.1123]
2045 BOOL16 WINAPI mmThreadIsCurrent16(HANDLE16 hndl)
2049 TRACE("(%04x)!\n", hndl);
2051 if (hndl && mmThreadIsValid16(hndl)) {
2052 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
2053 ret = (GetCurrentThreadId() == lpMMThd->dwThreadID);
2055 TRACE("=> %d\n", ret);
2059 /**************************************************************************
2060 * mmThreadIsValid [MMSYSTEM.1124]
2062 BOOL16 WINAPI mmThreadIsValid16(HANDLE16 hndl)
2066 TRACE("(%04x)!\n", hndl);
2069 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
2071 if (!IsBadWritePtr(lpMMThd, sizeof(WINE_MMTHREAD)) &&
2072 lpMMThd->dwSignature == WINE_MMTHREAD_CREATED &&
2073 IsTask16(lpMMThd->hTask)) {
2074 lpMMThd->dwCounter++;
2075 if (lpMMThd->hThread != 0) {
2077 if (GetExitCodeThread(lpMMThd->hThread, &dwThreadRet) &&
2078 dwThreadRet == STATUS_PENDING) {
2084 lpMMThd->dwCounter--;
2087 TRACE("=> %d\n", ret);
2091 /**************************************************************************
2092 * mmThreadGetTask [MMSYSTEM.1125]
2094 HANDLE16 WINAPI mmThreadGetTask16(HANDLE16 hndl)
2098 TRACE("(%04x)\n", hndl);
2100 if (mmThreadIsValid16(hndl)) {
2101 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
2102 ret = lpMMThd->hTask;
2107 /**************************************************************************
2108 * __wine_mmThreadEntryPoint (MMSYSTEM.2047)
2110 void WINAPI WINE_mmThreadEntryPoint(DWORD _pmt)
2112 HANDLE16 hndl = (HANDLE16)_pmt;
2113 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
2115 TRACE("(%04x %p)\n", hndl, lpMMThd);
2117 lpMMThd->hTask = LOWORD(GetCurrentTask());
2118 TRACE("[10-%p] setting hTask to 0x%08x\n", lpMMThd->hThread, lpMMThd->hTask);
2119 lpMMThd->dwStatus = 0x10;
2120 MMSYSTEM_ThreadBlock(lpMMThd);
2121 TRACE("[20-%p]\n", lpMMThd->hThread);
2122 lpMMThd->dwStatus = 0x20;
2123 if (lpMMThd->fpThread) {
2124 WOWCallback16((DWORD)lpMMThd->fpThread, lpMMThd->dwThreadPmt);
2126 lpMMThd->dwStatus = 0x30;
2127 TRACE("[30-%p]\n", lpMMThd->hThread);
2128 while (lpMMThd->dwCounter) {
2130 /* K32WOWYield16();*/
2132 TRACE("[XX-%p]\n", lpMMThd->hThread);
2134 lpMMThd->dwSignature = WINE_MMTHREAD_DELETED;
2135 /* close lpMMThread->hVxD directIO */
2136 if (lpMMThd->hEvent)
2137 CloseHandle(lpMMThd->hEvent);
2142 typedef BOOL16 (WINAPI *MMCPLCALLBACK)(HWND, LPCSTR, LPCSTR, LPCSTR);
2144 /**************************************************************************
2145 * mmShowMMCPLPropertySheet [MMSYSTEM.1150]
2147 BOOL16 WINAPI mmShowMMCPLPropertySheet16(HWND hWnd, LPCSTR lpStrDevice,
2148 LPCSTR lpStrTab, LPCSTR lpStrTitle)
2153 TRACE("(%p \"%s\" \"%s\" \"%s\")\n", hWnd, lpStrDevice, lpStrTab, lpStrTitle);
2155 hndl = LoadLibraryA("MMSYS.CPL");
2157 MMCPLCALLBACK fp = (MMCPLCALLBACK)GetProcAddress(hndl, "ShowMMCPLPropertySheet");
2160 ReleaseThunkLock(&lc);
2161 ret = (fp)(hWnd, lpStrDevice, lpStrTab, lpStrTitle);
2162 RestoreThunkLock(lc);
2170 /**************************************************************************
2171 * StackEnter [MMSYSTEM.32]
2173 void WINAPI StackEnter16(void)
2176 /* mmsystem.dll from Win 95 does only this: so does Wine */
2181 /**************************************************************************
2182 * StackLeave [MMSYSTEM.33]
2184 void WINAPI StackLeave16(void)
2187 /* mmsystem.dll from Win 95 does only this: so does Wine */
2192 /**************************************************************************
2193 * WMMMidiRunOnce [MMSYSTEM.8]
2195 void WINAPI WMMMidiRunOnce16(void)
2197 FIXME("(), stub!\n");
2200 /* ###################################################
2202 * ###################################################
2205 /**************************************************************************
2206 * DRIVER_MapMsg32To16 [internal]
2208 * Map a 32 bit driver message to a 16 bit driver message.
2210 static WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
2212 WINMM_MapType ret = WINMM_MAP_MSGERROR;
2219 case DRV_QUERYCONFIGURE:
2221 case DRV_EXITSESSION:
2222 case DRV_EXITAPPLICATION:
2224 case DRV_CLOSE: /* should be 0/0 */
2225 case DRV_OPEN: /* pass through */
2226 /* lParam1 and lParam2 are not used */
2231 /* lParam1 is a handle to a window (conf) or to a driver (inst) or not used,
2232 * lParam2 is a pointer to DRVCONFIGINFO
2235 LPDRVCONFIGINFO16 dci16 = HeapAlloc( GetProcessHeap(), 0, sizeof(*dci16) );
2236 LPDRVCONFIGINFO dci32 = (LPDRVCONFIGINFO)(*lParam2);
2241 dci16->dwDCISize = sizeof(DRVCONFIGINFO16);
2243 if (dci32->lpszDCISectionName) {
2244 len = WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCISectionName, -1, NULL, 0, NULL, NULL );
2245 str1 = HeapAlloc( GetProcessHeap(), 0, len );
2247 WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCISectionName, -1, str1, len, NULL, NULL );
2248 dci16->lpszDCISectionName = MapLS( str1 );
2250 return WINMM_MAP_NOMEM;
2253 dci16->lpszDCISectionName = 0L;
2255 if (dci32->lpszDCIAliasName) {
2256 len = WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCIAliasName, -1, NULL, 0, NULL, NULL );
2257 str1 = HeapAlloc( GetProcessHeap(), 0, len );
2259 WideCharToMultiByte( CP_ACP, 0, dci32->lpszDCIAliasName, -1, str1, len, NULL, NULL );
2260 dci16->lpszDCIAliasName = MapLS( str1 );
2262 return WINMM_MAP_NOMEM;
2265 dci16->lpszDCISectionName = 0L;
2268 return WINMM_MAP_NOMEM;
2270 *lParam2 = MapLS( dci16 );
2271 ret = WINMM_MAP_OKMEM;
2277 if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) {
2278 FIXME("Unknown message 0x%04x\n", wMsg);
2285 /**************************************************************************
2286 * DRIVER_UnMapMsg32To16 [internal]
2288 * UnMap a 32 bit driver message to a 16 bit driver message.
2290 static WINMM_MapType DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
2292 WINMM_MapType ret = WINMM_MAP_MSGERROR;
2299 case DRV_QUERYCONFIGURE:
2301 case DRV_EXITSESSION:
2302 case DRV_EXITAPPLICATION:
2306 /* lParam1 and lParam2 are not used */
2310 /* lParam1 is a handle to a window (or not used), lParam2 is a pointer to DRVCONFIGINFO, lParam2 */
2312 LPDRVCONFIGINFO16 dci16 = MapSL(lParam2);
2313 HeapFree( GetProcessHeap(), 0, MapSL(dci16->lpszDCISectionName) );
2314 HeapFree( GetProcessHeap(), 0, MapSL(dci16->lpszDCIAliasName) );
2316 UnMapLS( dci16->lpszDCISectionName );
2317 UnMapLS( dci16->lpszDCIAliasName );
2318 HeapFree( GetProcessHeap(), 0, dci16 );
2323 if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) {
2324 FIXME("Unknown message 0x%04x\n", wMsg);
2331 /**************************************************************************
2332 * DRIVER_TryOpenDriver16 [internal]
2334 * Tries to load a 16 bit driver whose DLL's (module) name is lpFileName.
2336 static LPWINE_DRIVER DRIVER_OpenDriver16(LPCSTR fn, LPCSTR sn, LPARAM lParam2)
2338 LPWINE_DRIVER lpDrv = NULL;
2341 TRACE("(%s, %08lX);\n", debugstr_a(sn), lParam2);
2343 lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER));
2344 if (lpDrv == NULL) {cause = "OOM"; goto exit;}
2346 /* FIXME: shall we do some black magic here on sn ?
2347 * drivers32 => drivers
2351 lpDrv->d.d16.hDriver16 = OpenDriver16(fn, sn, lParam2);
2352 if (lpDrv->d.d16.hDriver16 == 0) {cause = "Not a 16 bit driver"; goto exit;}
2353 lpDrv->dwFlags = WINE_GDF_16BIT;
2355 TRACE("=> %p\n", lpDrv);
2358 HeapFree(GetProcessHeap(), 0, lpDrv);
2359 TRACE("Unable to load 16 bit module %s: %s\n", debugstr_a(fn), cause);
2363 /******************************************************************
2364 * DRIVER_SendMessage16
2368 static LRESULT DRIVER_SendMessage16(HDRVR16 hDrv16, UINT msg,
2369 LPARAM lParam1, LPARAM lParam2)
2374 TRACE("Before sdm16 call hDrv=%04x wMsg=%04x p1=%08lx p2=%08lx\n",
2375 hDrv16, msg, lParam1, lParam2);
2377 switch (map = DRIVER_MapMsg32To16(msg, &lParam1, &lParam2)) {
2378 case WINMM_MAP_OKMEM:
2380 ret = SendDriverMessage16(hDrv16, msg, lParam1, lParam2);
2381 if (map == WINMM_MAP_OKMEM)
2382 DRIVER_UnMapMsg32To16(msg, lParam1, lParam2);
2389 /******************************************************************
2390 * DRIVER_CloseDriver16
2394 static LRESULT DRIVER_CloseDriver16(HDRVR16 hDrv16, LPARAM lParam1, LPARAM lParam2)
2396 return CloseDriver16(hDrv16, lParam1, lParam2);
2399 /**************************************************************************
2400 * DrvOpen [MMSYSTEM.1100]
2402 HDRVR16 WINAPI DrvOpen16(LPSTR lpDriverName, LPSTR lpSectionName, LPARAM lParam)
2404 return OpenDriver16(lpDriverName, lpSectionName, lParam);
2407 /**************************************************************************
2408 * DrvClose [MMSYSTEM.1101]
2410 LRESULT WINAPI DrvClose16(HDRVR16 hDrv, LPARAM lParam1, LPARAM lParam2)
2412 return CloseDriver16(hDrv, lParam1, lParam2);
2415 /**************************************************************************
2416 * DrvSendMessage [MMSYSTEM.1102]
2418 LRESULT WINAPI DrvSendMessage16(HDRVR16 hDrv, WORD msg, LPARAM lParam1,
2421 return SendDriverMessage16(hDrv, msg, lParam1, lParam2);
2424 /**************************************************************************
2425 * DrvGetModuleHandle [MMSYSTEM.1103]
2427 HANDLE16 WINAPI DrvGetModuleHandle16(HDRVR16 hDrv)
2429 return GetDriverModuleHandle16(hDrv);
2432 /**************************************************************************
2433 * DrvDefDriverProc [MMSYSTEM.1104]
2435 LRESULT WINAPI DrvDefDriverProc16(DWORD dwDriverID, HDRVR16 hDrv, WORD wMsg,
2436 DWORD dwParam1, DWORD dwParam2)
2438 return DefDriverProc16(dwDriverID, hDrv, wMsg, dwParam1, dwParam2);
2441 /**************************************************************************
2442 * DriverProc [MMSYSTEM.6]
2444 LRESULT WINAPI DriverProc16(DWORD dwDevID, HDRVR16 hDrv, WORD wMsg,
2445 DWORD dwParam1, DWORD dwParam2)
2447 TRACE("dwDevID=%08lx hDrv=%04x wMsg=%04x dwParam1=%08lx dwParam2=%08lx\n",
2448 dwDevID, hDrv, wMsg, dwParam1, dwParam2);
2450 return DrvDefDriverProc16(dwDevID, hDrv, wMsg, dwParam1, dwParam2);
2453 /* ###################################################
2455 * ###################################################
2458 /******************************************************************
2459 * MMSYSTEM_MMTIME32to16
2463 void MMSYSTEM_MMTIME32to16(LPMMTIME16 mmt16, const MMTIME* mmt32)
2465 mmt16->wType = mmt32->wType;
2466 /* layout of rest is the same for 32/16,
2467 * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding
2469 memcpy(&(mmt16->u), &(mmt32->u), sizeof(mmt16->u));
2472 /******************************************************************
2473 * MMSYSTEM_MMTIME16to32
2477 void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32, const MMTIME16* mmt16)
2479 mmt32->wType = mmt16->wType;
2480 /* layout of rest is the same for 32/16,
2481 * Note: mmt16->u is 2 bytes smaller than mmt32->u, which has padding
2483 memcpy(&(mmt32->u), &(mmt16->u), sizeof(mmt16->u));
2486 /**************************************************************************
2487 * timeGetSystemTime [MMSYSTEM.601]
2489 MMRESULT16 WINAPI timeGetSystemTime16(LPMMTIME16 lpTime, UINT16 wSize)
2491 TRACE("(%p, %u);\n", lpTime, wSize);
2493 if (wSize >= sizeof(*lpTime)) {
2494 lpTime->wType = TIME_MS;
2496 lpTime->u.ms = WINMM_IData->mmSysTimeMS;
2498 TRACE("=> %lu\n", lpTime->u.ms);
2504 /**************************************************************************
2505 * timeSetEvent [MMSYSTEM.602]
2507 MMRESULT16 WINAPI timeSetEvent16(UINT16 wDelay, UINT16 wResol, LPTIMECALLBACK16 lpFunc,
2508 DWORD dwUser, UINT16 wFlags)
2510 if (wFlags & WINE_TIMER_IS32)
2511 WARN("Unknown windows flag... wine internally used.. ooch\n");
2513 return TIME_SetEventInternal(wDelay, wResol, (FARPROC16)lpFunc,
2514 dwUser, wFlags & ~WINE_TIMER_IS32);
2517 /**************************************************************************
2518 * timeKillEvent [MMSYSTEM.603]
2520 MMRESULT16 WINAPI timeKillEvent16(UINT16 wID)
2522 return timeKillEvent(wID);
2525 /**************************************************************************
2526 * timeGetDevCaps [MMSYSTEM.604]
2528 MMRESULT16 WINAPI timeGetDevCaps16(LPTIMECAPS16 lpCaps, UINT16 wSize)
2533 TRACE("(%p, %u) !\n", lpCaps, wSize);
2535 ret = timeGetDevCaps(&caps, sizeof(caps));
2536 lpCaps->wPeriodMin = caps.wPeriodMin;
2537 lpCaps->wPeriodMax = caps.wPeriodMax;
2541 /**************************************************************************
2542 * timeBeginPeriod [MMSYSTEM.605]
2544 MMRESULT16 WINAPI timeBeginPeriod16(UINT16 wPeriod)
2546 TRACE("(%u) !\n", wPeriod);
2548 return timeBeginPeriod(wPeriod);
2551 /**************************************************************************
2552 * timeEndPeriod [MMSYSTEM.606]
2554 MMRESULT16 WINAPI timeEndPeriod16(UINT16 wPeriod)
2556 TRACE("(%u) !\n", wPeriod);
2558 return timeEndPeriod(wPeriod);
2561 /**************************************************************************
2562 * mciSendString [MMSYSTEM.702]
2564 DWORD WINAPI mciSendString16(LPCSTR lpstrCommand, LPSTR lpstrRet,
2565 UINT16 uRetLen, HWND16 hwndCallback)
2567 return mciSendStringA(lpstrCommand, lpstrRet, uRetLen, HWND_32(hwndCallback));
2570 /**************************************************************************
2571 * mciLoadCommandResource [MMSYSTEM.705]
2573 UINT16 WINAPI mciLoadCommandResource16(HINSTANCE16 hInst, LPCSTR resname, UINT16 type)
2579 if (!(res = FindResource16( hInst, resname, (LPSTR)RT_RCDATA))) return MCI_NO_COMMAND_TABLE;
2580 if (!(handle = LoadResource16( hInst, res ))) return MCI_NO_COMMAND_TABLE;
2581 ptr = LockResource16(handle);
2582 return MCI_SetCommandTable(ptr, type);
2583 /* FIXME: FreeResource */
2586 /**************************************************************************
2587 * mciFreeCommandResource [MMSYSTEM.713]
2589 BOOL16 WINAPI mciFreeCommandResource16(UINT16 uTable)
2591 TRACE("(%04x)!\n", uTable);
2593 return mciFreeCommandResource(uTable);
2596 /* ###################################################
2598 * ###################################################
2601 /****************************************************************
2602 * MMIO_Map32To16 [INTERNAL]
2604 static LRESULT MMIO_Map32To16(DWORD wMsg, LPARAM* lp1, LPARAM* lp2)
2614 case MMIOM_WRITEFLUSH:
2615 *lp1 = MapLS( (void *)*lp1 );
2618 *lp1 = MapLS( (void *)*lp1 );
2619 *lp2 = MapLS( (void *)*lp2 );
2622 if (wMsg < MMIOM_USER)
2623 TRACE("Not a mappable message (%ld)\n", wMsg);
2625 return MMSYSERR_NOERROR;
2628 /****************************************************************
2629 * MMIO_UnMap32To16 [INTERNAL]
2631 static LRESULT MMIO_UnMap32To16(DWORD wMsg, LPARAM lParam1, LPARAM lParam2,
2632 LPARAM lp1, LPARAM lp2)
2642 case MMIOM_WRITEFLUSH:
2650 if (wMsg < MMIOM_USER)
2651 TRACE("Not a mappable message (%ld)\n", wMsg);
2653 return MMSYSERR_NOERROR;
2656 /******************************************************************
2661 static LRESULT MMIO_Callback16(SEGPTR cb16, LPMMIOINFO lpmmioinfo, UINT uMessage,
2662 LPARAM lParam1, LPARAM lParam2)
2665 MMIOINFO16 mmioInfo16;
2666 SEGPTR segmmioInfo16;
2667 LPARAM lp1 = lParam1, lp2 = lParam2;
2670 memset(&mmioInfo16, 0, sizeof(MMIOINFO16));
2671 mmioInfo16.lDiskOffset = lpmmioinfo->lDiskOffset;
2672 mmioInfo16.adwInfo[0] = lpmmioinfo->adwInfo[0];
2673 mmioInfo16.adwInfo[1] = lpmmioinfo->adwInfo[1];
2674 mmioInfo16.adwInfo[2] = lpmmioinfo->adwInfo[2];
2675 mmioInfo16.adwInfo[3] = lpmmioinfo->adwInfo[3];
2676 /* map (lParam1, lParam2) into (lp1, lp2) 32=>16 */
2677 if ((result = MMIO_Map32To16(uMessage, &lp1, &lp2)) != MMSYSERR_NOERROR)
2680 segmmioInfo16 = MapLS(&mmioInfo16);
2681 args[6] = HIWORD(segmmioInfo16);
2682 args[5] = LOWORD(segmmioInfo16);
2684 args[3] = HIWORD(lp1);
2685 args[2] = LOWORD(lp1);
2686 args[1] = HIWORD(lp2);
2687 args[0] = LOWORD(lp2);
2688 WOWCallback16Ex( cb16, WCB16_PASCAL, sizeof(args), args, &result );
2689 UnMapLS(segmmioInfo16);
2690 MMIO_UnMap32To16(uMessage, lParam1, lParam2, lp1, lp2);
2692 lpmmioinfo->lDiskOffset = mmioInfo16.lDiskOffset;
2693 lpmmioinfo->adwInfo[0] = mmioInfo16.adwInfo[0];
2694 lpmmioinfo->adwInfo[1] = mmioInfo16.adwInfo[1];
2695 lpmmioinfo->adwInfo[2] = mmioInfo16.adwInfo[2];
2696 lpmmioinfo->adwInfo[3] = mmioInfo16.adwInfo[3];
2701 /******************************************************************
2702 * MMIO_ResetSegmentedData
2705 static LRESULT MMIO_SetSegmentedBuffer(HMMIO hmmio, SEGPTR ptr, BOOL release)
2709 if ((wm = MMIO_Get(hmmio)) == NULL)
2710 return MMSYSERR_INVALHANDLE;
2711 if (release) UnMapLS(wm->segBuffer16);
2712 wm->segBuffer16 = ptr;
2713 return MMSYSERR_NOERROR;
2716 /**************************************************************************
2717 * mmioOpen [MMSYSTEM.1210]
2719 HMMIO16 WINAPI mmioOpen16(LPSTR szFileName, MMIOINFO16* lpmmioinfo16,
2727 memset(&mmioinfo, 0, sizeof(mmioinfo));
2729 mmioinfo.dwFlags = lpmmioinfo16->dwFlags;
2730 mmioinfo.fccIOProc = lpmmioinfo16->fccIOProc;
2731 mmioinfo.pIOProc = (LPMMIOPROC)lpmmioinfo16->pIOProc;
2732 mmioinfo.cchBuffer = lpmmioinfo16->cchBuffer;
2733 mmioinfo.pchBuffer = MapSL((DWORD)lpmmioinfo16->pchBuffer);
2734 mmioinfo.adwInfo[0] = lpmmioinfo16->adwInfo[0];
2735 /* if we don't have a file name, it's likely a passed open file descriptor */
2737 mmioinfo.adwInfo[0] = (DWORD)DosFileHandleToWin32Handle(mmioinfo.adwInfo[0]);
2738 mmioinfo.adwInfo[1] = lpmmioinfo16->adwInfo[1];
2739 mmioinfo.adwInfo[2] = lpmmioinfo16->adwInfo[2];
2740 mmioinfo.adwInfo[3] = lpmmioinfo16->adwInfo[3];
2742 ret = MMIO_Open(szFileName, &mmioinfo, dwOpenFlags, MMIO_PROC_16);
2743 MMIO_SetSegmentedBuffer(mmioinfo.hmmio, (SEGPTR)lpmmioinfo16->pchBuffer, FALSE);
2745 lpmmioinfo16->wErrorRet = mmioinfo.wErrorRet;
2746 lpmmioinfo16->hmmio = HMMIO_16(mmioinfo.hmmio);
2748 ret = MMIO_Open(szFileName, NULL, dwOpenFlags, MMIO_PROC_32A);
2750 return HMMIO_16(ret);
2753 /**************************************************************************
2754 * mmioClose [MMSYSTEM.1211]
2756 MMRESULT16 WINAPI mmioClose16(HMMIO16 hmmio, UINT16 uFlags)
2758 MMIO_SetSegmentedBuffer(HMMIO_32(hmmio), (SEGPTR)NULL, TRUE);
2759 return mmioClose(HMMIO_32(hmmio), uFlags);
2762 /**************************************************************************
2763 * mmioRead [MMSYSTEM.1212]
2765 LONG WINAPI mmioRead16(HMMIO16 hmmio, HPSTR pch, LONG cch)
2767 return mmioRead(HMMIO_32(hmmio), pch, cch);
2770 /**************************************************************************
2771 * mmioWrite [MMSYSTEM.1213]
2773 LONG WINAPI mmioWrite16(HMMIO16 hmmio, HPCSTR pch, LONG cch)
2775 return mmioWrite(HMMIO_32(hmmio),pch,cch);
2778 /**************************************************************************
2779 * mmioSeek [MMSYSTEM.1214]
2781 LONG WINAPI mmioSeek16(HMMIO16 hmmio, LONG lOffset, INT16 iOrigin)
2783 return mmioSeek(HMMIO_32(hmmio), lOffset, iOrigin);
2786 /**************************************************************************
2787 * mmioGetInfo [MMSYSTEM.1215]
2789 MMRESULT16 WINAPI mmioGetInfo16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags)
2795 TRACE("(0x%04x,%p,0x%08x)\n", hmmio, lpmmioinfo, uFlags);
2797 if ((wm = MMIO_Get(HMMIO_32(hmmio))) == NULL)
2798 return MMSYSERR_INVALHANDLE;
2800 ret = mmioGetInfo(HMMIO_32(hmmio), &mmioinfo, uFlags);
2801 if (ret != MMSYSERR_NOERROR) return ret;
2803 lpmmioinfo->dwFlags = mmioinfo.dwFlags;
2804 lpmmioinfo->fccIOProc = mmioinfo.fccIOProc;
2805 lpmmioinfo->pIOProc = (wm->ioProc->type == MMIO_PROC_16) ?
2806 (LPMMIOPROC16)wm->ioProc->pIOProc : NULL;
2807 lpmmioinfo->wErrorRet = mmioinfo.wErrorRet;
2808 lpmmioinfo->hTask = HTASK_16(mmioinfo.hTask);
2809 lpmmioinfo->cchBuffer = mmioinfo.cchBuffer;
2810 lpmmioinfo->pchBuffer = (void*)wm->segBuffer16;
2811 lpmmioinfo->pchNext = (void*)(wm->segBuffer16 + (mmioinfo.pchNext - mmioinfo.pchBuffer));
2812 lpmmioinfo->pchEndRead = (void*)(wm->segBuffer16 + (mmioinfo.pchEndRead - mmioinfo.pchBuffer));
2813 lpmmioinfo->pchEndWrite = (void*)(wm->segBuffer16 + (mmioinfo.pchEndWrite - mmioinfo.pchBuffer));
2814 lpmmioinfo->lBufOffset = mmioinfo.lBufOffset;
2815 lpmmioinfo->lDiskOffset = mmioinfo.lDiskOffset;
2816 lpmmioinfo->adwInfo[0] = mmioinfo.adwInfo[0];
2817 lpmmioinfo->adwInfo[1] = mmioinfo.adwInfo[1];
2818 lpmmioinfo->adwInfo[2] = mmioinfo.adwInfo[2];
2819 lpmmioinfo->adwInfo[3] = mmioinfo.adwInfo[3];
2820 lpmmioinfo->dwReserved1 = 0;
2821 lpmmioinfo->dwReserved2 = 0;
2822 lpmmioinfo->hmmio = HMMIO_16(mmioinfo.hmmio);
2824 return MMSYSERR_NOERROR;
2827 /**************************************************************************
2828 * mmioSetInfo [MMSYSTEM.1216]
2830 MMRESULT16 WINAPI mmioSetInfo16(HMMIO16 hmmio, const MMIOINFO16* lpmmioinfo, UINT16 uFlags)
2835 TRACE("(0x%04x,%p,0x%08x)\n",hmmio,lpmmioinfo,uFlags);
2837 ret = mmioGetInfo(HMMIO_32(hmmio), &mmioinfo, 0);
2838 if (ret != MMSYSERR_NOERROR) return ret;
2840 /* check if seg and lin buffers are the same */
2841 if (mmioinfo.cchBuffer != lpmmioinfo->cchBuffer ||
2842 mmioinfo.pchBuffer != MapSL((DWORD)lpmmioinfo->pchBuffer))
2843 return MMSYSERR_INVALPARAM;
2845 /* check pointers coherence */
2846 if (lpmmioinfo->pchNext < lpmmioinfo->pchBuffer ||
2847 lpmmioinfo->pchNext > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer ||
2848 lpmmioinfo->pchEndRead < lpmmioinfo->pchBuffer ||
2849 lpmmioinfo->pchEndRead > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer ||
2850 lpmmioinfo->pchEndWrite < lpmmioinfo->pchBuffer ||
2851 lpmmioinfo->pchEndWrite > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer)
2852 return MMSYSERR_INVALPARAM;
2854 mmioinfo.pchNext = mmioinfo.pchBuffer + (lpmmioinfo->pchNext - lpmmioinfo->pchBuffer);
2855 mmioinfo.pchEndRead = mmioinfo.pchBuffer + (lpmmioinfo->pchEndRead - lpmmioinfo->pchBuffer);
2856 mmioinfo.pchEndWrite = mmioinfo.pchBuffer + (lpmmioinfo->pchEndWrite - lpmmioinfo->pchBuffer);
2858 return mmioSetInfo(HMMIO_32(hmmio), &mmioinfo, uFlags);
2861 /**************************************************************************
2862 * mmioSetBuffer [MMSYSTEM.1217]
2864 MMRESULT16 WINAPI mmioSetBuffer16(HMMIO16 hmmio, LPSTR pchBuffer,
2865 LONG cchBuffer, UINT16 uFlags)
2867 MMRESULT ret = mmioSetBuffer(HMMIO_32(hmmio), MapSL((DWORD)pchBuffer),
2870 if (ret == MMSYSERR_NOERROR)
2871 MMIO_SetSegmentedBuffer(HMMIO_32(hmmio), (DWORD)pchBuffer, TRUE);
2873 UnMapLS((DWORD)pchBuffer);
2877 /**************************************************************************
2878 * mmioFlush [MMSYSTEM.1218]
2880 MMRESULT16 WINAPI mmioFlush16(HMMIO16 hmmio, UINT16 uFlags)
2882 return mmioFlush(HMMIO_32(hmmio), uFlags);
2885 /***********************************************************************
2886 * mmioAdvance [MMSYSTEM.1219]
2888 MMRESULT16 WINAPI mmioAdvance16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags)
2893 /* WARNING: this heavily relies on mmioAdvance implementation (for choosing which
2898 mmioinfo.pchBuffer = MapSL((DWORD)lpmmioinfo->pchBuffer);
2899 mmioinfo.pchNext = MapSL((DWORD)lpmmioinfo->pchNext);
2900 mmioinfo.dwFlags = lpmmioinfo->dwFlags;
2901 mmioinfo.lBufOffset = lpmmioinfo->lBufOffset;
2902 ret = mmioAdvance(HMMIO_32(hmmio), &mmioinfo, uFlags);
2905 ret = mmioAdvance(HMMIO_32(hmmio), NULL, uFlags);
2907 if (ret != MMSYSERR_NOERROR) return ret;
2911 lpmmioinfo->dwFlags = mmioinfo.dwFlags;
2912 lpmmioinfo->pchNext = (void*)(lpmmioinfo->pchBuffer + (mmioinfo.pchNext - mmioinfo.pchBuffer));
2913 lpmmioinfo->pchEndRead = (void*)(lpmmioinfo->pchBuffer + (mmioinfo.pchEndRead - mmioinfo.pchBuffer));
2914 lpmmioinfo->pchEndWrite = (void*)(lpmmioinfo->pchBuffer + (mmioinfo.pchEndWrite - mmioinfo.pchBuffer));
2915 lpmmioinfo->lBufOffset = mmioinfo.lBufOffset;
2916 lpmmioinfo->lDiskOffset = mmioinfo.lDiskOffset;
2919 return MMSYSERR_NOERROR;
2922 /**************************************************************************
2923 * mmioStringToFOURCC [MMSYSTEM.1220]
2925 FOURCC WINAPI mmioStringToFOURCC16(LPCSTR sz, UINT16 uFlags)
2927 return mmioStringToFOURCCA(sz, uFlags);
2930 /**************************************************************************
2931 * mmioInstallIOProc [MMSYSTEM.1221]
2933 LPMMIOPROC16 WINAPI mmioInstallIOProc16(FOURCC fccIOProc, LPMMIOPROC16 pIOProc,
2936 return (LPMMIOPROC16)MMIO_InstallIOProc(fccIOProc, (LPMMIOPROC)pIOProc,
2937 dwFlags, MMIO_PROC_16);
2940 /**************************************************************************
2941 * mmioSendMessage [MMSYSTEM.1222]
2943 LRESULT WINAPI mmioSendMessage16(HMMIO16 hmmio, UINT16 uMessage,
2944 LPARAM lParam1, LPARAM lParam2)
2946 return MMIO_SendMessage(HMMIO_32(hmmio), uMessage,
2947 lParam1, lParam2, MMIO_PROC_16);
2950 /**************************************************************************
2951 * mmioDescend [MMSYSTEM.1223]
2953 MMRESULT16 WINAPI mmioDescend16(HMMIO16 hmmio, LPMMCKINFO lpck,
2954 const MMCKINFO* lpckParent, UINT16 uFlags)
2956 return mmioDescend(HMMIO_32(hmmio), lpck, lpckParent, uFlags);
2959 /**************************************************************************
2960 * mmioAscend [MMSYSTEM.1224]
2962 MMRESULT16 WINAPI mmioAscend16(HMMIO16 hmmio, MMCKINFO* lpck, UINT16 uFlags)
2964 return mmioAscend(HMMIO_32(hmmio),lpck,uFlags);
2967 /**************************************************************************
2968 * mmioCreateChunk [MMSYSTEM.1225]
2970 MMRESULT16 WINAPI mmioCreateChunk16(HMMIO16 hmmio, MMCKINFO* lpck, UINT16 uFlags)
2972 return mmioCreateChunk(HMMIO_32(hmmio), lpck, uFlags);
2975 /**************************************************************************
2976 * mmioRename [MMSYSTEM.1226]
2978 MMRESULT16 WINAPI mmioRename16(LPCSTR szFileName, LPCSTR szNewFileName,
2979 MMIOINFO16* lpmmioinfo, DWORD dwRenameFlags)
2985 if (lpmmioinfo != NULL && lpmmioinfo->pIOProc != NULL &&
2986 lpmmioinfo->fccIOProc == 0) {
2987 FIXME("Can't handle this case yet\n");
2988 return MMSYSERR_ERROR;
2991 /* this is a bit hacky, but it'll work if we get a fourCC code or nothing.
2992 * but a non installed ioproc without a fourcc won't do
2994 if (lpmmioinfo && lpmmioinfo->fccIOProc && lpmmioinfo->pIOProc) {
2995 MMIO_InstallIOProc(lpmmioinfo->fccIOProc, (LPMMIOPROC)lpmmioinfo->pIOProc,
2996 MMIO_INSTALLPROC, MMIO_PROC_16);
2999 memset(&mmioinfo, 0, sizeof(mmioinfo));
3000 mmioinfo.fccIOProc = lpmmioinfo->fccIOProc;
3001 ret = mmioRenameA(szFileName, szNewFileName, &mmioinfo, dwRenameFlags);
3003 MMIO_InstallIOProc(lpmmioinfo->fccIOProc, NULL,
3004 MMIO_REMOVEPROC, MMIO_PROC_16);
3009 /* ###################################################
3011 * ###################################################
3014 /**************************************************************************
3015 * joyGetNumDevs [MMSYSTEM.101]
3017 UINT16 WINAPI joyGetNumDevs16(void)
3019 return joyGetNumDevs();
3022 /**************************************************************************
3023 * joyGetDevCaps [MMSYSTEM.102]
3025 MMRESULT16 WINAPI joyGetDevCaps16(UINT16 wID, LPJOYCAPS16 lpCaps, UINT16 wSize)
3028 MMRESULT ret = joyGetDevCapsA(wID, &jca, sizeof(jca));
3030 if (ret != JOYERR_NOERROR) return ret;
3031 lpCaps->wMid = jca.wMid;
3032 lpCaps->wPid = jca.wPid;
3033 strcpy(lpCaps->szPname, jca.szPname);
3034 lpCaps->wXmin = jca.wXmin;
3035 lpCaps->wXmax = jca.wXmax;
3036 lpCaps->wYmin = jca.wYmin;
3037 lpCaps->wYmax = jca.wYmax;
3038 lpCaps->wZmin = jca.wZmin;
3039 lpCaps->wZmax = jca.wZmax;
3040 lpCaps->wNumButtons = jca.wNumButtons;
3041 lpCaps->wPeriodMin = jca.wPeriodMin;
3042 lpCaps->wPeriodMax = jca.wPeriodMax;
3044 if (wSize >= sizeof(JOYCAPS16)) { /* Win95 extensions ? */
3045 lpCaps->wRmin = jca.wRmin;
3046 lpCaps->wRmax = jca.wRmax;
3047 lpCaps->wUmin = jca.wUmin;
3048 lpCaps->wUmax = jca.wUmax;
3049 lpCaps->wVmin = jca.wVmin;
3050 lpCaps->wVmax = jca.wVmax;
3051 lpCaps->wCaps = jca.wCaps;
3052 lpCaps->wMaxAxes = jca.wMaxAxes;
3053 lpCaps->wNumAxes = jca.wNumAxes;
3054 lpCaps->wMaxButtons = jca.wMaxButtons;
3055 strcpy(lpCaps->szRegKey, jca.szRegKey);
3056 strcpy(lpCaps->szOEMVxD, jca.szOEMVxD);
3062 /**************************************************************************
3063 * joyGetPosEx [MMSYSTEM.110]
3065 MMRESULT16 WINAPI joyGetPosEx16(UINT16 wID, LPJOYINFOEX lpInfo)
3067 return joyGetPosEx(wID, lpInfo);
3070 /**************************************************************************
3071 * joyGetPos [MMSYSTEM.103]
3073 MMRESULT16 WINAPI joyGetPos16(UINT16 wID, LPJOYINFO16 lpInfo)
3078 TRACE("(%d, %p);\n", wID, lpInfo);
3080 if ((ret = joyGetPos(wID, &ji)) == JOYERR_NOERROR) {
3081 lpInfo->wXpos = ji.wXpos;
3082 lpInfo->wYpos = ji.wYpos;
3083 lpInfo->wZpos = ji.wZpos;
3084 lpInfo->wButtons = ji.wButtons;
3089 /**************************************************************************
3090 * joyGetThreshold [MMSYSTEM.104]
3092 MMRESULT16 WINAPI joyGetThreshold16(UINT16 wID, LPUINT16 lpThreshold)
3097 ret = joyGetThreshold(wID, &t);
3098 if (ret == JOYERR_NOERROR)
3103 /**************************************************************************
3104 * joyReleaseCapture [MMSYSTEM.105]
3106 MMRESULT16 WINAPI joyReleaseCapture16(UINT16 wID)
3108 return joyReleaseCapture(wID);
3111 /**************************************************************************
3112 * joySetCapture [MMSYSTEM.106]
3114 MMRESULT16 WINAPI joySetCapture16(HWND16 hWnd, UINT16 wID, UINT16 wPeriod, BOOL16 bChanged)
3116 return joySetCapture16(hWnd, wID, wPeriod, bChanged);
3119 /**************************************************************************
3120 * joySetThreshold [MMSYSTEM.107]
3122 MMRESULT16 WINAPI joySetThreshold16(UINT16 wID, UINT16 wThreshold)
3124 return joySetThreshold16(wID,wThreshold);
3127 /**************************************************************************
3128 * joySetCalibration [MMSYSTEM.109]
3130 MMRESULT16 WINAPI joySetCalibration16(UINT16 wID)
3132 FIXME("(%04X): stub.\n", wID);
3133 return JOYERR_NOCANDO;