1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
6 * Copyright 1993 Martin Ayotte
7 * 1998-2002 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
29 /* FIXME: I think there are some segmented vs. linear pointer weirdnesses
30 * and long term pointers to 16 bit space in here
38 #include "wine/mmsystem16.h"
39 #include "wine/winuser16.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(mmsys);
47 /* ### start build ### */
48 extern LONG CALLBACK MMSYSTEM_CallTo16_long_l (FARPROC16,LONG);
49 extern LONG CALLBACK MMSYSTEM_CallTo16_long_lwll (LPMMIOPROC16,LONG,WORD,LONG,LONG);
50 /* ### stop build ### */
52 static WINE_MMTHREAD* WINMM_GetmmThread(HANDLE16);
53 static LRESULT MMIO_Callback16(SEGPTR, LPMMIOINFO, UINT, LPARAM, LPARAM);
55 /* ###################################################
57 * ###################################################
60 /**************************************************************************
61 * DllEntryPoint (MMSYSTEM.2046)
63 * MMSYSTEM DLL entry point
66 BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
67 WORD wHeapSize, DWORD dwReserved1, WORD wReserved2)
69 TRACE("0x%x 0x%lx\n", hinstDLL, fdwReason);
72 case DLL_PROCESS_ATTACH:
73 /* need to load WinMM in order to:
74 * - initiate correctly shared variables (WINMM_Init())
76 if (!GetModuleHandleA("WINMM.DLL") && !LoadLibraryA("WINMM.DLL"))
78 ERR("Could not load sibling WinMM.dll\n");
81 WINMM_IData->hWinMM16Instance = hinstDLL;
82 /* hook in our 16 bit function pointers */
83 pFnGetMMThread16 = WINMM_GetmmThread;
84 pFnMmioCallback16 = MMIO_Callback16;
86 case DLL_PROCESS_DETACH:
87 WINMM_IData->hWinMM16Instance = 0;
88 pFnGetMMThread16 = NULL;
89 pFnMmioCallback16 = NULL;
91 case DLL_THREAD_ATTACH:
92 case DLL_THREAD_DETACH:
98 /**************************************************************************
99 * MMSYSTEM_WEP [MMSYSTEM.1]
101 int WINAPI MMSYSTEM_WEP(HINSTANCE16 hInstance, WORD wDataSeg,
102 WORD cbHeapSize, LPSTR lpCmdLine)
104 FIXME("STUB: Unloading MMSystem DLL ... hInst=%04X \n", hInstance);
108 /* ###################################################
110 * ###################################################
113 /**************************************************************************
114 * PlaySound [MMSYSTEM.3]
116 BOOL16 WINAPI PlaySound16(LPCSTR pszSound, HMODULE16 hmod, DWORD fdwSound)
121 ReleaseThunkLock(&lc);
122 retv = PlaySoundA(pszSound, hmod, fdwSound);
123 RestoreThunkLock(lc);
128 /**************************************************************************
129 * sndPlaySound [MMSYSTEM.2]
131 BOOL16 WINAPI sndPlaySound16(LPCSTR lpszSoundName, UINT16 uFlags)
136 ReleaseThunkLock(&lc);
137 retv = sndPlaySoundA(lpszSoundName, uFlags);
138 RestoreThunkLock(lc);
143 /* ###################################################
145 * ###################################################
148 /**************************************************************************
149 * mmsystemGetVersion [MMSYSTEM.5]
152 UINT16 WINAPI mmsystemGetVersion16(void)
154 return mmsystemGetVersion();
157 /**************************************************************************
158 * DriverCallback [MMSYSTEM.31]
160 BOOL16 WINAPI DriverCallback16(DWORD dwCallBack, UINT16 uFlags, HDRVR16 hDev,
161 WORD wMsg, DWORD dwUser, DWORD dwParam1,
164 return DriverCallback(dwCallBack, uFlags, HDRVR_32(hDev), wMsg, dwUser, dwParam1, dwParam2);
167 /**************************************************************************
168 * OutputDebugStr [MMSYSTEM.30]
170 void WINAPI OutputDebugStr16(LPCSTR str)
172 OutputDebugStringA( str );
176 /* ###################################################
178 * ###################################################
181 /**************************************************************************
182 * Mixer devices. New to Win95
185 /**************************************************************************
186 * mixerGetNumDevs [MMSYSTEM.800]
188 UINT16 WINAPI mixerGetNumDevs16(void)
190 return MMDRV_GetNum(MMDRV_MIXER);
193 /**************************************************************************
194 * mixerGetDevCaps [MMSYSTEM.801]
196 UINT16 WINAPI mixerGetDevCaps16(UINT16 devid, LPMIXERCAPS16 mixcaps,
200 UINT ret = mixerGetDevCapsA(devid, &micA, sizeof(micA));
202 if (ret == MMSYSERR_NOERROR) {
203 mixcaps->wMid = micA.wMid;
204 mixcaps->wPid = micA.wPid;
205 mixcaps->vDriverVersion = micA.vDriverVersion;
206 strcpy(mixcaps->szPname, micA.szPname);
207 mixcaps->fdwSupport = micA.fdwSupport;
208 mixcaps->cDestinations = micA.cDestinations;
213 /**************************************************************************
214 * mixerOpen [MMSYSTEM.802]
216 UINT16 WINAPI mixerOpen16(LPHMIXER16 lphmix, UINT16 uDeviceID, DWORD dwCallback,
217 DWORD dwInstance, DWORD fdwOpen)
222 ret = MMSYSTEM_mixerOpen(&hmix, uDeviceID,
223 dwCallback, dwInstance, fdwOpen, FALSE);
224 if (lphmix) *lphmix = HMIXER_16(hmix);
228 /**************************************************************************
229 * mixerClose [MMSYSTEM.803]
231 UINT16 WINAPI mixerClose16(HMIXER16 hMix)
233 return mixerClose(HMIXER_32(hMix));
236 /**************************************************************************
237 * mixerGetID (MMSYSTEM.806)
239 UINT16 WINAPI mixerGetID16(HMIXEROBJ16 hmix, LPUINT16 lpid, DWORD fdwID)
242 UINT ret = mixerGetID(HMIXEROBJ_32(hmix), &xid, fdwID);
249 /**************************************************************************
250 * mixerGetControlDetails [MMSYSTEM.808]
252 UINT16 WINAPI mixerGetControlDetails16(HMIXEROBJ16 hmix,
253 LPMIXERCONTROLDETAILS16 lpmcd,
256 DWORD ret = MMSYSERR_NOTENABLED;
259 TRACE("(%04x, %p, %08lx)\n", hmix, lpmcd, fdwDetails);
261 if (lpmcd == NULL || lpmcd->cbStruct != sizeof(*lpmcd))
262 return MMSYSERR_INVALPARAM;
264 sppaDetails = (SEGPTR)lpmcd->paDetails;
265 lpmcd->paDetails = MapSL(sppaDetails);
266 ret = mixerGetControlDetailsA(HMIXEROBJ_32(hmix),
267 (LPMIXERCONTROLDETAILS)lpmcd, fdwDetails);
268 lpmcd->paDetails = (LPVOID)sppaDetails;
273 /**************************************************************************
274 * mixerGetLineControls [MMSYSTEM.807]
276 UINT16 WINAPI mixerGetLineControls16(HMIXEROBJ16 hmix,
277 LPMIXERLINECONTROLS16 lpmlc16,
280 MIXERLINECONTROLSA mlcA;
283 LPMIXERCONTROL16 lpmc16;
285 TRACE("(%04x, %p, %08lx)\n", hmix, lpmlc16, fdwControls);
287 if (lpmlc16 == NULL || lpmlc16->cbStruct != sizeof(*lpmlc16) ||
288 lpmlc16->cbmxctrl != sizeof(MIXERCONTROL16))
289 return MMSYSERR_INVALPARAM;
291 mlcA.cbStruct = sizeof(mlcA);
292 mlcA.dwLineID = lpmlc16->dwLineID;
293 mlcA.u.dwControlID = lpmlc16->u.dwControlID;
294 mlcA.u.dwControlType = lpmlc16->u.dwControlType;
295 mlcA.cControls = lpmlc16->cControls;
296 mlcA.cbmxctrl = sizeof(MIXERCONTROLA);
297 mlcA.pamxctrl = HeapAlloc(GetProcessHeap(), 0,
298 mlcA.cControls * mlcA.cbmxctrl);
300 ret = mixerGetLineControlsA(HMIXEROBJ_32(hmix), &mlcA, fdwControls);
302 if (ret == MMSYSERR_NOERROR) {
303 lpmlc16->dwLineID = mlcA.dwLineID;
304 lpmlc16->u.dwControlID = mlcA.u.dwControlID;
305 lpmlc16->u.dwControlType = mlcA.u.dwControlType;
306 lpmlc16->cControls = mlcA.cControls;
308 lpmc16 = MapSL(lpmlc16->pamxctrl);
310 for (i = 0; i < mlcA.cControls; i++) {
311 lpmc16[i].cbStruct = sizeof(MIXERCONTROL16);
312 lpmc16[i].dwControlID = mlcA.pamxctrl[i].dwControlID;
313 lpmc16[i].dwControlType = mlcA.pamxctrl[i].dwControlType;
314 lpmc16[i].fdwControl = mlcA.pamxctrl[i].fdwControl;
315 lpmc16[i].cMultipleItems = mlcA.pamxctrl[i].cMultipleItems;
316 strcpy(lpmc16[i].szShortName, mlcA.pamxctrl[i].szShortName);
317 strcpy(lpmc16[i].szName, mlcA.pamxctrl[i].szName);
318 /* sizeof(lpmc16[i].Bounds) == sizeof(mlcA.pamxctrl[i].Bounds) */
319 memcpy(&lpmc16[i].Bounds, &mlcA.pamxctrl[i].Bounds,
320 sizeof(mlcA.pamxctrl[i].Bounds));
321 /* sizeof(lpmc16[i].Metrics) == sizeof(mlcA.pamxctrl[i].Metrics) */
322 memcpy(&lpmc16[i].Metrics, &mlcA.pamxctrl[i].Metrics,
323 sizeof(mlcA.pamxctrl[i].Metrics));
327 HeapFree(GetProcessHeap(), 0, mlcA.pamxctrl);
332 /**************************************************************************
333 * mixerGetLineInfo [MMSYSTEM.805]
335 UINT16 WINAPI mixerGetLineInfo16(HMIXEROBJ16 hmix, LPMIXERLINE16 lpmli16,
341 TRACE("(%04x, %p, %08lx)\n", hmix, lpmli16, fdwInfo);
343 if (lpmli16 == NULL || lpmli16->cbStruct != sizeof(*lpmli16))
344 return MMSYSERR_INVALPARAM;
346 mliA.cbStruct = sizeof(mliA);
347 switch (fdwInfo & MIXER_GETLINEINFOF_QUERYMASK) {
348 case MIXER_GETLINEINFOF_COMPONENTTYPE:
349 mliA.dwComponentType = lpmli16->dwComponentType;
351 case MIXER_GETLINEINFOF_DESTINATION:
352 mliA.dwDestination = lpmli16->dwDestination;
354 case MIXER_GETLINEINFOF_LINEID:
355 mliA.dwLineID = lpmli16->dwLineID;
357 case MIXER_GETLINEINFOF_SOURCE:
358 mliA.dwDestination = lpmli16->dwDestination;
359 mliA.dwSource = lpmli16->dwSource;
361 case MIXER_GETLINEINFOF_TARGETTYPE:
362 mliA.Target.dwType = lpmli16->Target.dwType;
363 mliA.Target.wMid = lpmli16->Target.wMid;
364 mliA.Target.wPid = lpmli16->Target.wPid;
365 mliA.Target.vDriverVersion = lpmli16->Target.vDriverVersion;
366 strcpy(mliA.Target.szPname, lpmli16->Target.szPname);
369 FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo);
372 ret = mixerGetLineInfoA(HMIXEROBJ_32(hmix), &mliA, fdwInfo);
374 lpmli16->dwDestination = mliA.dwDestination;
375 lpmli16->dwSource = mliA.dwSource;
376 lpmli16->dwLineID = mliA.dwLineID;
377 lpmli16->fdwLine = mliA.fdwLine;
378 lpmli16->dwUser = mliA.dwUser;
379 lpmli16->dwComponentType = mliA.dwComponentType;
380 lpmli16->cChannels = mliA.cChannels;
381 lpmli16->cConnections = mliA.cConnections;
382 lpmli16->cControls = mliA.cControls;
383 strcpy(lpmli16->szShortName, mliA.szShortName);
384 strcpy(lpmli16->szName, mliA.szName);
385 lpmli16->Target.dwType = mliA.Target.dwType;
386 lpmli16->Target.dwDeviceID = mliA.Target.dwDeviceID;
387 lpmli16->Target.wMid = mliA.Target.wMid;
388 lpmli16->Target.wPid = mliA.Target.wPid;
389 lpmli16->Target.vDriverVersion = mliA.Target.vDriverVersion;
390 strcpy(lpmli16->Target.szPname, mliA.Target.szPname);
395 /**************************************************************************
396 * mixerSetControlDetails [MMSYSTEM.809]
398 UINT16 WINAPI mixerSetControlDetails16(HMIXEROBJ16 hmix,
399 LPMIXERCONTROLDETAILS16 lpmcd,
402 TRACE("(%04x, %p, %08lx)\n", hmix, lpmcd, fdwDetails);
403 return MMSYSERR_NOTENABLED;
406 /**************************************************************************
407 * mixerMessage [MMSYSTEM.804]
409 DWORD WINAPI mixerMessage16(HMIXER16 hmix, UINT16 uMsg, DWORD dwParam1,
412 return mixerMessage(HMIXER_32(hmix), uMsg, dwParam1, dwParam2);
415 /**************************************************************************
416 * auxGetNumDevs [MMSYSTEM.350]
418 UINT16 WINAPI auxGetNumDevs16(void)
420 return MMDRV_GetNum(MMDRV_AUX);
423 /* ###################################################
425 * ###################################################
428 /**************************************************************************
429 * auxGetDevCaps [MMSYSTEM.351]
431 UINT16 WINAPI auxGetDevCaps16(UINT16 uDeviceID, LPAUXCAPS16 lpCaps, UINT16 uSize)
435 TRACE("(%04X, %p, %d) !\n", uDeviceID, lpCaps, uSize);
437 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
438 return MMSYSERR_INVALHANDLE;
439 return MMDRV_Message(wmld, AUXDM_GETDEVCAPS, (DWORD)lpCaps, uSize, TRUE);
442 /**************************************************************************
443 * auxGetVolume [MMSYSTEM.352]
445 UINT16 WINAPI auxGetVolume16(UINT16 uDeviceID, LPDWORD lpdwVolume)
449 TRACE("(%04X, %p) !\n", uDeviceID, lpdwVolume);
451 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
452 return MMSYSERR_INVALHANDLE;
453 return MMDRV_Message(wmld, AUXDM_GETVOLUME, (DWORD)lpdwVolume, 0L, TRUE);
456 /**************************************************************************
457 * auxSetVolume [MMSYSTEM.353]
459 UINT16 WINAPI auxSetVolume16(UINT16 uDeviceID, DWORD dwVolume)
463 TRACE("(%04X, %lu) !\n", uDeviceID, dwVolume);
465 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
466 return MMSYSERR_INVALHANDLE;
467 return MMDRV_Message(wmld, AUXDM_SETVOLUME, dwVolume, 0L, TRUE);
470 /**************************************************************************
471 * auxOutMessage [MMSYSTEM.354]
473 DWORD WINAPI auxOutMessage16(UINT16 uDeviceID, UINT16 uMessage, DWORD dw1, DWORD dw2)
477 TRACE("(%04X, %04X, %08lX, %08lX)\n", uDeviceID, uMessage, dw1, dw2);
480 case AUXDM_GETNUMDEVS:
481 case AUXDM_SETVOLUME:
482 /* no argument conversion needed */
484 case AUXDM_GETVOLUME:
485 return auxGetVolume16(uDeviceID, MapSL(dw1));
486 case AUXDM_GETDEVCAPS:
487 return auxGetDevCaps16(uDeviceID, MapSL(dw1), dw2);
489 TRACE("(%04x, %04x, %08lx, %08lx): unhandled message\n",
490 uDeviceID, uMessage, dw1, dw2);
493 if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
494 return MMSYSERR_INVALHANDLE;
496 return MMDRV_Message(wmld, uMessage, dw1, dw2, TRUE);
499 /* ###################################################
501 * ###################################################
504 /**************************************************************************
505 * mciGetErrorString [MMSYSTEM.706]
507 BOOL16 WINAPI mciGetErrorString16(DWORD wError, LPSTR lpstrBuffer, UINT16 uLength)
509 return mciGetErrorStringA(wError, lpstrBuffer, uLength);
512 /**************************************************************************
513 * mciDriverNotify [MMSYSTEM.711]
515 BOOL16 WINAPI mciDriverNotify16(HWND16 hWndCallBack, UINT16 wDevID, UINT16 wStatus)
517 TRACE("(%04X, %04x, %04X)\n", hWndCallBack, wDevID, wStatus);
519 return PostMessageA(HWND_32(hWndCallBack), MM_MCINOTIFY, wStatus, wDevID);
522 /**************************************************************************
523 * mciGetDriverData [MMSYSTEM.708]
525 DWORD WINAPI mciGetDriverData16(UINT16 uDeviceID)
527 return mciGetDriverData(uDeviceID);
530 /**************************************************************************
531 * mciSetDriverData [MMSYSTEM.707]
533 BOOL16 WINAPI mciSetDriverData16(UINT16 uDeviceID, DWORD data)
535 return mciSetDriverData(uDeviceID, data);
538 /**************************************************************************
539 * mciSendCommand [MMSYSTEM.701]
541 DWORD WINAPI mciSendCommand16(UINT16 wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2)
545 TRACE("(%04X, %s, %08lX, %08lX)\n",
546 wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2);
548 dwRet = MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2, FALSE);
549 dwRet = MCI_CleanUp(dwRet, wMsg, dwParam2, FALSE);
550 TRACE("=> %ld\n", dwRet);
554 /**************************************************************************
555 * mciGetDeviceID [MMSYSTEM.703]
557 UINT16 WINAPI mciGetDeviceID16(LPCSTR lpstrName)
559 TRACE("(\"%s\")\n", lpstrName);
561 return MCI_GetDriverFromString(lpstrName);
564 /**************************************************************************
565 * mciSetYieldProc [MMSYSTEM.714]
567 BOOL16 WINAPI mciSetYieldProc16(UINT16 uDeviceID, YIELDPROC16 fpYieldProc, DWORD dwYieldData)
569 LPWINE_MCIDRIVER wmd;
571 TRACE("(%u, %p, %08lx)\n", uDeviceID, fpYieldProc, dwYieldData);
573 if (!(wmd = MCI_GetDriver(uDeviceID))) {
574 WARN("Bad uDeviceID\n");
578 wmd->lpfnYieldProc = (YIELDPROC)fpYieldProc;
579 wmd->dwYieldData = dwYieldData;
585 /**************************************************************************
586 * mciGetDeviceIDFromElementID [MMSYSTEM.715]
588 UINT16 WINAPI mciGetDeviceIDFromElementID16(DWORD dwElementID, LPCSTR lpstrType)
590 FIXME("(%lu, %s) stub\n", dwElementID, lpstrType);
594 /**************************************************************************
595 * mciGetYieldProc [MMSYSTEM.716]
597 YIELDPROC16 WINAPI mciGetYieldProc16(UINT16 uDeviceID, DWORD* lpdwYieldData)
599 LPWINE_MCIDRIVER wmd;
601 TRACE("(%u, %p)\n", uDeviceID, lpdwYieldData);
603 if (!(wmd = MCI_GetDriver(uDeviceID))) {
604 WARN("Bad uDeviceID\n");
607 if (!wmd->lpfnYieldProc) {
608 WARN("No proc set\n");
612 WARN("Proc is 32 bit\n");
615 return (YIELDPROC16)wmd->lpfnYieldProc;
618 /**************************************************************************
619 * mciGetCreatorTask [MMSYSTEM.717]
621 HTASK16 WINAPI mciGetCreatorTask16(UINT16 uDeviceID)
623 LPWINE_MCIDRIVER wmd;
626 if ((wmd = MCI_GetDriver(uDeviceID))) ret = K32WOWHandle16(wmd->CreatorThread, WOW_TYPE_HTASK);
628 TRACE("(%u) => %04x\n", uDeviceID, ret);
632 /**************************************************************************
633 * mciDriverYield [MMSYSTEM.710]
635 UINT16 WINAPI mciDriverYield16(UINT16 uDeviceID)
637 LPWINE_MCIDRIVER wmd;
640 /* TRACE("(%04x)\n", uDeviceID); */
642 if (!(wmd = MCI_GetDriver(uDeviceID)) || !wmd->lpfnYieldProc || wmd->bIs32) {
645 ret = wmd->lpfnYieldProc(uDeviceID, wmd->dwYieldData);
651 /* ###################################################
653 * ###################################################
656 /**************************************************************************
657 * midiOutGetNumDevs [MMSYSTEM.201]
659 UINT16 WINAPI midiOutGetNumDevs16(void)
661 return MMDRV_GetNum(MMDRV_MIDIOUT);
664 /**************************************************************************
665 * midiOutGetDevCaps [MMSYSTEM.202]
667 UINT16 WINAPI midiOutGetDevCaps16(UINT16 uDeviceID, LPMIDIOUTCAPS16 lpCaps,
673 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
675 dwRet = midiOutGetDevCapsA(uDeviceID, &capsA, sizeof(capsA));
676 if (dwRet == MMSYSERR_NOERROR) {
677 lpCaps->wMid = capsA.wMid;
678 lpCaps->wPid = capsA.wPid;
679 lpCaps->vDriverVersion = capsA.vDriverVersion;
680 strcpy(lpCaps->szPname, capsA.szPname);
681 lpCaps->wTechnology = capsA.wTechnology;
682 lpCaps->wVoices = capsA.wVoices;
683 lpCaps->wNotes = capsA.wNotes;
684 lpCaps->wChannelMask = capsA.wChannelMask;
685 lpCaps->dwSupport = capsA.dwSupport;
690 /**************************************************************************
691 * midiOutGetErrorText [MMSYSTEM.203]
693 UINT16 WINAPI midiOutGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
695 return midiOutGetErrorTextA(uError, lpText, uSize);
698 /**************************************************************************
699 * midiOutOpen [MMSYSTEM.204]
701 UINT16 WINAPI midiOutOpen16(HMIDIOUT16* lphMidiOut, UINT16 uDeviceID,
702 DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
707 ret = MMSYSTEM_midiOutOpen(&hmo, uDeviceID, dwCallback, dwInstance,
710 if (lphMidiOut != NULL) *lphMidiOut = HMIDIOUT_16(hmo);
714 /**************************************************************************
715 * midiOutClose [MMSYSTEM.205]
717 UINT16 WINAPI midiOutClose16(HMIDIOUT16 hMidiOut)
719 return midiOutClose(HMIDIOUT_32(hMidiOut));
722 /**************************************************************************
723 * midiOutPrepareHeader [MMSYSTEM.206]
725 UINT16 WINAPI midiOutPrepareHeader16(HMIDIOUT16 hMidiOut, /* [in] */
726 SEGPTR lpsegMidiOutHdr, /* [???] */
727 UINT16 uSize) /* [in] */
731 TRACE("(%04X, %08lx, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
733 if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
734 return MMSYSERR_INVALHANDLE;
736 return MMDRV_Message(wmld, MODM_PREPARE, lpsegMidiOutHdr, uSize, FALSE);
739 /**************************************************************************
740 * midiOutUnprepareHeader [MMSYSTEM.207]
742 UINT16 WINAPI midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut, /* [in] */
743 SEGPTR lpsegMidiOutHdr, /* [???] */
744 UINT16 uSize) /* [in] */
747 LPMIDIHDR16 lpMidiOutHdr = MapSL(lpsegMidiOutHdr);
749 TRACE("(%04X, %08lx, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
751 if (!(lpMidiOutHdr->dwFlags & MHDR_PREPARED)) {
752 return MMSYSERR_NOERROR;
755 if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
756 return MMSYSERR_INVALHANDLE;
758 return MMDRV_Message(wmld, MODM_UNPREPARE, (DWORD)lpsegMidiOutHdr, uSize, FALSE);
761 /**************************************************************************
762 * midiOutShortMsg [MMSYSTEM.208]
764 UINT16 WINAPI midiOutShortMsg16(HMIDIOUT16 hMidiOut, DWORD dwMsg)
766 return midiOutShortMsg(HMIDIOUT_32(hMidiOut), dwMsg);
769 /**************************************************************************
770 * midiOutLongMsg [MMSYSTEM.209]
772 UINT16 WINAPI midiOutLongMsg16(HMIDIOUT16 hMidiOut, /* [in] */
773 LPMIDIHDR16 lpsegMidiOutHdr, /* [???] NOTE: SEGPTR */
774 UINT16 uSize) /* [in] */
778 TRACE("(%04X, %p, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
780 if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
781 return MMSYSERR_INVALHANDLE;
783 return MMDRV_Message(wmld, MODM_LONGDATA, (DWORD)lpsegMidiOutHdr, uSize, FALSE);
786 /**************************************************************************
787 * midiOutReset [MMSYSTEM.210]
789 UINT16 WINAPI midiOutReset16(HMIDIOUT16 hMidiOut)
791 return midiOutReset(HMIDIOUT_32(hMidiOut));
794 /**************************************************************************
795 * midiOutGetVolume [MMSYSTEM.211]
797 UINT16 WINAPI midiOutGetVolume16(UINT16 uDeviceID, DWORD* lpdwVolume)
799 return midiOutGetVolume(uDeviceID, lpdwVolume);
802 /**************************************************************************
803 * midiOutSetVolume [MMSYSTEM.212]
805 UINT16 WINAPI midiOutSetVolume16(UINT16 uDeviceID, DWORD dwVolume)
807 return midiOutSetVolume(uDeviceID, dwVolume);
810 /**************************************************************************
811 * midiOutCachePatches [MMSYSTEM.213]
813 UINT16 WINAPI midiOutCachePatches16(HMIDIOUT16 hMidiOut, UINT16 uBank,
814 WORD* lpwPatchArray, UINT16 uFlags)
816 return midiOutCachePatches(HMIDIOUT_32(hMidiOut), uBank, lpwPatchArray,
820 /**************************************************************************
821 * midiOutCacheDrumPatches [MMSYSTEM.214]
823 UINT16 WINAPI midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut, UINT16 uPatch,
824 WORD* lpwKeyArray, UINT16 uFlags)
826 return midiOutCacheDrumPatches(HMIDIOUT_32(hMidiOut), uPatch, lpwKeyArray, uFlags);
829 /**************************************************************************
830 * midiOutGetID [MMSYSTEM.215]
832 UINT16 WINAPI midiOutGetID16(HMIDIOUT16 hMidiOut, UINT16* lpuDeviceID)
836 TRACE("(%04X, %p)\n", hMidiOut, lpuDeviceID);
838 if (lpuDeviceID == NULL) return MMSYSERR_INVALPARAM;
839 if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
840 return MMSYSERR_INVALHANDLE;
842 *lpuDeviceID = wmld->uDeviceID;
843 return MMSYSERR_NOERROR;
846 /**************************************************************************
847 * midiOutMessage [MMSYSTEM.216]
849 DWORD WINAPI midiOutMessage16(HMIDIOUT16 hMidiOut, UINT16 uMessage,
850 DWORD dwParam1, DWORD dwParam2)
854 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiOut, uMessage, dwParam1, dwParam2);
856 if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
857 return MMSYSERR_INVALHANDLE;
862 FIXME("can't handle OPEN or CLOSE message!\n");
863 return MMSYSERR_NOTSUPPORTED;
866 return midiOutGetVolume16(hMidiOut, MapSL(dwParam1));
868 return midiOutLongMsg16(hMidiOut, MapSL(dwParam1), dwParam2);
870 /* lpMidiOutHdr is still a segmented pointer for this function */
871 return midiOutPrepareHeader16(hMidiOut, dwParam1, dwParam2);
873 return midiOutUnprepareHeader16(hMidiOut, dwParam1, dwParam2);
875 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
878 /**************************************************************************
879 * midiInGetNumDevs [MMSYSTEM.301]
881 UINT16 WINAPI midiInGetNumDevs16(void)
883 return MMDRV_GetNum(MMDRV_MIDIIN);
886 /**************************************************************************
887 * midiInGetDevCaps [MMSYSTEM.302]
889 UINT16 WINAPI midiInGetDevCaps16(UINT16 uDeviceID, LPMIDIINCAPS16 lpCaps,
893 UINT ret = midiInGetDevCapsA(uDeviceID, &micA, uSize);
895 if (ret == MMSYSERR_NOERROR) {
896 lpCaps->wMid = micA.wMid;
897 lpCaps->wPid = micA.wPid;
898 lpCaps->vDriverVersion = micA.vDriverVersion;
899 strcpy(lpCaps->szPname, micA.szPname);
900 lpCaps->dwSupport = micA.dwSupport;
906 /**************************************************************************
907 * midiInGetErrorText [MMSYSTEM.303]
909 UINT16 WINAPI midiInGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
911 return midiInGetErrorTextA(uError, lpText, uSize);
914 /**************************************************************************
915 * midiInOpen [MMSYSTEM.304]
917 UINT16 WINAPI midiInOpen16(HMIDIIN16* lphMidiIn, UINT16 uDeviceID,
918 DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
923 ret = MMSYSTEM_midiInOpen(&xhmid, uDeviceID, dwCallback, dwInstance,
926 if (lphMidiIn) *lphMidiIn = HMIDIIN_16(xhmid);
930 /**************************************************************************
931 * midiInClose [MMSYSTEM.305]
933 UINT16 WINAPI midiInClose16(HMIDIIN16 hMidiIn)
935 return midiInClose(HMIDIIN_32(hMidiIn));
938 /**************************************************************************
939 * midiInPrepareHeader [MMSYSTEM.306]
941 UINT16 WINAPI midiInPrepareHeader16(HMIDIIN16 hMidiIn, /* [in] */
942 SEGPTR lpsegMidiInHdr, /* [???] */
943 UINT16 uSize) /* [in] */
947 TRACE("(%04X, %08lx, %d)\n", hMidiIn, lpsegMidiInHdr, uSize);
949 if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL)
950 return MMSYSERR_INVALHANDLE;
952 return MMDRV_Message(wmld, MIDM_PREPARE, (DWORD)lpsegMidiInHdr, uSize, FALSE);
955 /**************************************************************************
956 * midiInUnprepareHeader [MMSYSTEM.307]
958 UINT16 WINAPI midiInUnprepareHeader16(HMIDIIN16 hMidiIn, /* [in] */
959 SEGPTR lpsegMidiInHdr, /* [???] */
960 UINT16 uSize) /* [in] */
963 LPMIDIHDR16 lpMidiInHdr = MapSL(lpsegMidiInHdr);
965 TRACE("(%04X, %08lx, %d)\n", hMidiIn, lpsegMidiInHdr, uSize);
967 if (!(lpMidiInHdr->dwFlags & MHDR_PREPARED)) {
968 return MMSYSERR_NOERROR;
971 if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL)
972 return MMSYSERR_INVALHANDLE;
974 return MMDRV_Message(wmld, MIDM_UNPREPARE, (DWORD)lpsegMidiInHdr, uSize, FALSE);
977 /**************************************************************************
978 * midiInAddBuffer [MMSYSTEM.308]
980 UINT16 WINAPI midiInAddBuffer16(HMIDIIN16 hMidiIn, /* [in] */
981 MIDIHDR16* lpsegMidiInHdr, /* [???] NOTE: SEGPTR */
982 UINT16 uSize) /* [in] */
986 TRACE("(%04X, %p, %d)\n", hMidiIn, lpsegMidiInHdr, uSize);
988 if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL)
989 return MMSYSERR_INVALHANDLE;
991 return MMDRV_Message(wmld, MIDM_ADDBUFFER, (DWORD)lpsegMidiInHdr, uSize, FALSE);
994 /**************************************************************************
995 * midiInStart [MMSYSTEM.309]
997 UINT16 WINAPI midiInStart16(HMIDIIN16 hMidiIn)
999 return midiInStart(HMIDIIN_32(hMidiIn));
1002 /**************************************************************************
1003 * midiInStop [MMSYSTEM.310]
1005 UINT16 WINAPI midiInStop16(HMIDIIN16 hMidiIn)
1007 return midiInStop(HMIDIIN_32(hMidiIn));
1010 /**************************************************************************
1011 * midiInReset [MMSYSTEM.311]
1013 UINT16 WINAPI midiInReset16(HMIDIIN16 hMidiIn)
1015 return midiInReset(HMIDIIN_32(hMidiIn));
1018 /**************************************************************************
1019 * midiInGetID [MMSYSTEM.312]
1021 UINT16 WINAPI midiInGetID16(HMIDIIN16 hMidiIn, UINT16* lpuDeviceID)
1025 TRACE("(%04X, %p)\n", hMidiIn, lpuDeviceID);
1027 if (lpuDeviceID == NULL) return MMSYSERR_INVALPARAM;
1029 if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, TRUE)) == NULL)
1030 return MMSYSERR_INVALHANDLE;
1032 *lpuDeviceID = wmld->uDeviceID;
1034 return MMSYSERR_NOERROR;
1037 /**************************************************************************
1038 * midiInMessage [MMSYSTEM.313]
1040 DWORD WINAPI midiInMessage16(HMIDIIN16 hMidiIn, UINT16 uMessage,
1041 DWORD dwParam1, DWORD dwParam2)
1045 TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn, uMessage, dwParam1, dwParam2);
1050 FIXME("can't handle OPEN or CLOSE message!\n");
1051 return MMSYSERR_NOTSUPPORTED;
1053 case MIDM_GETDEVCAPS:
1054 return midiInGetDevCaps16(hMidiIn, MapSL(dwParam1), dwParam2);
1056 return midiInPrepareHeader16(hMidiIn, dwParam1, dwParam2);
1057 case MIDM_UNPREPARE:
1058 return midiInUnprepareHeader16(hMidiIn, dwParam1, dwParam2);
1059 case MIDM_ADDBUFFER:
1060 return midiInAddBuffer16(hMidiIn, MapSL(dwParam1), dwParam2);
1063 if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL)
1064 return MMSYSERR_INVALHANDLE;
1066 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, FALSE);
1069 /**************************************************************************
1070 * midiStreamClose [MMSYSTEM.252]
1072 MMRESULT16 WINAPI midiStreamClose16(HMIDISTRM16 hMidiStrm)
1074 return midiStreamClose(HMIDISTRM_32(hMidiStrm));
1077 /**************************************************************************
1078 * midiStreamOpen [MMSYSTEM.251]
1080 MMRESULT16 WINAPI midiStreamOpen16(HMIDISTRM16* phMidiStrm, LPUINT16 devid,
1081 DWORD cMidi, DWORD dwCallback,
1082 DWORD dwInstance, DWORD fdwOpen)
1084 HMIDISTRM hMidiStrm32;
1088 if (!phMidiStrm || !devid)
1089 return MMSYSERR_INVALPARAM;
1091 ret = MMSYSTEM_MidiStream_Open(&hMidiStrm32, &devid32, cMidi, dwCallback,
1092 dwInstance, fdwOpen, FALSE);
1093 *phMidiStrm = HMIDISTRM_16(hMidiStrm32);
1098 /**************************************************************************
1099 * midiStreamOut [MMSYSTEM.254]
1101 MMRESULT16 WINAPI midiStreamOut16(HMIDISTRM16 hMidiStrm, LPMIDIHDR16 lpMidiHdr, UINT16 cbMidiHdr)
1103 return midiStreamOut(HMIDISTRM_32(hMidiStrm), (LPMIDIHDR)lpMidiHdr,
1107 /**************************************************************************
1108 * midiStreamPause [MMSYSTEM.255]
1110 MMRESULT16 WINAPI midiStreamPause16(HMIDISTRM16 hMidiStrm)
1112 return midiStreamPause(HMIDISTRM_32(hMidiStrm));
1115 /**************************************************************************
1116 * midiStreamPosition [MMSYSTEM.253]
1118 MMRESULT16 WINAPI midiStreamPosition16(HMIDISTRM16 hMidiStrm, LPMMTIME16 lpmmt16, UINT16 cbmmt)
1124 return MMSYSERR_INVALPARAM;
1125 MMSYSTEM_MMTIME16to32(&mmt32, lpmmt16);
1126 ret = midiStreamPosition(HMIDISTRM_32(hMidiStrm), &mmt32, sizeof(MMTIME));
1127 MMSYSTEM_MMTIME32to16(lpmmt16, &mmt32);
1131 /**************************************************************************
1132 * midiStreamProperty [MMSYSTEM.250]
1134 MMRESULT16 WINAPI midiStreamProperty16(HMIDISTRM16 hMidiStrm, LPBYTE lpPropData, DWORD dwProperty)
1136 return midiStreamProperty(HMIDISTRM_32(hMidiStrm), lpPropData, dwProperty);
1139 /**************************************************************************
1140 * midiStreamRestart [MMSYSTEM.256]
1142 MMRESULT16 WINAPI midiStreamRestart16(HMIDISTRM16 hMidiStrm)
1144 return midiStreamRestart(HMIDISTRM_32(hMidiStrm));
1147 /**************************************************************************
1148 * midiStreamStop [MMSYSTEM.257]
1150 MMRESULT16 WINAPI midiStreamStop16(HMIDISTRM16 hMidiStrm)
1152 return midiStreamStop(HMIDISTRM_32(hMidiStrm));
1155 /* ###################################################
1157 * ###################################################
1160 /**************************************************************************
1161 * waveOutGetNumDevs [MMSYSTEM.401]
1163 UINT16 WINAPI waveOutGetNumDevs16(void)
1165 return MMDRV_GetNum(MMDRV_WAVEOUT);
1168 /**************************************************************************
1169 * waveOutGetDevCaps [MMSYSTEM.402]
1171 UINT16 WINAPI waveOutGetDevCaps16(UINT16 uDeviceID,
1172 LPWAVEOUTCAPS16 lpCaps, UINT16 uSize)
1177 TRACE("(%u %p %u)!\n", uDeviceID, lpCaps, uSize);
1178 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
1180 ret = waveOutGetDevCapsA(uDeviceID, &wocA, sizeof(wocA));
1182 if (ret == MMSYSERR_NOERROR) {
1183 lpCaps->wMid = wocA.wMid;
1184 lpCaps->wPid = wocA.wPid;
1185 lpCaps->vDriverVersion = wocA.vDriverVersion;
1186 strcpy(lpCaps->szPname, wocA.szPname);
1187 lpCaps->dwFormats = wocA.dwFormats;
1188 lpCaps->wChannels = wocA.wChannels;
1189 lpCaps->dwSupport = wocA.dwSupport;
1194 /**************************************************************************
1195 * waveOutGetErrorText [MMSYSTEM.403]
1197 UINT16 WINAPI waveOutGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
1199 return waveOutGetErrorTextA(uError, lpText, uSize);
1202 /**************************************************************************
1203 * waveOutOpen [MMSYSTEM.404]
1205 UINT16 WINAPI waveOutOpen16(HWAVEOUT16* lphWaveOut, UINT16 uDeviceID,
1206 const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
1207 DWORD dwInstance, DWORD dwFlags)
1212 /* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
1213 * call the 32 bit version
1214 * however, we need to promote correctly the wave mapper id
1215 * (0xFFFFFFFF and not 0x0000FFFF)
1217 ret = MMSYSTEM_waveOpen(&hWaveOut, (uDeviceID == (UINT16)-1) ? (UINT)-1 : uDeviceID,
1218 MMDRV_WAVEOUT, lpFormat, dwCallback, dwInstance, dwFlags, FALSE);
1220 if (lphWaveOut != NULL) *lphWaveOut = HWAVEOUT_16(hWaveOut);
1224 /**************************************************************************
1225 * waveOutClose [MMSYSTEM.405]
1227 UINT16 WINAPI waveOutClose16(HWAVEOUT16 hWaveOut)
1232 ReleaseThunkLock(&level);
1233 ret = waveOutClose(HWAVEOUT_32(hWaveOut));
1234 RestoreThunkLock(level);
1238 /**************************************************************************
1239 * waveOutPrepareHeader [MMSYSTEM.406]
1241 UINT16 WINAPI waveOutPrepareHeader16(HWAVEOUT16 hWaveOut, /* [in] */
1242 SEGPTR lpsegWaveOutHdr, /* [???] */
1243 UINT16 uSize) /* [in] */
1246 LPWAVEHDR lpWaveOutHdr = MapSL(lpsegWaveOutHdr);
1248 TRACE("(%04X, %08lx, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
1250 if (lpWaveOutHdr == NULL) return MMSYSERR_INVALPARAM;
1252 if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
1253 return MMSYSERR_INVALHANDLE;
1255 return MMDRV_Message(wmld, WODM_PREPARE, (DWORD)lpsegWaveOutHdr, uSize, FALSE);
1258 /**************************************************************************
1259 * waveOutUnprepareHeader [MMSYSTEM.407]
1261 UINT16 WINAPI waveOutUnprepareHeader16(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->dwFlags & WHDR_PREPARED)) {
1271 return MMSYSERR_NOERROR;
1274 if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
1275 return MMSYSERR_INVALHANDLE;
1277 return MMDRV_Message(wmld, WODM_UNPREPARE, (DWORD)lpsegWaveOutHdr, uSize, FALSE);
1280 /**************************************************************************
1281 * waveOutWrite [MMSYSTEM.408]
1283 UINT16 WINAPI waveOutWrite16(HWAVEOUT16 hWaveOut, /* [in] */
1284 LPWAVEHDR lpsegWaveOutHdr, /* [???] NOTE: SEGPTR */
1285 UINT16 uSize) /* [in] */
1289 TRACE("(%04X, %p, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
1291 if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
1292 return MMSYSERR_INVALHANDLE;
1294 return MMDRV_Message(wmld, WODM_WRITE, (DWORD)lpsegWaveOutHdr, uSize, FALSE);
1297 /**************************************************************************
1298 * waveOutBreakLoop [MMSYSTEM.419]
1300 UINT16 WINAPI waveOutBreakLoop16(HWAVEOUT16 hWaveOut16)
1305 ReleaseThunkLock(&level);
1306 ret = waveOutBreakLoop(HWAVEOUT_32(hWaveOut16));
1307 RestoreThunkLock(level);
1311 /**************************************************************************
1312 * waveOutPause [MMSYSTEM.409]
1314 UINT16 WINAPI waveOutPause16(HWAVEOUT16 hWaveOut16)
1319 ReleaseThunkLock(&level);
1320 ret = waveOutPause(HWAVEOUT_32(hWaveOut16));
1321 RestoreThunkLock(level);
1325 /**************************************************************************
1326 * waveOutReset [MMSYSTEM.411]
1328 UINT16 WINAPI waveOutReset16(HWAVEOUT16 hWaveOut16)
1333 ReleaseThunkLock(&level);
1334 ret = waveOutReset(HWAVEOUT_32(hWaveOut16));
1335 RestoreThunkLock(level);
1339 /**************************************************************************
1340 * waveOutRestart [MMSYSTEM.410]
1342 UINT16 WINAPI waveOutRestart16(HWAVEOUT16 hWaveOut16)
1347 ReleaseThunkLock(&level);
1348 ret = waveOutRestart(HWAVEOUT_32(hWaveOut16));
1349 RestoreThunkLock(level);
1353 /**************************************************************************
1354 * waveOutGetPosition [MMSYSTEM.412]
1356 UINT16 WINAPI waveOutGetPosition16(HWAVEOUT16 hWaveOut, LPMMTIME16 lpTime,
1362 mmt.wType = lpTime->wType;
1363 ret = waveOutGetPosition(HWAVEOUT_32(hWaveOut), &mmt, sizeof(mmt));
1364 MMSYSTEM_MMTIME32to16(lpTime, &mmt);
1368 /**************************************************************************
1369 * waveOutGetPitch [MMSYSTEM.413]
1371 UINT16 WINAPI waveOutGetPitch16(HWAVEOUT16 hWaveOut16, LPDWORD lpdw)
1373 return waveOutGetPitch(HWAVEOUT_32(hWaveOut16), lpdw);
1376 /**************************************************************************
1377 * waveOutSetPitch [MMSYSTEM.414]
1379 UINT16 WINAPI waveOutSetPitch16(HWAVEOUT16 hWaveOut16, DWORD dw)
1381 return waveOutSetPitch(HWAVEOUT_32(hWaveOut16), dw);
1384 /**************************************************************************
1385 * waveOutGetPlaybackRate [MMSYSTEM.417]
1387 UINT16 WINAPI waveOutGetPlaybackRate16(HWAVEOUT16 hWaveOut16, LPDWORD lpdw)
1389 return waveOutGetPlaybackRate(HWAVEOUT_32(hWaveOut16), lpdw);
1392 /**************************************************************************
1393 * waveOutSetPlaybackRate [MMSYSTEM.418]
1395 UINT16 WINAPI waveOutSetPlaybackRate16(HWAVEOUT16 hWaveOut16, DWORD dw)
1397 return waveOutSetPlaybackRate(HWAVEOUT_32(hWaveOut16), dw);
1400 /**************************************************************************
1401 * waveOutGetVolume [MMSYSTEM.415]
1403 UINT16 WINAPI waveOutGetVolume16(UINT16 devid, LPDWORD lpdw)
1405 return waveOutGetVolume(devid, lpdw);
1408 /**************************************************************************
1409 * waveOutSetVolume [MMSYSTEM.416]
1411 UINT16 WINAPI waveOutSetVolume16(UINT16 devid, DWORD dw)
1413 return waveOutSetVolume(devid, dw);
1416 /**************************************************************************
1417 * waveOutGetID [MMSYSTEM.420]
1419 UINT16 WINAPI waveOutGetID16(HWAVEOUT16 hWaveOut, UINT16* lpuDeviceID)
1423 TRACE("(%04X, %p);\n", hWaveOut, lpuDeviceID);
1425 if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
1427 if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
1428 return MMSYSERR_INVALHANDLE;
1430 *lpuDeviceID = wmld->uDeviceID;
1434 /**************************************************************************
1435 * waveOutMessage [MMSYSTEM.421]
1437 DWORD WINAPI waveOutMessage16(HWAVEOUT16 hWaveOut, UINT16 uMessage,
1438 DWORD dwParam1, DWORD dwParam2)
1442 TRACE("(%04x, %u, %ld, %ld)\n", hWaveOut, uMessage, dwParam1, dwParam2);
1444 if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL) {
1445 if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, TRUE)) != NULL) {
1446 return MMDRV_PhysicalFeatures(wmld, uMessage, dwParam1, dwParam2);
1448 return MMSYSERR_INVALHANDLE;
1452 if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
1453 return MMSYSERR_INVALPARAM;
1455 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, FALSE);
1458 /**************************************************************************
1459 * waveInGetNumDevs [MMSYSTEM.501]
1461 UINT16 WINAPI waveInGetNumDevs16(void)
1463 return MMDRV_GetNum(MMDRV_WAVEIN);
1466 /**************************************************************************
1467 * waveInGetDevCaps [MMSYSTEM.502]
1469 UINT16 WINAPI waveInGetDevCaps16(UINT16 uDeviceID, LPWAVEINCAPS16 lpCaps,
1473 UINT ret = waveInGetDevCapsA(uDeviceID, &wicA, sizeof(wicA));
1475 if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
1477 if (ret == MMSYSERR_NOERROR) {
1478 lpCaps->wMid = wicA.wMid;
1479 lpCaps->wPid = wicA.wPid;
1480 lpCaps->vDriverVersion = wicA.vDriverVersion;
1481 strcpy(lpCaps->szPname, wicA.szPname);
1482 lpCaps->dwFormats = wicA.dwFormats;
1483 lpCaps->wChannels = wicA.wChannels;
1488 /**************************************************************************
1489 * waveInGetErrorText [MMSYSTEM.503]
1491 UINT16 WINAPI waveInGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
1493 return waveInGetErrorTextA(uError, lpText, uSize);
1496 /**************************************************************************
1497 * waveInOpen [MMSYSTEM.504]
1499 UINT16 WINAPI waveInOpen16(HWAVEIN16* lphWaveIn, UINT16 uDeviceID,
1500 const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
1501 DWORD dwInstance, DWORD dwFlags)
1506 /* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
1507 * call the 32 bit version
1508 * however, we need to promote correctly the wave mapper id
1509 * (0xFFFFFFFF and not 0x0000FFFF)
1511 ret = MMSYSTEM_waveOpen(&hWaveIn, (uDeviceID == (UINT16)-1) ? (UINT)-1 : uDeviceID,
1512 MMDRV_WAVEIN, lpFormat, dwCallback, dwInstance, dwFlags, FALSE);
1514 if (lphWaveIn != NULL) *lphWaveIn = HWAVEIN_16(hWaveIn);
1518 /**************************************************************************
1519 * waveInClose [MMSYSTEM.505]
1521 UINT16 WINAPI waveInClose16(HWAVEIN16 hWaveIn)
1526 ReleaseThunkLock(&level);
1527 ret = waveInClose(HWAVEIN_32(hWaveIn));
1528 RestoreThunkLock(level);
1532 /**************************************************************************
1533 * waveInPrepareHeader [MMSYSTEM.506]
1535 UINT16 WINAPI waveInPrepareHeader16(HWAVEIN16 hWaveIn, /* [in] */
1536 SEGPTR lpsegWaveInHdr, /* [???] */
1537 UINT16 uSize) /* [in] */
1540 LPWAVEHDR lpWaveInHdr = MapSL(lpsegWaveInHdr);
1543 TRACE("(%04X, %p, %u);\n", hWaveIn, lpWaveInHdr, uSize);
1545 if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
1546 if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
1547 return MMSYSERR_INVALHANDLE;
1549 lpWaveInHdr->dwBytesRecorded = 0;
1551 ret = MMDRV_Message(wmld, WIDM_PREPARE, (DWORD)lpsegWaveInHdr, uSize, FALSE);
1555 /**************************************************************************
1556 * waveInUnprepareHeader [MMSYSTEM.507]
1558 UINT16 WINAPI waveInUnprepareHeader16(HWAVEIN16 hWaveIn, /* [in] */
1559 SEGPTR lpsegWaveInHdr, /* [???] */
1560 UINT16 uSize) /* [in] */
1563 LPWAVEHDR lpWaveInHdr = MapSL(lpsegWaveInHdr);
1565 TRACE("(%04X, %08lx, %u);\n", hWaveIn, lpsegWaveInHdr, uSize);
1567 if (lpWaveInHdr == NULL) return MMSYSERR_INVALPARAM;
1569 if (!(lpWaveInHdr->dwFlags & WHDR_PREPARED)) {
1570 return MMSYSERR_NOERROR;
1573 if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
1574 return MMSYSERR_INVALHANDLE;
1576 return MMDRV_Message(wmld, WIDM_UNPREPARE, (DWORD)lpsegWaveInHdr, uSize, FALSE);
1579 /**************************************************************************
1580 * waveInAddBuffer [MMSYSTEM.508]
1582 UINT16 WINAPI waveInAddBuffer16(HWAVEIN16 hWaveIn, /* [in] */
1583 WAVEHDR* lpsegWaveInHdr, /* [???] NOTE: SEGPTR */
1584 UINT16 uSize) /* [in] */
1588 TRACE("(%04X, %p, %u);\n", hWaveIn, lpsegWaveInHdr, uSize);
1590 if (lpsegWaveInHdr == NULL) return MMSYSERR_INVALPARAM;
1591 if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
1592 return MMSYSERR_INVALHANDLE;
1594 return MMDRV_Message(wmld, WIDM_ADDBUFFER, (DWORD)lpsegWaveInHdr, uSize, FALSE);
1597 /**************************************************************************
1598 * waveInReset [MMSYSTEM.511]
1600 UINT16 WINAPI waveInReset16(HWAVEIN16 hWaveIn16)
1605 ReleaseThunkLock(&level);
1606 ret = waveInReset(HWAVEIN_32(hWaveIn16));
1607 RestoreThunkLock(level);
1611 /**************************************************************************
1612 * waveInStart [MMSYSTEM.509]
1614 UINT16 WINAPI waveInStart16(HWAVEIN16 hWaveIn16)
1619 ReleaseThunkLock(&level);
1620 ret = waveInStart(HWAVEIN_32(hWaveIn16));
1621 RestoreThunkLock(level);
1625 /**************************************************************************
1626 * waveInStop [MMSYSTEM.510]
1628 UINT16 WINAPI waveInStop16(HWAVEIN16 hWaveIn16)
1633 ReleaseThunkLock(&level);
1634 ret = waveInStop(HWAVEIN_32(hWaveIn16));
1635 RestoreThunkLock(level);
1639 /**************************************************************************
1640 * waveInGetPosition [MMSYSTEM.512]
1642 UINT16 WINAPI waveInGetPosition16(HWAVEIN16 hWaveIn, LPMMTIME16 lpTime,
1648 mmt.wType = lpTime->wType;
1649 ret = waveInGetPosition(HWAVEIN_32(hWaveIn), &mmt, sizeof(mmt));
1650 MMSYSTEM_MMTIME32to16(lpTime, &mmt);
1654 /**************************************************************************
1655 * waveInGetID [MMSYSTEM.513]
1657 UINT16 WINAPI waveInGetID16(HWAVEIN16 hWaveIn, UINT16* lpuDeviceID)
1661 TRACE("(%04X, %p);\n", hWaveIn, lpuDeviceID);
1663 if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
1665 if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
1666 return MMSYSERR_INVALHANDLE;
1668 *lpuDeviceID = wmld->uDeviceID;
1669 return MMSYSERR_NOERROR;
1672 /**************************************************************************
1673 * waveInMessage [MMSYSTEM.514]
1675 DWORD WINAPI waveInMessage16(HWAVEIN16 hWaveIn, UINT16 uMessage,
1676 DWORD dwParam1, DWORD dwParam2)
1680 TRACE("(%04x, %u, %ld, %ld)\n", hWaveIn, uMessage, dwParam1, dwParam2);
1683 if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
1684 return MMSYSERR_INVALPARAM;
1686 if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
1687 return MMSYSERR_INVALHANDLE;
1689 return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
1692 /* ###################################################
1694 * ###################################################
1697 /*#define USE_MM_TSK_WINE*/
1699 /**************************************************************************
1700 * mmTaskCreate [MMSYSTEM.900]
1702 * Creates a 16 bit MM task. It's entry point is lpFunc, and it should be
1703 * called upon creation with dwPmt as parameter.
1705 HINSTANCE16 WINAPI mmTaskCreate16(SEGPTR spProc, HINSTANCE16 *lphMmTask, DWORD dwPmt)
1710 DWORD showCmd = 0x40002;
1713 TRACE("(%08lx, %p, %08lx);\n", spProc, lphMmTask, dwPmt);
1714 /* This to work requires NE modules to be started with a binary command line
1715 * which is not currently the case. A patch exists but has never been committed.
1716 * A workaround would be to integrate code for mmtask.tsk into Wine, but
1717 * this requires tremendous work (starting with patching tools/build to
1718 * create NE executables (and not only DLLs) for builtins modules.
1721 FIXME("This is currently broken. It will fail\n");
1724 *(LPDWORD)(cmdline + 1) = (DWORD)spProc;
1725 *(LPDWORD)(cmdline + 5) = dwPmt;
1726 *(LPDWORD)(cmdline + 9) = 0;
1728 lp.hEnvironment = 0;
1729 lp.cmdLine = MapLS(cmdline);
1730 lp.showCmd = MapLS(&showCmd);
1733 #ifndef USE_MM_TSK_WINE
1734 handle = LoadModule16("c:\\windows\\system\\mmtask.tsk", &lp);
1736 handle = LoadModule16("mmtask.tsk", &lp);
1739 ret = (handle) ? 1 : 2;
1745 *lphMmTask = handle;
1747 UnMapLS( lp.cmdLine );
1748 UnMapLS( lp.showCmd );
1749 TRACE("=> 0x%04x/%d\n", handle, ret);
1753 #ifdef USE_MM_TSK_WINE
1754 /* C equivalent to mmtask.tsk binary content */
1755 void mmTaskEntryPoint16(LPSTR cmdLine, WORD di, WORD si)
1757 int len = cmdLine[0x80];
1760 void (*fpProc)(DWORD) = MapSL(*((DWORD*)(cmdLine + 1)));
1761 DWORD dwPmt = *((DWORD*)(cmdLine + 5));
1764 InitTask16(); /* FIXME: pmts / from context ? */
1767 if (SetMessageQueue16(0x40)) {
1769 if (HIWORD(fpProc)) {
1771 /* EPP StackEnter16(); */
1783 /**************************************************************************
1784 * mmTaskBlock [MMSYSTEM.902]
1786 void WINAPI mmTaskBlock16(HINSTANCE16 WINE_UNUSED hInst)
1791 GetMessageA(&msg, 0, 0, 0);
1793 TranslateMessage(&msg);
1794 DispatchMessageA(&msg);
1796 } while (msg.message < 0x3A0);
1799 /**************************************************************************
1800 * mmTaskSignal [MMSYSTEM.903]
1802 LRESULT WINAPI mmTaskSignal16(HTASK16 ht)
1804 TRACE("(%04x);\n", ht);
1805 return PostAppMessage16(ht, WM_USER, 0, 0);
1808 /**************************************************************************
1809 * mmGetCurrentTask [MMSYSTEM.904]
1811 HTASK16 WINAPI mmGetCurrentTask16(void)
1813 return GetCurrentTask();
1816 /**************************************************************************
1817 * mmTaskYield [MMSYSTEM.905]
1819 void WINAPI mmTaskYield16(void)
1823 if (PeekMessageA(&msg, 0, 0, 0, 0)) {
1828 extern DWORD WINAPI GetProcessFlags(DWORD);
1830 /******************************************************************
1835 static WINE_MMTHREAD* WINMM_GetmmThread(HANDLE16 h)
1837 return (WINE_MMTHREAD*)MapSL( MAKESEGPTR(h, 0) );
1840 void WINAPI WINE_mmThreadEntryPoint(DWORD);
1842 /**************************************************************************
1843 * mmThreadCreate [MMSYSTEM.1120]
1846 * Creates a MM thread, calling fpThreadAddr(dwPmt).
1848 * bit.0 set means create a 16 bit task instead of thread calling a 16 bit proc
1849 * bit.1 set means to open a VxD for this thread (unsupported)
1851 LRESULT WINAPI mmThreadCreate16(FARPROC16 fpThreadAddr, LPHANDLE lpHndl, DWORD dwPmt, DWORD dwFlags)
1856 TRACE("(%p, %p, %08lx, %08lx)!\n", fpThreadAddr, lpHndl, dwPmt, dwFlags);
1858 hndl = GlobalAlloc16(sizeof(WINE_MMTHREAD), GMEM_SHARE|GMEM_ZEROINIT);
1863 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
1866 /* force mmtask routines even if mmthread is required */
1867 /* this will work only if the patch about binary cmd line and NE tasks
1873 lpMMThd->dwSignature = WINE_MMTHREAD_CREATED;
1874 lpMMThd->dwCounter = 0;
1875 lpMMThd->hThread = 0;
1876 lpMMThd->dwThreadID = 0;
1877 lpMMThd->fpThread = fpThreadAddr;
1878 lpMMThd->dwThreadPmt = dwPmt;
1879 lpMMThd->dwSignalCount = 0;
1880 lpMMThd->hEvent = 0;
1882 lpMMThd->dwStatus = 0;
1883 lpMMThd->dwFlags = dwFlags;
1886 if ((dwFlags & 1) == 0 && (GetProcessFlags(GetCurrentThreadId()) & 8) == 0) {
1887 lpMMThd->hEvent = CreateEventA(0, 0, 1, 0);
1889 TRACE("Let's go crazy... trying new MM thread. lpMMThd=%p\n", lpMMThd);
1890 if (lpMMThd->dwFlags & 2) {
1891 /* as long as we don't support MM VxD in wine, we don't need
1892 * to care about this flag
1894 /* FIXME("Don't know how to properly open VxD handles\n"); */
1895 /* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */
1898 lpMMThd->hThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)WINE_mmThreadEntryPoint,
1899 (LPVOID)(DWORD)hndl, CREATE_SUSPENDED, &lpMMThd->dwThreadID);
1900 if (lpMMThd->hThread == 0) {
1901 WARN("Couldn't create thread\n");
1902 /* clean-up(VxDhandle...); devicedirectio... */
1903 if (lpMMThd->hEvent != 0)
1904 CloseHandle(lpMMThd->hEvent);
1907 TRACE("Got a nice thread hndl=0x%04x id=0x%08lx\n", lpMMThd->hThread, lpMMThd->dwThreadID);
1911 /* get WINE_mmThreadEntryPoint()
1912 * 2047 is its ordinal in mmsystem.spec
1914 FARPROC16 fp = GetProcAddress16(GetModuleHandle16("MMSYSTEM"), (LPCSTR)2047);
1916 TRACE("farproc seg=0x%08lx lin=%p\n", (DWORD)fp, MapSL((SEGPTR)fp));
1918 ret = (fp == 0) ? 2 : mmTaskCreate16((DWORD)fp, 0, hndl);
1922 if (lpMMThd->hThread && !ResumeThread(lpMMThd->hThread))
1923 WARN("Couldn't resume thread\n");
1925 while (lpMMThd->dwStatus != 0x10) { /* test also HIWORD of dwStatus */
1939 TRACE("ok => %ld\n", ret);
1943 /**************************************************************************
1944 * mmThreadSignal [MMSYSTEM.1121]
1946 void WINAPI mmThreadSignal16(HANDLE16 hndl)
1948 TRACE("(%04x)!\n", hndl);
1951 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
1953 lpMMThd->dwCounter++;
1954 if (lpMMThd->hThread != 0) {
1955 InterlockedIncrement(&lpMMThd->dwSignalCount);
1956 SetEvent(lpMMThd->hEvent);
1958 mmTaskSignal16(lpMMThd->hTask);
1960 lpMMThd->dwCounter--;
1964 static void MMSYSTEM_ThreadBlock(WINE_MMTHREAD* lpMMThd)
1969 if (lpMMThd->dwThreadID != GetCurrentThreadId())
1970 ERR("Not called by thread itself\n");
1973 ResetEvent(lpMMThd->hEvent);
1974 if (InterlockedDecrement(&lpMMThd->dwSignalCount) >= 0)
1976 InterlockedIncrement(&lpMMThd->dwSignalCount);
1980 ret = MsgWaitForMultipleObjects(1, &lpMMThd->hEvent, FALSE, INFINITE, QS_ALLINPUT);
1982 case WAIT_OBJECT_0: /* Event */
1985 case WAIT_OBJECT_0 + 1: /* Msg */
1987 if (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) {
1988 TranslateMessage(&msg);
1989 DispatchMessageA(&msg);
1993 WARN("S2.x unsupported ret val 0x%08lx\n", ret);
1999 /**************************************************************************
2000 * mmThreadBlock [MMSYSTEM.1122]
2002 void WINAPI mmThreadBlock16(HANDLE16 hndl)
2004 TRACE("(%04x)!\n", hndl);
2007 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
2009 if (lpMMThd->hThread != 0) {
2012 ReleaseThunkLock(&lc);
2013 MMSYSTEM_ThreadBlock(lpMMThd);
2014 RestoreThunkLock(lc);
2016 mmTaskBlock16(lpMMThd->hTask);
2022 /**************************************************************************
2023 * mmThreadIsCurrent [MMSYSTEM.1123]
2025 BOOL16 WINAPI mmThreadIsCurrent16(HANDLE16 hndl)
2029 TRACE("(%04x)!\n", hndl);
2031 if (hndl && mmThreadIsValid16(hndl)) {
2032 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
2033 ret = (GetCurrentThreadId() == lpMMThd->dwThreadID);
2035 TRACE("=> %d\n", ret);
2039 /**************************************************************************
2040 * mmThreadIsValid [MMSYSTEM.1124]
2042 BOOL16 WINAPI mmThreadIsValid16(HANDLE16 hndl)
2046 TRACE("(%04x)!\n", hndl);
2049 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
2051 if (!IsBadWritePtr(lpMMThd, sizeof(WINE_MMTHREAD)) &&
2052 lpMMThd->dwSignature == WINE_MMTHREAD_CREATED &&
2053 IsTask16(lpMMThd->hTask)) {
2054 lpMMThd->dwCounter++;
2055 if (lpMMThd->hThread != 0) {
2057 if (GetExitCodeThread(lpMMThd->hThread, &dwThreadRet) &&
2058 dwThreadRet == STATUS_PENDING) {
2064 lpMMThd->dwCounter--;
2067 TRACE("=> %d\n", ret);
2071 /**************************************************************************
2072 * mmThreadGetTask [MMSYSTEM.1125]
2074 HANDLE16 WINAPI mmThreadGetTask16(HANDLE16 hndl)
2078 TRACE("(%04x)\n", hndl);
2080 if (mmThreadIsValid16(hndl)) {
2081 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
2082 ret = lpMMThd->hTask;
2087 /**************************************************************************
2088 * WINE_mmThreadEntryPoint (MMSYSTEM.2047)
2090 void WINAPI WINE_mmThreadEntryPoint(DWORD _pmt)
2092 HANDLE16 hndl = (HANDLE16)_pmt;
2093 WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl);
2095 TRACE("(%04x %p)\n", hndl, lpMMThd);
2097 lpMMThd->hTask = LOWORD(GetCurrentTask());
2098 TRACE("[10-%08x] setting hTask to 0x%08x\n", lpMMThd->hThread, lpMMThd->hTask);
2099 lpMMThd->dwStatus = 0x10;
2100 MMSYSTEM_ThreadBlock(lpMMThd);
2101 TRACE("[20-%08x]\n", lpMMThd->hThread);
2102 lpMMThd->dwStatus = 0x20;
2103 if (lpMMThd->fpThread) {
2104 MMSYSTEM_CallTo16_long_l(lpMMThd->fpThread, lpMMThd->dwThreadPmt);
2106 lpMMThd->dwStatus = 0x30;
2107 TRACE("[30-%08x]\n", lpMMThd->hThread);
2108 while (lpMMThd->dwCounter) {
2110 /* K32WOWYield16();*/
2112 TRACE("[XX-%08x]\n", lpMMThd->hThread);
2114 lpMMThd->dwSignature = WINE_MMTHREAD_DELETED;
2115 /* close lpMMThread->hVxD directIO */
2116 if (lpMMThd->hEvent)
2117 CloseHandle(lpMMThd->hEvent);
2122 typedef BOOL16 (WINAPI *MMCPLCALLBACK)(HWND, LPCSTR, LPCSTR, LPCSTR);
2124 /**************************************************************************
2125 * mmShowMMCPLPropertySheet [MMSYSTEM.1150]
2127 BOOL16 WINAPI mmShowMMCPLPropertySheet16(HWND hWnd, LPCSTR lpStrDevice,
2128 LPCSTR lpStrTab, LPCSTR lpStrTitle)
2133 TRACE("(%04x \"%s\" \"%s\" \"%s\")\n", hWnd, lpStrDevice, lpStrTab, lpStrTitle);
2135 hndl = LoadLibraryA("MMSYS.CPL");
2137 MMCPLCALLBACK fp = (MMCPLCALLBACK)GetProcAddress(hndl, "ShowMMCPLPropertySheet");
2140 ReleaseThunkLock(&lc);
2141 ret = (fp)(hWnd, lpStrDevice, lpStrTab, lpStrTitle);
2142 RestoreThunkLock(lc);
2150 /**************************************************************************
2151 * StackEnter [MMSYSTEM.32]
2153 void WINAPI StackEnter16(void)
2156 /* mmsystem.dll from Win 95 does only this: so does Wine */
2161 /**************************************************************************
2162 * StackLeave [MMSYSTEM.33]
2164 void WINAPI StackLeave16(void)
2167 /* mmsystem.dll from Win 95 does only this: so does Wine */
2172 /**************************************************************************
2173 * WMMMidiRunOnce [MMSYSTEM.8]
2175 void WINAPI WMMMidiRunOnce16(void)
2177 FIXME("(), stub!\n");
2180 /* ###################################################
2182 * ###################################################
2185 /**************************************************************************
2186 * DRIVER_MapMsg32To16 [internal]
2188 * Map a 32 bit driver message to a 16 bit driver message.
2190 WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
2192 WINMM_MapType ret = WINMM_MAP_MSGERROR;
2199 case DRV_QUERYCONFIGURE:
2201 case DRV_EXITSESSION:
2202 case DRV_EXITAPPLICATION:
2204 case DRV_CLOSE: /* should be 0/0 */
2205 case DRV_OPEN: /* pass through */
2206 /* lParam1 and lParam2 are not used */
2211 /* lParam1 is a handle to a window (conf) or to a driver (inst) or not used,
2212 * lParam2 is a pointer to DRVCONFIGINFO
2215 LPDRVCONFIGINFO16 dci16 = HeapAlloc( GetProcessHeap(), 0, sizeof(*dci16) );
2216 LPDRVCONFIGINFO dci32 = (LPDRVCONFIGINFO)(*lParam2);
2221 dci16->dwDCISize = sizeof(DRVCONFIGINFO16);
2223 if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCISectionName)) != NULL)
2225 dci16->lpszDCISectionName = MapLS( str1 );
2227 return WINMM_MAP_NOMEM;
2229 if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCIAliasName)) != NULL)
2231 dci16->lpszDCIAliasName = MapLS( str1 );
2233 return WINMM_MAP_NOMEM;
2236 return WINMM_MAP_NOMEM;
2238 *lParam2 = MapLS( dci16 );
2239 ret = WINMM_MAP_OKMEM;
2245 if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) {
2246 FIXME("Unknown message 0x%04x\n", wMsg);
2253 /**************************************************************************
2254 * DRIVER_UnMapMsg32To16 [internal]
2256 * UnMap a 32 bit driver message to a 16 bit driver message.
2258 WINMM_MapType DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
2260 WINMM_MapType ret = WINMM_MAP_MSGERROR;
2267 case DRV_QUERYCONFIGURE:
2269 case DRV_EXITSESSION:
2270 case DRV_EXITAPPLICATION:
2274 /* lParam1 and lParam2 are not used */
2278 /* lParam1 is a handle to a window (or not used), lParam2 is a pointer to DRVCONFIGINFO, lParam2 */
2280 LPDRVCONFIGINFO16 dci16 = MapSL(lParam2);
2281 HeapFree( GetProcessHeap(), 0, MapSL(dci16->lpszDCISectionName) );
2282 HeapFree( GetProcessHeap(), 0, MapSL(dci16->lpszDCIAliasName) );
2284 UnMapLS( dci16->lpszDCISectionName );
2285 UnMapLS( dci16->lpszDCIAliasName );
2286 HeapFree( GetProcessHeap(), 0, dci16 );
2291 if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) {
2292 FIXME("Unknown message 0x%04x\n", wMsg);
2299 /**************************************************************************
2300 * DrvOpen [MMSYSTEM.1100]
2302 HDRVR16 WINAPI DrvOpen16(LPSTR lpDriverName, LPSTR lpSectionName, LPARAM lParam)
2304 return OpenDriver16(lpDriverName, lpSectionName, lParam);
2307 /**************************************************************************
2308 * DrvClose [MMSYSTEM.1101]
2310 LRESULT WINAPI DrvClose16(HDRVR16 hDrv, LPARAM lParam1, LPARAM lParam2)
2312 return CloseDriver16(hDrv, lParam1, lParam2);
2315 /**************************************************************************
2316 * DrvSendMessage [MMSYSTEM.1102]
2318 LRESULT WINAPI DrvSendMessage16(HDRVR16 hDrv, WORD msg, LPARAM lParam1,
2321 return SendDriverMessage16(hDrv, msg, lParam1, lParam2);
2324 /**************************************************************************
2325 * DrvGetModuleHandle [MMSYSTEM.1103]
2327 HANDLE16 WINAPI DrvGetModuleHandle16(HDRVR16 hDrv)
2329 return GetDriverModuleHandle16(hDrv);
2332 /**************************************************************************
2333 * DrvDefDriverProc [MMSYSTEM.1104]
2335 LRESULT WINAPI DrvDefDriverProc16(DWORD dwDriverID, HDRVR16 hDrv, WORD wMsg,
2336 DWORD dwParam1, DWORD dwParam2)
2338 return DefDriverProc16(dwDriverID, hDrv, wMsg, dwParam1, dwParam2);
2341 /**************************************************************************
2342 * DriverProc [MMSYSTEM.6]
2344 LRESULT WINAPI DriverProc16(DWORD dwDevID, HDRVR16 hDrv, WORD wMsg,
2345 DWORD dwParam1, DWORD dwParam2)
2347 TRACE("dwDevID=%08lx hDrv=%04x wMsg=%04x dwParam1=%08lx dwParam2=%08lx\n",
2348 dwDevID, hDrv, wMsg, dwParam1, dwParam2);
2350 return DrvDefDriverProc16(dwDevID, hDrv, wMsg, dwParam1, dwParam2);
2353 /* ###################################################
2355 * ###################################################
2358 /**************************************************************************
2359 * timeGetSystemTime [MMSYSTEM.601]
2361 MMRESULT16 WINAPI timeGetSystemTime16(LPMMTIME16 lpTime, UINT16 wSize)
2363 TRACE("(%p, %u);\n", lpTime, wSize);
2365 if (wSize >= sizeof(*lpTime)) {
2366 lpTime->wType = TIME_MS;
2368 lpTime->u.ms = WINMM_IData->mmSysTimeMS;
2370 TRACE("=> %lu\n", lpTime->u.ms);
2376 /**************************************************************************
2377 * timeSetEvent [MMSYSTEM.602]
2379 MMRESULT16 WINAPI timeSetEvent16(UINT16 wDelay, UINT16 wResol, LPTIMECALLBACK16 lpFunc,
2380 DWORD dwUser, UINT16 wFlags)
2382 if (wFlags & WINE_TIMER_IS32)
2383 WARN("Unknown windows flag... wine internally used.. ooch\n");
2385 return timeSetEventInternal(wDelay, wResol, (FARPROC16)lpFunc,
2386 dwUser, wFlags & ~WINE_TIMER_IS32);
2389 /**************************************************************************
2390 * timeKillEvent [MMSYSTEM.603]
2392 MMRESULT16 WINAPI timeKillEvent16(UINT16 wID)
2394 return timeKillEvent(wID);
2397 /**************************************************************************
2398 * timeGetDevCaps [MMSYSTEM.604]
2400 MMRESULT16 WINAPI timeGetDevCaps16(LPTIMECAPS16 lpCaps, UINT16 wSize)
2405 TRACE("(%p, %u) !\n", lpCaps, wSize);
2407 ret = timeGetDevCaps(&caps, sizeof(caps));
2408 lpCaps->wPeriodMin = caps.wPeriodMin;
2409 lpCaps->wPeriodMax = caps.wPeriodMax;
2413 /**************************************************************************
2414 * timeBeginPeriod [MMSYSTEM.605]
2416 MMRESULT16 WINAPI timeBeginPeriod16(UINT16 wPeriod)
2418 TRACE("(%u) !\n", wPeriod);
2420 return timeBeginPeriod(wPeriod);
2423 /**************************************************************************
2424 * timeEndPeriod [MMSYSTEM.606]
2426 MMRESULT16 WINAPI timeEndPeriod16(UINT16 wPeriod)
2428 TRACE("(%u) !\n", wPeriod);
2430 return timeEndPeriod(wPeriod);
2433 /**************************************************************************
2434 * mciSendString [MMSYSTEM.702]
2436 DWORD WINAPI mciSendString16(LPCSTR lpstrCommand, LPSTR lpstrRet,
2437 UINT16 uRetLen, HWND16 hwndCallback)
2439 return mciSendStringA(lpstrCommand, lpstrRet, uRetLen, HWND_32(hwndCallback));
2442 /**************************************************************************
2443 * mciLoadCommandResource [MMSYSTEM.705]
2445 UINT16 WINAPI mciLoadCommandResource16(HANDLE16 hInst, LPCSTR resname, UINT16 type)
2447 LPCWSTR ptr = HEAP_strdupAtoW(GetProcessHeap(), 0, resname);
2448 UINT ret = mciLoadCommandResource(hInst, ptr, type);
2449 HeapFree(GetProcessHeap(), 0, (LPWSTR)ptr);
2453 /**************************************************************************
2454 * mciFreeCommandResource [MMSYSTEM.713]
2456 BOOL16 WINAPI mciFreeCommandResource16(UINT16 uTable)
2458 TRACE("(%04x)!\n", uTable);
2460 return mciFreeCommandResource(uTable);
2463 /* ###################################################
2465 * ###################################################
2468 /****************************************************************
2469 * MMIO_Map32To16 [INTERNAL]
2471 static LRESULT MMIO_Map32To16(DWORD wMsg, LPARAM* lp1, LPARAM* lp2)
2481 case MMIOM_WRITEFLUSH:
2482 *lp1 = MapLS( (void *)*lp1 );
2485 *lp1 = MapLS( (void *)*lp1 );
2486 *lp2 = MapLS( (void *)*lp2 );
2489 if (wMsg < MMIOM_USER)
2490 TRACE("Not a mappable message (%ld)\n", wMsg);
2492 return MMSYSERR_NOERROR;
2495 /****************************************************************
2496 * MMIO_UnMap32To16 [INTERNAL]
2498 static LRESULT MMIO_UnMap32To16(DWORD wMsg, LPARAM lParam1, LPARAM lParam2,
2499 LPARAM lp1, LPARAM lp2)
2509 case MMIOM_WRITEFLUSH:
2517 if (wMsg < MMIOM_USER)
2518 TRACE("Not a mappable message (%ld)\n", wMsg);
2520 return MMSYSERR_NOERROR;
2523 /******************************************************************
2528 static LRESULT MMIO_Callback16(SEGPTR cb16, LPMMIOINFO lpmmioinfo, UINT uMessage,
2529 LPARAM lParam1, LPARAM lParam2)
2532 MMIOINFO16 mmioInfo16;
2533 SEGPTR segmmioInfo16;
2534 LPARAM lp1 = lParam1, lp2 = lParam2;
2536 memset(&mmioInfo16, 0, sizeof(MMIOINFO16));
2537 mmioInfo16.lDiskOffset = lpmmioinfo->lDiskOffset;
2538 mmioInfo16.adwInfo[0] = lpmmioinfo->adwInfo[0];
2539 mmioInfo16.adwInfo[1] = lpmmioinfo->adwInfo[1];
2540 mmioInfo16.adwInfo[2] = lpmmioinfo->adwInfo[2];
2541 mmioInfo16.adwInfo[3] = lpmmioinfo->adwInfo[3];
2542 /* map (lParam1, lParam2) into (lp1, lp2) 32=>16 */
2543 if ((result = MMIO_Map32To16(uMessage, &lp1, &lp2)) != MMSYSERR_NOERROR)
2546 segmmioInfo16 = MapLS(&mmioInfo16);
2548 result = MMSYSTEM_CallTo16_long_lwll((LPMMIOPROC16)cb16, segmmioInfo16, uMessage, lp1, lp2);
2549 UnMapLS(segmmioInfo16);
2550 MMIO_UnMap32To16(uMessage, lParam1, lParam2, lp1, lp2);
2552 lpmmioinfo->lDiskOffset = mmioInfo16.lDiskOffset;
2553 lpmmioinfo->adwInfo[0] = mmioInfo16.adwInfo[0];
2554 lpmmioinfo->adwInfo[1] = mmioInfo16.adwInfo[1];
2555 lpmmioinfo->adwInfo[2] = mmioInfo16.adwInfo[2];
2556 lpmmioinfo->adwInfo[3] = mmioInfo16.adwInfo[3];
2561 /******************************************************************
2562 * MMIO_ResetSegmentedData
2565 static LRESULT MMIO_SetSegmentedBuffer(HMMIO hmmio, SEGPTR ptr)
2569 if ((wm = MMIO_Get(hmmio)) == NULL)
2570 return MMSYSERR_INVALHANDLE;
2571 wm->segBuffer16 = ptr;
2572 return MMSYSERR_NOERROR;
2575 /**************************************************************************
2576 * mmioOpen [MMSYSTEM.1210]
2578 HMMIO16 WINAPI mmioOpen16(LPSTR szFileName, MMIOINFO16* lpmmioinfo16,
2586 memset(&mmioinfo, 0, sizeof(mmioinfo));
2588 mmioinfo.dwFlags = lpmmioinfo16->dwFlags;
2589 mmioinfo.fccIOProc = lpmmioinfo16->fccIOProc;
2590 mmioinfo.pIOProc = (LPMMIOPROC)lpmmioinfo16->pIOProc;
2591 mmioinfo.cchBuffer = lpmmioinfo16->cchBuffer;
2592 mmioinfo.pchBuffer = MapSL((DWORD)lpmmioinfo16->pchBuffer);
2593 mmioinfo.adwInfo[0] = lpmmioinfo16->adwInfo[0];
2594 /* if we don't have a file name, it's likely a passed open file descriptor */
2596 mmioinfo.adwInfo[0] = DosFileHandleToWin32Handle(mmioinfo.adwInfo[0]);
2597 mmioinfo.adwInfo[1] = lpmmioinfo16->adwInfo[1];
2598 mmioinfo.adwInfo[2] = lpmmioinfo16->adwInfo[2];
2599 mmioinfo.adwInfo[3] = lpmmioinfo16->adwInfo[3];
2601 ret = MMIO_Open(szFileName, &mmioinfo, dwOpenFlags, MMIO_PROC_16);
2602 MMIO_SetSegmentedBuffer(mmioinfo.hmmio, (SEGPTR)lpmmioinfo16->pchBuffer);
2604 lpmmioinfo16->wErrorRet = mmioinfo.wErrorRet;
2605 lpmmioinfo16->hmmio = HMMIO_16(mmioinfo.hmmio);
2607 ret = MMIO_Open(szFileName, NULL, dwOpenFlags, MMIO_PROC_32A);
2609 return HMMIO_16(ret);
2612 /**************************************************************************
2613 * mmioClose [MMSYSTEM.1211]
2615 MMRESULT16 WINAPI mmioClose16(HMMIO16 hmmio, UINT16 uFlags)
2617 return mmioClose(HMMIO_32(hmmio), uFlags);
2620 /**************************************************************************
2621 * mmioRead [MMSYSTEM.1212]
2623 LONG WINAPI mmioRead16(HMMIO16 hmmio, HPSTR pch, LONG cch)
2625 return mmioRead(HMMIO_32(hmmio), pch, cch);
2628 /**************************************************************************
2629 * mmioWrite [MMSYSTEM.1213]
2631 LONG WINAPI mmioWrite16(HMMIO16 hmmio, HPCSTR pch, LONG cch)
2633 return mmioWrite(HMMIO_32(hmmio),pch,cch);
2636 /**************************************************************************
2637 * mmioSeek [MMSYSTEM.1214]
2639 LONG WINAPI mmioSeek16(HMMIO16 hmmio, LONG lOffset, INT16 iOrigin)
2641 return mmioSeek(HMMIO_32(hmmio), lOffset, iOrigin);
2644 /**************************************************************************
2645 * mmioGetInfo [MMSYSTEM.1215]
2647 MMRESULT16 WINAPI mmioGetInfo16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags)
2653 TRACE("(0x%04x,%p,0x%08x)\n", hmmio, lpmmioinfo, uFlags);
2655 if ((wm = MMIO_Get(hmmio)) == NULL)
2656 return MMSYSERR_INVALHANDLE;
2658 ret = mmioGetInfo(HMMIO_32(hmmio), &mmioinfo, uFlags);
2659 if (ret != MMSYSERR_NOERROR) return ret;
2661 lpmmioinfo->dwFlags = mmioinfo.dwFlags;
2662 lpmmioinfo->fccIOProc = mmioinfo.fccIOProc;
2663 lpmmioinfo->pIOProc = (wm->ioProc->type == MMIO_PROC_16) ?
2664 (LPMMIOPROC16)wm->ioProc->pIOProc : NULL;
2665 lpmmioinfo->wErrorRet = mmioinfo.wErrorRet;
2666 lpmmioinfo->hTask = mmioinfo.hTask;
2667 lpmmioinfo->cchBuffer = mmioinfo.cchBuffer;
2668 lpmmioinfo->pchBuffer = (void*)wm->segBuffer16;
2669 lpmmioinfo->pchNext = (void*)(wm->segBuffer16 + (mmioinfo.pchNext - mmioinfo.pchBuffer));
2670 lpmmioinfo->pchEndRead = (void*)(wm->segBuffer16 + (mmioinfo.pchEndRead - mmioinfo.pchBuffer));
2671 lpmmioinfo->pchEndWrite = (void*)(wm->segBuffer16 + (mmioinfo.pchEndWrite - mmioinfo.pchBuffer));
2672 lpmmioinfo->lBufOffset = mmioinfo.lBufOffset;
2673 lpmmioinfo->lDiskOffset = mmioinfo.lDiskOffset;
2674 lpmmioinfo->adwInfo[0] = mmioinfo.adwInfo[0];
2675 lpmmioinfo->adwInfo[1] = mmioinfo.adwInfo[1];
2676 lpmmioinfo->adwInfo[2] = mmioinfo.adwInfo[2];
2677 lpmmioinfo->adwInfo[3] = mmioinfo.adwInfo[3];
2678 lpmmioinfo->dwReserved1 = 0;
2679 lpmmioinfo->dwReserved2 = 0;
2680 lpmmioinfo->hmmio = HMMIO_16(mmioinfo.hmmio);
2682 return MMSYSERR_NOERROR;
2685 /**************************************************************************
2686 * mmioSetInfo [MMSYSTEM.1216]
2688 MMRESULT16 WINAPI mmioSetInfo16(HMMIO16 hmmio, const MMIOINFO16* lpmmioinfo, UINT16 uFlags)
2693 TRACE("(0x%04x,%p,0x%08x)\n",hmmio,lpmmioinfo,uFlags);
2695 ret = mmioGetInfo(HMMIO_32(hmmio), &mmioinfo, 0);
2696 if (ret != MMSYSERR_NOERROR) return ret;
2698 /* check if seg and lin buffers are the same */
2699 if (mmioinfo.cchBuffer != lpmmioinfo->cchBuffer ||
2700 mmioinfo.pchBuffer != MapSL((DWORD)lpmmioinfo->pchBuffer))
2701 return MMSYSERR_INVALPARAM;
2703 /* check pointers coherence */
2704 if (lpmmioinfo->pchNext < lpmmioinfo->pchBuffer ||
2705 lpmmioinfo->pchNext > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer ||
2706 lpmmioinfo->pchEndRead < lpmmioinfo->pchBuffer ||
2707 lpmmioinfo->pchEndRead > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer ||
2708 lpmmioinfo->pchEndWrite < lpmmioinfo->pchBuffer ||
2709 lpmmioinfo->pchEndWrite > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer)
2710 return MMSYSERR_INVALPARAM;
2712 mmioinfo.pchNext = mmioinfo.pchBuffer + (lpmmioinfo->pchNext - lpmmioinfo->pchBuffer);
2713 mmioinfo.pchEndRead = mmioinfo.pchBuffer + (lpmmioinfo->pchEndRead - lpmmioinfo->pchBuffer);
2714 mmioinfo.pchEndWrite = mmioinfo.pchBuffer + (lpmmioinfo->pchEndWrite - lpmmioinfo->pchBuffer);
2716 return mmioSetInfo(HMMIO_32(hmmio), &mmioinfo, uFlags);
2719 /**************************************************************************
2720 * mmioSetBuffer [MMSYSTEM.1217]
2722 MMRESULT16 WINAPI mmioSetBuffer16(HMMIO16 hmmio, LPSTR pchBuffer,
2723 LONG cchBuffer, UINT16 uFlags)
2725 MMRESULT ret = mmioSetBuffer(HMMIO_32(hmmio), MapSL((DWORD)pchBuffer),
2728 if (ret == MMSYSERR_NOERROR)
2729 MMIO_SetSegmentedBuffer(HMMIO_32(hmmio), (DWORD)pchBuffer);
2733 /**************************************************************************
2734 * mmioFlush [MMSYSTEM.1218]
2736 MMRESULT16 WINAPI mmioFlush16(HMMIO16 hmmio, UINT16 uFlags)
2738 return mmioFlush(HMMIO_32(hmmio), uFlags);
2741 /***********************************************************************
2742 * mmioAdvance [MMSYSTEM.1219]
2744 MMRESULT16 WINAPI mmioAdvance16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags)
2749 /* WARNING: this heavily relies on mmioAdvance implementation (for choosing which
2754 mmioinfo.pchBuffer = MapSL((DWORD)lpmmioinfo->pchBuffer);
2755 mmioinfo.pchNext = MapSL((DWORD)lpmmioinfo->pchNext);
2756 mmioinfo.dwFlags = lpmmioinfo->dwFlags;
2757 mmioinfo.lBufOffset = lpmmioinfo->lBufOffset;
2758 ret = mmioAdvance(HMMIO_32(hmmio), &mmioinfo, uFlags);
2761 ret = mmioAdvance(HMMIO_32(hmmio), NULL, uFlags);
2763 if (ret != MMSYSERR_NOERROR) return ret;
2767 lpmmioinfo->dwFlags = mmioinfo.dwFlags;
2768 lpmmioinfo->pchNext = (void*)(lpmmioinfo->pchBuffer + (mmioinfo.pchNext - mmioinfo.pchBuffer));
2769 lpmmioinfo->pchEndRead = (void*)(lpmmioinfo->pchBuffer + (mmioinfo.pchEndRead - mmioinfo.pchBuffer));
2770 lpmmioinfo->pchEndWrite = (void*)(lpmmioinfo->pchBuffer + (mmioinfo.pchEndWrite - mmioinfo.pchBuffer));
2771 lpmmioinfo->lBufOffset = mmioinfo.lBufOffset;
2772 lpmmioinfo->lDiskOffset = mmioinfo.lDiskOffset;
2775 return MMSYSERR_NOERROR;
2778 /**************************************************************************
2779 * mmioStringToFOURCC [MMSYSTEM.1220]
2781 FOURCC WINAPI mmioStringToFOURCC16(LPCSTR sz, UINT16 uFlags)
2783 return mmioStringToFOURCCA(sz, uFlags);
2786 /**************************************************************************
2787 * mmioInstallIOProc [MMSYSTEM.1221]
2789 LPMMIOPROC16 WINAPI mmioInstallIOProc16(FOURCC fccIOProc, LPMMIOPROC16 pIOProc,
2792 return (LPMMIOPROC16)MMIO_InstallIOProc(fccIOProc, (LPMMIOPROC)pIOProc,
2793 dwFlags, MMIO_PROC_16);
2796 /**************************************************************************
2797 * mmioSendMessage [MMSYSTEM.1222]
2799 LRESULT WINAPI mmioSendMessage16(HMMIO16 hmmio, UINT16 uMessage,
2800 LPARAM lParam1, LPARAM lParam2)
2802 return MMIO_SendMessage(HMMIO_32(hmmio), uMessage,
2803 lParam1, lParam2, MMIO_PROC_16);
2806 /**************************************************************************
2807 * mmioDescend [MMSYSTEM.1223]
2809 MMRESULT16 WINAPI mmioDescend16(HMMIO16 hmmio, LPMMCKINFO lpck,
2810 const MMCKINFO* lpckParent, UINT16 uFlags)
2812 return mmioDescend(HMMIO_32(hmmio), lpck, lpckParent, uFlags);
2815 /**************************************************************************
2816 * mmioAscend [MMSYSTEM.1224]
2818 MMRESULT16 WINAPI mmioAscend16(HMMIO16 hmmio, MMCKINFO* lpck, UINT16 uFlags)
2820 return mmioAscend(HMMIO_32(hmmio),lpck,uFlags);
2823 /**************************************************************************
2824 * mmioCreateChunk [MMSYSTEM.1225]
2826 MMRESULT16 WINAPI mmioCreateChunk16(HMMIO16 hmmio, MMCKINFO* lpck, UINT16 uFlags)
2828 return mmioCreateChunk(HMMIO_32(hmmio), lpck, uFlags);
2831 /**************************************************************************
2832 * mmioRename [MMSYSTEM.1226]
2834 MMRESULT16 WINAPI mmioRename16(LPCSTR szFileName, LPCSTR szNewFileName,
2835 MMIOINFO16* lpmmioinfo, DWORD dwRenameFlags)
2841 if (lpmmioinfo != NULL && lpmmioinfo->pIOProc != NULL &&
2842 lpmmioinfo->fccIOProc == 0) {
2843 FIXME("Can't handle this case yet\n");
2844 return MMSYSERR_ERROR;
2847 /* this is a bit hacky, but it'll work if we get a fourCC code or nothing.
2848 * but a non installed ioproc without a fourcc won't do
2850 if (lpmmioinfo && lpmmioinfo->fccIOProc && lpmmioinfo->pIOProc) {
2851 MMIO_InstallIOProc(lpmmioinfo->fccIOProc, (LPMMIOPROC)lpmmioinfo->pIOProc,
2852 MMIO_INSTALLPROC, MMIO_PROC_16);
2855 memset(&mmioinfo, 0, sizeof(mmioinfo));
2856 mmioinfo.fccIOProc = lpmmioinfo->fccIOProc;
2857 ret = mmioRenameA(szFileName, szNewFileName, &mmioinfo, dwRenameFlags);
2859 MMIO_InstallIOProc(lpmmioinfo->fccIOProc, NULL,
2860 MMIO_REMOVEPROC, MMIO_PROC_16);