wine/dlls/winmm/mmsystem.c

2120 lines
61 KiB
C

/* -*- tab-width: 8; c-basic-offset: 4 -*- */
/*
* MMSYTEM functions
*
* Copyright 1993 Martin Ayotte
* 1998-2002 Eric Pouech
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Eric POUECH :
* 99/4 added mmTask and mmThread functions support
*/
/* FIXME: I think there are some segmented vs. linear pointer weirdnesses
* and long term pointers to 16 bit space in here
*/
#include <string.h>
#include "mmsystem.h"
#include "winbase.h"
#include "wine/mmsystem16.h"
#include "wine/winuser16.h"
#include "winemm.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(mmsys);
/**************************************************************************
* DllEntryPoint (MMSYSTEM.2046)
*
* MMSYSTEM DLL entry point
*
*/
BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
WORD wHeapSize, DWORD dwReserved1, WORD wReserved2)
{
HANDLE hndl;
LPWINE_MM_IDATA iData;
TRACE("0x%x 0x%lx\n", hinstDLL, fdwReason);
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
/* need to load WinMM in order to:
* - initiate correctly shared variables (MULTIMEDIA_Init())
* - create correctly the per process WINE_MM_IDATA chunk
*/
hndl = LoadLibraryA("WINMM.DLL");
if (!hndl) {
ERR("Could not load sibling WinMM.dll\n");
return FALSE;
}
iData = MULTIMEDIA_GetIData();
iData->hWinMM16Instance = hinstDLL;
iData->h16Module32 = hndl;
break;
case DLL_PROCESS_DETACH:
iData = MULTIMEDIA_GetIData();
FreeLibrary(iData->h16Module32);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
/**************************************************************************
* MMSYSTEM_WEP [MMSYSTEM.1]
*/
int WINAPI MMSYSTEM_WEP(HINSTANCE16 hInstance, WORD wDataSeg,
WORD cbHeapSize, LPSTR lpCmdLine)
{
FIXME("STUB: Unloading MMSystem DLL ... hInst=%04X \n", hInstance);
return TRUE;
}
/**************************************************************************
* PlaySound [MMSYSTEM.3]
*/
BOOL16 WINAPI PlaySound16(LPCSTR pszSound, HMODULE16 hmod, DWORD fdwSound)
{
BOOL16 retv;
DWORD lc;
ReleaseThunkLock(&lc);
retv = PlaySoundA(pszSound, hmod, fdwSound);
RestoreThunkLock(lc);
return retv;
}
/**************************************************************************
* sndPlaySound [MMSYSTEM.2]
*/
BOOL16 WINAPI sndPlaySound16(LPCSTR lpszSoundName, UINT16 uFlags)
{
BOOL16 retv;
DWORD lc;
ReleaseThunkLock(&lc);
retv = sndPlaySoundA(lpszSoundName, uFlags);
RestoreThunkLock(lc);
return retv;
}
/**************************************************************************
* mmsystemGetVersion [MMSYSTEM.5]
*
*/
UINT16 WINAPI mmsystemGetVersion16(void)
{
return mmsystemGetVersion();
}
/**************************************************************************
* DriverCallback [MMSYSTEM.31]
*/
BOOL16 WINAPI DriverCallback16(DWORD dwCallBack, UINT16 uFlags, HDRVR16 hDev,
WORD wMsg, DWORD dwUser, DWORD dwParam1,
DWORD dwParam2)
{
return DriverCallback(dwCallBack, uFlags, HDRVR_32(hDev), wMsg, dwUser, dwParam1, dwParam2);
}
/**************************************************************************
* Mixer devices. New to Win95
*/
/**************************************************************************
* mixerGetNumDevs [MMSYSTEM.800]
*/
UINT16 WINAPI mixerGetNumDevs16(void)
{
return MMDRV_GetNum(MMDRV_MIXER);
}
/**************************************************************************
* mixerGetDevCaps [MMSYSTEM.801]
*/
UINT16 WINAPI mixerGetDevCaps16(UINT16 devid, LPMIXERCAPS16 mixcaps,
UINT16 size)
{
MIXERCAPSA micA;
UINT ret = mixerGetDevCapsA(devid, &micA, sizeof(micA));
if (ret == MMSYSERR_NOERROR) {
mixcaps->wMid = micA.wMid;
mixcaps->wPid = micA.wPid;
mixcaps->vDriverVersion = micA.vDriverVersion;
strcpy(mixcaps->szPname, micA.szPname);
mixcaps->fdwSupport = micA.fdwSupport;
mixcaps->cDestinations = micA.cDestinations;
}
return ret;
}
/**************************************************************************
* mixerOpen [MMSYSTEM.802]
*/
UINT16 WINAPI mixerOpen16(LPHMIXER16 lphmix, UINT16 uDeviceID, DWORD dwCallback,
DWORD dwInstance, DWORD fdwOpen)
{
HMIXER hmix;
UINT ret;
ret = MMSYSTEM_mixerOpen(&hmix, uDeviceID,
dwCallback, dwInstance, fdwOpen, FALSE);
if (lphmix) *lphmix = HMIXER_16(hmix);
return ret;
}
/**************************************************************************
* mixerClose [MMSYSTEM.803]
*/
UINT16 WINAPI mixerClose16(HMIXER16 hMix)
{
return mixerClose(HMIXER_32(hMix));
}
/**************************************************************************
* mixerGetID (MMSYSTEM.806)
*/
UINT16 WINAPI mixerGetID16(HMIXEROBJ16 hmix, LPUINT16 lpid, DWORD fdwID)
{
UINT xid;
UINT ret = mixerGetID(HMIXEROBJ_32(hmix), &xid, fdwID);
if (lpid)
*lpid = xid;
return ret;
}
/**************************************************************************
* mixerGetControlDetails [MMSYSTEM.808]
*/
UINT16 WINAPI mixerGetControlDetails16(HMIXEROBJ16 hmix,
LPMIXERCONTROLDETAILS16 lpmcd,
DWORD fdwDetails)
{
DWORD ret = MMSYSERR_NOTENABLED;
SEGPTR sppaDetails;
TRACE("(%04x, %p, %08lx)\n", hmix, lpmcd, fdwDetails);
if (lpmcd == NULL || lpmcd->cbStruct != sizeof(*lpmcd))
return MMSYSERR_INVALPARAM;
sppaDetails = (SEGPTR)lpmcd->paDetails;
lpmcd->paDetails = MapSL(sppaDetails);
ret = mixerGetControlDetailsA(HMIXEROBJ_32(hmix),
(LPMIXERCONTROLDETAILS)lpmcd, fdwDetails);
lpmcd->paDetails = (LPVOID)sppaDetails;
return ret;
}
/**************************************************************************
* mixerGetLineControls [MMSYSTEM.807]
*/
UINT16 WINAPI mixerGetLineControls16(HMIXEROBJ16 hmix,
LPMIXERLINECONTROLS16 lpmlc16,
DWORD fdwControls)
{
MIXERLINECONTROLSA mlcA;
DWORD ret;
int i;
LPMIXERCONTROL16 lpmc16;
TRACE("(%04x, %p, %08lx)\n", hmix, lpmlc16, fdwControls);
if (lpmlc16 == NULL || lpmlc16->cbStruct != sizeof(*lpmlc16) ||
lpmlc16->cbmxctrl != sizeof(MIXERCONTROL16))
return MMSYSERR_INVALPARAM;
mlcA.cbStruct = sizeof(mlcA);
mlcA.dwLineID = lpmlc16->dwLineID;
mlcA.u.dwControlID = lpmlc16->u.dwControlID;
mlcA.u.dwControlType = lpmlc16->u.dwControlType;
mlcA.cControls = lpmlc16->cControls;
mlcA.cbmxctrl = sizeof(MIXERCONTROLA);
mlcA.pamxctrl = HeapAlloc(GetProcessHeap(), 0,
mlcA.cControls * mlcA.cbmxctrl);
ret = mixerGetLineControlsA(HMIXEROBJ_32(hmix), &mlcA, fdwControls);
if (ret == MMSYSERR_NOERROR) {
lpmlc16->dwLineID = mlcA.dwLineID;
lpmlc16->u.dwControlID = mlcA.u.dwControlID;
lpmlc16->u.dwControlType = mlcA.u.dwControlType;
lpmlc16->cControls = mlcA.cControls;
lpmc16 = MapSL(lpmlc16->pamxctrl);
for (i = 0; i < mlcA.cControls; i++) {
lpmc16[i].cbStruct = sizeof(MIXERCONTROL16);
lpmc16[i].dwControlID = mlcA.pamxctrl[i].dwControlID;
lpmc16[i].dwControlType = mlcA.pamxctrl[i].dwControlType;
lpmc16[i].fdwControl = mlcA.pamxctrl[i].fdwControl;
lpmc16[i].cMultipleItems = mlcA.pamxctrl[i].cMultipleItems;
strcpy(lpmc16[i].szShortName, mlcA.pamxctrl[i].szShortName);
strcpy(lpmc16[i].szName, mlcA.pamxctrl[i].szName);
/* sizeof(lpmc16[i].Bounds) == sizeof(mlcA.pamxctrl[i].Bounds) */
memcpy(&lpmc16[i].Bounds, &mlcA.pamxctrl[i].Bounds,
sizeof(mlcA.pamxctrl[i].Bounds));
/* sizeof(lpmc16[i].Metrics) == sizeof(mlcA.pamxctrl[i].Metrics) */
memcpy(&lpmc16[i].Metrics, &mlcA.pamxctrl[i].Metrics,
sizeof(mlcA.pamxctrl[i].Metrics));
}
}
HeapFree(GetProcessHeap(), 0, mlcA.pamxctrl);
return ret;
}
/**************************************************************************
* mixerGetLineInfo [MMSYSTEM.805]
*/
UINT16 WINAPI mixerGetLineInfo16(HMIXEROBJ16 hmix, LPMIXERLINE16 lpmli16,
DWORD fdwInfo)
{
MIXERLINEA mliA;
UINT ret;
TRACE("(%04x, %p, %08lx)\n", hmix, lpmli16, fdwInfo);
if (lpmli16 == NULL || lpmli16->cbStruct != sizeof(*lpmli16))
return MMSYSERR_INVALPARAM;
mliA.cbStruct = sizeof(mliA);
switch (fdwInfo & MIXER_GETLINEINFOF_QUERYMASK) {
case MIXER_GETLINEINFOF_COMPONENTTYPE:
mliA.dwComponentType = lpmli16->dwComponentType;
break;
case MIXER_GETLINEINFOF_DESTINATION:
mliA.dwDestination = lpmli16->dwDestination;
break;
case MIXER_GETLINEINFOF_LINEID:
mliA.dwLineID = lpmli16->dwLineID;
break;
case MIXER_GETLINEINFOF_SOURCE:
mliA.dwDestination = lpmli16->dwDestination;
mliA.dwSource = lpmli16->dwSource;
break;
case MIXER_GETLINEINFOF_TARGETTYPE:
mliA.Target.dwType = lpmli16->Target.dwType;
mliA.Target.wMid = lpmli16->Target.wMid;
mliA.Target.wPid = lpmli16->Target.wPid;
mliA.Target.vDriverVersion = lpmli16->Target.vDriverVersion;
strcpy(mliA.Target.szPname, lpmli16->Target.szPname);
break;
default:
FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo);
}
ret = mixerGetLineInfoA(HMIXEROBJ_32(hmix), &mliA, fdwInfo);
lpmli16->dwDestination = mliA.dwDestination;
lpmli16->dwSource = mliA.dwSource;
lpmli16->dwLineID = mliA.dwLineID;
lpmli16->fdwLine = mliA.fdwLine;
lpmli16->dwUser = mliA.dwUser;
lpmli16->dwComponentType = mliA.dwComponentType;
lpmli16->cChannels = mliA.cChannels;
lpmli16->cConnections = mliA.cConnections;
lpmli16->cControls = mliA.cControls;
strcpy(lpmli16->szShortName, mliA.szShortName);
strcpy(lpmli16->szName, mliA.szName);
lpmli16->Target.dwType = mliA.Target.dwType;
lpmli16->Target.dwDeviceID = mliA.Target.dwDeviceID;
lpmli16->Target.wMid = mliA.Target.wMid;
lpmli16->Target.wPid = mliA.Target.wPid;
lpmli16->Target.vDriverVersion = mliA.Target.vDriverVersion;
strcpy(lpmli16->Target.szPname, mliA.Target.szPname);
return ret;
}
/**************************************************************************
* mixerSetControlDetails [MMSYSTEM.809]
*/
UINT16 WINAPI mixerSetControlDetails16(HMIXEROBJ16 hmix,
LPMIXERCONTROLDETAILS16 lpmcd,
DWORD fdwDetails)
{
TRACE("(%04x, %p, %08lx)\n", hmix, lpmcd, fdwDetails);
return MMSYSERR_NOTENABLED;
}
/**************************************************************************
* mixerMessage [MMSYSTEM.804]
*/
DWORD WINAPI mixerMessage16(HMIXER16 hmix, UINT16 uMsg, DWORD dwParam1,
DWORD dwParam2)
{
return mixerMessage(HMIXER_32(hmix), uMsg, dwParam1, dwParam2);
}
/**************************************************************************
* auxGetNumDevs [MMSYSTEM.350]
*/
UINT16 WINAPI auxGetNumDevs16(void)
{
return MMDRV_GetNum(MMDRV_AUX);
}
/**************************************************************************
* auxGetDevCaps [MMSYSTEM.351]
*/
UINT16 WINAPI auxGetDevCaps16(UINT16 uDeviceID, LPAUXCAPS16 lpCaps, UINT16 uSize)
{
LPWINE_MLD wmld;
TRACE("(%04X, %p, %d) !\n", uDeviceID, lpCaps, uSize);
if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, AUXDM_GETDEVCAPS, (DWORD)lpCaps, uSize, TRUE);
}
/**************************************************************************
* auxGetVolume [MMSYSTEM.352]
*/
UINT16 WINAPI auxGetVolume16(UINT16 uDeviceID, LPDWORD lpdwVolume)
{
LPWINE_MLD wmld;
TRACE("(%04X, %p) !\n", uDeviceID, lpdwVolume);
if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, AUXDM_GETVOLUME, (DWORD)lpdwVolume, 0L, TRUE);
}
/**************************************************************************
* auxSetVolume [MMSYSTEM.353]
*/
UINT16 WINAPI auxSetVolume16(UINT16 uDeviceID, DWORD dwVolume)
{
LPWINE_MLD wmld;
TRACE("(%04X, %lu) !\n", uDeviceID, dwVolume);
if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, AUXDM_SETVOLUME, dwVolume, 0L, TRUE);
}
/**************************************************************************
* auxOutMessage [MMSYSTEM.354]
*/
DWORD WINAPI auxOutMessage16(UINT16 uDeviceID, UINT16 uMessage, DWORD dw1, DWORD dw2)
{
LPWINE_MLD wmld;
TRACE("(%04X, %04X, %08lX, %08lX)\n", uDeviceID, uMessage, dw1, dw2);
switch (uMessage) {
case AUXDM_GETNUMDEVS:
case AUXDM_SETVOLUME:
/* no argument conversion needed */
break;
case AUXDM_GETVOLUME:
return auxGetVolume16(uDeviceID, MapSL(dw1));
case AUXDM_GETDEVCAPS:
return auxGetDevCaps16(uDeviceID, MapSL(dw1), dw2);
default:
TRACE("(%04x, %04x, %08lx, %08lx): unhandled message\n",
uDeviceID, uMessage, dw1, dw2);
break;
}
if ((wmld = MMDRV_Get(uDeviceID, MMDRV_AUX, TRUE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, uMessage, dw1, dw2, TRUE);
}
/**************************************************************************
* mciGetErrorString [MMSYSTEM.706]
*/
BOOL16 WINAPI mciGetErrorString16(DWORD wError, LPSTR lpstrBuffer, UINT16 uLength)
{
return mciGetErrorStringA(wError, lpstrBuffer, uLength);
}
/**************************************************************************
* mciDriverNotify [MMSYSTEM.711]
*/
BOOL16 WINAPI mciDriverNotify16(HWND16 hWndCallBack, UINT16 wDevID, UINT16 wStatus)
{
TRACE("(%04X, %04x, %04X)\n", hWndCallBack, wDevID, wStatus);
return PostMessageA(HWND_32(hWndCallBack), MM_MCINOTIFY, wStatus, wDevID);
}
/**************************************************************************
* mciGetDriverData [MMSYSTEM.708]
*/
DWORD WINAPI mciGetDriverData16(UINT16 uDeviceID)
{
return mciGetDriverData(uDeviceID);
}
/**************************************************************************
* mciSetDriverData [MMSYSTEM.707]
*/
BOOL16 WINAPI mciSetDriverData16(UINT16 uDeviceID, DWORD data)
{
return mciSetDriverData(uDeviceID, data);
}
/**************************************************************************
* mciSendCommand [MMSYSTEM.701]
*/
DWORD WINAPI mciSendCommand16(UINT16 wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2)
{
DWORD dwRet;
TRACE("(%04X, %s, %08lX, %08lX)\n",
wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2);
dwRet = MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2, FALSE);
dwRet = MCI_CleanUp(dwRet, wMsg, dwParam2, FALSE);
TRACE("=> %ld\n", dwRet);
return dwRet;
}
/**************************************************************************
* mciGetDeviceID [MMSYSTEM.703]
*/
UINT16 WINAPI mciGetDeviceID16(LPCSTR lpstrName)
{
TRACE("(\"%s\")\n", lpstrName);
return MCI_GetDriverFromString(lpstrName);
}
/**************************************************************************
* mciSetYieldProc [MMSYSTEM.714]
*/
BOOL16 WINAPI mciSetYieldProc16(UINT16 uDeviceID, YIELDPROC16 fpYieldProc, DWORD dwYieldData)
{
LPWINE_MCIDRIVER wmd;
TRACE("(%u, %p, %08lx)\n", uDeviceID, fpYieldProc, dwYieldData);
if (!(wmd = MCI_GetDriver(uDeviceID))) {
WARN("Bad uDeviceID\n");
return FALSE;
}
wmd->lpfnYieldProc = (YIELDPROC)fpYieldProc;
wmd->dwYieldData = dwYieldData;
wmd->bIs32 = FALSE;
return TRUE;
}
/**************************************************************************
* mciGetDeviceIDFromElementID [MMSYSTEM.715]
*/
UINT16 WINAPI mciGetDeviceIDFromElementID16(DWORD dwElementID, LPCSTR lpstrType)
{
FIXME("(%lu, %s) stub\n", dwElementID, lpstrType);
return 0;
}
/**************************************************************************
* mciGetYieldProc [MMSYSTEM.716]
*/
YIELDPROC16 WINAPI mciGetYieldProc16(UINT16 uDeviceID, DWORD* lpdwYieldData)
{
LPWINE_MCIDRIVER wmd;
TRACE("(%u, %p)\n", uDeviceID, lpdwYieldData);
if (!(wmd = MCI_GetDriver(uDeviceID))) {
WARN("Bad uDeviceID\n");
return NULL;
}
if (!wmd->lpfnYieldProc) {
WARN("No proc set\n");
return NULL;
}
if (wmd->bIs32) {
WARN("Proc is 32 bit\n");
return NULL;
}
return (YIELDPROC16)wmd->lpfnYieldProc;
}
/**************************************************************************
* mciGetCreatorTask [MMSYSTEM.717]
*/
HTASK16 WINAPI mciGetCreatorTask16(UINT16 uDeviceID)
{
LPWINE_MCIDRIVER wmd;
HTASK16 ret = 0;
if ((wmd = MCI_GetDriver(uDeviceID))) ret = wmd->hCreatorTask;
TRACE("(%u) => %04x\n", uDeviceID, ret);
return ret;
}
/**************************************************************************
* mciDriverYield [MMSYSTEM.710]
*/
UINT16 WINAPI mciDriverYield16(UINT16 uDeviceID)
{
LPWINE_MCIDRIVER wmd;
UINT16 ret = 0;
/* TRACE("(%04x)\n", uDeviceID); */
if (!(wmd = MCI_GetDriver(uDeviceID)) || !wmd->lpfnYieldProc || wmd->bIs32) {
UserYield16();
} else {
ret = wmd->lpfnYieldProc(uDeviceID, wmd->dwYieldData);
}
return ret;
}
/**************************************************************************
* midiOutGetNumDevs [MMSYSTEM.201]
*/
UINT16 WINAPI midiOutGetNumDevs16(void)
{
return MMDRV_GetNum(MMDRV_MIDIOUT);
}
/**************************************************************************
* midiOutGetDevCaps [MMSYSTEM.202]
*/
UINT16 WINAPI midiOutGetDevCaps16(UINT16 uDeviceID, LPMIDIOUTCAPS16 lpCaps,
UINT16 uSize)
{
MIDIOUTCAPSA capsA;
UINT dwRet;
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
dwRet = midiOutGetDevCapsA(uDeviceID, &capsA, sizeof(capsA));
if (dwRet == MMSYSERR_NOERROR) {
lpCaps->wMid = capsA.wMid;
lpCaps->wPid = capsA.wPid;
lpCaps->vDriverVersion = capsA.vDriverVersion;
strcpy(lpCaps->szPname, capsA.szPname);
lpCaps->wTechnology = capsA.wTechnology;
lpCaps->wVoices = capsA.wVoices;
lpCaps->wNotes = capsA.wNotes;
lpCaps->wChannelMask = capsA.wChannelMask;
lpCaps->dwSupport = capsA.dwSupport;
}
return dwRet;
}
/**************************************************************************
* midiOutGetErrorText [MMSYSTEM.203]
*/
UINT16 WINAPI midiOutGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
{
return midiOutGetErrorTextA(uError, lpText, uSize);
}
/**************************************************************************
* midiOutOpen [MMSYSTEM.204]
*/
UINT16 WINAPI midiOutOpen16(HMIDIOUT16* lphMidiOut, UINT16 uDeviceID,
DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
{
HMIDIOUT hmo;
UINT ret;
ret = MMSYSTEM_midiOutOpen(&hmo, uDeviceID, dwCallback, dwInstance,
dwFlags, FALSE);
if (lphMidiOut != NULL) *lphMidiOut = HMIDIOUT_16(hmo);
return ret;
}
/**************************************************************************
* midiOutClose [MMSYSTEM.205]
*/
UINT16 WINAPI midiOutClose16(HMIDIOUT16 hMidiOut)
{
return midiOutClose(HMIDIOUT_32(hMidiOut));
}
/**************************************************************************
* midiOutPrepareHeader [MMSYSTEM.206]
*/
UINT16 WINAPI midiOutPrepareHeader16(HMIDIOUT16 hMidiOut, /* [in] */
SEGPTR lpsegMidiOutHdr, /* [???] */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
TRACE("(%04X, %08lx, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, MODM_PREPARE, lpsegMidiOutHdr, uSize, FALSE);
}
/**************************************************************************
* midiOutUnprepareHeader [MMSYSTEM.207]
*/
UINT16 WINAPI midiOutUnprepareHeader16(HMIDIOUT16 hMidiOut, /* [in] */
SEGPTR lpsegMidiOutHdr, /* [???] */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
LPMIDIHDR16 lpMidiOutHdr = MapSL(lpsegMidiOutHdr);
TRACE("(%04X, %08lx, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
if (!(lpMidiOutHdr->dwFlags & MHDR_PREPARED)) {
return MMSYSERR_NOERROR;
}
if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, MODM_UNPREPARE, (DWORD)lpsegMidiOutHdr, uSize, FALSE);
}
/**************************************************************************
* midiOutShortMsg [MMSYSTEM.208]
*/
UINT16 WINAPI midiOutShortMsg16(HMIDIOUT16 hMidiOut, DWORD dwMsg)
{
return midiOutShortMsg(HMIDIOUT_32(hMidiOut), dwMsg);
}
/**************************************************************************
* midiOutLongMsg [MMSYSTEM.209]
*/
UINT16 WINAPI midiOutLongMsg16(HMIDIOUT16 hMidiOut, /* [in] */
LPMIDIHDR16 lpsegMidiOutHdr, /* [???] NOTE: SEGPTR */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
TRACE("(%04X, %p, %d)\n", hMidiOut, lpsegMidiOutHdr, uSize);
if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, MODM_LONGDATA, (DWORD)lpsegMidiOutHdr, uSize, FALSE);
}
/**************************************************************************
* midiOutReset [MMSYSTEM.210]
*/
UINT16 WINAPI midiOutReset16(HMIDIOUT16 hMidiOut)
{
return midiOutReset(HMIDIOUT_32(hMidiOut));
}
/**************************************************************************
* midiOutGetVolume [MMSYSTEM.211]
*/
UINT16 WINAPI midiOutGetVolume16(UINT16 uDeviceID, DWORD* lpdwVolume)
{
return midiOutGetVolume(uDeviceID, lpdwVolume);
}
/**************************************************************************
* midiOutSetVolume [MMSYSTEM.212]
*/
UINT16 WINAPI midiOutSetVolume16(UINT16 uDeviceID, DWORD dwVolume)
{
return midiOutSetVolume(uDeviceID, dwVolume);
}
/**************************************************************************
* midiOutCachePatches [MMSYSTEM.213]
*/
UINT16 WINAPI midiOutCachePatches16(HMIDIOUT16 hMidiOut, UINT16 uBank,
WORD* lpwPatchArray, UINT16 uFlags)
{
return midiOutCachePatches(HMIDIOUT_32(hMidiOut), uBank, lpwPatchArray,
uFlags);
}
/**************************************************************************
* midiOutCacheDrumPatches [MMSYSTEM.214]
*/
UINT16 WINAPI midiOutCacheDrumPatches16(HMIDIOUT16 hMidiOut, UINT16 uPatch,
WORD* lpwKeyArray, UINT16 uFlags)
{
return midiOutCacheDrumPatches(HMIDIOUT_32(hMidiOut), uPatch, lpwKeyArray, uFlags);
}
/**************************************************************************
* midiOutGetID [MMSYSTEM.215]
*/
UINT16 WINAPI midiOutGetID16(HMIDIOUT16 hMidiOut, UINT16* lpuDeviceID)
{
LPWINE_MLD wmld;
TRACE("(%04X, %p)\n", hMidiOut, lpuDeviceID);
if (lpuDeviceID == NULL) return MMSYSERR_INVALPARAM;
if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
*lpuDeviceID = wmld->uDeviceID;
return MMSYSERR_NOERROR;
}
/**************************************************************************
* midiOutMessage [MMSYSTEM.216]
*/
DWORD WINAPI midiOutMessage16(HMIDIOUT16 hMidiOut, UINT16 uMessage,
DWORD dwParam1, DWORD dwParam2)
{
LPWINE_MLD wmld;
TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiOut, uMessage, dwParam1, dwParam2);
if ((wmld = MMDRV_Get(HMIDIOUT_32(hMidiOut), MMDRV_MIDIOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
switch (uMessage) {
case MODM_OPEN:
case MODM_CLOSE:
FIXME("can't handle OPEN or CLOSE message!\n");
return MMSYSERR_NOTSUPPORTED;
case MODM_GETVOLUME:
return midiOutGetVolume16(hMidiOut, MapSL(dwParam1));
case MODM_LONGDATA:
return midiOutLongMsg16(hMidiOut, MapSL(dwParam1), dwParam2);
case MODM_PREPARE:
/* lpMidiOutHdr is still a segmented pointer for this function */
return midiOutPrepareHeader16(hMidiOut, dwParam1, dwParam2);
case MODM_UNPREPARE:
return midiOutUnprepareHeader16(hMidiOut, dwParam1, dwParam2);
}
return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
}
/**************************************************************************
* midiInGetNumDevs [MMSYSTEM.301]
*/
UINT16 WINAPI midiInGetNumDevs16(void)
{
return MMDRV_GetNum(MMDRV_MIDIIN);
}
/**************************************************************************
* midiInGetDevCaps [MMSYSTEM.302]
*/
UINT16 WINAPI midiInGetDevCaps16(UINT16 uDeviceID, LPMIDIINCAPS16 lpCaps,
UINT16 uSize)
{
MIDIINCAPSA micA;
UINT ret = midiInGetDevCapsA(uDeviceID, &micA, uSize);
if (ret == MMSYSERR_NOERROR) {
lpCaps->wMid = micA.wMid;
lpCaps->wPid = micA.wPid;
lpCaps->vDriverVersion = micA.vDriverVersion;
strcpy(lpCaps->szPname, micA.szPname);
lpCaps->dwSupport = micA.dwSupport;
}
return ret;
}
/**************************************************************************
* midiInGetErrorText [MMSYSTEM.303]
*/
UINT16 WINAPI midiInGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
{
return midiInGetErrorTextA(uError, lpText, uSize);
}
/**************************************************************************
* midiInOpen [MMSYSTEM.304]
*/
UINT16 WINAPI midiInOpen16(HMIDIIN16* lphMidiIn, UINT16 uDeviceID,
DWORD dwCallback, DWORD dwInstance, DWORD dwFlags)
{
HMIDIIN xhmid;
UINT ret;
ret = MMSYSTEM_midiInOpen(&xhmid, uDeviceID, dwCallback, dwInstance,
dwFlags, FALSE);
if (lphMidiIn) *lphMidiIn = HMIDIIN_16(xhmid);
return ret;
}
/**************************************************************************
* midiInClose [MMSYSTEM.305]
*/
UINT16 WINAPI midiInClose16(HMIDIIN16 hMidiIn)
{
return midiInClose(HMIDIIN_32(hMidiIn));
}
/**************************************************************************
* midiInPrepareHeader [MMSYSTEM.306]
*/
UINT16 WINAPI midiInPrepareHeader16(HMIDIIN16 hMidiIn, /* [in] */
SEGPTR lpsegMidiInHdr, /* [???] */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
TRACE("(%04X, %08lx, %d)\n", hMidiIn, lpsegMidiInHdr, uSize);
if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, MIDM_PREPARE, (DWORD)lpsegMidiInHdr, uSize, FALSE);
}
/**************************************************************************
* midiInUnprepareHeader [MMSYSTEM.307]
*/
UINT16 WINAPI midiInUnprepareHeader16(HMIDIIN16 hMidiIn, /* [in] */
SEGPTR lpsegMidiInHdr, /* [???] */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
LPMIDIHDR16 lpMidiInHdr = MapSL(lpsegMidiInHdr);
TRACE("(%04X, %08lx, %d)\n", hMidiIn, lpsegMidiInHdr, uSize);
if (!(lpMidiInHdr->dwFlags & MHDR_PREPARED)) {
return MMSYSERR_NOERROR;
}
if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, MIDM_UNPREPARE, (DWORD)lpsegMidiInHdr, uSize, FALSE);
}
/**************************************************************************
* midiInAddBuffer [MMSYSTEM.308]
*/
UINT16 WINAPI midiInAddBuffer16(HMIDIIN16 hMidiIn, /* [in] */
MIDIHDR16* lpsegMidiInHdr, /* [???] NOTE: SEGPTR */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
TRACE("(%04X, %p, %d)\n", hMidiIn, lpsegMidiInHdr, uSize);
if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, MIDM_ADDBUFFER, (DWORD)lpsegMidiInHdr, uSize, FALSE);
}
/**************************************************************************
* midiInStart [MMSYSTEM.309]
*/
UINT16 WINAPI midiInStart16(HMIDIIN16 hMidiIn)
{
return midiInStart(HMIDIIN_32(hMidiIn));
}
/**************************************************************************
* midiInStop [MMSYSTEM.310]
*/
UINT16 WINAPI midiInStop16(HMIDIIN16 hMidiIn)
{
return midiInStop(HMIDIIN_32(hMidiIn));
}
/**************************************************************************
* midiInReset [MMSYSTEM.311]
*/
UINT16 WINAPI midiInReset16(HMIDIIN16 hMidiIn)
{
return midiInReset(HMIDIIN_32(hMidiIn));
}
/**************************************************************************
* midiInGetID [MMSYSTEM.312]
*/
UINT16 WINAPI midiInGetID16(HMIDIIN16 hMidiIn, UINT16* lpuDeviceID)
{
LPWINE_MLD wmld;
TRACE("(%04X, %p)\n", hMidiIn, lpuDeviceID);
if (lpuDeviceID == NULL) return MMSYSERR_INVALPARAM;
if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, TRUE)) == NULL)
return MMSYSERR_INVALHANDLE;
*lpuDeviceID = wmld->uDeviceID;
return MMSYSERR_NOERROR;
}
/**************************************************************************
* midiInMessage [MMSYSTEM.313]
*/
DWORD WINAPI midiInMessage16(HMIDIIN16 hMidiIn, UINT16 uMessage,
DWORD dwParam1, DWORD dwParam2)
{
LPWINE_MLD wmld;
TRACE("(%04X, %04X, %08lX, %08lX)\n", hMidiIn, uMessage, dwParam1, dwParam2);
switch (uMessage) {
case MIDM_OPEN:
case MIDM_CLOSE:
FIXME("can't handle OPEN or CLOSE message!\n");
return MMSYSERR_NOTSUPPORTED;
case MIDM_GETDEVCAPS:
return midiInGetDevCaps16(hMidiIn, MapSL(dwParam1), dwParam2);
case MIDM_PREPARE:
return midiInPrepareHeader16(hMidiIn, dwParam1, dwParam2);
case MIDM_UNPREPARE:
return midiInUnprepareHeader16(hMidiIn, dwParam1, dwParam2);
case MIDM_ADDBUFFER:
return midiInAddBuffer16(hMidiIn, MapSL(dwParam1), dwParam2);
}
if ((wmld = MMDRV_Get(HMIDIIN_32(hMidiIn), MMDRV_MIDIIN, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, FALSE);
}
/**************************************************************************
* midiStreamClose [MMSYSTEM.252]
*/
MMRESULT16 WINAPI midiStreamClose16(HMIDISTRM16 hMidiStrm)
{
return midiStreamClose(HMIDISTRM_32(hMidiStrm));
}
/**************************************************************************
* midiStreamOpen [MMSYSTEM.251]
*/
MMRESULT16 WINAPI midiStreamOpen16(HMIDISTRM16* phMidiStrm, LPUINT16 devid,
DWORD cMidi, DWORD dwCallback,
DWORD dwInstance, DWORD fdwOpen)
{
HMIDISTRM hMidiStrm32;
MMRESULT ret;
UINT devid32;
if (!phMidiStrm || !devid)
return MMSYSERR_INVALPARAM;
devid32 = *devid;
ret = MMSYSTEM_MidiStream_Open(&hMidiStrm32, &devid32, cMidi, dwCallback,
dwInstance, fdwOpen, FALSE);
*phMidiStrm = HMIDISTRM_16(hMidiStrm32);
*devid = devid32;
return ret;
}
/**************************************************************************
* midiStreamOut [MMSYSTEM.254]
*/
MMRESULT16 WINAPI midiStreamOut16(HMIDISTRM16 hMidiStrm, LPMIDIHDR16 lpMidiHdr, UINT16 cbMidiHdr)
{
return midiStreamOut(HMIDISTRM_32(hMidiStrm), (LPMIDIHDR)lpMidiHdr,
cbMidiHdr);
}
/**************************************************************************
* midiStreamPause [MMSYSTEM.255]
*/
MMRESULT16 WINAPI midiStreamPause16(HMIDISTRM16 hMidiStrm)
{
return midiStreamPause(HMIDISTRM_32(hMidiStrm));
}
/**************************************************************************
* midiStreamPosition [MMSYSTEM.253]
*/
MMRESULT16 WINAPI midiStreamPosition16(HMIDISTRM16 hMidiStrm, LPMMTIME16 lpmmt16, UINT16 cbmmt)
{
MMTIME mmt32;
MMRESULT ret;
if (!lpmmt16)
return MMSYSERR_INVALPARAM;
MMSYSTEM_MMTIME16to32(&mmt32, lpmmt16);
ret = midiStreamPosition(HMIDISTRM_32(hMidiStrm), &mmt32, sizeof(MMTIME));
MMSYSTEM_MMTIME32to16(lpmmt16, &mmt32);
return ret;
}
/**************************************************************************
* midiStreamProperty [MMSYSTEM.250]
*/
MMRESULT16 WINAPI midiStreamProperty16(HMIDISTRM16 hMidiStrm, LPBYTE lpPropData, DWORD dwProperty)
{
return midiStreamProperty(HMIDISTRM_32(hMidiStrm), lpPropData, dwProperty);
}
/**************************************************************************
* midiStreamRestart [MMSYSTEM.256]
*/
MMRESULT16 WINAPI midiStreamRestart16(HMIDISTRM16 hMidiStrm)
{
return midiStreamRestart(HMIDISTRM_32(hMidiStrm));
}
/**************************************************************************
* midiStreamStop [MMSYSTEM.257]
*/
MMRESULT16 WINAPI midiStreamStop16(HMIDISTRM16 hMidiStrm)
{
return midiStreamStop(HMIDISTRM_32(hMidiStrm));
}
/**************************************************************************
* waveOutGetNumDevs [MMSYSTEM.401]
*/
UINT16 WINAPI waveOutGetNumDevs16(void)
{
return MMDRV_GetNum(MMDRV_WAVEOUT);
}
/**************************************************************************
* waveOutGetDevCaps [MMSYSTEM.402]
*/
UINT16 WINAPI waveOutGetDevCaps16(UINT16 uDeviceID,
LPWAVEOUTCAPS16 lpCaps, UINT16 uSize)
{
WAVEOUTCAPSA wocA;
UINT ret;
TRACE("(%u %p %u)!\n", uDeviceID, lpCaps, uSize);
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
ret = waveOutGetDevCapsA(uDeviceID, &wocA, sizeof(wocA));
if (ret == MMSYSERR_NOERROR) {
lpCaps->wMid = wocA.wMid;
lpCaps->wPid = wocA.wPid;
lpCaps->vDriverVersion = wocA.vDriverVersion;
strcpy(lpCaps->szPname, wocA.szPname);
lpCaps->dwFormats = wocA.dwFormats;
lpCaps->wChannels = wocA.wChannels;
lpCaps->dwSupport = wocA.dwSupport;
}
return ret;
}
/**************************************************************************
* waveOutGetErrorText [MMSYSTEM.403]
*/
UINT16 WINAPI waveOutGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
{
return waveOutGetErrorTextA(uError, lpText, uSize);
}
/**************************************************************************
* waveOutOpen [MMSYSTEM.404]
*/
UINT16 WINAPI waveOutOpen16(HWAVEOUT16* lphWaveOut, UINT16 uDeviceID,
const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
DWORD dwInstance, DWORD dwFlags)
{
HWAVEOUT hWaveOut;
UINT ret;
/* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
* call the 32 bit version
* however, we need to promote correctly the wave mapper id
* (0xFFFFFFFF and not 0x0000FFFF)
*/
ret = MMSYSTEM_waveOpen(&hWaveOut, (uDeviceID == (UINT16)-1) ? (UINT)-1 : uDeviceID,
MMDRV_WAVEOUT, lpFormat, dwCallback, dwInstance, dwFlags, FALSE);
if (lphWaveOut != NULL) *lphWaveOut = HWAVEOUT_16(hWaveOut);
return ret;
}
/**************************************************************************
* waveOutClose [MMSYSTEM.405]
*/
UINT16 WINAPI waveOutClose16(HWAVEOUT16 hWaveOut)
{
DWORD level;
UINT16 ret;
ReleaseThunkLock(&level);
ret = waveOutClose(HWAVEOUT_32(hWaveOut));
RestoreThunkLock(level);
return ret;
}
/**************************************************************************
* waveOutPrepareHeader [MMSYSTEM.406]
*/
UINT16 WINAPI waveOutPrepareHeader16(HWAVEOUT16 hWaveOut, /* [in] */
SEGPTR lpsegWaveOutHdr, /* [???] */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
LPWAVEHDR lpWaveOutHdr = MapSL(lpsegWaveOutHdr);
TRACE("(%04X, %08lx, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
if (lpWaveOutHdr == NULL) return MMSYSERR_INVALPARAM;
if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, WODM_PREPARE, (DWORD)lpsegWaveOutHdr, uSize, FALSE);
}
/**************************************************************************
* waveOutUnprepareHeader [MMSYSTEM.407]
*/
UINT16 WINAPI waveOutUnprepareHeader16(HWAVEOUT16 hWaveOut, /* [in] */
SEGPTR lpsegWaveOutHdr, /* [???] */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
LPWAVEHDR lpWaveOutHdr = MapSL(lpsegWaveOutHdr);
TRACE("(%04X, %08lx, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
if (!(lpWaveOutHdr->dwFlags & WHDR_PREPARED)) {
return MMSYSERR_NOERROR;
}
if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, WODM_UNPREPARE, (DWORD)lpsegWaveOutHdr, uSize, FALSE);
}
/**************************************************************************
* waveOutWrite [MMSYSTEM.408]
*/
UINT16 WINAPI waveOutWrite16(HWAVEOUT16 hWaveOut, /* [in] */
LPWAVEHDR lpsegWaveOutHdr, /* [???] NOTE: SEGPTR */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
TRACE("(%04X, %p, %u);\n", hWaveOut, lpsegWaveOutHdr, uSize);
if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, WODM_WRITE, (DWORD)lpsegWaveOutHdr, uSize, FALSE);
}
/**************************************************************************
* waveOutBreakLoop [MMSYSTEM.419]
*/
UINT16 WINAPI waveOutBreakLoop16(HWAVEOUT16 hWaveOut16)
{
DWORD level;
UINT16 ret;
ReleaseThunkLock(&level);
ret = waveOutBreakLoop(HWAVEOUT_32(hWaveOut16));
RestoreThunkLock(level);
return ret;
}
/**************************************************************************
* waveOutPause [MMSYSTEM.409]
*/
UINT16 WINAPI waveOutPause16(HWAVEOUT16 hWaveOut16)
{
DWORD level;
UINT16 ret;
ReleaseThunkLock(&level);
ret = waveOutPause(HWAVEOUT_32(hWaveOut16));
RestoreThunkLock(level);
return ret;
}
/**************************************************************************
* waveOutReset [MMSYSTEM.411]
*/
UINT16 WINAPI waveOutReset16(HWAVEOUT16 hWaveOut16)
{
DWORD level;
UINT16 ret;
ReleaseThunkLock(&level);
ret = waveOutReset(HWAVEOUT_32(hWaveOut16));
RestoreThunkLock(level);
return ret;
}
/**************************************************************************
* waveOutRestart [MMSYSTEM.410]
*/
UINT16 WINAPI waveOutRestart16(HWAVEOUT16 hWaveOut16)
{
DWORD level;
UINT16 ret;
ReleaseThunkLock(&level);
ret = waveOutRestart(HWAVEOUT_32(hWaveOut16));
RestoreThunkLock(level);
return ret;
}
/**************************************************************************
* waveOutGetPosition [MMSYSTEM.412]
*/
UINT16 WINAPI waveOutGetPosition16(HWAVEOUT16 hWaveOut, LPMMTIME16 lpTime,
UINT16 uSize)
{
UINT ret;
MMTIME mmt;
mmt.wType = lpTime->wType;
ret = waveOutGetPosition(HWAVEOUT_32(hWaveOut), &mmt, sizeof(mmt));
MMSYSTEM_MMTIME32to16(lpTime, &mmt);
return ret;
}
/**************************************************************************
* waveOutGetPitch [MMSYSTEM.413]
*/
UINT16 WINAPI waveOutGetPitch16(HWAVEOUT16 hWaveOut16, LPDWORD lpdw)
{
return waveOutGetPitch(HWAVEOUT_32(hWaveOut16), lpdw);
}
/**************************************************************************
* waveOutSetPitch [MMSYSTEM.414]
*/
UINT16 WINAPI waveOutSetPitch16(HWAVEOUT16 hWaveOut16, DWORD dw)
{
return waveOutSetPitch(HWAVEOUT_32(hWaveOut16), dw);
}
/**************************************************************************
* waveOutGetPlaybackRate [MMSYSTEM.417]
*/
UINT16 WINAPI waveOutGetPlaybackRate16(HWAVEOUT16 hWaveOut16, LPDWORD lpdw)
{
return waveOutGetPlaybackRate(HWAVEOUT_32(hWaveOut16), lpdw);
}
/**************************************************************************
* waveOutSetPlaybackRate [MMSYSTEM.418]
*/
UINT16 WINAPI waveOutSetPlaybackRate16(HWAVEOUT16 hWaveOut16, DWORD dw)
{
return waveOutSetPlaybackRate(HWAVEOUT_32(hWaveOut16), dw);
}
/**************************************************************************
* waveOutGetVolume [MMSYSTEM.415]
*/
UINT16 WINAPI waveOutGetVolume16(UINT16 devid, LPDWORD lpdw)
{
return waveOutGetVolume(devid, lpdw);
}
/**************************************************************************
* waveOutSetVolume [MMSYSTEM.416]
*/
UINT16 WINAPI waveOutSetVolume16(UINT16 devid, DWORD dw)
{
return waveOutSetVolume(devid, dw);
}
/**************************************************************************
* waveOutGetID [MMSYSTEM.420]
*/
UINT16 WINAPI waveOutGetID16(HWAVEOUT16 hWaveOut, UINT16* lpuDeviceID)
{
LPWINE_MLD wmld;
TRACE("(%04X, %p);\n", hWaveOut, lpuDeviceID);
if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
*lpuDeviceID = wmld->uDeviceID;
return 0;
}
/**************************************************************************
* waveOutMessage [MMSYSTEM.421]
*/
DWORD WINAPI waveOutMessage16(HWAVEOUT16 hWaveOut, UINT16 uMessage,
DWORD dwParam1, DWORD dwParam2)
{
LPWINE_MLD wmld;
TRACE("(%04x, %u, %ld, %ld)\n", hWaveOut, uMessage, dwParam1, dwParam2);
if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, FALSE)) == NULL) {
if ((wmld = MMDRV_Get(HWAVEOUT_32(hWaveOut), MMDRV_WAVEOUT, TRUE)) != NULL) {
return MMDRV_PhysicalFeatures(wmld, uMessage, dwParam1, dwParam2);
}
return MMSYSERR_INVALHANDLE;
}
/* from M$ KB */
if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
return MMSYSERR_INVALPARAM;
return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, FALSE);
}
/**************************************************************************
* waveInGetNumDevs [MMSYSTEM.501]
*/
UINT16 WINAPI waveInGetNumDevs16(void)
{
return MMDRV_GetNum(MMDRV_WAVEIN);
}
/**************************************************************************
* waveInGetDevCaps [MMSYSTEM.502]
*/
UINT16 WINAPI waveInGetDevCaps16(UINT16 uDeviceID, LPWAVEINCAPS16 lpCaps,
UINT16 uSize)
{
WAVEINCAPSA wicA;
UINT ret = waveInGetDevCapsA(uDeviceID, &wicA, sizeof(wicA));
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
if (ret == MMSYSERR_NOERROR) {
lpCaps->wMid = wicA.wMid;
lpCaps->wPid = wicA.wPid;
lpCaps->vDriverVersion = wicA.vDriverVersion;
strcpy(lpCaps->szPname, wicA.szPname);
lpCaps->dwFormats = wicA.dwFormats;
lpCaps->wChannels = wicA.wChannels;
}
return ret;
}
/**************************************************************************
* waveInGetErrorText [MMSYSTEM.503]
*/
UINT16 WINAPI waveInGetErrorText16(UINT16 uError, LPSTR lpText, UINT16 uSize)
{
return waveInGetErrorTextA(uError, lpText, uSize);
}
/**************************************************************************
* waveInOpen [MMSYSTEM.504]
*/
UINT16 WINAPI waveInOpen16(HWAVEIN16* lphWaveIn, UINT16 uDeviceID,
const LPWAVEFORMATEX lpFormat, DWORD dwCallback,
DWORD dwInstance, DWORD dwFlags)
{
HWAVEIN hWaveIn;
UINT ret;
/* since layout of WAVEFORMATEX is the same for 16/32 bits, we directly
* call the 32 bit version
* however, we need to promote correctly the wave mapper id
* (0xFFFFFFFF and not 0x0000FFFF)
*/
ret = MMSYSTEM_waveOpen(&hWaveIn, (uDeviceID == (UINT16)-1) ? (UINT)-1 : uDeviceID,
MMDRV_WAVEIN, lpFormat, dwCallback, dwInstance, dwFlags, FALSE);
if (lphWaveIn != NULL) *lphWaveIn = HWAVEIN_16(hWaveIn);
return ret;
}
/**************************************************************************
* waveInClose [MMSYSTEM.505]
*/
UINT16 WINAPI waveInClose16(HWAVEIN16 hWaveIn)
{
DWORD level;
UINT16 ret;
ReleaseThunkLock(&level);
ret = waveInClose(HWAVEIN_32(hWaveIn));
RestoreThunkLock(level);
return ret;
}
/**************************************************************************
* waveInPrepareHeader [MMSYSTEM.506]
*/
UINT16 WINAPI waveInPrepareHeader16(HWAVEIN16 hWaveIn, /* [in] */
SEGPTR lpsegWaveInHdr, /* [???] */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
LPWAVEHDR lpWaveInHdr = MapSL(lpsegWaveInHdr);
UINT16 ret;
TRACE("(%04X, %p, %u);\n", hWaveIn, lpWaveInHdr, uSize);
if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
lpWaveInHdr->dwBytesRecorded = 0;
ret = MMDRV_Message(wmld, WIDM_PREPARE, (DWORD)lpsegWaveInHdr, uSize, FALSE);
return ret;
}
/**************************************************************************
* waveInUnprepareHeader [MMSYSTEM.507]
*/
UINT16 WINAPI waveInUnprepareHeader16(HWAVEIN16 hWaveIn, /* [in] */
SEGPTR lpsegWaveInHdr, /* [???] */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
LPWAVEHDR lpWaveInHdr = MapSL(lpsegWaveInHdr);
TRACE("(%04X, %08lx, %u);\n", hWaveIn, lpsegWaveInHdr, uSize);
if (lpWaveInHdr == NULL) return MMSYSERR_INVALPARAM;
if (!(lpWaveInHdr->dwFlags & WHDR_PREPARED)) {
return MMSYSERR_NOERROR;
}
if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, WIDM_UNPREPARE, (DWORD)lpsegWaveInHdr, uSize, FALSE);
}
/**************************************************************************
* waveInAddBuffer [MMSYSTEM.508]
*/
UINT16 WINAPI waveInAddBuffer16(HWAVEIN16 hWaveIn, /* [in] */
WAVEHDR* lpsegWaveInHdr, /* [???] NOTE: SEGPTR */
UINT16 uSize) /* [in] */
{
LPWINE_MLD wmld;
TRACE("(%04X, %p, %u);\n", hWaveIn, lpsegWaveInHdr, uSize);
if (lpsegWaveInHdr == NULL) return MMSYSERR_INVALPARAM;
if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, WIDM_ADDBUFFER, (DWORD)lpsegWaveInHdr, uSize, FALSE);
}
/**************************************************************************
* waveInReset [MMSYSTEM.511]
*/
UINT16 WINAPI waveInReset16(HWAVEIN16 hWaveIn16)
{
DWORD level;
UINT16 ret;
ReleaseThunkLock(&level);
ret = waveInReset(HWAVEIN_32(hWaveIn16));
RestoreThunkLock(level);
return ret;
}
/**************************************************************************
* waveInStart [MMSYSTEM.509]
*/
UINT16 WINAPI waveInStart16(HWAVEIN16 hWaveIn16)
{
DWORD level;
UINT16 ret;
ReleaseThunkLock(&level);
ret = waveInStart(HWAVEIN_32(hWaveIn16));
RestoreThunkLock(level);
return ret;
}
/**************************************************************************
* waveInStop [MMSYSTEM.510]
*/
UINT16 WINAPI waveInStop16(HWAVEIN16 hWaveIn16)
{
DWORD level;
UINT16 ret;
ReleaseThunkLock(&level);
ret = waveInStop(HWAVEIN_32(hWaveIn16));
RestoreThunkLock(level);
return ret;
}
/**************************************************************************
* waveInGetPosition [MMSYSTEM.512]
*/
UINT16 WINAPI waveInGetPosition16(HWAVEIN16 hWaveIn, LPMMTIME16 lpTime,
UINT16 uSize)
{
UINT ret;
MMTIME mmt;
mmt.wType = lpTime->wType;
ret = waveInGetPosition(HWAVEIN_32(hWaveIn), &mmt, sizeof(mmt));
MMSYSTEM_MMTIME32to16(lpTime, &mmt);
return ret;
}
/**************************************************************************
* waveInGetID [MMSYSTEM.513]
*/
UINT16 WINAPI waveInGetID16(HWAVEIN16 hWaveIn, UINT16* lpuDeviceID)
{
LPWINE_MLD wmld;
TRACE("(%04X, %p);\n", hWaveIn, lpuDeviceID);
if (lpuDeviceID == NULL) return MMSYSERR_INVALHANDLE;
if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
*lpuDeviceID = wmld->uDeviceID;
return MMSYSERR_NOERROR;
}
/**************************************************************************
* waveInMessage [MMSYSTEM.514]
*/
DWORD WINAPI waveInMessage16(HWAVEIN16 hWaveIn, UINT16 uMessage,
DWORD dwParam1, DWORD dwParam2)
{
LPWINE_MLD wmld;
TRACE("(%04x, %u, %ld, %ld)\n", hWaveIn, uMessage, dwParam1, dwParam2);
/* from M$ KB */
if (uMessage < DRVM_IOCTL || (uMessage >= DRVM_IOCTL_LAST && uMessage < DRVM_MAPPER))
return MMSYSERR_INVALPARAM;
if ((wmld = MMDRV_Get(HWAVEIN_32(hWaveIn), MMDRV_WAVEIN, FALSE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, uMessage, dwParam1, dwParam2, TRUE);
}
/*#define USE_MM_TSK_WINE*/
/**************************************************************************
* mmTaskCreate [MMSYSTEM.900]
*
* Creates a 16 bit MM task. It's entry point is lpFunc, and it should be
* called upon creation with dwPmt as parameter.
*/
HINSTANCE16 WINAPI mmTaskCreate16(SEGPTR spProc, HINSTANCE16 *lphMmTask, DWORD dwPmt)
{
HINSTANCE16 ret;
HINSTANCE16 handle;
char cmdline[16];
DWORD showCmd = 0x40002;
LOADPARAMS16 lp;
TRACE("(%08lx, %p, %08lx);\n", spProc, lphMmTask, dwPmt);
/* This to work requires NE modules to be started with a binary command line
* which is not currently the case. A patch exists but has never been committed.
* A workaround would be to integrate code for mmtask.tsk into Wine, but
* this requires tremendous work (starting with patching tools/build to
* create NE executables (and not only DLLs) for builtins modules.
* EP 99/04/25
*/
FIXME("This is currently broken. It will fail\n");
cmdline[0] = 0x0d;
*(LPDWORD)(cmdline + 1) = (DWORD)spProc;
*(LPDWORD)(cmdline + 5) = dwPmt;
*(LPDWORD)(cmdline + 9) = 0;
lp.hEnvironment = 0;
lp.cmdLine = MapLS(cmdline);
lp.showCmd = MapLS(&showCmd);
lp.reserved = 0;
#ifndef USE_MM_TSK_WINE
handle = LoadModule16("c:\\windows\\system\\mmtask.tsk", &lp);
#else
handle = LoadModule16("mmtask.tsk", &lp);
#endif
if (handle < 32) {
ret = (handle) ? 1 : 2;
handle = 0;
} else {
ret = 0;
}
if (lphMmTask)
*lphMmTask = handle;
UnMapLS( lp.cmdLine );
UnMapLS( lp.showCmd );
TRACE("=> 0x%04x/%d\n", handle, ret);
return ret;
}
#ifdef USE_MM_TSK_WINE
/* C equivalent to mmtask.tsk binary content */
void mmTaskEntryPoint16(LPSTR cmdLine, WORD di, WORD si)
{
int len = cmdLine[0x80];
if (len / 2 == 6) {
void (*fpProc)(DWORD) = MapSL(*((DWORD*)(cmdLine + 1)));
DWORD dwPmt = *((DWORD*)(cmdLine + 5));
#if 0
InitTask16(); /* FIXME: pmts / from context ? */
InitApp(di);
#endif
if (SetMessageQueue16(0x40)) {
WaitEvent16(0);
if (HIWORD(fpProc)) {
OldYield16();
/* EPP StackEnter16(); */
(fpProc)(dwPmt);
}
}
}
OldYield16();
OldYield16();
OldYield16();
ExitProcess(0);
}
#endif
/**************************************************************************
* mmTaskBlock [MMSYSTEM.902]
*/
void WINAPI mmTaskBlock16(HINSTANCE16 WINE_UNUSED hInst)
{
MSG msg;
do {
GetMessageA(&msg, 0, 0, 0);
if (msg.hwnd) {
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
} while (msg.message < 0x3A0);
}
/**************************************************************************
* mmTaskSignal [MMSYSTEM.903]
*/
LRESULT WINAPI mmTaskSignal16(HTASK16 ht)
{
TRACE("(%04x);\n", ht);
return PostAppMessage16(ht, WM_USER, 0, 0);
}
/**************************************************************************
* mmGetCurrentTask [MMSYSTEM.904]
*/
HTASK16 WINAPI mmGetCurrentTask16(void)
{
return GetCurrentTask();
}
/**************************************************************************
* mmTaskYield [MMSYSTEM.905]
*/
void WINAPI mmTaskYield16(void)
{
MSG msg;
if (PeekMessageA(&msg, 0, 0, 0, 0)) {
K32WOWYield16();
}
}
extern DWORD WINAPI GetProcessFlags(DWORD);
/**************************************************************************
* mmThreadCreate [MMSYSTEM.1120]
*
* undocumented
* Creates a MM thread, calling fpThreadAddr(dwPmt).
* dwFlags:
* bit.0 set means create a 16 bit task instead of thread calling a 16 bit proc
* bit.1 set means to open a VxD for this thread (unsupported)
*/
LRESULT WINAPI mmThreadCreate16(FARPROC16 fpThreadAddr, LPHANDLE lpHndl, DWORD dwPmt, DWORD dwFlags)
{
HANDLE16 hndl;
LRESULT ret;
TRACE("(%p, %p, %08lx, %08lx)!\n", fpThreadAddr, lpHndl, dwPmt, dwFlags);
hndl = GlobalAlloc16(sizeof(WINE_MMTHREAD), GMEM_SHARE|GMEM_ZEROINIT);
if (hndl == 0) {
ret = 2;
} else {
WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
#if 0
/* force mmtask routines even if mmthread is required */
/* this will work only if the patch about binary cmd line and NE tasks
* is committed
*/
dwFlags |= 1;
#endif
lpMMThd->dwSignature = WINE_MMTHREAD_CREATED;
lpMMThd->dwCounter = 0;
lpMMThd->hThread = 0;
lpMMThd->dwThreadID = 0;
lpMMThd->fpThread = fpThreadAddr;
lpMMThd->dwThreadPmt = dwPmt;
lpMMThd->dwSignalCount = 0;
lpMMThd->hEvent = 0;
lpMMThd->hVxD = 0;
lpMMThd->dwStatus = 0;
lpMMThd->dwFlags = dwFlags;
lpMMThd->hTask = 0;
if ((dwFlags & 1) == 0 && (GetProcessFlags(GetCurrentThreadId()) & 8) == 0) {
lpMMThd->hEvent = CreateEventA(0, 0, 1, 0);
TRACE("Let's go crazy... trying new MM thread. lpMMThd=%p\n", lpMMThd);
if (lpMMThd->dwFlags & 2) {
/* as long as we don't support MM VxD in wine, we don't need
* to care about this flag
*/
/* FIXME("Don't know how to properly open VxD handles\n"); */
/* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */
}
lpMMThd->hThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)WINE_mmThreadEntryPoint,
(LPVOID)(DWORD)hndl, CREATE_SUSPENDED, &lpMMThd->dwThreadID);
if (lpMMThd->hThread == 0) {
WARN("Couldn't create thread\n");
/* clean-up(VxDhandle...); devicedirectio... */
if (lpMMThd->hEvent != 0)
CloseHandle(lpMMThd->hEvent);
ret = 2;
} else {
TRACE("Got a nice thread hndl=0x%04x id=0x%08lx\n", lpMMThd->hThread, lpMMThd->dwThreadID);
ret = 0;
}
} else {
/* get WINE_mmThreadEntryPoint()
* 2047 is its ordinal in mmsystem.spec
*/
FARPROC16 fp = GetProcAddress16(GetModuleHandle16("MMSYSTEM"), (LPCSTR)2047);
TRACE("farproc seg=0x%08lx lin=%p\n", (DWORD)fp, MapSL((SEGPTR)fp));
ret = (fp == 0) ? 2 : mmTaskCreate16((DWORD)fp, 0, hndl);
}
if (ret == 0) {
if (lpMMThd->hThread && !ResumeThread(lpMMThd->hThread))
WARN("Couldn't resume thread\n");
while (lpMMThd->dwStatus != 0x10) { /* test also HIWORD of dwStatus */
UserYield16();
}
}
}
if (ret != 0) {
GlobalFree16(hndl);
hndl = 0;
}
if (lpHndl)
*lpHndl = hndl;
TRACE("ok => %ld\n", ret);
return ret;
}
/**************************************************************************
* mmThreadSignal [MMSYSTEM.1121]
*/
void WINAPI mmThreadSignal16(HANDLE16 hndl)
{
TRACE("(%04x)!\n", hndl);
if (hndl) {
WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
lpMMThd->dwCounter++;
if (lpMMThd->hThread != 0) {
InterlockedIncrement(&lpMMThd->dwSignalCount);
SetEvent(lpMMThd->hEvent);
} else {
mmTaskSignal16(lpMMThd->hTask);
}
lpMMThd->dwCounter--;
}
}
static void MMSYSTEM_ThreadBlock(WINE_MMTHREAD* lpMMThd)
{
MSG msg;
DWORD ret;
if (lpMMThd->dwThreadID != GetCurrentThreadId())
ERR("Not called by thread itself\n");
for (;;) {
ResetEvent(lpMMThd->hEvent);
if (InterlockedDecrement(&lpMMThd->dwSignalCount) >= 0)
break;
InterlockedIncrement(&lpMMThd->dwSignalCount);
TRACE("S1\n");
ret = MsgWaitForMultipleObjects(1, &lpMMThd->hEvent, FALSE, INFINITE, QS_ALLINPUT);
switch (ret) {
case WAIT_OBJECT_0: /* Event */
TRACE("S2.1\n");
break;
case WAIT_OBJECT_0 + 1: /* Msg */
TRACE("S2.2\n");
if (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
break;
default:
WARN("S2.x unsupported ret val 0x%08lx\n", ret);
}
TRACE("S3\n");
}
}
/**************************************************************************
* mmThreadBlock [MMSYSTEM.1122]
*/
void WINAPI mmThreadBlock16(HANDLE16 hndl)
{
TRACE("(%04x)!\n", hndl);
if (hndl) {
WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
if (lpMMThd->hThread != 0) {
DWORD lc;
ReleaseThunkLock(&lc);
MMSYSTEM_ThreadBlock(lpMMThd);
RestoreThunkLock(lc);
} else {
mmTaskBlock16(lpMMThd->hTask);
}
}
TRACE("done\n");
}
/**************************************************************************
* mmThreadIsCurrent [MMSYSTEM.1123]
*/
BOOL16 WINAPI mmThreadIsCurrent16(HANDLE16 hndl)
{
BOOL16 ret = FALSE;
TRACE("(%04x)!\n", hndl);
if (hndl && mmThreadIsValid16(hndl)) {
WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
ret = (GetCurrentThreadId() == lpMMThd->dwThreadID);
}
TRACE("=> %d\n", ret);
return ret;
}
/**************************************************************************
* mmThreadIsValid [MMSYSTEM.1124]
*/
BOOL16 WINAPI mmThreadIsValid16(HANDLE16 hndl)
{
BOOL16 ret = FALSE;
TRACE("(%04x)!\n", hndl);
if (hndl) {
WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
if (!IsBadWritePtr(lpMMThd, sizeof(WINE_MMTHREAD)) &&
lpMMThd->dwSignature == WINE_MMTHREAD_CREATED &&
IsTask16(lpMMThd->hTask)) {
lpMMThd->dwCounter++;
if (lpMMThd->hThread != 0) {
DWORD dwThreadRet;
if (GetExitCodeThread(lpMMThd->hThread, &dwThreadRet) &&
dwThreadRet == STATUS_PENDING) {
ret = TRUE;
}
} else {
ret = TRUE;
}
lpMMThd->dwCounter--;
}
}
TRACE("=> %d\n", ret);
return ret;
}
/**************************************************************************
* mmThreadGetTask [MMSYSTEM.1125]
*/
HANDLE16 WINAPI mmThreadGetTask16(HANDLE16 hndl)
{
HANDLE16 ret = 0;
TRACE("(%04x)\n", hndl);
if (mmThreadIsValid16(hndl)) {
WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
ret = lpMMThd->hTask;
}
return ret;
}
/* ### start build ### */
extern LONG CALLBACK MMSYSTEM_CallTo16_long_l (FARPROC16,LONG);
/* ### stop build ### */
/**************************************************************************
* __wine_mmThreadEntryPoint (MMSYSTEM.2047)
*/
void WINAPI WINE_mmThreadEntryPoint(DWORD _pmt)
{
HANDLE16 hndl = (HANDLE16)_pmt;
WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(hndl, 0) );
TRACE("(%04x %p)\n", hndl, lpMMThd);
lpMMThd->hTask = LOWORD(GetCurrentTask());
TRACE("[10-%08x] setting hTask to 0x%08x\n", lpMMThd->hThread, lpMMThd->hTask);
lpMMThd->dwStatus = 0x10;
MMSYSTEM_ThreadBlock(lpMMThd);
TRACE("[20-%08x]\n", lpMMThd->hThread);
lpMMThd->dwStatus = 0x20;
if (lpMMThd->fpThread) {
MMSYSTEM_CallTo16_long_l(lpMMThd->fpThread, lpMMThd->dwThreadPmt);
}
lpMMThd->dwStatus = 0x30;
TRACE("[30-%08x]\n", lpMMThd->hThread);
while (lpMMThd->dwCounter) {
Sleep(1);
/* K32WOWYield16();*/
}
TRACE("[XX-%08x]\n", lpMMThd->hThread);
/* paranoia */
lpMMThd->dwSignature = WINE_MMTHREAD_DELETED;
/* close lpMMThread->hVxD directIO */
if (lpMMThd->hEvent)
CloseHandle(lpMMThd->hEvent);
GlobalFree16(hndl);
TRACE("done\n");
}
typedef BOOL16 (WINAPI *MMCPLCALLBACK)(HWND, LPCSTR, LPCSTR, LPCSTR);
/**************************************************************************
* mmShowMMCPLPropertySheet [MMSYSTEM.1150]
*/
BOOL16 WINAPI mmShowMMCPLPropertySheet16(HWND hWnd, LPCSTR lpStrDevice,
LPCSTR lpStrTab, LPCSTR lpStrTitle)
{
HANDLE hndl;
BOOL16 ret = FALSE;
TRACE("(%04x \"%s\" \"%s\" \"%s\")\n", hWnd, lpStrDevice, lpStrTab, lpStrTitle);
hndl = LoadLibraryA("MMSYS.CPL");
if (hndl != 0) {
MMCPLCALLBACK fp = (MMCPLCALLBACK)GetProcAddress(hndl, "ShowMMCPLPropertySheet");
if (fp != NULL) {
DWORD lc;
ReleaseThunkLock(&lc);
ret = (fp)(hWnd, lpStrDevice, lpStrTab, lpStrTitle);
RestoreThunkLock(lc);
}
FreeLibrary(hndl);
}
return ret;
}
/**************************************************************************
* StackEnter [MMSYSTEM.32]
*/
void WINAPI StackEnter16(void)
{
#ifdef __i386__
/* mmsystem.dll from Win 95 does only this: so does Wine */
__asm__("stc");
#endif
}
/**************************************************************************
* StackLeave [MMSYSTEM.33]
*/
void WINAPI StackLeave16(void)
{
#ifdef __i386__
/* mmsystem.dll from Win 95 does only this: so does Wine */
__asm__("stc");
#endif
}
/**************************************************************************
* WMMMidiRunOnce [MMSYSTEM.8]
*/
void WINAPI WMMMidiRunOnce16(void)
{
FIXME("(), stub!\n");
}
/**************************************************************************
* OutputDebugStr [MMSYSTEM.30]
*/
void WINAPI OutputDebugStr16(
LPCSTR str) /* [in] The message to be logged and given to the debugger. */
{
OutputDebugStringA( str );
}