From 1563fab4db71440f61c347796860b9c319fd0d2e Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Mon, 28 Oct 2002 20:53:10 +0000 Subject: [PATCH] Move low level multimedia message mapping out of 32 bit code. --- dlls/winmm/lolvldrv.c | 3233 ++++++++------------------------ dlls/winmm/{lolvldrv.c => message16.c} | 1640 +++++++++------- dlls/winmm/winemm.h | 207 +- 3 files changed, 1793 insertions(+), 3287 deletions(-) rewrite dlls/winmm/lolvldrv.c (69%) copy dlls/winmm/{lolvldrv.c => message16.c} (61%) diff --git a/dlls/winmm/lolvldrv.c b/dlls/winmm/lolvldrv.c dissimilarity index 69% index ebc276db4dd..d17ed45bb3e 100644 --- a/dlls/winmm/lolvldrv.c +++ b/dlls/winmm/lolvldrv.c @@ -1,2487 +1,746 @@ -/* -*- tab-width: 8; c-basic-offset: 4 -*- */ - -/* - * MMSYTEM low level drivers handling functions - * - * Copyright 1999 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 - */ - -#include -#include -#include -#include "wine/winbase16.h" -#include "winreg.h" -#include "winver.h" -#include "winemm.h" -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(mmsys); - -typedef DWORD (CALLBACK *WINEMM_msgFunc16)(UINT16, WORD, DWORD, DWORD, DWORD); -typedef DWORD (CALLBACK *WINEMM_msgFunc32)(UINT , UINT, DWORD, DWORD, DWORD); - -/* for each loaded driver and each known type of driver, this structure contains - * the information needed to access it - */ -typedef struct tagWINE_MM_DRIVER_PART { - int nIDMin; /* lower bound of global indexes for this type */ - int nIDMax; /* hhigher bound of global indexes for this type */ - union { - WINEMM_msgFunc32 fnMessage32; /* pointer to fonction */ - WINEMM_msgFunc16 fnMessage16; - } u; -} WINE_MM_DRIVER_PART; - -/* each low-level .drv will be associated with an instance of this structure */ -typedef struct tagWINE_MM_DRIVER { - HDRVR hDriver; - LPSTR drvname; /* name of the driver */ - BOOL bIs32 : 1, /* TRUE if 32 bit driver, FALSE for 16 */ - bIsMapper : 1; /* TRUE if mapper */ - WINE_MM_DRIVER_PART parts[MMDRV_MAX];/* Information for all known types */ -} WINE_MM_DRIVER, *LPWINE_MM_DRIVER; - -typedef WINMM_MapType (*MMDRV_MAPFUNC)(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); - -/* each known type of driver has an instance of this structure */ -typedef struct tagWINE_LLTYPE { - /* those attributes depend on the specification of the type */ - LPSTR typestr; /* name (for debugging) */ - BOOL bSupportMapper; /* if type is allowed to support mapper */ - MMDRV_MAPFUNC Map16To32A; /* those are function pointers to handle */ - MMDRV_MAPFUNC UnMap16To32A; /* the parameter conversion (16 vs 32 bit) */ - MMDRV_MAPFUNC Map32ATo16; /* when hi-func (in mmsystem or winmm) and */ - MMDRV_MAPFUNC UnMap32ATo16; /* low-func (in .drv) do not match */ - LPDRVCALLBACK Callback; /* handles callback for a specified type */ - /* those attributes reflect the loaded/current situation for the type */ - UINT wMaxId; /* number of loaded devices (sum across all loaded drivers */ - LPWINE_MLD lpMlds; /* "static" mlds to access the part though device IDs */ - int nMapper; /* index to mapper */ -} WINE_LLTYPE; - -static int MMDrvsHi /* = 0 */; -static WINE_MM_DRIVER MMDrvs[3]; -static LPWINE_MLD MM_MLDrvs[40]; -#define MAX_MM_MLDRVS (sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) - -/* ### start build ### */ -extern WORD CALLBACK MMDRV_CallTo16_word_wwlll(FARPROC16,WORD,WORD,LONG,LONG,LONG); -/* ### stop build ### */ - -/************************************************************************** - * MMDRV_GetDescription16 [internal] - */ -static BOOL MMDRV_GetDescription16(const char* fname, char* buf, int buflen) -{ - OFSTRUCT ofs; - HFILE hFile; - WORD w; - DWORD dw; - BOOL ret = FALSE; - - if ((hFile = OpenFile(fname, &ofs, OF_READ | OF_SHARE_DENY_WRITE)) == HFILE_ERROR) { - ERR("Can't open file %s (builtin driver ?)\n", fname); - return FALSE; - } - -#define E(_x) do {TRACE _x;goto theEnd;} while(0) - - if (_lread(hFile, &w, 2) != 2) E(("Can't read sig\n")); - if (w != ('Z' * 256 + 'M')) E(("Bad sig %04x\n", w)); - if (_llseek(hFile, 0x3C, SEEK_SET) < 0) E(("Can't seek to ext header offset\n")); - if (_lread(hFile, &dw, 4) != 4) E(("Can't read ext header offset\n")); - if (_llseek(hFile, dw + 0x2C, SEEK_SET) < 0) E(("Can't seek to ext header.nr table %lu\n", dw+0x2C)); - if (_lread(hFile, &dw, 4) != 4) E(("Can't read nr table offset\n")); - if (_llseek(hFile, dw, SEEK_SET) < 0) E(("Can't seek to nr table %lu\n", dw)); - if (_lread(hFile, buf, 1) != 1) E(("Can't read descr length\n")); - buflen = min((int)(unsigned)(BYTE)buf[0], buflen - 1); - if (_lread(hFile, buf, buflen) != buflen) E(("Can't read descr (%d)\n", buflen)); - buf[buflen] = '\0'; - ret = TRUE; - TRACE("Got '%s' [%d]\n", buf, buflen); -theEnd: - CloseHandle(hFile); - return ret; -} - -/************************************************************************** - * MMDRV_GetDescription32 [internal] - */ -static BOOL MMDRV_GetDescription32(const char* fname, char* buf, int buflen) -{ - OFSTRUCT ofs; - DWORD h; - LPVOID ptr = 0; - LPVOID val; - DWORD dw; - BOOL ret = FALSE; - UINT u; - FARPROC pGetFileVersionInfoSizeA; - FARPROC pGetFileVersionInfoA; - FARPROC pVerQueryValueA; - HMODULE hmodule = 0; - -#define E(_x) do {TRACE _x;goto theEnd;} while(0) - - if (OpenFile(fname, &ofs, OF_EXIST)==HFILE_ERROR) E(("Can't find file %s\n", fname)); - - if (!(hmodule = LoadLibraryA( "version.dll" ))) goto theEnd; - if (!(pGetFileVersionInfoSizeA = GetProcAddress( hmodule, "GetFileVersionInfoSizeA" ))) - goto theEnd; - if (!(pGetFileVersionInfoA = GetProcAddress( hmodule, "GetFileVersionInfoA" ))) - goto theEnd; - if (!(pVerQueryValueA = GetProcAddress( hmodule, "pVerQueryValueA" ))) - goto theEnd; - - if (!(dw = pGetFileVersionInfoSizeA(ofs.szPathName, &h))) E(("Can't get FVIS\n")); - if (!(ptr = HeapAlloc(GetProcessHeap(), 0, dw))) E(("OOM\n")); - if (!pGetFileVersionInfoA(ofs.szPathName, h, dw, ptr)) E(("Can't get FVI\n")); - -#define A(_x) if (pVerQueryValueA(ptr, "\\StringFileInfo\\040904B0\\" #_x, &val, &u)) \ - TRACE(#_x " => %s\n", (LPSTR)val); else TRACE(#_x " @\n") - - A(CompanyName); - A(FileDescription); - A(FileVersion); - A(InternalName); - A(LegalCopyright); - A(OriginalFilename); - A(ProductName); - A(ProductVersion); - A(Comments); - A(LegalTrademarks); - A(PrivateBuild); - A(SpecialBuild); -#undef A - - if (!pVerQueryValueA(ptr, "\\StringFileInfo\\040904B0\\ProductName", &val, &u)) E(("Can't get product name\n")); - lstrcpynA(buf, val, buflen); - -#undef E - ret = TRUE; -theEnd: - HeapFree(GetProcessHeap(), 0, ptr); - if (hmodule) FreeLibrary( hmodule ); - return ret; -} - -/************************************************************************** - * MMDRV_Callback [internal] - */ -static void MMDRV_Callback(LPWINE_MLD mld, HDRVR hDev, UINT uMsg, DWORD dwParam1, DWORD dwParam2) -{ - TRACE("CB (*%08lx)(%08x %08x %08lx %08lx %08lx\n", - mld->dwCallback, hDev, uMsg, mld->dwClientInstance, dwParam1, dwParam2); - - if (!mld->bFrom32 && (mld->dwFlags & DCB_TYPEMASK) == DCB_FUNCTION) { - /* 16 bit func, call it */ - TRACE("Function (16 bit) !\n"); - MMDRV_CallTo16_word_wwlll((FARPROC16)mld->dwCallback, HDRVR_16(hDev), uMsg, - mld->dwClientInstance, dwParam1, dwParam2); - } else { - DriverCallback(mld->dwCallback, mld->dwFlags, hDev, uMsg, - mld->dwClientInstance, dwParam1, dwParam2); - } -} - -/* ================================= - * A U X M A P P E R S - * ================================= */ - -/************************************************************************** - * MMDRV_Aux_Map16To32A [internal] - */ -static WINMM_MapType MMDRV_Aux_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_Aux_UnMap16To32A [internal] - */ -static WINMM_MapType MMDRV_Aux_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_Aux_Map32ATo16 [internal] - */ -static WINMM_MapType MMDRV_Aux_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_Aux_UnMap32ATo16 [internal] - */ -static WINMM_MapType MMDRV_Aux_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ -#if 0 - case AUXDM_GETDEVCAPS: - lpCaps->wMid = ac16.wMid; - lpCaps->wPid = ac16.wPid; - lpCaps->vDriverVersion = ac16.vDriverVersion; - strcpy(lpCaps->szPname, ac16.szPname); - lpCaps->wTechnology = ac16.wTechnology; - lpCaps->dwSupport = ac16.dwSupport; -#endif - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_Aux_Callback [internal] - */ -static void CALLBACK MMDRV_Aux_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) -{ - LPWINE_MLD mld = (LPWINE_MLD)dwInstance; - - FIXME("NIY\n"); - MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); -} - -/* ================================= - * M I X E R M A P P E R S - * ================================= */ - -/************************************************************************** - * xMMDRV_Mixer_Map16To32A [internal] - */ -static WINMM_MapType MMDRV_Mixer_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_Mixer_UnMap16To32A [internal] - */ -static WINMM_MapType MMDRV_Mixer_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ -#if 0 - 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; -#endif - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_Mixer_Map32ATo16 [internal] - */ -static WINMM_MapType MMDRV_Mixer_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_Mixer_UnMap32ATo16 [internal] - */ -static WINMM_MapType MMDRV_Mixer_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_Mixer_Callback [internal] - */ -static void CALLBACK MMDRV_Mixer_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) -{ - LPWINE_MLD mld = (LPWINE_MLD)dwInstance; - - FIXME("NIY\n"); - MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); -} - -/* ================================= - * M I D I I N M A P P E R S - * ================================= */ - -/************************************************************************** - * MMDRV_MidiIn_Map16To32A [internal] - */ -static WINMM_MapType MMDRV_MidiIn_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_MidiIn_UnMap16To32A [internal] - */ -static WINMM_MapType MMDRV_MidiIn_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_MidiIn_Map32ATo16 [internal] - */ -static WINMM_MapType MMDRV_MidiIn_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_MidiIn_UnMap32ATo16 [internal] - */ -static WINMM_MapType MMDRV_MidiIn_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - return WINMM_MAP_MSGERROR; -} - -/************************************************************************** - * MMDRV_MidiIn_Callback [internal] - */ -static void CALLBACK MMDRV_MidiIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) -{ - LPWINE_MLD mld = (LPWINE_MLD)dwInstance; - - switch (uMsg) { - case MIM_OPEN: - case MIM_CLOSE: - /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */ - - case MIM_DATA: - case MIM_MOREDATA: - case MIM_ERROR: - /* dwParam1 & dwParam2 are are data, nothing to do */ - break; - case MIM_LONGDATA: - case MIM_LONGERROR: - /* dwParam1 points to a MidiHdr, work to be done !!! */ - if (mld->bFrom32 && !MMDrvs[mld->mmdIndex].bIs32) { - /* initial map is: 32 => 16 */ - LPMIDIHDR mh16 = MapSL(dwParam1); - LPMIDIHDR mh32 = *(LPMIDIHDR*)((LPSTR)mh16 - sizeof(LPMIDIHDR)); - - dwParam1 = (DWORD)mh32; - mh32->dwFlags = mh16->dwFlags; - mh32->dwBytesRecorded = mh16->dwBytesRecorded; - if (mh32->reserved >= sizeof(MIDIHDR)) - mh32->dwOffset = mh16->dwOffset; - } else if (!mld->bFrom32 && MMDrvs[mld->mmdIndex].bIs32) { - /* initial map is: 16 => 32 */ - LPMIDIHDR mh32 = (LPMIDIHDR)(dwParam1); - SEGPTR segmh16 = *(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR)); - LPMIDIHDR mh16 = MapSL(segmh16); - - dwParam1 = (DWORD)segmh16; - mh16->dwFlags = mh32->dwFlags; - mh16->dwBytesRecorded = mh32->dwBytesRecorded; - if (mh16->reserved >= sizeof(MIDIHDR)) - mh16->dwOffset = mh32->dwOffset; - } - /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/ - break; - /* case MOM_POSITIONCB: */ - default: - ERR("Unknown msg %u\n", uMsg); - } - - MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); -} - -/* ================================= - * M I D I O U T M A P P E R S - * ================================= */ - -/************************************************************************** - * MMDRV_MidiOut_Map16To32A [internal] - */ -static WINMM_MapType MMDRV_MidiOut_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case MODM_GETNUMDEVS: - case MODM_DATA: - case MODM_RESET: - case MODM_SETVOLUME: - ret = WINMM_MAP_OK; - break; - - case MODM_OPEN: - case MODM_CLOSE: - case MODM_GETVOLUME: - FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n"); - break; - - case MODM_GETDEVCAPS: - { - LPMIDIOUTCAPSA moc32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMIDIOUTCAPS16) + sizeof(MIDIOUTCAPSA)); - LPMIDIOUTCAPS16 moc16 = MapSL(*lpParam1); - - if (moc32) { - *(LPMIDIOUTCAPS16*)moc32 = moc16; - moc32 = (LPMIDIOUTCAPSA)((LPSTR)moc32 + sizeof(LPMIDIOUTCAPS16)); - *lpParam1 = (DWORD)moc32; - *lpParam2 = sizeof(MIDIOUTCAPSA); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case MODM_PREPARE: - { - LPMIDIHDR mh32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMIDIHDR) + sizeof(MIDIHDR)); - LPMIDIHDR mh16 = MapSL(*lpParam1); - - if (mh32) { - *(LPMIDIHDR*)mh32 = (LPMIDIHDR)*lpParam1; - mh32 = (LPMIDIHDR)((LPSTR)mh32 + sizeof(LPMIDIHDR)); - mh32->lpData = MapSL((SEGPTR)mh16->lpData); - mh32->dwBufferLength = mh16->dwBufferLength; - mh32->dwBytesRecorded = mh16->dwBytesRecorded; - mh32->dwUser = mh16->dwUser; - mh32->dwFlags = mh16->dwFlags; - /* FIXME: nothing on mh32->lpNext */ - /* could link the mh32->lpNext at this level for memory house keeping */ - mh32->dwOffset = (*lpParam2 >= sizeof(MIDIHDR)) ? ((LPMIDIHDR)mh16)->dwOffset : 0; - mh16->lpNext = mh32; /* for reuse in unprepare and write */ - /* store size of passed MIDIHDR?? structure to know if dwOffset is available or not */ - mh16->reserved = *lpParam2; - *lpParam1 = (DWORD)mh32; - *lpParam2 = sizeof(MIDIHDR); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case MODM_UNPREPARE: - case MODM_LONGDATA: - { - LPMIDIHDR mh16 = MapSL(*lpParam1); - LPMIDIHDR mh32 = (LPMIDIHDR)mh16->lpNext; - - *lpParam1 = (DWORD)mh32; - *lpParam2 = sizeof(MIDIHDR); - /* dwBufferLength can be reduced between prepare & write */ - if (wMsg == MODM_LONGDATA && mh32->dwBufferLength < mh16->dwBufferLength) { - ERR("Size of buffer has been increased from %ld to %ld, keeping initial value\n", - mh32->dwBufferLength, mh16->dwBufferLength); - } else - mh32->dwBufferLength = mh16->dwBufferLength; - ret = WINMM_MAP_OKMEM; - } - break; - - case MODM_CACHEPATCHES: - case MODM_CACHEDRUMPATCHES: - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_MidiOut_UnMap16To32A [internal] - */ -static WINMM_MapType MMDRV_MidiOut_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case MODM_GETNUMDEVS: - case MODM_DATA: - case MODM_RESET: - case MODM_SETVOLUME: - ret = WINMM_MAP_OK; - break; - - case MODM_OPEN: - case MODM_CLOSE: - case MODM_GETVOLUME: - FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n"); - break; - - case MODM_GETDEVCAPS: - { - LPMIDIOUTCAPSA moc32 = (LPMIDIOUTCAPSA)(*lpParam1); - LPMIDIOUTCAPS16 moc16 = *(LPMIDIOUTCAPS16*)((LPSTR)moc32 - sizeof(LPMIDIOUTCAPS16)); - - moc16->wMid = moc32->wMid; - moc16->wPid = moc32->wPid; - moc16->vDriverVersion = moc32->vDriverVersion; - strcpy(moc16->szPname, moc32->szPname); - moc16->wTechnology = moc32->wTechnology; - moc16->wVoices = moc32->wVoices; - moc16->wNotes = moc32->wNotes; - moc16->wChannelMask = moc32->wChannelMask; - moc16->dwSupport = moc32->dwSupport; - HeapFree(GetProcessHeap(), 0, (LPSTR)moc32 - sizeof(LPMIDIOUTCAPS16)); - ret = WINMM_MAP_OK; - } - break; - case MODM_PREPARE: - case MODM_UNPREPARE: - case MODM_LONGDATA: - { - LPMIDIHDR mh32 = (LPMIDIHDR)(*lpParam1); - LPMIDIHDR mh16 = MapSL(*(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR))); - - assert(mh16->lpNext == mh32); - mh16->dwBufferLength = mh32->dwBufferLength; - mh16->dwBytesRecorded = mh32->dwBytesRecorded; - mh16->dwUser = mh32->dwUser; - mh16->dwFlags = mh32->dwFlags; - if (mh16->reserved >= sizeof(MIDIHDR)) - mh16->dwOffset = mh32->dwOffset; - - if (wMsg == MODM_UNPREPARE) { - HeapFree(GetProcessHeap(), 0, (LPSTR)mh32 - sizeof(LPMIDIHDR)); - mh16->lpNext = 0; - } - ret = WINMM_MAP_OK; - } - break; - - case MODM_CACHEPATCHES: - case MODM_CACHEDRUMPATCHES: - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_MidiOut_Map32ATo16 [internal] - */ -static WINMM_MapType MMDRV_MidiOut_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case MODM_CLOSE: - case MODM_GETNUMDEVS: - case MODM_DATA: - case MODM_RESET: - case MODM_SETVOLUME: - ret = WINMM_MAP_OK; - break; - case MODM_GETDEVCAPS: - { - LPMIDIOUTCAPSA moc32 = (LPMIDIOUTCAPSA)*lpParam1; - LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMIDIOUTCAPSA)+sizeof(MIDIOUTCAPS16)); - - if (ptr) { - *(LPMIDIOUTCAPSA*)ptr = moc32; - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - *lpParam1 = (DWORD)MapLS(ptr) + sizeof(LPMIDIOUTCAPSA); - *lpParam2 = sizeof(MIDIOUTCAPS16); - } - break; - case MODM_PREPARE: - { - LPMIDIHDR mh32 = (LPMIDIHDR)*lpParam1; - LPMIDIHDR mh16; - LPVOID ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPMIDIHDR) + sizeof(MIDIHDR) + mh32->dwBufferLength); - - if (ptr) { - *(LPMIDIHDR*)ptr = mh32; - mh16 = (LPMIDIHDR)((LPSTR)ptr + sizeof(LPMIDIHDR)); - *lpParam1 = MapLS(mh16); - mh16->lpData = (LPSTR)*lpParam1 + sizeof(MIDIHDR); - /* data will be copied on WODM_WRITE */ - mh16->dwBufferLength = mh32->dwBufferLength; - mh16->dwBytesRecorded = mh32->dwBytesRecorded; - mh16->dwUser = mh32->dwUser; - mh16->dwFlags = mh32->dwFlags; - /* FIXME: nothing on mh32->lpNext */ - /* could link the mh32->lpNext at this level for memory house keeping */ - mh16->dwOffset = (*lpParam2 >= sizeof(MIDIHDR)) ? mh32->dwOffset : 0; - - mh32->lpNext = (LPMIDIHDR)mh16; /* for reuse in unprepare and write */ - mh32->reserved = *lpParam2; - - TRACE("mh16=%08lx mh16->lpData=%08lx mh32->buflen=%lu mh32->lpData=%08lx\n", - *lpParam1, (DWORD)mh16->lpData, - mh32->dwBufferLength, (DWORD)mh32->lpData); - *lpParam2 = sizeof(MIDIHDR); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case MODM_UNPREPARE: - case MODM_LONGDATA: - { - LPMIDIHDR mh32 = (LPMIDIHDR)(*lpParam1); - LPMIDIHDR mh16 = (LPMIDIHDR)mh32->lpNext; - LPSTR ptr = (LPSTR)mh16 - sizeof(LPMIDIHDR); - - assert(*(LPMIDIHDR*)ptr == mh32); - - if (wMsg == MODM_LONGDATA) - memcpy((LPSTR)mh16 + sizeof(MIDIHDR), mh32->lpData, mh32->dwBufferLength); - - *lpParam1 = MapLS(mh16); - *lpParam2 = sizeof(MIDIHDR); - TRACE("mh16=%08lx mh16->lpData=%08lx mh32->buflen=%lu mh32->lpData=%08lx\n", - *lpParam1, (DWORD)mh16->lpData, mh32->dwBufferLength, (DWORD)mh32->lpData); - - /* dwBufferLength can be reduced between prepare & write */ - if (wMsg == MODM_LONGDATA && mh16->dwBufferLength < mh32->dwBufferLength) { - ERR("Size of buffer has been increased from %ld to %ld, keeping initial value\n", - mh16->dwBufferLength, mh32->dwBufferLength); - } else - mh16->dwBufferLength = mh32->dwBufferLength; - ret = WINMM_MAP_OKMEM; - } - break; - case MODM_OPEN: - { - LPMIDIOPENDESC mod32 = (LPMIDIOPENDESC)*lpParam1; - LPVOID ptr; - LPMIDIOPENDESC16 mod16; - - /* allocated data are mapped as follows: - LPMIDIOPENDESC ptr to orig lParam1 - DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance - DWORD dwUser passed to driver - MIDIOPENDESC16 mod16: openDesc passed to driver - MIDIOPENSTRMID cIds - */ - ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPMIDIOPENDESC) + 2*sizeof(DWORD) + sizeof(MIDIOPENDESC16) + - mod32->cIds ? (mod32->cIds - 1) * sizeof(MIDIOPENSTRMID) : 0); - - if (ptr) { - SEGPTR segptr = MapLS(ptr); - *(LPMIDIOPENDESC*)ptr = mod32; - *(LPDWORD)((char*)ptr + sizeof(LPMIDIOPENDESC)) = *lpdwUser; - mod16 = (LPMIDIOPENDESC16)((LPSTR)ptr + sizeof(LPMIDIOPENDESC) + 2*sizeof(DWORD)); - - mod16->hMidi = HMIDI_16(mod32->hMidi); - mod16->dwCallback = mod32->dwCallback; - mod16->dwInstance = mod32->dwInstance; - mod16->dnDevNode = mod32->dnDevNode; - mod16->cIds = mod32->cIds; - memcpy(&mod16->rgIds, &mod32->rgIds, mod32->cIds * sizeof(MIDIOPENSTRMID)); - - *lpParam1 = (DWORD)segptr + sizeof(LPMIDIOPENDESC) + 2*sizeof(DWORD); - *lpdwUser = (DWORD)segptr + sizeof(LPMIDIOPENDESC) + sizeof(DWORD); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case MODM_GETVOLUME: - case MODM_CACHEPATCHES: - case MODM_CACHEDRUMPATCHES: - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_MidiOut_UnMap32ATo16 [internal] - */ -static WINMM_MapType MMDRV_MidiOut_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case MODM_CLOSE: - case MODM_GETNUMDEVS: - case MODM_DATA: - case MODM_RESET: - case MODM_SETVOLUME: - ret = WINMM_MAP_OK; - break; - case MODM_GETDEVCAPS: - { - LPMIDIOUTCAPS16 moc16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)moc16 - sizeof(LPMIDIOUTCAPSA); - LPMIDIOUTCAPSA moc32 = *(LPMIDIOUTCAPSA*)ptr; - - moc32->wMid = moc16->wMid; - moc32->wPid = moc16->wPid; - moc32->vDriverVersion = moc16->vDriverVersion; - strcpy(moc32->szPname, moc16->szPname); - moc32->wTechnology = moc16->wTechnology; - moc32->wVoices = moc16->wVoices; - moc32->wNotes = moc16->wNotes; - moc32->wChannelMask = moc16->wChannelMask; - moc32->dwSupport = moc16->dwSupport; - UnMapLS( *lpParam1 ); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case MODM_PREPARE: - case MODM_UNPREPARE: - case MODM_LONGDATA: - { - LPMIDIHDR mh16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)mh16 - sizeof(LPMIDIHDR); - LPMIDIHDR mh32 = *(LPMIDIHDR*)ptr; - - assert(mh32->lpNext == (LPMIDIHDR)mh16); - UnMapLS( *lpParam1 ); - mh32->dwBytesRecorded = mh16->dwBytesRecorded; - mh32->dwUser = mh16->dwUser; - mh32->dwFlags = mh16->dwFlags; - - if (wMsg == MODM_UNPREPARE) { - HeapFree( GetProcessHeap(), 0, ptr ); - mh32->lpNext = 0; - } - ret = WINMM_MAP_OK; - } - break; - case MODM_OPEN: - { - LPMIDIOPENDESC16 mod16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)mod16 - sizeof(LPMIDIOPENDESC) - 2*sizeof(DWORD); - UnMapLS( *lpParam1 ); - **(DWORD**)(ptr + sizeof(LPMIDIOPENDESC)) = *(LPDWORD)(ptr + sizeof(LPMIDIOPENDESC) + sizeof(DWORD)); - - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case MODM_GETVOLUME: - case MODM_CACHEPATCHES: - case MODM_CACHEDRUMPATCHES: - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_MidiOut_Callback [internal] - */ -static void CALLBACK MMDRV_MidiOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) -{ - LPWINE_MLD mld = (LPWINE_MLD)dwInstance; - - switch (uMsg) { - case MOM_OPEN: - case MOM_CLOSE: - /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */ - break; - case MOM_DONE: - if (mld->bFrom32 && !MMDrvs[mld->mmdIndex].bIs32) { - /* initial map is: 32 => 16 */ - LPMIDIHDR mh16 = MapSL(dwParam1); - LPMIDIHDR mh32 = *(LPMIDIHDR*)((LPSTR)mh16 - sizeof(LPMIDIHDR)); - - dwParam1 = (DWORD)mh32; - mh32->dwFlags = mh16->dwFlags; - mh32->dwOffset = mh16->dwOffset; - if (mh32->reserved >= sizeof(MIDIHDR)) - mh32->dwOffset = mh16->dwOffset; - } else if (!mld->bFrom32 && MMDrvs[mld->mmdIndex].bIs32) { - /* initial map is: 16 => 32 */ - LPMIDIHDR mh32 = (LPMIDIHDR)(dwParam1); - SEGPTR segmh16 = *(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR)); - LPMIDIHDR mh16 = MapSL(segmh16); - - dwParam1 = (DWORD)segmh16; - mh16->dwFlags = mh32->dwFlags; - if (mh16->reserved >= sizeof(MIDIHDR)) - mh16->dwOffset = mh32->dwOffset; - } - /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/ - break; - /* case MOM_POSITIONCB: */ - default: - ERR("Unknown msg %u\n", uMsg); - } - - MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); -} - -/* ================================= - * W A V E I N M A P P E R S - * ================================= */ - -/************************************************************************** - * MMDRV_WaveIn_Map16To32A [internal] - */ -static WINMM_MapType MMDRV_WaveIn_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case WIDM_GETNUMDEVS: - case WIDM_RESET: - case WIDM_START: - case WIDM_STOP: - ret = WINMM_MAP_OK; - break; - case WIDM_OPEN: - case WIDM_CLOSE: - FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n"); - break; - case WIDM_GETDEVCAPS: - { - LPWAVEINCAPSA wic32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEINCAPS16) + sizeof(WAVEINCAPSA)); - LPWAVEINCAPS16 wic16 = MapSL(*lpParam1); - - if (wic32) { - *(LPWAVEINCAPS16*)wic32 = wic16; - wic32 = (LPWAVEINCAPSA)((LPSTR)wic32 + sizeof(LPWAVEINCAPS16)); - *lpParam1 = (DWORD)wic32; - *lpParam2 = sizeof(WAVEINCAPSA); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WIDM_GETPOS: - { - LPMMTIME mmt32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMMTIME16) + sizeof(MMTIME)); - LPMMTIME16 mmt16 = MapSL(*lpParam1); - - if (mmt32) { - *(LPMMTIME16*)mmt32 = mmt16; - mmt32 = (LPMMTIME)((LPSTR)mmt32 + sizeof(LPMMTIME16)); - - mmt32->wType = mmt16->wType; - *lpParam1 = (DWORD)mmt32; - *lpParam2 = sizeof(MMTIME); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WIDM_PREPARE: - { - LPWAVEHDR wh32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEHDR) + sizeof(WAVEHDR)); - LPWAVEHDR wh16 = MapSL(*lpParam1); - - if (wh32) { - *(LPWAVEHDR*)wh32 = (LPWAVEHDR)*lpParam1; - wh32 = (LPWAVEHDR)((LPSTR)wh32 + sizeof(LPWAVEHDR)); - wh32->lpData = MapSL((SEGPTR)wh16->lpData); - wh32->dwBufferLength = wh16->dwBufferLength; - wh32->dwBytesRecorded = wh16->dwBytesRecorded; - wh32->dwUser = wh16->dwUser; - wh32->dwFlags = wh16->dwFlags; - wh32->dwLoops = wh16->dwLoops; - /* FIXME: nothing on wh32->lpNext */ - /* could link the wh32->lpNext at this level for memory house keeping */ - wh16->lpNext = wh32; /* for reuse in unprepare and write */ - *lpParam1 = (DWORD)wh32; - *lpParam2 = sizeof(WAVEHDR); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WIDM_ADDBUFFER: - case WIDM_UNPREPARE: - { - LPWAVEHDR wh16 = MapSL(*lpParam1); - LPWAVEHDR wh32 = (LPWAVEHDR)wh16->lpNext; - - *lpParam1 = (DWORD)wh32; - *lpParam2 = sizeof(WAVEHDR); - /* dwBufferLength can be reduced between prepare & write */ - if (wMsg == WIDM_ADDBUFFER && wh32->dwBufferLength < wh16->dwBufferLength) { - ERR("Size of buffer has been increased from %ld to %ld, keeping initial value\n", - wh32->dwBufferLength, wh16->dwBufferLength); - } else - wh32->dwBufferLength = wh16->dwBufferLength; - ret = WINMM_MAP_OKMEM; - } - break; - case WIDM_MAPPER_STATUS: - /* just a single DWORD */ - *lpParam2 = (DWORD)MapSL(*lpParam2); - ret = WINMM_MAP_OK; - break; - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_WaveIn_UnMap16To32A [internal] - */ -static WINMM_MapType MMDRV_WaveIn_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case WIDM_GETNUMDEVS: - case WIDM_RESET: - case WIDM_START: - case WIDM_STOP: - case WIDM_MAPPER_STATUS: - ret = WINMM_MAP_OK; - break; - case WIDM_OPEN: - case WIDM_CLOSE: - FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n"); - break; - case WIDM_GETDEVCAPS: - { - LPWAVEINCAPSA wic32 = (LPWAVEINCAPSA)(*lpParam1); - LPWAVEINCAPS16 wic16 = *(LPWAVEINCAPS16*)((LPSTR)wic32 - sizeof(LPWAVEINCAPS16)); - - wic16->wMid = wic32->wMid; - wic16->wPid = wic32->wPid; - wic16->vDriverVersion = wic32->vDriverVersion; - strcpy(wic16->szPname, wic32->szPname); - wic16->dwFormats = wic32->dwFormats; - wic16->wChannels = wic32->wChannels; - HeapFree(GetProcessHeap(), 0, (LPSTR)wic32 - sizeof(LPWAVEINCAPS16)); - ret = WINMM_MAP_OK; - } - break; - case WIDM_GETPOS: - { - LPMMTIME mmt32 = (LPMMTIME)(*lpParam1); - LPMMTIME16 mmt16 = *(LPMMTIME16*)((LPSTR)mmt32 - sizeof(LPMMTIME16)); - - MMSYSTEM_MMTIME32to16(mmt16, mmt32); - HeapFree(GetProcessHeap(), 0, (LPSTR)mmt32 - sizeof(LPMMTIME16)); - ret = WINMM_MAP_OK; - } - break; - case WIDM_ADDBUFFER: - case WIDM_PREPARE: - case WIDM_UNPREPARE: - { - LPWAVEHDR wh32 = (LPWAVEHDR)(*lpParam1); - LPWAVEHDR wh16 = MapSL(*(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR))); - - assert(wh16->lpNext == wh32); - wh16->dwBufferLength = wh32->dwBufferLength; - wh16->dwBytesRecorded = wh32->dwBytesRecorded; - wh16->dwUser = wh32->dwUser; - wh16->dwFlags = wh32->dwFlags; - wh16->dwLoops = wh32->dwLoops; - - if (wMsg == WIDM_UNPREPARE) { - HeapFree(GetProcessHeap(), 0, (LPSTR)wh32 - sizeof(LPWAVEHDR)); - wh16->lpNext = 0; - } - ret = WINMM_MAP_OK; - } - break; - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_WaveIn_Map32ATo16 [internal] - */ -static WINMM_MapType MMDRV_WaveIn_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case WIDM_CLOSE: - case WIDM_GETNUMDEVS: - case WIDM_RESET: - case WIDM_START: - case WIDM_STOP: - ret = WINMM_MAP_OK; - break; - - case WIDM_OPEN: - { - LPWAVEOPENDESC wod32 = (LPWAVEOPENDESC)*lpParam1; - int sz = sizeof(WAVEFORMATEX); - LPVOID ptr; - LPWAVEOPENDESC16 wod16; - - /* allocated data are mapped as follows: - LPWAVEOPENDESC ptr to orig lParam1 - DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance - DWORD dwUser passed to driver - WAVEOPENDESC16 wod16: openDesc passed to driver - WAVEFORMATEX openDesc->lpFormat passed to driver - xxx extra bytes to WAVEFORMATEX - */ - if (wod32->lpFormat->wFormatTag != WAVE_FORMAT_PCM) { - TRACE("Allocating %u extra bytes (%d)\n", ((LPWAVEFORMATEX)wod32->lpFormat)->cbSize, wod32->lpFormat->wFormatTag); - sz += ((LPWAVEFORMATEX)wod32->lpFormat)->cbSize; - } - - ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16) + sz); - - if (ptr) { - SEGPTR seg_ptr = MapLS( ptr ); - *(LPWAVEOPENDESC*)ptr = wod32; - *(LPDWORD)((char*)ptr + sizeof(LPWAVEOPENDESC)) = *lpdwUser; - wod16 = (LPWAVEOPENDESC16)((LPSTR)ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD)); - - wod16->hWave = HWAVE_16(wod32->hWave); - wod16->lpFormat = (LPWAVEFORMATEX)(seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16)); - memcpy(wod16 + 1, wod32->lpFormat, sz); - - wod16->dwCallback = wod32->dwCallback; - wod16->dwInstance = wod32->dwInstance; - wod16->uMappedDeviceID = wod32->uMappedDeviceID; - wod16->dnDevNode = wod32->dnDevNode; - - *lpParam1 = seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD); - *lpdwUser = seg_ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WIDM_PREPARE: - { - LPWAVEHDR wh32 = (LPWAVEHDR)*lpParam1; - LPWAVEHDR wh16; - LPVOID ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPWAVEHDR) + sizeof(WAVEHDR) + wh32->dwBufferLength); - - if (ptr) { - SEGPTR seg_ptr = MapLS( ptr ); - *(LPWAVEHDR*)ptr = wh32; - wh16 = (LPWAVEHDR)((LPSTR)ptr + sizeof(LPWAVEHDR)); - wh16->lpData = (LPSTR)seg_ptr + sizeof(LPWAVEHDR) + sizeof(WAVEHDR); - /* data will be copied on WODM_WRITE */ - wh16->dwBufferLength = wh32->dwBufferLength; - wh16->dwBytesRecorded = wh32->dwBytesRecorded; - wh16->dwUser = wh32->dwUser; - wh16->dwFlags = wh32->dwFlags; - wh16->dwLoops = wh32->dwLoops; - /* FIXME: nothing on wh32->lpNext */ - /* could link the wh32->lpNext at this level for memory house keeping */ - wh32->lpNext = wh16; /* for reuse in unprepare and write */ - TRACE("wh16=%08lx wh16->lpData=%08lx wh32->buflen=%lu wh32->lpData=%08lx\n", - seg_ptr + sizeof(LPWAVEHDR), (DWORD)wh16->lpData, - wh32->dwBufferLength, (DWORD)wh32->lpData); - *lpParam1 = seg_ptr + sizeof(LPWAVEHDR); - *lpParam2 = sizeof(WAVEHDR); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WIDM_ADDBUFFER: - case WIDM_UNPREPARE: - { - LPWAVEHDR wh32 = (LPWAVEHDR)(*lpParam1); - LPWAVEHDR wh16 = wh32->lpNext; - LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR); - SEGPTR seg_ptr = MapLS( ptr ); - - assert(*(LPWAVEHDR*)ptr == wh32); - - TRACE("wh16=%08lx wh16->lpData=%08lx wh32->buflen=%lu wh32->lpData=%08lx\n", - seg_ptr + sizeof(LPWAVEHDR), (DWORD)wh16->lpData, - wh32->dwBufferLength, (DWORD)wh32->lpData); - - if (wMsg == WIDM_ADDBUFFER) - memcpy((LPSTR)wh16 + sizeof(WAVEHDR), wh32->lpData, wh32->dwBufferLength); - - *lpParam1 = seg_ptr + sizeof(LPWAVEHDR); - *lpParam2 = sizeof(WAVEHDR); - /* dwBufferLength can be reduced between prepare & write */ - if (wMsg == WIDM_ADDBUFFER && wh16->dwBufferLength < wh32->dwBufferLength) { - ERR("Size of buffer has been increased from %ld to %ld, keeping initial value\n", - wh16->dwBufferLength, wh32->dwBufferLength); - } else - wh16->dwBufferLength = wh32->dwBufferLength; - ret = WINMM_MAP_OKMEM; - } - break; - case WIDM_GETDEVCAPS: - { - LPWAVEINCAPSA wic32 = (LPWAVEINCAPSA)*lpParam1; - LPSTR ptr = HeapAlloc( GetProcessHeap(), 0 ,sizeof(LPWAVEINCAPSA) + sizeof(WAVEINCAPS16)); - - if (ptr) { - *(LPWAVEINCAPSA*)ptr = wic32; - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - *lpParam1 = MapLS(ptr) + sizeof(LPWAVEINCAPSA); - *lpParam2 = sizeof(WAVEINCAPS16); - } - break; - case WIDM_GETPOS: - { - LPMMTIME mmt32 = (LPMMTIME)*lpParam1; - LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMMTIME) + sizeof(MMTIME16)); - LPMMTIME16 mmt16 = (LPMMTIME16)(ptr + sizeof(LPMMTIME)); - - if (ptr) { - *(LPMMTIME*)ptr = mmt32; - mmt16->wType = mmt32->wType; - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - *lpParam1 = MapLS(ptr) + sizeof(LPMMTIME); - *lpParam2 = sizeof(MMTIME16); - } - break; - case DRVM_MAPPER_STATUS: - { - LPDWORD p32 = (LPDWORD)*lpParam2; - *lpParam2 = MapLS(p32); - ret = WINMM_MAP_OKMEM; - } - break; - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_WaveIn_UnMap32ATo16 [internal] - */ -static WINMM_MapType MMDRV_WaveIn_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - case WIDM_CLOSE: - case WIDM_GETNUMDEVS: - case WIDM_RESET: - case WIDM_START: - case WIDM_STOP: - ret = WINMM_MAP_OK; - break; - - case WIDM_OPEN: - { - LPWAVEOPENDESC16 wod16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)wod16 - sizeof(LPWAVEOPENDESC) - 2*sizeof(DWORD); - LPWAVEOPENDESC wod32 = *(LPWAVEOPENDESC*)ptr; - - UnMapLS( *lpParam1 ); - wod32->uMappedDeviceID = wod16->uMappedDeviceID; - **(DWORD**)(ptr + sizeof(LPWAVEOPENDESC)) = *(LPDWORD)(ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD)); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - - case WIDM_ADDBUFFER: - case WIDM_PREPARE: - case WIDM_UNPREPARE: - { - LPWAVEHDR wh16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR); - LPWAVEHDR wh32 = *(LPWAVEHDR*)ptr; - - assert(wh32->lpNext == wh16); - wh32->dwBytesRecorded = wh16->dwBytesRecorded; - wh32->dwUser = wh16->dwUser; - wh32->dwFlags = wh16->dwFlags; - wh32->dwLoops = wh16->dwLoops; - UnMapLS( *lpParam1 ); - - if (wMsg == WIDM_UNPREPARE) { - HeapFree( GetProcessHeap(), 0, ptr ); - wh32->lpNext = 0; - } - ret = WINMM_MAP_OK; - } - break; - case WIDM_GETDEVCAPS: - { - LPWAVEINCAPS16 wic16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)wic16 - sizeof(LPWAVEINCAPSA); - LPWAVEINCAPSA wic32 = *(LPWAVEINCAPSA*)ptr; - - wic32->wMid = wic16->wMid; - wic32->wPid = wic16->wPid; - wic32->vDriverVersion = wic16->vDriverVersion; - strcpy(wic32->szPname, wic16->szPname); - wic32->dwFormats = wic16->dwFormats; - wic32->wChannels = wic16->wChannels; - UnMapLS( *lpParam1 ); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case WIDM_GETPOS: - { - LPMMTIME16 mmt16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)mmt16 - sizeof(LPMMTIME); - LPMMTIME mmt32 = *(LPMMTIME*)ptr; - - MMSYSTEM_MMTIME16to32(mmt32, mmt16); - UnMapLS( *lpParam1 ); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case DRVM_MAPPER_STATUS: - { - UnMapLS( *lpParam2 ); - ret = WINMM_MAP_OK; - } - break; - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_WaveIn_Callback [internal] - */ -static void CALLBACK MMDRV_WaveIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) -{ - LPWINE_MLD mld = (LPWINE_MLD)dwInstance; - - switch (uMsg) { - case WIM_OPEN: - case WIM_CLOSE: - /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */ - break; - case WIM_DATA: - if (mld->bFrom32 && !MMDrvs[mld->mmdIndex].bIs32) { - /* initial map is: 32 => 16 */ - LPWAVEHDR wh16 = MapSL(dwParam1); - LPWAVEHDR wh32 = *(LPWAVEHDR*)((LPSTR)wh16 - sizeof(LPWAVEHDR)); - - dwParam1 = (DWORD)wh32; - wh32->dwFlags = wh16->dwFlags; - wh32->dwBytesRecorded = wh16->dwBytesRecorded; - } else if (!mld->bFrom32 && MMDrvs[mld->mmdIndex].bIs32) { - /* initial map is: 16 => 32 */ - LPWAVEHDR wh32 = (LPWAVEHDR)(dwParam1); - SEGPTR segwh16 = *(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR)); - LPWAVEHDR wh16 = MapSL(segwh16); - - dwParam1 = (DWORD)segwh16; - wh16->dwFlags = wh32->dwFlags; - wh16->dwBytesRecorded = wh32->dwBytesRecorded; - } - /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/ - break; - default: - ERR("Unknown msg %u\n", uMsg); - } - - MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); -} - -/* ================================= - * W A V E O U T M A P P E R S - * ================================= */ - -/************************************************************************** - * MMDRV_WaveOut_Map16To32A [internal] - */ -static WINMM_MapType MMDRV_WaveOut_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - /* nothing to do */ - case WODM_BREAKLOOP: - case WODM_CLOSE: - case WODM_GETNUMDEVS: - case WODM_PAUSE: - case WODM_RESET: - case WODM_RESTART: - case WODM_SETPITCH: - case WODM_SETPLAYBACKRATE: - case WODM_SETVOLUME: - ret = WINMM_MAP_OK; - break; - - case WODM_GETPITCH: - case WODM_GETPLAYBACKRATE: - case WODM_GETVOLUME: - case WODM_OPEN: - FIXME("Shouldn't be used: the corresponding 16 bit functions use the 32 bit interface\n"); - break; - - case WODM_GETDEVCAPS: - { - LPWAVEOUTCAPSA woc32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEOUTCAPS16) + sizeof(WAVEOUTCAPSA)); - LPWAVEOUTCAPS16 woc16 = MapSL(*lpParam1); - - if (woc32) { - *(LPWAVEOUTCAPS16*)woc32 = woc16; - woc32 = (LPWAVEOUTCAPSA)((LPSTR)woc32 + sizeof(LPWAVEOUTCAPS16)); - *lpParam1 = (DWORD)woc32; - *lpParam2 = sizeof(WAVEOUTCAPSA); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WODM_GETPOS: - { - LPMMTIME mmt32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMMTIME16) + sizeof(MMTIME)); - LPMMTIME16 mmt16 = MapSL(*lpParam1); - - if (mmt32) { - *(LPMMTIME16*)mmt32 = mmt16; - mmt32 = (LPMMTIME)((LPSTR)mmt32 + sizeof(LPMMTIME16)); - - mmt32->wType = mmt16->wType; - *lpParam1 = (DWORD)mmt32; - *lpParam2 = sizeof(MMTIME); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WODM_PREPARE: - { - LPWAVEHDR wh32 = HeapAlloc(GetProcessHeap(), 0, sizeof(LPWAVEHDR) + sizeof(WAVEHDR)); - LPWAVEHDR wh16 = MapSL(*lpParam1); - - if (wh32) { - *(LPWAVEHDR*)wh32 = (LPWAVEHDR)*lpParam1; - wh32 = (LPWAVEHDR)((LPSTR)wh32 + sizeof(LPWAVEHDR)); - wh32->lpData = MapSL((SEGPTR)wh16->lpData); - wh32->dwBufferLength = wh16->dwBufferLength; - wh32->dwBytesRecorded = wh16->dwBytesRecorded; - wh32->dwUser = wh16->dwUser; - wh32->dwFlags = wh16->dwFlags; - wh32->dwLoops = wh16->dwLoops; - /* FIXME: nothing on wh32->lpNext */ - /* could link the wh32->lpNext at this level for memory house keeping */ - wh16->lpNext = wh32; /* for reuse in unprepare and write */ - *lpParam1 = (DWORD)wh32; - *lpParam2 = sizeof(WAVEHDR); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WODM_UNPREPARE: - case WODM_WRITE: - { - LPWAVEHDR wh16 = MapSL(*lpParam1); - LPWAVEHDR wh32 = (LPWAVEHDR)wh16->lpNext; - - *lpParam1 = (DWORD)wh32; - *lpParam2 = sizeof(WAVEHDR); - /* dwBufferLength can be reduced between prepare & write */ - if (wMsg == WODM_WRITE && wh32->dwBufferLength < wh16->dwBufferLength) { - ERR("Size of buffer has been increased from %ld to %ld, keeping initial value\n", - wh32->dwBufferLength, wh16->dwBufferLength); - } else - wh32->dwBufferLength = wh16->dwBufferLength; - ret = WINMM_MAP_OKMEM; - } - break; - case WODM_MAPPER_STATUS: - *lpParam2 = (DWORD)MapSL(*lpParam2); - ret = WINMM_MAP_OK; - break; - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_WaveOut_UnMap16To32A [internal] - */ -static WINMM_MapType MMDRV_WaveOut_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - WINMM_MapType ret = WINMM_MAP_MSGERROR; - - switch (wMsg) { - /* nothing to do */ - case WODM_BREAKLOOP: - case WODM_CLOSE: - case WODM_GETNUMDEVS: - case WODM_PAUSE: - case WODM_RESET: - case WODM_RESTART: - case WODM_SETPITCH: - case WODM_SETPLAYBACKRATE: - case WODM_SETVOLUME: - case WODM_MAPPER_STATUS: - ret = WINMM_MAP_OK; - break; - - case WODM_GETPITCH: - case WODM_GETPLAYBACKRATE: - case WODM_GETVOLUME: - case WODM_OPEN: - FIXME("Shouldn't be used: those 16 bit functions use the 32 bit interface\n"); - break; - - case WODM_GETDEVCAPS: - { - LPWAVEOUTCAPSA woc32 = (LPWAVEOUTCAPSA)(*lpParam1); - LPWAVEOUTCAPS16 woc16 = *(LPWAVEOUTCAPS16*)((LPSTR)woc32 - sizeof(LPWAVEOUTCAPS16)); - - woc16->wMid = woc32->wMid; - woc16->wPid = woc32->wPid; - woc16->vDriverVersion = woc32->vDriverVersion; - strcpy(woc16->szPname, woc32->szPname); - woc16->dwFormats = woc32->dwFormats; - woc16->wChannels = woc32->wChannels; - woc16->dwSupport = woc32->dwSupport; - HeapFree(GetProcessHeap(), 0, (LPSTR)woc32 - sizeof(LPWAVEOUTCAPS16)); - ret = WINMM_MAP_OK; - } - break; - case WODM_GETPOS: - { - LPMMTIME mmt32 = (LPMMTIME)(*lpParam1); - LPMMTIME16 mmt16 = *(LPMMTIME16*)((LPSTR)mmt32 - sizeof(LPMMTIME16)); - - MMSYSTEM_MMTIME32to16(mmt16, mmt32); - HeapFree(GetProcessHeap(), 0, (LPSTR)mmt32 - sizeof(LPMMTIME16)); - ret = WINMM_MAP_OK; - } - break; - case WODM_PREPARE: - case WODM_UNPREPARE: - case WODM_WRITE: - { - LPWAVEHDR wh32 = (LPWAVEHDR)(*lpParam1); - LPWAVEHDR wh16 = MapSL(*(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR))); - - assert(wh16->lpNext == wh32); - wh16->dwBufferLength = wh32->dwBufferLength; - wh16->dwBytesRecorded = wh32->dwBytesRecorded; - wh16->dwUser = wh32->dwUser; - wh16->dwFlags = wh32->dwFlags; - wh16->dwLoops = wh32->dwLoops; - - if (wMsg == WODM_UNPREPARE) { - HeapFree(GetProcessHeap(), 0, (LPSTR)wh32 - sizeof(LPWAVEHDR)); - wh16->lpNext = 0; - } - ret = WINMM_MAP_OK; - } - break; - default: - FIXME("NIY: no conversion yet for %u [%lx,%lx]\n", wMsg, *lpParam1, *lpParam2); - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_WaveOut_Map32ATo16 [internal] - */ -static WINMM_MapType MMDRV_WaveOut_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - WINMM_MapType ret; - - switch (wMsg) { - /* nothing to do */ - case WODM_BREAKLOOP: - case WODM_CLOSE: - case WODM_GETNUMDEVS: - case WODM_PAUSE: - case WODM_RESET: - case WODM_RESTART: - case WODM_SETPITCH: - case WODM_SETPLAYBACKRATE: - case WODM_SETVOLUME: - ret = WINMM_MAP_OK; - break; - - case WODM_GETDEVCAPS: - { - LPWAVEOUTCAPSA woc32 = (LPWAVEOUTCAPSA)*lpParam1; - LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPWAVEOUTCAPSA) + sizeof(WAVEOUTCAPS16)); - - if (ptr) { - *(LPWAVEOUTCAPSA*)ptr = woc32; - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - *lpParam1 = MapLS(ptr) + sizeof(LPWAVEOUTCAPSA); - *lpParam2 = sizeof(WAVEOUTCAPS16); - } - break; - case WODM_GETPITCH: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - case WODM_GETPLAYBACKRATE: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - case WODM_GETPOS: - { - LPMMTIME mmt32 = (LPMMTIME)*lpParam1; - LPSTR ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPMMTIME) + sizeof(MMTIME16)); - LPMMTIME16 mmt16 = (LPMMTIME16)(ptr + sizeof(LPMMTIME)); - - if (ptr) { - *(LPMMTIME*)ptr = mmt32; - mmt16->wType = mmt32->wType; - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - *lpParam1 = MapLS(ptr) + sizeof(LPMMTIME); - *lpParam2 = sizeof(MMTIME16); - } - break; - case WODM_GETVOLUME: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - case WODM_OPEN: - { - LPWAVEOPENDESC wod32 = (LPWAVEOPENDESC)*lpParam1; - int sz = sizeof(WAVEFORMATEX); - LPVOID ptr; - LPWAVEOPENDESC16 wod16; - - /* allocated data are mapped as follows: - LPWAVEOPENDESC ptr to orig lParam1 - DWORD orig dwUser, which is a pointer to DWORD:driver dwInstance - DWORD dwUser passed to driver - WAVEOPENDESC16 wod16: openDesc passed to driver - WAVEFORMATEX openDesc->lpFormat passed to driver - xxx extra bytes to WAVEFORMATEX - */ - if (wod32->lpFormat->wFormatTag != WAVE_FORMAT_PCM) { - TRACE("Allocating %u extra bytes (%d)\n", ((LPWAVEFORMATEX)wod32->lpFormat)->cbSize, wod32->lpFormat->wFormatTag); - sz += ((LPWAVEFORMATEX)wod32->lpFormat)->cbSize; - } - - ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16) + sz); - - if (ptr) { - SEGPTR seg_ptr = MapLS( ptr ); - *(LPWAVEOPENDESC*)ptr = wod32; - *(LPDWORD)((char*)ptr + sizeof(LPWAVEOPENDESC)) = *lpdwUser; - wod16 = (LPWAVEOPENDESC16)((LPSTR)ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD)); - - wod16->hWave = HWAVE_16(wod32->hWave); - wod16->lpFormat = (LPWAVEFORMATEX)(seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD) + sizeof(WAVEOPENDESC16)); - memcpy(wod16 + 1, wod32->lpFormat, sz); - - wod16->dwCallback = wod32->dwCallback; - wod16->dwInstance = wod32->dwInstance; - wod16->uMappedDeviceID = wod32->uMappedDeviceID; - wod16->dnDevNode = wod32->dnDevNode; - - *lpParam1 = seg_ptr + sizeof(LPWAVEOPENDESC) + 2*sizeof(DWORD); - *lpdwUser = seg_ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WODM_PREPARE: - { - LPWAVEHDR wh32 = (LPWAVEHDR)*lpParam1; - LPWAVEHDR wh16; - LPVOID ptr = HeapAlloc( GetProcessHeap(), 0, - sizeof(LPWAVEHDR) + sizeof(WAVEHDR) + wh32->dwBufferLength); - - if (ptr) { - SEGPTR seg_ptr = MapLS( ptr ); - *(LPWAVEHDR*)ptr = wh32; - wh16 = (LPWAVEHDR)((LPSTR)ptr + sizeof(LPWAVEHDR)); - wh16->lpData = (LPSTR)seg_ptr + sizeof(LPWAVEHDR) + sizeof(WAVEHDR); - /* data will be copied on WODM_WRITE */ - wh16->dwBufferLength = wh32->dwBufferLength; - wh16->dwBytesRecorded = wh32->dwBytesRecorded; - wh16->dwUser = wh32->dwUser; - wh16->dwFlags = wh32->dwFlags; - wh16->dwLoops = wh32->dwLoops; - /* FIXME: nothing on wh32->lpNext */ - /* could link the wh32->lpNext at this level for memory house keeping */ - wh32->lpNext = wh16; /* for reuse in unprepare and write */ - TRACE("wh16=%08lx wh16->lpData=%08lx wh32->buflen=%lu wh32->lpData=%08lx\n", - seg_ptr + sizeof(LPWAVEHDR), (DWORD)wh16->lpData, - wh32->dwBufferLength, (DWORD)wh32->lpData); - *lpParam1 = seg_ptr + sizeof(LPWAVEHDR); - *lpParam2 = sizeof(WAVEHDR); - - ret = WINMM_MAP_OKMEM; - } else { - ret = WINMM_MAP_NOMEM; - } - } - break; - case WODM_UNPREPARE: - case WODM_WRITE: - { - LPWAVEHDR wh32 = (LPWAVEHDR)(*lpParam1); - LPWAVEHDR wh16 = wh32->lpNext; - LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR); - SEGPTR seg_ptr = MapLS( ptr ); - - assert(*(LPWAVEHDR*)ptr == wh32); - - TRACE("wh16=%08lx wh16->lpData=%08lx wh32->buflen=%lu wh32->lpData=%08lx\n", - seg_ptr + sizeof(LPWAVEHDR), (DWORD)wh16->lpData, - wh32->dwBufferLength, (DWORD)wh32->lpData); - - if (wMsg == WODM_WRITE) - memcpy((LPSTR)wh16 + sizeof(WAVEHDR), wh32->lpData, wh32->dwBufferLength); - - *lpParam1 = seg_ptr + sizeof(LPWAVEHDR); - *lpParam2 = sizeof(WAVEHDR); - /* dwBufferLength can be reduced between prepare & write */ - if (wMsg == WODM_WRITE && wh16->dwBufferLength < wh32->dwBufferLength) { - ERR("Size of buffer has been increased from %ld to %ld, keeping initial value\n", - wh16->dwBufferLength, wh32->dwBufferLength); - } else - wh16->dwBufferLength = wh32->dwBufferLength; - ret = WINMM_MAP_OKMEM; - } - break; - case DRVM_MAPPER_STATUS: - { - LPDWORD p32 = (LPDWORD)*lpParam2; - *lpParam2 = MapLS(p32); - ret = WINMM_MAP_OKMEM; - } - break; - default: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_WaveOut_UnMap32ATo16 [internal] - */ -static WINMM_MapType MMDRV_WaveOut_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) -{ - WINMM_MapType ret; - - switch (wMsg) { - /* nothing to do */ - case WODM_BREAKLOOP: - case WODM_CLOSE: - case WODM_GETNUMDEVS: - case WODM_PAUSE: - case WODM_RESET: - case WODM_RESTART: - case WODM_SETPITCH: - case WODM_SETPLAYBACKRATE: - case WODM_SETVOLUME: - ret = WINMM_MAP_OK; - break; - - case WODM_GETDEVCAPS: - { - LPWAVEOUTCAPS16 woc16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)woc16 - sizeof(LPWAVEOUTCAPSA); - LPWAVEOUTCAPSA woc32 = *(LPWAVEOUTCAPSA*)ptr; - - woc32->wMid = woc16->wMid; - woc32->wPid = woc16->wPid; - woc32->vDriverVersion = woc16->vDriverVersion; - strcpy(woc32->szPname, woc16->szPname); - woc32->dwFormats = woc16->dwFormats; - woc32->wChannels = woc16->wChannels; - woc32->dwSupport = woc16->dwSupport; - UnMapLS( *lpParam1 ); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case WODM_GETPITCH: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - case WODM_GETPLAYBACKRATE: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - case WODM_GETPOS: - { - LPMMTIME16 mmt16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)mmt16 - sizeof(LPMMTIME); - LPMMTIME mmt32 = *(LPMMTIME*)ptr; - - MMSYSTEM_MMTIME16to32(mmt32, mmt16); - UnMapLS( *lpParam1 ); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case WODM_OPEN: - { - LPWAVEOPENDESC16 wod16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)wod16 - sizeof(LPWAVEOPENDESC) - 2*sizeof(DWORD); - LPWAVEOPENDESC wod32 = *(LPWAVEOPENDESC*)ptr; - - wod32->uMappedDeviceID = wod16->uMappedDeviceID; - **(DWORD**)(ptr + sizeof(LPWAVEOPENDESC)) = *(LPDWORD)(ptr + sizeof(LPWAVEOPENDESC) + sizeof(DWORD)); - UnMapLS( *lpParam1 ); - HeapFree( GetProcessHeap(), 0, ptr ); - ret = WINMM_MAP_OK; - } - break; - case WODM_PREPARE: - case WODM_UNPREPARE: - case WODM_WRITE: - { - LPWAVEHDR wh16 = MapSL(*lpParam1); - LPSTR ptr = (LPSTR)wh16 - sizeof(LPWAVEHDR); - LPWAVEHDR wh32 = *(LPWAVEHDR*)ptr; - - assert(wh32->lpNext == wh16); - wh32->dwBytesRecorded = wh16->dwBytesRecorded; - wh32->dwUser = wh16->dwUser; - wh32->dwFlags = wh16->dwFlags; - wh32->dwLoops = wh16->dwLoops; - - UnMapLS( *lpParam1 ); - if (wMsg == WODM_UNPREPARE) { - HeapFree( GetProcessHeap(), 0, ptr ); - wh32->lpNext = 0; - } - ret = WINMM_MAP_OK; - } - break; - case WODM_GETVOLUME: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - case DRVM_MAPPER_STATUS: - { - UnMapLS( *lpParam2 ); - ret = WINMM_MAP_OK; - } - break; - default: - FIXME("NIY: no conversion yet\n"); - ret = WINMM_MAP_MSGERROR; - break; - } - return ret; -} - -/************************************************************************** - * MMDRV_WaveOut_Callback [internal] - */ -static void CALLBACK MMDRV_WaveOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) -{ - LPWINE_MLD mld = (LPWINE_MLD)dwInstance; - - switch (uMsg) { - case WOM_OPEN: - case WOM_CLOSE: - /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */ - break; - case WOM_DONE: - if (mld->bFrom32 && !MMDrvs[mld->mmdIndex].bIs32) { - /* initial map is: 32 => 16 */ - LPWAVEHDR wh16 = MapSL(dwParam1); - LPWAVEHDR wh32 = *(LPWAVEHDR*)((LPSTR)wh16 - sizeof(LPWAVEHDR)); - - dwParam1 = (DWORD)wh32; - wh32->dwFlags = wh16->dwFlags; - } else if (!mld->bFrom32 && MMDrvs[mld->mmdIndex].bIs32) { - /* initial map is: 16 => 32 */ - LPWAVEHDR wh32 = (LPWAVEHDR)(dwParam1); - SEGPTR segwh16 = *(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR)); - LPWAVEHDR wh16 = MapSL(segwh16); - - dwParam1 = (DWORD)segwh16; - wh16->dwFlags = wh32->dwFlags; - } - /* else { 16 => 16 or 32 => 32, nothing to do, same struct is kept }*/ - break; - default: - ERR("Unknown msg %u\n", uMsg); - } - - MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); -} - -#define A(_x,_y) {#_y, _x, \ -MMDRV_##_y##_Map16To32A, MMDRV_##_y##_UnMap16To32A, \ -MMDRV_##_y##_Map32ATo16, MMDRV_##_y##_UnMap32ATo16, \ -MMDRV_##_y##_Callback, 0, NULL, -1} - -/* Note: the indices of this array must match the definitions - * of the MMDRV_???? manifest constants - */ -static WINE_LLTYPE llTypes[MMDRV_MAX] = { - A(TRUE, Aux), - A(FALSE, Mixer), - A(TRUE, MidiIn), - A(TRUE, MidiOut), - A(TRUE, WaveIn), - A(TRUE, WaveOut), -}; -#undef A - -/************************************************************************** - * MMDRV_GetNum [internal] - */ -UINT MMDRV_GetNum(UINT type) -{ - assert(type < MMDRV_MAX); - return llTypes[type].wMaxId; -} - -/************************************************************************** - * WINE_Message [internal] - */ -DWORD MMDRV_Message(LPWINE_MLD mld, WORD wMsg, DWORD dwParam1, - DWORD dwParam2, BOOL bFrom32) -{ - LPWINE_MM_DRIVER lpDrv; - DWORD ret; - WINE_MM_DRIVER_PART* part; - WINE_LLTYPE* llType = &llTypes[mld->type]; - WINMM_MapType map; - int devID; - - TRACE("(%s %u %u 0x%08lx 0x%08lx 0x%08lx %c)!\n", - llTypes[mld->type].typestr, mld->uDeviceID, wMsg, - mld->dwDriverInstance, dwParam1, dwParam2, bFrom32?'Y':'N'); - - if (mld->uDeviceID == (UINT16)-1) { - if (!llType->bSupportMapper) { - WARN("uDev=-1 requested on non-mappable ll type %s\n", - llTypes[mld->type].typestr); - return MMSYSERR_BADDEVICEID; - } - devID = -1; - } else { - if (mld->uDeviceID >= llType->wMaxId) { - WARN("uDev(%u) requested >= max (%d)\n", mld->uDeviceID, llType->wMaxId); - return MMSYSERR_BADDEVICEID; - } - devID = mld->uDeviceID; - } - - lpDrv = &MMDrvs[mld->mmdIndex]; - part = &lpDrv->parts[mld->type]; - -#if 0 - /* some sanity checks */ - if (!(part->nIDMin <= devID)) - ERR("!(part->nIDMin(%d) <= devID(%d))\n", part->nIDMin, devID); - if (!(devID < part->nIDMax)) - ERR("!(devID(%d) < part->nIDMax(%d))\n", devID, part->nIDMax); -#endif - - if (lpDrv->bIs32) { - assert(part->u.fnMessage32); - - if (bFrom32) { - TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n", - mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - ret = part->u.fnMessage32(mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - TRACE("=> %lu\n", ret); - } else { - map = llType->Map16To32A(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); - switch (map) { - case WINMM_MAP_NOMEM: - ret = MMSYSERR_NOMEM; - break; - case WINMM_MAP_MSGERROR: - FIXME("NIY: no conversion yet 16->32 (%u)\n", wMsg); - ret = MMSYSERR_ERROR; - break; - case WINMM_MAP_OK: - case WINMM_MAP_OKMEM: - TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n", - mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - ret = part->u.fnMessage32(mld->uDeviceID, wMsg, mld->dwDriverInstance, - dwParam1, dwParam2); - TRACE("=> %lu\n", ret); - if (map == WINMM_MAP_OKMEM) - llType->UnMap16To32A(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); - break; - default: - FIXME("NIY ?\n"); - ret = MMSYSERR_NOTSUPPORTED; - break; - } - } - } else { - assert(part->u.fnMessage16); - - if (bFrom32) { - map = llType->Map32ATo16(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); - switch (map) { - case WINMM_MAP_NOMEM: - ret = MMSYSERR_NOMEM; - break; - case WINMM_MAP_MSGERROR: - FIXME("NIY: no conversion yet 32->16 (%u)\n", wMsg); - ret = MMSYSERR_ERROR; - break; - case WINMM_MAP_OK: - case WINMM_MAP_OKMEM: - TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n", - mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - ret = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, mld->uDeviceID, - wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - TRACE("=> %lu\n", ret); - if (map == WINMM_MAP_OKMEM) - llType->UnMap32ATo16(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); - break; - default: - FIXME("NIY\n"); - ret = MMSYSERR_NOTSUPPORTED; - break; - } - } else { - TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n", - mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - ret = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, mld->uDeviceID, - wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - TRACE("=> %lu\n", ret); - } - } - return ret; -} - -/************************************************************************** - * MMDRV_Alloc [internal] - */ -LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags, - DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32) -{ - LPWINE_MLD mld; - - mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); - if (!mld) return NULL; - - /* find an empty slot in MM_MLDrvs table */ - for (*hndl = 0; *hndl < MAX_MM_MLDRVS; (*hndl)++) { - if (!MM_MLDrvs[(UINT)*hndl]) break; - } - if (*hndl == MAX_MM_MLDRVS) { - /* the MM_MLDrvs table could be made growable in the future if needed */ - ERR("Too many open drivers\n"); - return NULL; - } - MM_MLDrvs[(UINT)*hndl] = mld; - *hndl = (HANDLE)((UINT)*hndl | 0x8000); - - mld->type = type; - if ((UINT)*hndl < MMDRV_GetNum(type) || HIWORD(*hndl) != 0) { - /* FIXME: those conditions must be fulfilled so that: - * - we can distinguish between device IDs and handles - * - we can use handles as 16 or 32 bit entities - */ - ERR("Shouldn't happen. Bad allocation scheme\n"); - } - - mld->bFrom32 = bFrom32; - mld->dwFlags = HIWORD(*dwFlags); - mld->dwCallback = *dwCallback; - mld->dwClientInstance = *dwInstance; - - *dwFlags = LOWORD(*dwFlags) | CALLBACK_FUNCTION; - *dwCallback = (DWORD)llTypes[type].Callback; - *dwInstance = (DWORD)mld; /* FIXME: wouldn't some 16 bit drivers only use the loword ? */ - - return mld; -} - -/************************************************************************** - * MMDRV_Free [internal] - */ -void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld) -{ - if ((UINT)hndl & 0x8000) { - unsigned idx = (UINT)hndl & ~0x8000; - if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) { - MM_MLDrvs[idx] = NULL; - HeapFree(GetProcessHeap(), 0, mld); - return; - } - } - ERR("Bad Handle %08x at %p (not freed)\n", hndl, mld); -} - -/************************************************************************** - * MMDRV_Open [internal] - */ -DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwFlags) -{ - DWORD dwRet = MMSYSERR_BADDEVICEID; - DWORD dwInstance; - WINE_LLTYPE* llType = &llTypes[mld->type]; - - mld->dwDriverInstance = (DWORD)&dwInstance; - - if (mld->uDeviceID == (UINT)-1 || mld->uDeviceID == (UINT16)-1) { - TRACE("MAPPER mode requested !\n"); - /* check if mapper is supported by type */ - if (llType->bSupportMapper) { - if (llType->nMapper == -1) { - /* no driver for mapper has been loaded, try a dumb implementation */ - TRACE("No mapper loaded, doing it by hand\n"); - for (mld->uDeviceID = 0; mld->uDeviceID < llType->wMaxId; mld->uDeviceID++) { - if ((dwRet = MMDRV_Open(mld, wMsg, dwParam1, dwFlags)) == MMSYSERR_NOERROR) { - /* to share this function epilog */ - dwInstance = mld->dwDriverInstance; - break; - } - } - } else { - mld->uDeviceID = (UINT16)-1; - mld->mmdIndex = llType->lpMlds[-1].mmdIndex; - TRACE("Setting mmdIndex to %u\n", mld->mmdIndex); - dwRet = MMDRV_Message(mld, wMsg, dwParam1, dwFlags, TRUE); - } - } - } else { - if (mld->uDeviceID < llType->wMaxId) { - mld->mmdIndex = llType->lpMlds[mld->uDeviceID].mmdIndex; - TRACE("Setting mmdIndex to %u\n", mld->mmdIndex); - dwRet = MMDRV_Message(mld, wMsg, dwParam1, dwFlags, TRUE); - } - } - if (dwRet == MMSYSERR_NOERROR) - mld->dwDriverInstance = dwInstance; - return dwRet; -} - -/************************************************************************** - * MMDRV_Close [internal] - */ -DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg) -{ - return MMDRV_Message(mld, wMsg, 0L, 0L, TRUE); -} - -/************************************************************************** - * MMDRV_GetByID [internal] - */ -LPWINE_MLD MMDRV_GetByID(UINT uDevID, UINT type) -{ - if (uDevID < llTypes[type].wMaxId) - return &llTypes[type].lpMlds[uDevID]; - if ((uDevID == (UINT16)-1 || uDevID == (UINT)-1) && llTypes[type].nMapper != -1) - return &llTypes[type].lpMlds[-1]; - return NULL; -} - -/************************************************************************** - * MMDRV_Get [internal] - */ -LPWINE_MLD MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID) -{ - LPWINE_MLD mld = NULL; - - assert(type < MMDRV_MAX); - - if ((UINT)hndl >= llTypes[type].wMaxId && - hndl != (UINT16)-1 && hndl != (UINT)-1) { - if ((UINT)hndl & 0x8000) { - hndl = (HANDLE)((UINT)hndl & ~0x8000); - if (hndl < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) { - mld = MM_MLDrvs[(UINT)hndl]; - if (!mld || !HeapValidate(GetProcessHeap(), 0, mld) || mld->type != type) - mld = NULL; - } - hndl = (HANDLE)((UINT)hndl | 0x8000); - } - } - if (mld == NULL && bCanBeID) { - mld = MMDRV_GetByID((UINT)hndl, type); - } - return mld; -} - -/************************************************************************** - * MMDRV_GetRelated [internal] - */ -LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType, - BOOL bSrcCanBeID, UINT dstType) -{ - LPWINE_MLD mld; - - if ((mld = MMDRV_Get(hndl, srcType, bSrcCanBeID)) != NULL) { - WINE_MM_DRIVER_PART* part = &MMDrvs[mld->mmdIndex].parts[dstType]; - if (part->nIDMin < part->nIDMax) - return MMDRV_GetByID(part->nIDMin, dstType); - } - return NULL; -} - -/************************************************************************** - * MMDRV_PhysicalFeatures [internal] - */ -UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD dwParam1, - DWORD dwParam2) -{ - WINE_MM_DRIVER* lpDrv = &MMDrvs[mld->mmdIndex]; - - TRACE("(%p, %04x, %08lx, %08lx)\n", mld, uMsg, dwParam1, dwParam2); - - /* all those function calls are undocumented */ - switch (uMsg) { - case DRV_QUERYDRVENTRY: - lstrcpynA((LPSTR)dwParam1, lpDrv->drvname, LOWORD(dwParam2)); - break; - case DRV_QUERYDEVNODE: - *(LPDWORD)dwParam1 = 0L; /* should be DevNode */ - break; - case DRV_QUERYNAME: - WARN("NIY QueryName\n"); - break; - case DRV_QUERYDRIVERIDS: - WARN("NIY call VxD\n"); - /* should call VxD MMDEVLDR with (DevNode, dwParam1 and dwParam2) as pmts - * dwParam1 is buffer and dwParam2 is sizeof buffer - * I don't know where the result is stored though - */ - break; - case DRV_QUERYMAPPABLE: - return (lpDrv->bIsMapper) ? 2 : 0; - - case DRV_QUERYDSOUNDIFACE: /* Wine-specific: Retrieve DirectSound interface */ - return MMDRV_Message(mld, uMsg, dwParam1, dwParam2, TRUE); - - default: - WARN("Unknown call %04x\n", uMsg); - return MMSYSERR_INVALPARAM; - } - return 0L; -} - -/************************************************************************** - * MMDRV_InitPerType [internal] - */ -static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg) -{ - WINE_MM_DRIVER_PART* part = &lpDrv->parts[type]; - DWORD ret; - UINT count = 0; - int i, k; - - part->nIDMin = part->nIDMax = 0; - - /* for DRVM_INIT and DRVM_ENABLE, dwParam2 should be PnP node */ - /* the DRVM_ENABLE is only required when the PnP node is non zero */ - - if (lpDrv->bIs32 && part->u.fnMessage32) { - ret = part->u.fnMessage32(0, DRVM_INIT, 0L, 0L, 0L); - TRACE("DRVM_INIT => %08lx\n", ret); -#if 0 - ret = part->u.fnMessage32(0, DRVM_ENABLE, 0L, 0L, 0L); - TRACE("DRVM_ENABLE => %08lx\n", ret); -#endif - count = part->u.fnMessage32(0, wMsg, 0L, 0L, 0L); - } else if (!lpDrv->bIs32 && part->u.fnMessage16) { - ret = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, - 0, DRVM_INIT, 0L, 0L, 0L); - TRACE("DRVM_INIT => %08lx\n", ret); -#if 0 - ret = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, - 0, DRVM_ENABLE, 0L, 0L, 0L); - TRACE("DRVM_ENABLE => %08lx\n", ret); -#endif - count = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, - 0, wMsg, 0L, 0L, 0L); - } else { - return FALSE; - } - - TRACE("Got %u dev for (%s:%s)\n", count, lpDrv->drvname, llTypes[type].typestr); - - /* got some drivers */ - if (lpDrv->bIsMapper) { - /* it seems native mappers return 0 devices :-( */ - if (llTypes[type].nMapper != -1) - ERR("Two mappers for type %s (%d, %s)\n", - llTypes[type].typestr, llTypes[type].nMapper, lpDrv->drvname); - if (count > 1) - ERR("Strange: mapper with %d > 1 devices\n", count); - llTypes[type].nMapper = MMDrvsHi; - } else { - if (count == 0) - return FALSE; - part->nIDMin = llTypes[type].wMaxId; - llTypes[type].wMaxId += count; - part->nIDMax = llTypes[type].wMaxId; - } - TRACE("Setting min=%d max=%d (ttop=%d) for (%s:%s)\n", - part->nIDMin, part->nIDMax, llTypes[type].wMaxId, - lpDrv->drvname, llTypes[type].typestr); - /* realloc translation table */ - llTypes[type].lpMlds = (LPWINE_MLD) - HeapReAlloc(GetProcessHeap(), 0, (llTypes[type].lpMlds) ? llTypes[type].lpMlds - 1 : NULL, - sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)) + 1; - /* re-build the translation table */ - if (llTypes[type].nMapper != -1) { - TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, -1, MMDrvs[llTypes[type].nMapper].drvname); - llTypes[type].lpMlds[-1].uDeviceID = (UINT16)-1; - llTypes[type].lpMlds[-1].type = type; - llTypes[type].lpMlds[-1].mmdIndex = llTypes[type].nMapper; - llTypes[type].lpMlds[-1].dwDriverInstance = 0; - } - for (i = k = 0; i <= MMDrvsHi; i++) { - while (MMDrvs[i].parts[type].nIDMin <= k && k < MMDrvs[i].parts[type].nIDMax) { - TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, k, MMDrvs[i].drvname); - llTypes[type].lpMlds[k].uDeviceID = k; - llTypes[type].lpMlds[k].type = type; - llTypes[type].lpMlds[k].mmdIndex = i; - llTypes[type].lpMlds[k].dwDriverInstance = 0; - k++; - } - } - return TRUE; -} - -/************************************************************************** - * MMDRV_Install [internal] - */ -static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper) -{ - int i, count = 0; - char buffer[128]; - LPWINE_MM_DRIVER lpDrv = &MMDrvs[MMDrvsHi]; - LPWINE_DRIVER d; - - TRACE("('%s', '%s', mapper=%c);\n", drvRegName, drvFileName, bIsMapper ? 'Y' : 'N'); - - /* be sure that size of MMDrvs matches the max number of loadable drivers !! - * if not just increase size of MMDrvs */ - assert(MMDrvsHi <= sizeof(MMDrvs)/sizeof(MMDrvs[0])); - - for (i = 0; i < MMDrvsHi; i++) { - if (!strcmp(drvRegName, MMDrvs[i].drvname)) return FALSE; - } - - memset(lpDrv, 0, sizeof(*lpDrv)); - - if (!(lpDrv->hDriver = OpenDriverA(drvFileName, 0, 0))) { - WARN("Couldn't open driver '%s'\n", drvFileName); - return FALSE; - } - - d = DRIVER_FindFromHDrvr(lpDrv->hDriver); - lpDrv->bIs32 = (d->dwFlags & WINE_GDF_16BIT) ? FALSE : TRUE; - - /* Then look for xxxMessage functions */ -#define AA(_h,_w,_x,_y,_z) \ - func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \ - if (func != NULL) \ - { lpDrv->parts[_w].u.fnMessage##_y = func; count++; \ - TRACE("Got %d bit func '%s'\n", _y, #_x); } - - if (lpDrv->bIs32) { - WINEMM_msgFunc32 func; - - if (d->d.d32.hModule) { -#define A(_x,_y) AA(d->d.d32.hModule,_x,_y,32,GetProcAddress) - A(MMDRV_AUX, auxMessage); - A(MMDRV_MIXER, mixMessage); - A(MMDRV_MIDIIN, midMessage); - A(MMDRV_MIDIOUT, modMessage); - A(MMDRV_WAVEIN, widMessage); - A(MMDRV_WAVEOUT, wodMessage); -#undef A - } - } else { - WINEMM_msgFunc16 func; - - /* - * DESCRIPTION 'wave,aux,mixer:Creative Labs Sound Blaster 16 Driver' - * The beginning of the module description indicates the driver supports - * waveform, auxiliary, and mixer devices. Use one of the following - * device-type names, followed by a colon (:) to indicate the type of - * device your driver supports. If the driver supports more than one - * type of device, separate each device-type name with a comma (,). - * - * wave for waveform audio devices - * wavemapper for wave mappers - * midi for MIDI audio devices - * midimapper for midi mappers - * aux for auxiliary audio devices - * mixer for mixer devices - */ - - if (d->d.d16.hDriver16) { - HMODULE16 hMod16 = GetDriverModuleHandle16(d->d.d16.hDriver16); - -#define A(_x,_y) AA(hMod16,_x,_y,16,GetProcAddress16) - A(MMDRV_AUX, auxMessage); - A(MMDRV_MIXER, mixMessage); - A(MMDRV_MIDIIN, midMessage); - A(MMDRV_MIDIOUT, modMessage); - A(MMDRV_WAVEIN, widMessage); - A(MMDRV_WAVEOUT, wodMessage); -#undef A - } - } -#undef AA - - if (TRACE_ON(mmsys)) { - if ((lpDrv->bIs32) ? MMDRV_GetDescription32(drvFileName, buffer, sizeof(buffer)) : - MMDRV_GetDescription16(drvFileName, buffer, sizeof(buffer))) - TRACE("%s => %s\n", drvFileName, buffer); - else - TRACE("%s => No description\n", drvFileName); - } - - if (!count) { - CloseDriver(lpDrv->hDriver, 0, 0); - WARN("No message functions found\n"); - return FALSE; - } - - /* FIXME: being a mapper or not should be known by another way */ - /* it's known for NE drvs (the description is of the form '*mapper: *' - * I don't have any clue for PE drvs - */ - lpDrv->bIsMapper = bIsMapper; - lpDrv->drvname = strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(drvRegName) + 1), drvRegName); - - /* Finish init and get the count of the devices */ - MMDRV_InitPerType(lpDrv, MMDRV_AUX, AUXDM_GETNUMDEVS); - MMDRV_InitPerType(lpDrv, MMDRV_MIXER, MXDM_GETNUMDEVS); - MMDRV_InitPerType(lpDrv, MMDRV_MIDIIN, MIDM_GETNUMDEVS); - MMDRV_InitPerType(lpDrv, MMDRV_MIDIOUT, MODM_GETNUMDEVS); - MMDRV_InitPerType(lpDrv, MMDRV_WAVEIN, WIDM_GETNUMDEVS); - MMDRV_InitPerType(lpDrv, MMDRV_WAVEOUT, WODM_GETNUMDEVS); - /* FIXME: if all those func calls return FALSE, - * then the driver must be unloaded - */ - - MMDrvsHi++; - - return TRUE; -} - -/************************************************************************** - * MMDRV_InitFromRegistry [internal] - */ -static BOOL MMDRV_InitFromRegistry(void) -{ - HKEY hKey; - char buffer[256]; - char* p1; - char* p2; - DWORD type, size; - BOOL ret = FALSE; - - if (RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\WinMM", &hKey)) { - TRACE("Cannot open WinMM config key\n"); - return FALSE; - } - - size = sizeof(buffer); - if (!RegQueryValueExA(hKey, "Drivers", 0, &type, (LPVOID)buffer, &size)) { - p1 = buffer; - while (p1) { - p2 = strchr(p1, ';'); - if (p2) *p2++ = '\0'; - ret |= MMDRV_Install(p1, p1, FALSE); - p1 = p2; - } - } - - /* finish with mappers */ - size = sizeof(buffer); - if (!RegQueryValueExA(hKey, "WaveMapper", 0, &type, (LPVOID)buffer, &size)) - ret |= MMDRV_Install("wavemapper", buffer, TRUE); - size = sizeof(buffer); - if (!RegQueryValueExA(hKey, "MidiMapper", 0, &type, (LPVOID)buffer, &size)) - ret |= MMDRV_Install("midimapper", buffer, TRUE); - - RegCloseKey(hKey); - - return ret; -} - -/************************************************************************** - * MMDRV_InitHardcoded [internal] - */ -static BOOL MMDRV_InitHardcoded(void) -{ - /* first load hardware drivers */ - MMDRV_Install("wineoss.drv", "wineoss.drv", FALSE); - - /* finish with mappers */ - MMDRV_Install("wavemapper", "msacm.drv", TRUE); - MMDRV_Install("midimapper", "midimap.drv", TRUE); - - return TRUE; -} - -/************************************************************************** - * MMDRV_Init [internal] - */ -BOOL MMDRV_Init(void) -{ - /* FIXME: MMDRV_InitFromRegistry shall be MMDRV_Init in a near future */ - return MMDRV_InitFromRegistry() || MMDRV_InitHardcoded(); -} +/* -*- tab-width: 8; c-basic-offset: 4 -*- */ + +/* + * MMSYTEM low level drivers handling functions + * + * Copyright 1999 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 + */ + +#include +#include +#include +#include "wine/winbase16.h" +#include "winreg.h" +#include "winver.h" +#include "winemm.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mmsys); + +extern WORD CALLBACK MMDRV_CallTo16_word_wwlll(FARPROC16,WORD,WORD,LONG,LONG,LONG); + +/* each known type of driver has an instance of this structure */ +typedef struct tagWINE_LLTYPE { + /* those attributes depend on the specification of the type */ + LPSTR typestr; /* name (for debugging) */ + BOOL bSupportMapper; /* if type is allowed to support mapper */ + MMDRV_MAPFUNC Map16To32A; /* those are function pointers to handle */ + MMDRV_MAPFUNC UnMap16To32A; /* the parameter conversion (16 vs 32 bit) */ + MMDRV_MAPFUNC Map32ATo16; /* when hi-func (in mmsystem or winmm) and */ + MMDRV_MAPFUNC UnMap32ATo16; /* low-func (in .drv) do not match */ + LPDRVCALLBACK Callback; /* handles callback for a specified type */ + /* those attributes reflect the loaded/current situation for the type */ + UINT wMaxId; /* number of loaded devices (sum across all loaded drivers */ + LPWINE_MLD lpMlds; /* "static" mlds to access the part though device IDs */ + int nMapper; /* index to mapper */ +} WINE_LLTYPE; + +static int MMDrvsHi /* = 0 */; +static WINE_MM_DRIVER MMDrvs[3]; +static LPWINE_MLD MM_MLDrvs[40]; +#define MAX_MM_MLDRVS (sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) + +/****************************************************************** + * MMDRV_Is32 + * + */ +BOOL MMDRV_Is32(unsigned int idx) +{ + return MMDrvs[idx].bIs32; +} + +/************************************************************************** + * MMDRV_GetDescription32 [internal] + */ +static BOOL MMDRV_GetDescription32(const char* fname, char* buf, int buflen) +{ + OFSTRUCT ofs; + DWORD h; + LPVOID ptr = 0; + LPVOID val; + DWORD dw; + BOOL ret = FALSE; + UINT u; + FARPROC pGetFileVersionInfoSizeA; + FARPROC pGetFileVersionInfoA; + FARPROC pVerQueryValueA; + HMODULE hmodule = 0; + +#define E(_x) do {TRACE _x;goto theEnd;} while(0) + + if (OpenFile(fname, &ofs, OF_EXIST)==HFILE_ERROR) E(("Can't find file %s\n", fname)); + + if (!(hmodule = LoadLibraryA( "version.dll" ))) goto theEnd; + if (!(pGetFileVersionInfoSizeA = GetProcAddress( hmodule, "GetFileVersionInfoSizeA" ))) + goto theEnd; + if (!(pGetFileVersionInfoA = GetProcAddress( hmodule, "GetFileVersionInfoA" ))) + goto theEnd; + if (!(pVerQueryValueA = GetProcAddress( hmodule, "pVerQueryValueA" ))) + goto theEnd; + + if (!(dw = pGetFileVersionInfoSizeA(ofs.szPathName, &h))) E(("Can't get FVIS\n")); + if (!(ptr = HeapAlloc(GetProcessHeap(), 0, dw))) E(("OOM\n")); + if (!pGetFileVersionInfoA(ofs.szPathName, h, dw, ptr)) E(("Can't get FVI\n")); + +#define A(_x) if (pVerQueryValueA(ptr, "\\StringFileInfo\\040904B0\\" #_x, &val, &u)) \ + TRACE(#_x " => %s\n", (LPSTR)val); else TRACE(#_x " @\n") + + A(CompanyName); + A(FileDescription); + A(FileVersion); + A(InternalName); + A(LegalCopyright); + A(OriginalFilename); + A(ProductName); + A(ProductVersion); + A(Comments); + A(LegalTrademarks); + A(PrivateBuild); + A(SpecialBuild); +#undef A + + if (!pVerQueryValueA(ptr, "\\StringFileInfo\\040904B0\\ProductName", &val, &u)) E(("Can't get product name\n")); + lstrcpynA(buf, val, buflen); + +#undef E + ret = TRUE; +theEnd: + HeapFree(GetProcessHeap(), 0, ptr); + if (hmodule) FreeLibrary( hmodule ); + return ret; +} + +#define A(_x,_y) {#_y, _x, \ +MMDRV_##_y##_Map16To32A, MMDRV_##_y##_UnMap16To32A, \ +MMDRV_##_y##_Map32ATo16, MMDRV_##_y##_UnMap32ATo16, \ +MMDRV_##_y##_Callback, 0, NULL, -1} + +/* Note: the indices of this array must match the definitions + * of the MMDRV_???? manifest constants + */ +static WINE_LLTYPE llTypes[MMDRV_MAX] = { + A(TRUE, Aux), + A(FALSE, Mixer), + A(TRUE, MidiIn), + A(TRUE, MidiOut), + A(TRUE, WaveIn), + A(TRUE, WaveOut), +}; +#undef A + +/************************************************************************** + * MMDRV_GetNum [internal] + */ +UINT MMDRV_GetNum(UINT type) +{ + assert(type < MMDRV_MAX); + return llTypes[type].wMaxId; +} + +/************************************************************************** + * WINE_Message [internal] + */ +DWORD MMDRV_Message(LPWINE_MLD mld, WORD wMsg, DWORD dwParam1, + DWORD dwParam2, BOOL bFrom32) +{ + LPWINE_MM_DRIVER lpDrv; + DWORD ret; + WINE_MM_DRIVER_PART* part; + WINE_LLTYPE* llType = &llTypes[mld->type]; + WINMM_MapType map; + int devID; + + TRACE("(%s %u %u 0x%08lx 0x%08lx 0x%08lx %c)!\n", + llTypes[mld->type].typestr, mld->uDeviceID, wMsg, + mld->dwDriverInstance, dwParam1, dwParam2, bFrom32?'Y':'N'); + + if (mld->uDeviceID == (UINT16)-1) { + if (!llType->bSupportMapper) { + WARN("uDev=-1 requested on non-mappable ll type %s\n", + llTypes[mld->type].typestr); + return MMSYSERR_BADDEVICEID; + } + devID = -1; + } else { + if (mld->uDeviceID >= llType->wMaxId) { + WARN("uDev(%u) requested >= max (%d)\n", mld->uDeviceID, llType->wMaxId); + return MMSYSERR_BADDEVICEID; + } + devID = mld->uDeviceID; + } + + lpDrv = &MMDrvs[mld->mmdIndex]; + part = &lpDrv->parts[mld->type]; + +#if 0 + /* some sanity checks */ + if (!(part->nIDMin <= devID)) + ERR("!(part->nIDMin(%d) <= devID(%d))\n", part->nIDMin, devID); + if (!(devID < part->nIDMax)) + ERR("!(devID(%d) < part->nIDMax(%d))\n", devID, part->nIDMax); +#endif + + if (lpDrv->bIs32) { + assert(part->u.fnMessage32); + + if (bFrom32) { + TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n", + mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); + ret = part->u.fnMessage32(mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); + TRACE("=> %lu\n", ret); + } else { + map = llType->Map16To32A(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); + switch (map) { + case WINMM_MAP_NOMEM: + ret = MMSYSERR_NOMEM; + break; + case WINMM_MAP_MSGERROR: + FIXME("NIY: no conversion yet 16->32 (%u)\n", wMsg); + ret = MMSYSERR_ERROR; + break; + case WINMM_MAP_OK: + case WINMM_MAP_OKMEM: + TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n", + mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); + ret = part->u.fnMessage32(mld->uDeviceID, wMsg, mld->dwDriverInstance, + dwParam1, dwParam2); + TRACE("=> %lu\n", ret); + if (map == WINMM_MAP_OKMEM) + llType->UnMap16To32A(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); + break; + default: + FIXME("NIY ?\n"); + ret = MMSYSERR_NOTSUPPORTED; + break; + } + } + } else { + assert(part->u.fnMessage16); + + if (bFrom32) { + map = llType->Map32ATo16(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); + switch (map) { + case WINMM_MAP_NOMEM: + ret = MMSYSERR_NOMEM; + break; + case WINMM_MAP_MSGERROR: + FIXME("NIY: no conversion yet 32->16 (%u)\n", wMsg); + ret = MMSYSERR_ERROR; + break; + case WINMM_MAP_OK: + case WINMM_MAP_OKMEM: + TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n", + mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); + ret = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, mld->uDeviceID, + wMsg, mld->dwDriverInstance, dwParam1, dwParam2); + TRACE("=> %lu\n", ret); + if (map == WINMM_MAP_OKMEM) + llType->UnMap32ATo16(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); + break; + default: + FIXME("NIY\n"); + ret = MMSYSERR_NOTSUPPORTED; + break; + } + } else { + TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n", + mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); + ret = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, mld->uDeviceID, + wMsg, mld->dwDriverInstance, dwParam1, dwParam2); + TRACE("=> %lu\n", ret); + } + } + return ret; +} + +/************************************************************************** + * MMDRV_Alloc [internal] + */ +LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags, + DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32) +{ + LPWINE_MLD mld; + + mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); + if (!mld) return NULL; + + /* find an empty slot in MM_MLDrvs table */ + for (*hndl = 0; *hndl < MAX_MM_MLDRVS; (*hndl)++) { + if (!MM_MLDrvs[(UINT)*hndl]) break; + } + if (*hndl == MAX_MM_MLDRVS) { + /* the MM_MLDrvs table could be made growable in the future if needed */ + ERR("Too many open drivers\n"); + return NULL; + } + MM_MLDrvs[(UINT)*hndl] = mld; + *hndl = (HANDLE)((UINT)*hndl | 0x8000); + + mld->type = type; + if ((UINT)*hndl < MMDRV_GetNum(type) || HIWORD(*hndl) != 0) { + /* FIXME: those conditions must be fulfilled so that: + * - we can distinguish between device IDs and handles + * - we can use handles as 16 or 32 bit entities + */ + ERR("Shouldn't happen. Bad allocation scheme\n"); + } + + mld->bFrom32 = bFrom32; + mld->dwFlags = HIWORD(*dwFlags); + mld->dwCallback = *dwCallback; + mld->dwClientInstance = *dwInstance; + + *dwFlags = LOWORD(*dwFlags) | CALLBACK_FUNCTION; + *dwCallback = (DWORD)llTypes[type].Callback; + *dwInstance = (DWORD)mld; /* FIXME: wouldn't some 16 bit drivers only use the loword ? */ + + return mld; +} + +/************************************************************************** + * MMDRV_Free [internal] + */ +void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld) +{ + if ((UINT)hndl & 0x8000) { + unsigned idx = (UINT)hndl & ~0x8000; + if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) { + MM_MLDrvs[idx] = NULL; + HeapFree(GetProcessHeap(), 0, mld); + return; + } + } + ERR("Bad Handle %08x at %p (not freed)\n", hndl, mld); +} + +/************************************************************************** + * MMDRV_Open [internal] + */ +DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwFlags) +{ + DWORD dwRet = MMSYSERR_BADDEVICEID; + DWORD dwInstance; + WINE_LLTYPE* llType = &llTypes[mld->type]; + + mld->dwDriverInstance = (DWORD)&dwInstance; + + if (mld->uDeviceID == (UINT)-1 || mld->uDeviceID == (UINT16)-1) { + TRACE("MAPPER mode requested !\n"); + /* check if mapper is supported by type */ + if (llType->bSupportMapper) { + if (llType->nMapper == -1) { + /* no driver for mapper has been loaded, try a dumb implementation */ + TRACE("No mapper loaded, doing it by hand\n"); + for (mld->uDeviceID = 0; mld->uDeviceID < llType->wMaxId; mld->uDeviceID++) { + if ((dwRet = MMDRV_Open(mld, wMsg, dwParam1, dwFlags)) == MMSYSERR_NOERROR) { + /* to share this function epilog */ + dwInstance = mld->dwDriverInstance; + break; + } + } + } else { + mld->uDeviceID = (UINT16)-1; + mld->mmdIndex = llType->lpMlds[-1].mmdIndex; + TRACE("Setting mmdIndex to %u\n", mld->mmdIndex); + dwRet = MMDRV_Message(mld, wMsg, dwParam1, dwFlags, TRUE); + } + } + } else { + if (mld->uDeviceID < llType->wMaxId) { + mld->mmdIndex = llType->lpMlds[mld->uDeviceID].mmdIndex; + TRACE("Setting mmdIndex to %u\n", mld->mmdIndex); + dwRet = MMDRV_Message(mld, wMsg, dwParam1, dwFlags, TRUE); + } + } + if (dwRet == MMSYSERR_NOERROR) + mld->dwDriverInstance = dwInstance; + return dwRet; +} + +/************************************************************************** + * MMDRV_Close [internal] + */ +DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg) +{ + return MMDRV_Message(mld, wMsg, 0L, 0L, TRUE); +} + +/************************************************************************** + * MMDRV_GetByID [internal] + */ +LPWINE_MLD MMDRV_GetByID(UINT uDevID, UINT type) +{ + if (uDevID < llTypes[type].wMaxId) + return &llTypes[type].lpMlds[uDevID]; + if ((uDevID == (UINT16)-1 || uDevID == (UINT)-1) && llTypes[type].nMapper != -1) + return &llTypes[type].lpMlds[-1]; + return NULL; +} + +/************************************************************************** + * MMDRV_Get [internal] + */ +LPWINE_MLD MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID) +{ + LPWINE_MLD mld = NULL; + + assert(type < MMDRV_MAX); + + if ((UINT)hndl >= llTypes[type].wMaxId && + hndl != (UINT16)-1 && hndl != (UINT)-1) { + if ((UINT)hndl & 0x8000) { + hndl = (HANDLE)((UINT)hndl & ~0x8000); + if (hndl < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) { + mld = MM_MLDrvs[(UINT)hndl]; + if (!mld || !HeapValidate(GetProcessHeap(), 0, mld) || mld->type != type) + mld = NULL; + } + hndl = (HANDLE)((UINT)hndl | 0x8000); + } + } + if (mld == NULL && bCanBeID) { + mld = MMDRV_GetByID((UINT)hndl, type); + } + return mld; +} + +/************************************************************************** + * MMDRV_GetRelated [internal] + */ +LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType, + BOOL bSrcCanBeID, UINT dstType) +{ + LPWINE_MLD mld; + + if ((mld = MMDRV_Get(hndl, srcType, bSrcCanBeID)) != NULL) { + WINE_MM_DRIVER_PART* part = &MMDrvs[mld->mmdIndex].parts[dstType]; + if (part->nIDMin < part->nIDMax) + return MMDRV_GetByID(part->nIDMin, dstType); + } + return NULL; +} + +/************************************************************************** + * MMDRV_PhysicalFeatures [internal] + */ +UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD dwParam1, + DWORD dwParam2) +{ + WINE_MM_DRIVER* lpDrv = &MMDrvs[mld->mmdIndex]; + + TRACE("(%p, %04x, %08lx, %08lx)\n", mld, uMsg, dwParam1, dwParam2); + + /* all those function calls are undocumented */ + switch (uMsg) { + case DRV_QUERYDRVENTRY: + lstrcpynA((LPSTR)dwParam1, lpDrv->drvname, LOWORD(dwParam2)); + break; + case DRV_QUERYDEVNODE: + *(LPDWORD)dwParam1 = 0L; /* should be DevNode */ + break; + case DRV_QUERYNAME: + WARN("NIY QueryName\n"); + break; + case DRV_QUERYDRIVERIDS: + WARN("NIY call VxD\n"); + /* should call VxD MMDEVLDR with (DevNode, dwParam1 and dwParam2) as pmts + * dwParam1 is buffer and dwParam2 is sizeof buffer + * I don't know where the result is stored though + */ + break; + case DRV_QUERYMAPPABLE: + return (lpDrv->bIsMapper) ? 2 : 0; + + case DRV_QUERYDSOUNDIFACE: /* Wine-specific: Retrieve DirectSound interface */ + return MMDRV_Message(mld, uMsg, dwParam1, dwParam2, TRUE); + + default: + WARN("Unknown call %04x\n", uMsg); + return MMSYSERR_INVALPARAM; + } + return 0L; +} + +/************************************************************************** + * MMDRV_InitPerType [internal] + */ +static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg) +{ + WINE_MM_DRIVER_PART* part = &lpDrv->parts[type]; + DWORD ret; + UINT count = 0; + int i, k; + + part->nIDMin = part->nIDMax = 0; + + /* for DRVM_INIT and DRVM_ENABLE, dwParam2 should be PnP node */ + /* the DRVM_ENABLE is only required when the PnP node is non zero */ + + if (lpDrv->bIs32 && part->u.fnMessage32) { + ret = part->u.fnMessage32(0, DRVM_INIT, 0L, 0L, 0L); + TRACE("DRVM_INIT => %08lx\n", ret); +#if 0 + ret = part->u.fnMessage32(0, DRVM_ENABLE, 0L, 0L, 0L); + TRACE("DRVM_ENABLE => %08lx\n", ret); +#endif + count = part->u.fnMessage32(0, wMsg, 0L, 0L, 0L); + } else if (!lpDrv->bIs32 && part->u.fnMessage16) { + ret = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, + 0, DRVM_INIT, 0L, 0L, 0L); + TRACE("DRVM_INIT => %08lx\n", ret); +#if 0 + ret = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, + 0, DRVM_ENABLE, 0L, 0L, 0L); + TRACE("DRVM_ENABLE => %08lx\n", ret); +#endif + count = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, + 0, wMsg, 0L, 0L, 0L); + } else { + return FALSE; + } + + TRACE("Got %u dev for (%s:%s)\n", count, lpDrv->drvname, llTypes[type].typestr); + + /* got some drivers */ + if (lpDrv->bIsMapper) { + /* it seems native mappers return 0 devices :-( */ + if (llTypes[type].nMapper != -1) + ERR("Two mappers for type %s (%d, %s)\n", + llTypes[type].typestr, llTypes[type].nMapper, lpDrv->drvname); + if (count > 1) + ERR("Strange: mapper with %d > 1 devices\n", count); + llTypes[type].nMapper = MMDrvsHi; + } else { + if (count == 0) + return FALSE; + part->nIDMin = llTypes[type].wMaxId; + llTypes[type].wMaxId += count; + part->nIDMax = llTypes[type].wMaxId; + } + TRACE("Setting min=%d max=%d (ttop=%d) for (%s:%s)\n", + part->nIDMin, part->nIDMax, llTypes[type].wMaxId, + lpDrv->drvname, llTypes[type].typestr); + /* realloc translation table */ + llTypes[type].lpMlds = (LPWINE_MLD) + HeapReAlloc(GetProcessHeap(), 0, (llTypes[type].lpMlds) ? llTypes[type].lpMlds - 1 : NULL, + sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)) + 1; + /* re-build the translation table */ + if (llTypes[type].nMapper != -1) { + TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, -1, MMDrvs[llTypes[type].nMapper].drvname); + llTypes[type].lpMlds[-1].uDeviceID = (UINT16)-1; + llTypes[type].lpMlds[-1].type = type; + llTypes[type].lpMlds[-1].mmdIndex = llTypes[type].nMapper; + llTypes[type].lpMlds[-1].dwDriverInstance = 0; + } + for (i = k = 0; i <= MMDrvsHi; i++) { + while (MMDrvs[i].parts[type].nIDMin <= k && k < MMDrvs[i].parts[type].nIDMax) { + TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, k, MMDrvs[i].drvname); + llTypes[type].lpMlds[k].uDeviceID = k; + llTypes[type].lpMlds[k].type = type; + llTypes[type].lpMlds[k].mmdIndex = i; + llTypes[type].lpMlds[k].dwDriverInstance = 0; + k++; + } + } + return TRUE; +} + +/************************************************************************** + * MMDRV_Install [internal] + */ +static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper) +{ + int i, count = 0; + char buffer[128]; + LPWINE_MM_DRIVER lpDrv = &MMDrvs[MMDrvsHi]; + LPWINE_DRIVER d; + + TRACE("('%s', '%s', mapper=%c);\n", drvRegName, drvFileName, bIsMapper ? 'Y' : 'N'); + + /* be sure that size of MMDrvs matches the max number of loadable drivers !! + * if not just increase size of MMDrvs */ + assert(MMDrvsHi <= sizeof(MMDrvs)/sizeof(MMDrvs[0])); + + for (i = 0; i < MMDrvsHi; i++) { + if (!strcmp(drvRegName, MMDrvs[i].drvname)) return FALSE; + } + + memset(lpDrv, 0, sizeof(*lpDrv)); + + if (!(lpDrv->hDriver = OpenDriverA(drvFileName, 0, 0))) { + WARN("Couldn't open driver '%s'\n", drvFileName); + return FALSE; + } + + d = DRIVER_FindFromHDrvr(lpDrv->hDriver); + lpDrv->bIs32 = (d->dwFlags & WINE_GDF_16BIT) ? FALSE : TRUE; + + /* Then look for xxxMessage functions */ +#define AA(_h,_w,_x,_y,_z) \ + func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \ + if (func != NULL) \ + { lpDrv->parts[_w].u.fnMessage##_y = func; count++; \ + TRACE("Got %d bit func '%s'\n", _y, #_x); } + + if (lpDrv->bIs32) { + WINEMM_msgFunc32 func; + + if (d->d.d32.hModule) { +#define A(_x,_y) AA(d->d.d32.hModule,_x,_y,32,GetProcAddress) + A(MMDRV_AUX, auxMessage); + A(MMDRV_MIXER, mixMessage); + A(MMDRV_MIDIIN, midMessage); + A(MMDRV_MIDIOUT, modMessage); + A(MMDRV_WAVEIN, widMessage); + A(MMDRV_WAVEOUT, wodMessage); +#undef A + } + } else { + WINEMM_msgFunc16 func; + + /* + * DESCRIPTION 'wave,aux,mixer:Creative Labs Sound Blaster 16 Driver' + * The beginning of the module description indicates the driver supports + * waveform, auxiliary, and mixer devices. Use one of the following + * device-type names, followed by a colon (:) to indicate the type of + * device your driver supports. If the driver supports more than one + * type of device, separate each device-type name with a comma (,). + * + * wave for waveform audio devices + * wavemapper for wave mappers + * midi for MIDI audio devices + * midimapper for midi mappers + * aux for auxiliary audio devices + * mixer for mixer devices + */ + + if (d->d.d16.hDriver16) { + HMODULE16 hMod16 = GetDriverModuleHandle16(d->d.d16.hDriver16); + +#define A(_x,_y) AA(hMod16,_x,_y,16,GetProcAddress16) + A(MMDRV_AUX, auxMessage); + A(MMDRV_MIXER, mixMessage); + A(MMDRV_MIDIIN, midMessage); + A(MMDRV_MIDIOUT, modMessage); + A(MMDRV_WAVEIN, widMessage); + A(MMDRV_WAVEOUT, wodMessage); +#undef A + } + } +#undef AA + + if (TRACE_ON(mmsys)) { + if ((lpDrv->bIs32) ? MMDRV_GetDescription32(drvFileName, buffer, sizeof(buffer)) : + MMDRV_GetDescription16(drvFileName, buffer, sizeof(buffer))) + TRACE("%s => %s\n", drvFileName, buffer); + else + TRACE("%s => No description\n", drvFileName); + } + + if (!count) { + CloseDriver(lpDrv->hDriver, 0, 0); + WARN("No message functions found\n"); + return FALSE; + } + + /* FIXME: being a mapper or not should be known by another way */ + /* it's known for NE drvs (the description is of the form '*mapper: *' + * I don't have any clue for PE drvs + */ + lpDrv->bIsMapper = bIsMapper; + lpDrv->drvname = strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(drvRegName) + 1), drvRegName); + + /* Finish init and get the count of the devices */ + MMDRV_InitPerType(lpDrv, MMDRV_AUX, AUXDM_GETNUMDEVS); + MMDRV_InitPerType(lpDrv, MMDRV_MIXER, MXDM_GETNUMDEVS); + MMDRV_InitPerType(lpDrv, MMDRV_MIDIIN, MIDM_GETNUMDEVS); + MMDRV_InitPerType(lpDrv, MMDRV_MIDIOUT, MODM_GETNUMDEVS); + MMDRV_InitPerType(lpDrv, MMDRV_WAVEIN, WIDM_GETNUMDEVS); + MMDRV_InitPerType(lpDrv, MMDRV_WAVEOUT, WODM_GETNUMDEVS); + /* FIXME: if all those func calls return FALSE, + * then the driver must be unloaded + */ + + MMDrvsHi++; + + return TRUE; +} + +/************************************************************************** + * MMDRV_InitFromRegistry [internal] + */ +static BOOL MMDRV_InitFromRegistry(void) +{ + HKEY hKey; + char buffer[256]; + char* p1; + char* p2; + DWORD type, size; + BOOL ret = FALSE; + + if (RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\WinMM", &hKey)) { + TRACE("Cannot open WinMM config key\n"); + return FALSE; + } + + size = sizeof(buffer); + if (!RegQueryValueExA(hKey, "Drivers", 0, &type, (LPVOID)buffer, &size)) { + p1 = buffer; + while (p1) { + p2 = strchr(p1, ';'); + if (p2) *p2++ = '\0'; + ret |= MMDRV_Install(p1, p1, FALSE); + p1 = p2; + } + } + + /* finish with mappers */ + size = sizeof(buffer); + if (!RegQueryValueExA(hKey, "WaveMapper", 0, &type, (LPVOID)buffer, &size)) + ret |= MMDRV_Install("wavemapper", buffer, TRUE); + size = sizeof(buffer); + if (!RegQueryValueExA(hKey, "MidiMapper", 0, &type, (LPVOID)buffer, &size)) + ret |= MMDRV_Install("midimapper", buffer, TRUE); + + RegCloseKey(hKey); + + return ret; +} + +/************************************************************************** + * MMDRV_InitHardcoded [internal] + */ +static BOOL MMDRV_InitHardcoded(void) +{ + /* first load hardware drivers */ + MMDRV_Install("wineoss.drv", "wineoss.drv", FALSE); + + /* finish with mappers */ + MMDRV_Install("wavemapper", "msacm.drv", TRUE); + MMDRV_Install("midimapper", "midimap.drv", TRUE); + + return TRUE; +} + +/************************************************************************** + * MMDRV_Init [internal] + */ +BOOL MMDRV_Init(void) +{ + /* FIXME: MMDRV_InitFromRegistry shall be MMDRV_Init in a near future */ + return MMDRV_InitFromRegistry() || MMDRV_InitHardcoded(); +} diff --git a/dlls/winmm/lolvldrv.c b/dlls/winmm/message16.c similarity index 61% copy from dlls/winmm/lolvldrv.c copy to dlls/winmm/message16.c index ebc276db4dd..d077f0b410c 100644 --- a/dlls/winmm/lolvldrv.c +++ b/dlls/winmm/message16.c @@ -1,7 +1,7 @@ /* -*- tab-width: 8; c-basic-offset: 4 -*- */ /* - * MMSYTEM low level drivers handling functions + * MMSYTEM MCI and low level mapping functions * * Copyright 1999 Eric Pouech * @@ -27,162 +27,19 @@ #include "winreg.h" #include "winver.h" #include "winemm.h" +#include "digitalv.h" #include "wine/debug.h" -WINE_DEFAULT_DEBUG_CHANNEL(mmsys); - -typedef DWORD (CALLBACK *WINEMM_msgFunc16)(UINT16, WORD, DWORD, DWORD, DWORD); -typedef DWORD (CALLBACK *WINEMM_msgFunc32)(UINT , UINT, DWORD, DWORD, DWORD); - -/* for each loaded driver and each known type of driver, this structure contains - * the information needed to access it - */ -typedef struct tagWINE_MM_DRIVER_PART { - int nIDMin; /* lower bound of global indexes for this type */ - int nIDMax; /* hhigher bound of global indexes for this type */ - union { - WINEMM_msgFunc32 fnMessage32; /* pointer to fonction */ - WINEMM_msgFunc16 fnMessage16; - } u; -} WINE_MM_DRIVER_PART; - -/* each low-level .drv will be associated with an instance of this structure */ -typedef struct tagWINE_MM_DRIVER { - HDRVR hDriver; - LPSTR drvname; /* name of the driver */ - BOOL bIs32 : 1, /* TRUE if 32 bit driver, FALSE for 16 */ - bIsMapper : 1; /* TRUE if mapper */ - WINE_MM_DRIVER_PART parts[MMDRV_MAX];/* Information for all known types */ -} WINE_MM_DRIVER, *LPWINE_MM_DRIVER; - -typedef WINMM_MapType (*MMDRV_MAPFUNC)(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); - -/* each known type of driver has an instance of this structure */ -typedef struct tagWINE_LLTYPE { - /* those attributes depend on the specification of the type */ - LPSTR typestr; /* name (for debugging) */ - BOOL bSupportMapper; /* if type is allowed to support mapper */ - MMDRV_MAPFUNC Map16To32A; /* those are function pointers to handle */ - MMDRV_MAPFUNC UnMap16To32A; /* the parameter conversion (16 vs 32 bit) */ - MMDRV_MAPFUNC Map32ATo16; /* when hi-func (in mmsystem or winmm) and */ - MMDRV_MAPFUNC UnMap32ATo16; /* low-func (in .drv) do not match */ - LPDRVCALLBACK Callback; /* handles callback for a specified type */ - /* those attributes reflect the loaded/current situation for the type */ - UINT wMaxId; /* number of loaded devices (sum across all loaded drivers */ - LPWINE_MLD lpMlds; /* "static" mlds to access the part though device IDs */ - int nMapper; /* index to mapper */ -} WINE_LLTYPE; - -static int MMDrvsHi /* = 0 */; -static WINE_MM_DRIVER MMDrvs[3]; -static LPWINE_MLD MM_MLDrvs[40]; -#define MAX_MM_MLDRVS (sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) +WINE_DEFAULT_DEBUG_CHANNEL(winmm); /* ### start build ### */ extern WORD CALLBACK MMDRV_CallTo16_word_wwlll(FARPROC16,WORD,WORD,LONG,LONG,LONG); /* ### stop build ### */ /************************************************************************** - * MMDRV_GetDescription16 [internal] - */ -static BOOL MMDRV_GetDescription16(const char* fname, char* buf, int buflen) -{ - OFSTRUCT ofs; - HFILE hFile; - WORD w; - DWORD dw; - BOOL ret = FALSE; - - if ((hFile = OpenFile(fname, &ofs, OF_READ | OF_SHARE_DENY_WRITE)) == HFILE_ERROR) { - ERR("Can't open file %s (builtin driver ?)\n", fname); - return FALSE; - } - -#define E(_x) do {TRACE _x;goto theEnd;} while(0) - - if (_lread(hFile, &w, 2) != 2) E(("Can't read sig\n")); - if (w != ('Z' * 256 + 'M')) E(("Bad sig %04x\n", w)); - if (_llseek(hFile, 0x3C, SEEK_SET) < 0) E(("Can't seek to ext header offset\n")); - if (_lread(hFile, &dw, 4) != 4) E(("Can't read ext header offset\n")); - if (_llseek(hFile, dw + 0x2C, SEEK_SET) < 0) E(("Can't seek to ext header.nr table %lu\n", dw+0x2C)); - if (_lread(hFile, &dw, 4) != 4) E(("Can't read nr table offset\n")); - if (_llseek(hFile, dw, SEEK_SET) < 0) E(("Can't seek to nr table %lu\n", dw)); - if (_lread(hFile, buf, 1) != 1) E(("Can't read descr length\n")); - buflen = min((int)(unsigned)(BYTE)buf[0], buflen - 1); - if (_lread(hFile, buf, buflen) != buflen) E(("Can't read descr (%d)\n", buflen)); - buf[buflen] = '\0'; - ret = TRUE; - TRACE("Got '%s' [%d]\n", buf, buflen); -theEnd: - CloseHandle(hFile); - return ret; -} - -/************************************************************************** - * MMDRV_GetDescription32 [internal] - */ -static BOOL MMDRV_GetDescription32(const char* fname, char* buf, int buflen) -{ - OFSTRUCT ofs; - DWORD h; - LPVOID ptr = 0; - LPVOID val; - DWORD dw; - BOOL ret = FALSE; - UINT u; - FARPROC pGetFileVersionInfoSizeA; - FARPROC pGetFileVersionInfoA; - FARPROC pVerQueryValueA; - HMODULE hmodule = 0; - -#define E(_x) do {TRACE _x;goto theEnd;} while(0) - - if (OpenFile(fname, &ofs, OF_EXIST)==HFILE_ERROR) E(("Can't find file %s\n", fname)); - - if (!(hmodule = LoadLibraryA( "version.dll" ))) goto theEnd; - if (!(pGetFileVersionInfoSizeA = GetProcAddress( hmodule, "GetFileVersionInfoSizeA" ))) - goto theEnd; - if (!(pGetFileVersionInfoA = GetProcAddress( hmodule, "GetFileVersionInfoA" ))) - goto theEnd; - if (!(pVerQueryValueA = GetProcAddress( hmodule, "pVerQueryValueA" ))) - goto theEnd; - - if (!(dw = pGetFileVersionInfoSizeA(ofs.szPathName, &h))) E(("Can't get FVIS\n")); - if (!(ptr = HeapAlloc(GetProcessHeap(), 0, dw))) E(("OOM\n")); - if (!pGetFileVersionInfoA(ofs.szPathName, h, dw, ptr)) E(("Can't get FVI\n")); - -#define A(_x) if (pVerQueryValueA(ptr, "\\StringFileInfo\\040904B0\\" #_x, &val, &u)) \ - TRACE(#_x " => %s\n", (LPSTR)val); else TRACE(#_x " @\n") - - A(CompanyName); - A(FileDescription); - A(FileVersion); - A(InternalName); - A(LegalCopyright); - A(OriginalFilename); - A(ProductName); - A(ProductVersion); - A(Comments); - A(LegalTrademarks); - A(PrivateBuild); - A(SpecialBuild); -#undef A - - if (!pVerQueryValueA(ptr, "\\StringFileInfo\\040904B0\\ProductName", &val, &u)) E(("Can't get product name\n")); - lstrcpynA(buf, val, buflen); - -#undef E - ret = TRUE; -theEnd: - HeapFree(GetProcessHeap(), 0, ptr); - if (hmodule) FreeLibrary( hmodule ); - return ret; -} - -/************************************************************************** * MMDRV_Callback [internal] */ -static void MMDRV_Callback(LPWINE_MLD mld, HDRVR hDev, UINT uMsg, DWORD dwParam1, DWORD dwParam2) +void MMDRV_Callback(LPWINE_MLD mld, HDRVR hDev, UINT uMsg, DWORD dwParam1, DWORD dwParam2) { TRACE("CB (*%08lx)(%08x %08x %08lx %08lx %08lx\n", mld->dwCallback, hDev, uMsg, mld->dwClientInstance, dwParam1, dwParam2); @@ -205,7 +62,7 @@ static void MMDRV_Callback(LPWINE_MLD mld, HDRVR hDev, UINT uMsg, DWORD dwParam1 /************************************************************************** * MMDRV_Aux_Map16To32A [internal] */ -static WINMM_MapType MMDRV_Aux_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_Aux_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { return WINMM_MAP_MSGERROR; } @@ -213,7 +70,7 @@ static WINMM_MapType MMDRV_Aux_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD /************************************************************************** * MMDRV_Aux_UnMap16To32A [internal] */ -static WINMM_MapType MMDRV_Aux_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_Aux_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { return WINMM_MAP_MSGERROR; } @@ -221,7 +78,7 @@ static WINMM_MapType MMDRV_Aux_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD /************************************************************************** * MMDRV_Aux_Map32ATo16 [internal] */ -static WINMM_MapType MMDRV_Aux_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_Aux_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { return WINMM_MAP_MSGERROR; } @@ -229,7 +86,7 @@ static WINMM_MapType MMDRV_Aux_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD /************************************************************************** * MMDRV_Aux_UnMap32ATo16 [internal] */ -static WINMM_MapType MMDRV_Aux_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_Aux_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { #if 0 case AUXDM_GETDEVCAPS: @@ -246,7 +103,7 @@ static WINMM_MapType MMDRV_Aux_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD /************************************************************************** * MMDRV_Aux_Callback [internal] */ -static void CALLBACK MMDRV_Aux_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) +void CALLBACK MMDRV_Aux_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) { LPWINE_MLD mld = (LPWINE_MLD)dwInstance; @@ -261,7 +118,7 @@ static void CALLBACK MMDRV_Aux_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, /************************************************************************** * xMMDRV_Mixer_Map16To32A [internal] */ -static WINMM_MapType MMDRV_Mixer_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_Mixer_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { return WINMM_MAP_MSGERROR; } @@ -269,7 +126,7 @@ static WINMM_MapType MMDRV_Mixer_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWO /************************************************************************** * MMDRV_Mixer_UnMap16To32A [internal] */ -static WINMM_MapType MMDRV_Mixer_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_Mixer_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { #if 0 MIXERCAPSA micA; @@ -291,7 +148,7 @@ static WINMM_MapType MMDRV_Mixer_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWO /************************************************************************** * MMDRV_Mixer_Map32ATo16 [internal] */ -static WINMM_MapType MMDRV_Mixer_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_Mixer_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { return WINMM_MAP_MSGERROR; } @@ -299,7 +156,7 @@ static WINMM_MapType MMDRV_Mixer_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWO /************************************************************************** * MMDRV_Mixer_UnMap32ATo16 [internal] */ -static WINMM_MapType MMDRV_Mixer_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_Mixer_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { return WINMM_MAP_MSGERROR; } @@ -307,7 +164,7 @@ static WINMM_MapType MMDRV_Mixer_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWO /************************************************************************** * MMDRV_Mixer_Callback [internal] */ -static void CALLBACK MMDRV_Mixer_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) +void CALLBACK MMDRV_Mixer_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) { LPWINE_MLD mld = (LPWINE_MLD)dwInstance; @@ -322,7 +179,7 @@ static void CALLBACK MMDRV_Mixer_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstanc /************************************************************************** * MMDRV_MidiIn_Map16To32A [internal] */ -static WINMM_MapType MMDRV_MidiIn_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_MidiIn_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { return WINMM_MAP_MSGERROR; } @@ -330,7 +187,7 @@ static WINMM_MapType MMDRV_MidiIn_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDW /************************************************************************** * MMDRV_MidiIn_UnMap16To32A [internal] */ -static WINMM_MapType MMDRV_MidiIn_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_MidiIn_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { return WINMM_MAP_MSGERROR; } @@ -338,7 +195,7 @@ static WINMM_MapType MMDRV_MidiIn_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDW /************************************************************************** * MMDRV_MidiIn_Map32ATo16 [internal] */ -static WINMM_MapType MMDRV_MidiIn_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_MidiIn_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { return WINMM_MAP_MSGERROR; } @@ -346,7 +203,7 @@ static WINMM_MapType MMDRV_MidiIn_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDW /************************************************************************** * MMDRV_MidiIn_UnMap32ATo16 [internal] */ -static WINMM_MapType MMDRV_MidiIn_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_MidiIn_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { return WINMM_MAP_MSGERROR; } @@ -354,7 +211,7 @@ static WINMM_MapType MMDRV_MidiIn_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDW /************************************************************************** * MMDRV_MidiIn_Callback [internal] */ -static void CALLBACK MMDRV_MidiIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) +void CALLBACK MMDRV_MidiIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) { LPWINE_MLD mld = (LPWINE_MLD)dwInstance; @@ -371,7 +228,7 @@ static void CALLBACK MMDRV_MidiIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstan case MIM_LONGDATA: case MIM_LONGERROR: /* dwParam1 points to a MidiHdr, work to be done !!! */ - if (mld->bFrom32 && !MMDrvs[mld->mmdIndex].bIs32) { + if (mld->bFrom32 && !MMDRV_Is32(mld->mmdIndex)) { /* initial map is: 32 => 16 */ LPMIDIHDR mh16 = MapSL(dwParam1); LPMIDIHDR mh32 = *(LPMIDIHDR*)((LPSTR)mh16 - sizeof(LPMIDIHDR)); @@ -381,7 +238,7 @@ static void CALLBACK MMDRV_MidiIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstan mh32->dwBytesRecorded = mh16->dwBytesRecorded; if (mh32->reserved >= sizeof(MIDIHDR)) mh32->dwOffset = mh16->dwOffset; - } else if (!mld->bFrom32 && MMDrvs[mld->mmdIndex].bIs32) { + } else if (!mld->bFrom32 && MMDRV_Is32(mld->mmdIndex)) { /* initial map is: 16 => 32 */ LPMIDIHDR mh32 = (LPMIDIHDR)(dwParam1); SEGPTR segmh16 = *(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR)); @@ -410,7 +267,7 @@ static void CALLBACK MMDRV_MidiIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstan /************************************************************************** * MMDRV_MidiOut_Map16To32A [internal] */ -static WINMM_MapType MMDRV_MidiOut_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_MidiOut_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { WINMM_MapType ret = WINMM_MAP_MSGERROR; @@ -503,7 +360,7 @@ static WINMM_MapType MMDRV_MidiOut_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPD /************************************************************************** * MMDRV_MidiOut_UnMap16To32A [internal] */ -static WINMM_MapType MMDRV_MidiOut_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_MidiOut_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { WINMM_MapType ret = WINMM_MAP_MSGERROR; @@ -574,7 +431,7 @@ static WINMM_MapType MMDRV_MidiOut_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPD /************************************************************************** * MMDRV_MidiOut_Map32ATo16 [internal] */ -static WINMM_MapType MMDRV_MidiOut_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_MidiOut_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { WINMM_MapType ret = WINMM_MAP_MSGERROR; @@ -714,7 +571,7 @@ static WINMM_MapType MMDRV_MidiOut_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPD /************************************************************************** * MMDRV_MidiOut_UnMap32ATo16 [internal] */ -static WINMM_MapType MMDRV_MidiOut_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_MidiOut_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { WINMM_MapType ret = WINMM_MAP_MSGERROR; @@ -791,7 +648,7 @@ static WINMM_MapType MMDRV_MidiOut_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPD /************************************************************************** * MMDRV_MidiOut_Callback [internal] */ -static void CALLBACK MMDRV_MidiOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) +void CALLBACK MMDRV_MidiOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) { LPWINE_MLD mld = (LPWINE_MLD)dwInstance; @@ -801,7 +658,7 @@ static void CALLBACK MMDRV_MidiOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInsta /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */ break; case MOM_DONE: - if (mld->bFrom32 && !MMDrvs[mld->mmdIndex].bIs32) { + if (mld->bFrom32 && !MMDRV_Is32(mld->mmdIndex)) { /* initial map is: 32 => 16 */ LPMIDIHDR mh16 = MapSL(dwParam1); LPMIDIHDR mh32 = *(LPMIDIHDR*)((LPSTR)mh16 - sizeof(LPMIDIHDR)); @@ -811,7 +668,7 @@ static void CALLBACK MMDRV_MidiOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInsta mh32->dwOffset = mh16->dwOffset; if (mh32->reserved >= sizeof(MIDIHDR)) mh32->dwOffset = mh16->dwOffset; - } else if (!mld->bFrom32 && MMDrvs[mld->mmdIndex].bIs32) { + } else if (!mld->bFrom32 && MMDRV_Is32(mld->mmdIndex)) { /* initial map is: 16 => 32 */ LPMIDIHDR mh32 = (LPMIDIHDR)(dwParam1); SEGPTR segmh16 = *(SEGPTR*)((LPSTR)mh32 - sizeof(LPMIDIHDR)); @@ -839,7 +696,7 @@ static void CALLBACK MMDRV_MidiOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInsta /************************************************************************** * MMDRV_WaveIn_Map16To32A [internal] */ -static WINMM_MapType MMDRV_WaveIn_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_WaveIn_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { WINMM_MapType ret = WINMM_MAP_MSGERROR; @@ -948,7 +805,7 @@ static WINMM_MapType MMDRV_WaveIn_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDW /************************************************************************** * MMDRV_WaveIn_UnMap16To32A [internal] */ -static WINMM_MapType MMDRV_WaveIn_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_WaveIn_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { WINMM_MapType ret = WINMM_MAP_MSGERROR; @@ -1020,7 +877,7 @@ static WINMM_MapType MMDRV_WaveIn_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDW /************************************************************************** * MMDRV_WaveIn_Map32ATo16 [internal] */ -static WINMM_MapType MMDRV_WaveIn_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_WaveIn_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { WINMM_MapType ret = WINMM_MAP_MSGERROR; @@ -1190,7 +1047,7 @@ static WINMM_MapType MMDRV_WaveIn_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDW /************************************************************************** * MMDRV_WaveIn_UnMap32ATo16 [internal] */ -static WINMM_MapType MMDRV_WaveIn_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_WaveIn_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { WINMM_MapType ret = WINMM_MAP_MSGERROR; @@ -1284,7 +1141,7 @@ static WINMM_MapType MMDRV_WaveIn_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDW /************************************************************************** * MMDRV_WaveIn_Callback [internal] */ -static void CALLBACK MMDRV_WaveIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) +void CALLBACK MMDRV_WaveIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) { LPWINE_MLD mld = (LPWINE_MLD)dwInstance; @@ -1294,7 +1151,7 @@ static void CALLBACK MMDRV_WaveIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstan /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */ break; case WIM_DATA: - if (mld->bFrom32 && !MMDrvs[mld->mmdIndex].bIs32) { + if (mld->bFrom32 && !MMDRV_Is32(mld->mmdIndex)) { /* initial map is: 32 => 16 */ LPWAVEHDR wh16 = MapSL(dwParam1); LPWAVEHDR wh32 = *(LPWAVEHDR*)((LPSTR)wh16 - sizeof(LPWAVEHDR)); @@ -1302,7 +1159,7 @@ static void CALLBACK MMDRV_WaveIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstan dwParam1 = (DWORD)wh32; wh32->dwFlags = wh16->dwFlags; wh32->dwBytesRecorded = wh16->dwBytesRecorded; - } else if (!mld->bFrom32 && MMDrvs[mld->mmdIndex].bIs32) { + } else if (!mld->bFrom32 && MMDRV_Is32(mld->mmdIndex)) { /* initial map is: 16 => 32 */ LPWAVEHDR wh32 = (LPWAVEHDR)(dwParam1); SEGPTR segwh16 = *(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR)); @@ -1328,7 +1185,7 @@ static void CALLBACK MMDRV_WaveIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstan /************************************************************************** * MMDRV_WaveOut_Map16To32A [internal] */ -static WINMM_MapType MMDRV_WaveOut_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_WaveOut_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { WINMM_MapType ret = WINMM_MAP_MSGERROR; @@ -1446,7 +1303,7 @@ static WINMM_MapType MMDRV_WaveOut_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPD /************************************************************************** * MMDRV_WaveOut_UnMap16To32A [internal] */ -static WINMM_MapType MMDRV_WaveOut_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_WaveOut_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { WINMM_MapType ret = WINMM_MAP_MSGERROR; @@ -1529,7 +1386,7 @@ static WINMM_MapType MMDRV_WaveOut_UnMap16To32A(UINT wMsg, LPDWORD lpdwUser, LPD /************************************************************************** * MMDRV_WaveOut_Map32ATo16 [internal] */ -static WINMM_MapType MMDRV_WaveOut_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_WaveOut_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { WINMM_MapType ret; @@ -1718,7 +1575,7 @@ static WINMM_MapType MMDRV_WaveOut_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPD /************************************************************************** * MMDRV_WaveOut_UnMap32ATo16 [internal] */ -static WINMM_MapType MMDRV_WaveOut_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) +WINMM_MapType MMDRV_WaveOut_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2) { WINMM_MapType ret; @@ -1830,7 +1687,7 @@ static WINMM_MapType MMDRV_WaveOut_UnMap32ATo16(UINT wMsg, LPDWORD lpdwUser, LPD /************************************************************************** * MMDRV_WaveOut_Callback [internal] */ -static void CALLBACK MMDRV_WaveOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) +void CALLBACK MMDRV_WaveOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) { LPWINE_MLD mld = (LPWINE_MLD)dwInstance; @@ -1840,14 +1697,14 @@ static void CALLBACK MMDRV_WaveOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInsta /* dwParam1 & dwParam2 are supposed to be 0, nothing to do */ break; case WOM_DONE: - if (mld->bFrom32 && !MMDrvs[mld->mmdIndex].bIs32) { + if (mld->bFrom32 && !MMDRV_Is32(mld->mmdIndex)) { /* initial map is: 32 => 16 */ LPWAVEHDR wh16 = MapSL(dwParam1); LPWAVEHDR wh32 = *(LPWAVEHDR*)((LPSTR)wh16 - sizeof(LPWAVEHDR)); dwParam1 = (DWORD)wh32; wh32->dwFlags = wh16->dwFlags; - } else if (!mld->bFrom32 && MMDrvs[mld->mmdIndex].bIs32) { + } else if (!mld->bFrom32 && MMDRV_Is32(mld->mmdIndex)) { /* initial map is: 16 => 32 */ LPWAVEHDR wh32 = (LPWAVEHDR)(dwParam1); SEGPTR segwh16 = *(SEGPTR*)((LPSTR)wh32 - sizeof(LPWAVEHDR)); @@ -1865,623 +1722,948 @@ static void CALLBACK MMDRV_WaveOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInsta MMDRV_Callback(mld, hDev, uMsg, dwParam1, dwParam2); } -#define A(_x,_y) {#_y, _x, \ -MMDRV_##_y##_Map16To32A, MMDRV_##_y##_UnMap16To32A, \ -MMDRV_##_y##_Map32ATo16, MMDRV_##_y##_UnMap32ATo16, \ -MMDRV_##_y##_Callback, 0, NULL, -1} - -/* Note: the indices of this array must match the definitions - * of the MMDRV_???? manifest constants - */ -static WINE_LLTYPE llTypes[MMDRV_MAX] = { - A(TRUE, Aux), - A(FALSE, Mixer), - A(TRUE, MidiIn), - A(TRUE, MidiOut), - A(TRUE, WaveIn), - A(TRUE, WaveOut), -}; -#undef A - /************************************************************************** - * MMDRV_GetNum [internal] + * MMDRV_GetDescription16 [internal] */ -UINT MMDRV_GetNum(UINT type) +BOOL MMDRV_GetDescription16(const char* fname, char* buf, int buflen) { - assert(type < MMDRV_MAX); - return llTypes[type].wMaxId; -} + OFSTRUCT ofs; + HFILE hFile; + WORD w; + DWORD dw; + BOOL ret = FALSE; -/************************************************************************** - * WINE_Message [internal] - */ -DWORD MMDRV_Message(LPWINE_MLD mld, WORD wMsg, DWORD dwParam1, - DWORD dwParam2, BOOL bFrom32) -{ - LPWINE_MM_DRIVER lpDrv; - DWORD ret; - WINE_MM_DRIVER_PART* part; - WINE_LLTYPE* llType = &llTypes[mld->type]; - WINMM_MapType map; - int devID; - - TRACE("(%s %u %u 0x%08lx 0x%08lx 0x%08lx %c)!\n", - llTypes[mld->type].typestr, mld->uDeviceID, wMsg, - mld->dwDriverInstance, dwParam1, dwParam2, bFrom32?'Y':'N'); - - if (mld->uDeviceID == (UINT16)-1) { - if (!llType->bSupportMapper) { - WARN("uDev=-1 requested on non-mappable ll type %s\n", - llTypes[mld->type].typestr); - return MMSYSERR_BADDEVICEID; - } - devID = -1; - } else { - if (mld->uDeviceID >= llType->wMaxId) { - WARN("uDev(%u) requested >= max (%d)\n", mld->uDeviceID, llType->wMaxId); - return MMSYSERR_BADDEVICEID; - } - devID = mld->uDeviceID; + if ((hFile = OpenFile(fname, &ofs, OF_READ | OF_SHARE_DENY_WRITE)) == HFILE_ERROR) { + ERR("Can't open file %s (builtin driver ?)\n", fname); + return FALSE; } - lpDrv = &MMDrvs[mld->mmdIndex]; - part = &lpDrv->parts[mld->type]; - -#if 0 - /* some sanity checks */ - if (!(part->nIDMin <= devID)) - ERR("!(part->nIDMin(%d) <= devID(%d))\n", part->nIDMin, devID); - if (!(devID < part->nIDMax)) - ERR("!(devID(%d) < part->nIDMax(%d))\n", devID, part->nIDMax); -#endif - - if (lpDrv->bIs32) { - assert(part->u.fnMessage32); +#define E(_x) do {TRACE _x;goto theEnd;} while(0) - if (bFrom32) { - TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n", - mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - ret = part->u.fnMessage32(mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - TRACE("=> %lu\n", ret); - } else { - map = llType->Map16To32A(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); - switch (map) { - case WINMM_MAP_NOMEM: - ret = MMSYSERR_NOMEM; - break; - case WINMM_MAP_MSGERROR: - FIXME("NIY: no conversion yet 16->32 (%u)\n", wMsg); - ret = MMSYSERR_ERROR; - break; - case WINMM_MAP_OK: - case WINMM_MAP_OKMEM: - TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n", - mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - ret = part->u.fnMessage32(mld->uDeviceID, wMsg, mld->dwDriverInstance, - dwParam1, dwParam2); - TRACE("=> %lu\n", ret); - if (map == WINMM_MAP_OKMEM) - llType->UnMap16To32A(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); - break; - default: - FIXME("NIY ?\n"); - ret = MMSYSERR_NOTSUPPORTED; - break; - } - } - } else { - assert(part->u.fnMessage16); - - if (bFrom32) { - map = llType->Map32ATo16(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); - switch (map) { - case WINMM_MAP_NOMEM: - ret = MMSYSERR_NOMEM; - break; - case WINMM_MAP_MSGERROR: - FIXME("NIY: no conversion yet 32->16 (%u)\n", wMsg); - ret = MMSYSERR_ERROR; - break; - case WINMM_MAP_OK: - case WINMM_MAP_OKMEM: - TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n", - mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - ret = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, mld->uDeviceID, - wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - TRACE("=> %lu\n", ret); - if (map == WINMM_MAP_OKMEM) - llType->UnMap32ATo16(wMsg, &mld->dwDriverInstance, &dwParam1, &dwParam2); - break; - default: - FIXME("NIY\n"); - ret = MMSYSERR_NOTSUPPORTED; - break; - } - } else { - TRACE("Calling message(dev=%u msg=%u usr=0x%08lx p1=0x%08lx p2=0x%08lx\n", - mld->uDeviceID, wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - ret = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, mld->uDeviceID, - wMsg, mld->dwDriverInstance, dwParam1, dwParam2); - TRACE("=> %lu\n", ret); - } - } + if (_lread(hFile, &w, 2) != 2) E(("Can't read sig\n")); + if (w != ('Z' * 256 + 'M')) E(("Bad sig %04x\n", w)); + if (_llseek(hFile, 0x3C, SEEK_SET) < 0) E(("Can't seek to ext header offset\n")); + if (_lread(hFile, &dw, 4) != 4) E(("Can't read ext header offset\n")); + if (_llseek(hFile, dw + 0x2C, SEEK_SET) < 0) E(("Can't seek to ext header.nr table %lu\n", dw+0x2C)); + if (_lread(hFile, &dw, 4) != 4) E(("Can't read nr table offset\n")); + if (_llseek(hFile, dw, SEEK_SET) < 0) E(("Can't seek to nr table %lu\n", dw)); + if (_lread(hFile, buf, 1) != 1) E(("Can't read descr length\n")); + buflen = min((int)(unsigned)(BYTE)buf[0], buflen - 1); + if (_lread(hFile, buf, buflen) != buflen) E(("Can't read descr (%d)\n", buflen)); + buf[buflen] = '\0'; + ret = TRUE; + TRACE("Got '%s' [%d]\n", buf, buflen); +theEnd: + CloseHandle(hFile); return ret; } +/* ================================= + * M C I + * ================================= */ + /************************************************************************** - * MMDRV_Alloc [internal] + * MCI_MapMsg16To32A [internal] */ -LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags, - DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32) +WINMM_MapType MCI_MapMsg16To32A(WORD uDevType, WORD wMsg, DWORD* lParam) { - LPWINE_MLD mld; - - mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); - if (!mld) return NULL; - - /* find an empty slot in MM_MLDrvs table */ - for (*hndl = 0; *hndl < MAX_MM_MLDRVS; (*hndl)++) { - if (!MM_MLDrvs[(UINT)*hndl]) break; - } - if (*hndl == MAX_MM_MLDRVS) { - /* the MM_MLDrvs table could be made growable in the future if needed */ - ERR("Too many open drivers\n"); - return NULL; - } - MM_MLDrvs[(UINT)*hndl] = mld; - *hndl = (HANDLE)((UINT)*hndl | 0x8000); - - mld->type = type; - if ((UINT)*hndl < MMDRV_GetNum(type) || HIWORD(*hndl) != 0) { - /* FIXME: those conditions must be fulfilled so that: - * - we can distinguish between device IDs and handles - * - we can use handles as 16 or 32 bit entities + if (*lParam == 0) + return WINMM_MAP_OK; + /* FIXME: to add also (with seg/linear modifications to do): + * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE + * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO + */ + switch (wMsg) { + /* case MCI_CAPTURE */ + case MCI_CLOSE: + case MCI_CLOSE_DRIVER: + case MCI_CONFIGURE: + case MCI_COPY: + case MCI_CUE: + case MCI_CUT: + case MCI_DELETE: + case MCI_FREEZE: + case MCI_GETDEVCAPS: + /* case MCI_INDEX: */ + /* case MCI_MARK: */ + /* case MCI_MONITOR: */ + case MCI_PASTE: + case MCI_PAUSE: + case MCI_PLAY: + case MCI_PUT: + case MCI_REALIZE: + case MCI_RECORD: + case MCI_RESUME: + case MCI_SEEK: + case MCI_SET: + /* case MCI_SETTIMECODE:*/ + /* case MCI_SIGNAL:*/ + case MCI_SPIN: + case MCI_STATUS: /* FIXME: is wrong for digital video */ + case MCI_STEP: + case MCI_STOP: + /* case MCI_UNDO: */ + case MCI_UNFREEZE: + case MCI_UPDATE: + case MCI_WHERE: + *lParam = (DWORD)MapSL(*lParam); + return WINMM_MAP_OK; + case MCI_WINDOW: + /* in fact, I would also need the dwFlags... to see + * which members of lParam are effectively used */ - ERR("Shouldn't happen. Bad allocation scheme\n"); - } - - mld->bFrom32 = bFrom32; - mld->dwFlags = HIWORD(*dwFlags); - mld->dwCallback = *dwCallback; - mld->dwClientInstance = *dwInstance; - - *dwFlags = LOWORD(*dwFlags) | CALLBACK_FUNCTION; - *dwCallback = (DWORD)llTypes[type].Callback; - *dwInstance = (DWORD)mld; /* FIXME: wouldn't some 16 bit drivers only use the loword ? */ - - return mld; -} + *lParam = (DWORD)MapSL(*lParam); + FIXME("Current mapping may be wrong\n"); + break; + case MCI_BREAK: + { + LPMCI_BREAK_PARMS mbp32 = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_BREAK_PARMS)); + LPMCI_BREAK_PARMS16 mbp16 = MapSL(*lParam); -/************************************************************************** - * MMDRV_Free [internal] - */ -void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld) -{ - if ((UINT)hndl & 0x8000) { - unsigned idx = (UINT)hndl & ~0x8000; - if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) { - MM_MLDrvs[idx] = NULL; - HeapFree(GetProcessHeap(), 0, mld); - return; + if (mbp32) { + mbp32->dwCallback = mbp16->dwCallback; + mbp32->nVirtKey = mbp16->nVirtKey; + mbp32->hwndBreak = HWND_32(mbp16->hwndBreak); + } else { + return WINMM_MAP_NOMEM; + } + *lParam = (DWORD)mbp32; } - } - ERR("Bad Handle %08x at %p (not freed)\n", hndl, mld); -} + return WINMM_MAP_OKMEM; + case MCI_ESCAPE: + { + LPMCI_VD_ESCAPE_PARMSA mvep32a = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_VD_ESCAPE_PARMSA)); + LPMCI_VD_ESCAPE_PARMS16 mvep16 = MapSL(*lParam); -/************************************************************************** - * MMDRV_Open [internal] - */ -DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwFlags) -{ - DWORD dwRet = MMSYSERR_BADDEVICEID; - DWORD dwInstance; - WINE_LLTYPE* llType = &llTypes[mld->type]; - - mld->dwDriverInstance = (DWORD)&dwInstance; - - if (mld->uDeviceID == (UINT)-1 || mld->uDeviceID == (UINT16)-1) { - TRACE("MAPPER mode requested !\n"); - /* check if mapper is supported by type */ - if (llType->bSupportMapper) { - if (llType->nMapper == -1) { - /* no driver for mapper has been loaded, try a dumb implementation */ - TRACE("No mapper loaded, doing it by hand\n"); - for (mld->uDeviceID = 0; mld->uDeviceID < llType->wMaxId; mld->uDeviceID++) { - if ((dwRet = MMDRV_Open(mld, wMsg, dwParam1, dwFlags)) == MMSYSERR_NOERROR) { - /* to share this function epilog */ - dwInstance = mld->dwDriverInstance; - break; - } - } + if (mvep32a) { + mvep32a->dwCallback = mvep16->dwCallback; + mvep32a->lpstrCommand = MapSL(mvep16->lpstrCommand); } else { - mld->uDeviceID = (UINT16)-1; - mld->mmdIndex = llType->lpMlds[-1].mmdIndex; - TRACE("Setting mmdIndex to %u\n", mld->mmdIndex); - dwRet = MMDRV_Message(mld, wMsg, dwParam1, dwFlags, TRUE); + return WINMM_MAP_NOMEM; } + *lParam = (DWORD)mvep32a; } - } else { - if (mld->uDeviceID < llType->wMaxId) { - mld->mmdIndex = llType->lpMlds[mld->uDeviceID].mmdIndex; - TRACE("Setting mmdIndex to %u\n", mld->mmdIndex); - dwRet = MMDRV_Message(mld, wMsg, dwParam1, dwFlags, TRUE); + return WINMM_MAP_OKMEM; + case MCI_INFO: + { + LPMCI_INFO_PARMSA mip32a = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_INFO_PARMSA)); + LPMCI_INFO_PARMS16 mip16 = MapSL(*lParam); + + /* FIXME this is wrong if device is of type + * MCI_DEVTYPE_DIGITAL_VIDEO, some members are not mapped + */ + if (mip32a) { + mip32a->dwCallback = mip16->dwCallback; + mip32a->lpstrReturn = MapSL(mip16->lpstrReturn); + mip32a->dwRetSize = mip16->dwRetSize; + } else { + return WINMM_MAP_NOMEM; + } + *lParam = (DWORD)mip32a; } + return WINMM_MAP_OKMEM; + case MCI_OPEN: + case MCI_OPEN_DRIVER: + { + LPMCI_OPEN_PARMSA mop32a = HeapAlloc(GetProcessHeap(), 0, sizeof(LPMCI_OPEN_PARMS16) + sizeof(MCI_OPEN_PARMSA) + 2 * sizeof(DWORD)); + LPMCI_OPEN_PARMS16 mop16 = MapSL(*lParam); + + if (mop32a) { + *(LPMCI_OPEN_PARMS16*)(mop32a) = mop16; + mop32a = (LPMCI_OPEN_PARMSA)((char*)mop32a + sizeof(LPMCI_OPEN_PARMS16)); + mop32a->dwCallback = mop16->dwCallback; + mop32a->wDeviceID = mop16->wDeviceID; + mop32a->lpstrDeviceType = MapSL(mop16->lpstrDeviceType); + mop32a->lpstrElementName = MapSL(mop16->lpstrElementName); + mop32a->lpstrAlias = MapSL(mop16->lpstrAlias); + /* copy extended information if any... + * FIXME: this may seg fault if initial structure does not contain them and + * the reads after msip16 fail under LDT limits... + * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and + * should not take care of extended parameters, and should be used by MCI_Open + * to fetch uDevType. When, this is known, the mapping for sending the + * MCI_OPEN_DRIVER shall be done depending on uDevType. + */ + memcpy(mop32a + 1, mop16 + 1, 2 * sizeof(DWORD)); + } else { + return WINMM_MAP_NOMEM; + } + *lParam = (DWORD)mop32a; + } + return WINMM_MAP_OKMEM; + case MCI_SYSINFO: + { + LPMCI_SYSINFO_PARMSA msip32a = HeapAlloc(GetProcessHeap(), 0, sizeof(MCI_SYSINFO_PARMSA)); + LPMCI_SYSINFO_PARMS16 msip16 = MapSL(*lParam); + + if (msip32a) { + msip32a->dwCallback = msip16->dwCallback; + msip32a->lpstrReturn = MapSL(msip16->lpstrReturn); + msip32a->dwRetSize = msip16->dwRetSize; + msip32a->dwNumber = msip16->dwNumber; + msip32a->wDeviceType = msip16->wDeviceType; + } else { + return WINMM_MAP_NOMEM; + } + *lParam = (DWORD)msip32a; + } + return WINMM_MAP_OKMEM; + case DRV_LOAD: + case DRV_ENABLE: + case DRV_OPEN: + case DRV_CLOSE: + case DRV_DISABLE: + case DRV_FREE: + case DRV_CONFIGURE: + case DRV_QUERYCONFIGURE: + case DRV_INSTALL: + case DRV_REMOVE: + case DRV_EXITSESSION: + case DRV_EXITAPPLICATION: + case DRV_POWER: + FIXME("This is a hack\n"); + return WINMM_MAP_OK; + + default: + WARN("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg)); } - if (dwRet == MMSYSERR_NOERROR) - mld->dwDriverInstance = dwInstance; - return dwRet; + return WINMM_MAP_MSGERROR; } /************************************************************************** - * MMDRV_Close [internal] + * MCI_UnMapMsg16To32A [internal] */ -DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg) +WINMM_MapType MCI_UnMapMsg16To32A(WORD uDevType, WORD wMsg, DWORD lParam) { - return MMDRV_Message(mld, wMsg, 0L, 0L, TRUE); + switch (wMsg) { + /* case MCI_CAPTURE */ + case MCI_CLOSE: + case MCI_CLOSE_DRIVER: + case MCI_CONFIGURE: + case MCI_COPY: + case MCI_CUE: + case MCI_CUT: + case MCI_DELETE: + case MCI_FREEZE: + case MCI_GETDEVCAPS: + /* case MCI_INDEX: */ + /* case MCI_MARK: */ + /* case MCI_MONITOR: */ + case MCI_PASTE: + case MCI_PAUSE: + case MCI_PLAY: + case MCI_PUT: + case MCI_REALIZE: + case MCI_RECORD: + case MCI_RESUME: + case MCI_SEEK: + case MCI_SET: + /* case MCI_SETTIMECODE:*/ + /* case MCI_SIGNAL:*/ + case MCI_SPIN: + case MCI_STATUS: + case MCI_STEP: + case MCI_STOP: + /* case MCI_UNDO: */ + case MCI_UNFREEZE: + case MCI_UPDATE: + case MCI_WHERE: + return WINMM_MAP_OK; + + case MCI_WINDOW: + /* FIXME ?? see Map function */ + return WINMM_MAP_OK; + + case MCI_BREAK: + case MCI_ESCAPE: + case MCI_INFO: + case MCI_SYSINFO: + HeapFree(GetProcessHeap(), 0, (LPVOID)lParam); + return WINMM_MAP_OK; + case MCI_OPEN: + case MCI_OPEN_DRIVER: + if (lParam) { + LPMCI_OPEN_PARMSA mop32a = (LPMCI_OPEN_PARMSA)lParam; + LPMCI_OPEN_PARMS16 mop16 = *(LPMCI_OPEN_PARMS16*)((char*)mop32a - sizeof(LPMCI_OPEN_PARMS16)); + + mop16->wDeviceID = mop32a->wDeviceID; + if (!HeapFree(GetProcessHeap(), 0, (LPVOID)(lParam - sizeof(LPMCI_OPEN_PARMS16)))) + FIXME("bad free line=%d\n", __LINE__); + } + return WINMM_MAP_OK; + case DRV_LOAD: + case DRV_ENABLE: + case DRV_OPEN: + case DRV_CLOSE: + case DRV_DISABLE: + case DRV_FREE: + case DRV_CONFIGURE: + case DRV_QUERYCONFIGURE: + case DRV_INSTALL: + case DRV_REMOVE: + case DRV_EXITSESSION: + case DRV_EXITAPPLICATION: + case DRV_POWER: + FIXME("This is a hack\n"); + return WINMM_MAP_OK; + default: + FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg)); + } + return WINMM_MAP_MSGERROR; } -/************************************************************************** - * MMDRV_GetByID [internal] +/* + * 0000 stop + * 0001 squeeze signed 4 bytes to 2 bytes *( LPINT16)D = ( INT16)*( LPINT16)S; D += 2; S += 4 + * 0010 squeeze unsigned 4 bytes to 2 bytes *(LPUINT16)D = (UINT16)*(LPUINT16)S; D += 2; S += 4 + * 0100 + * 0101 + * 0110 zero 4 bytes *(DWORD)D = 0 D += 4; S += 4 + * 0111 copy string *(LPSTR*)D = seg dup(*(LPSTR*)S) D += 4; S += 4 + * 1xxx copy xxx + 1 bytes memcpy(D, S, xxx + 1); D += xxx+1; S += xxx+1 */ -LPWINE_MLD MMDRV_GetByID(UINT uDevID, UINT type) -{ - if (uDevID < llTypes[type].wMaxId) - return &llTypes[type].lpMlds[uDevID]; - if ((uDevID == (UINT16)-1 || uDevID == (UINT)-1) && llTypes[type].nMapper != -1) - return &llTypes[type].lpMlds[-1]; - return NULL; -} /************************************************************************** - * MMDRV_Get [internal] + * MCI_MsgMapper32To16_Create [internal] + * + * Helper for MCI_MapMsg32ATo16. + * Maps the 32 bit pointer (*ptr), of size bytes, to an allocated 16 bit + * segmented pointer. + * map contains a list of action to be performed for the mapping (see list + * above) + * if keep is TRUE, keeps track of in 32 bit ptr in allocated 16 bit area. */ -LPWINE_MLD MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID) +static WINMM_MapType MCI_MsgMapper32To16_Create(void** ptr, int size16, DWORD map, BOOLEAN keep) { - LPWINE_MLD mld = NULL; - - assert(type < MMDRV_MAX); - - if ((UINT)hndl >= llTypes[type].wMaxId && - hndl != (UINT16)-1 && hndl != (UINT)-1) { - if ((UINT)hndl & 0x8000) { - hndl = (HANDLE)((UINT)hndl & ~0x8000); - if (hndl < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) { - mld = MM_MLDrvs[(UINT)hndl]; - if (!mld || !HeapValidate(GetProcessHeap(), 0, mld) || mld->type != type) - mld = NULL; + void* lp = HeapAlloc( GetProcessHeap(), 0, (keep ? sizeof(void**) : 0) + size16 ); + LPBYTE p16, p32; + + if (!lp) { + return WINMM_MAP_NOMEM; + } + p32 = (LPBYTE)(*ptr); + if (keep) { + *(void**)lp = *ptr; + p16 = (LPBYTE)lp + sizeof(void**); + *ptr = (char*)MapLS(lp) + sizeof(void**); + } else { + p16 = lp; + *ptr = (void*)MapLS(lp); + } + + if (map == 0) { + memcpy(p16, p32, size16); + } else { + unsigned nibble; + unsigned sz; + + while (map & 0xF) { + nibble = map & 0xF; + if (nibble & 0x8) { + sz = (nibble & 7) + 1; + memcpy(p16, p32, sz); + p16 += sz; + p32 += sz; + size16 -= sz; /* DEBUG only */ + } else { + switch (nibble) { + case 0x1: + *(LPINT16)p16 = *(LPINT)p32; + p16 += sizeof(INT16); + p32 += sizeof(INT); + size16 -= sizeof(INT16); + break; + case 0x2: + *(LPUINT16)p16 = *(LPUINT)p32; + p16 += sizeof(UINT16); + p32 += sizeof(UINT); + size16 -= sizeof(UINT16); + break; + case 0x6: + *(LPDWORD)p16 = 0; + p16 += sizeof(DWORD); + p32 += sizeof(DWORD); + size16 -= sizeof(DWORD); + break; + case 0x7: + *(SEGPTR *)p16 = MapLS( *(LPSTR *)p32 ); + p16 += sizeof(SEGPTR); + p32 += sizeof(LPSTR); + size16 -= sizeof(SEGPTR); + break; + default: + FIXME("Unknown nibble for mapping (%x)\n", nibble); + } } - hndl = (HANDLE)((UINT)hndl | 0x8000); + map >>= 4; } + if (size16 != 0) /* DEBUG only */ + FIXME("Mismatch between 16 bit struct size and map nibbles serie\n"); } - if (mld == NULL && bCanBeID) { - mld = MMDRV_GetByID((UINT)hndl, type); - } - return mld; + return WINMM_MAP_OKMEM; } /************************************************************************** - * MMDRV_GetRelated [internal] + * MCI_MsgMapper32To16_Destroy [internal] + * + * Helper for MCI_UnMapMsg32ATo16. */ -LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType, - BOOL bSrcCanBeID, UINT dstType) +static WINMM_MapType MCI_MsgMapper32To16_Destroy(void* ptr, int size16, DWORD map, BOOLEAN kept) { - LPWINE_MLD mld; + if (ptr) { + void* msg16 = MapSL((SEGPTR)ptr); + void* alloc; + LPBYTE p32, p16; + unsigned nibble; + + UnMapLS( (SEGPTR)ptr ); + if (kept) { + alloc = (char*)msg16 - sizeof(void**); + p32 = *(void**)alloc; + p16 = msg16; + + if (map == 0) { + memcpy(p32, p16, size16); + } else { + while (map & 0xF) { + nibble = map & 0xF; + if (nibble & 0x8) { + memcpy(p32, p16, (nibble & 7) + 1); + p16 += (nibble & 7) + 1; + p32 += (nibble & 7) + 1; + size16 -= (nibble & 7) + 1; + } else { + switch (nibble) { + case 0x1: + *(LPINT)p32 = *(LPINT16)p16; + p16 += sizeof(INT16); + p32 += sizeof(INT); + size16 -= sizeof(INT16); + break; + case 0x2: + *(LPUINT)p32 = *(LPUINT16)p16; + p16 += sizeof(UINT16); + p32 += sizeof(UINT); + size16 -= sizeof(UINT16); + break; + case 0x6: + p16 += sizeof(UINT); + p32 += sizeof(UINT); + size16 -= sizeof(UINT); + break; + case 0x7: + UnMapLS( *(SEGPTR *)p16 ); + p16 += sizeof(SEGPTR); + p32 += sizeof(char*); + size16 -= sizeof(SEGPTR); + break; + default: + FIXME("Unknown nibble for mapping (%x)\n", nibble); + } + } + map >>= 4; + } + if (size16 != 0) /* DEBUG only */ + FIXME("Mismatch between 16 bit struct size and map nibbles serie\n"); + } + } else { + alloc = msg16; + } - if ((mld = MMDRV_Get(hndl, srcType, bSrcCanBeID)) != NULL) { - WINE_MM_DRIVER_PART* part = &MMDrvs[mld->mmdIndex].parts[dstType]; - if (part->nIDMin < part->nIDMax) - return MMDRV_GetByID(part->nIDMin, dstType); + HeapFree( GetProcessHeap(), 0, alloc ); } - return NULL; + return WINMM_MAP_OK; } /************************************************************************** - * MMDRV_PhysicalFeatures [internal] + * MCI_MapMsg32ATo16 [internal] + * + * Map a 32-A bit MCI message to a 16 bit MCI message. */ -UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD dwParam1, - DWORD dwParam2) +WINMM_MapType MCI_MapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD* lParam) { - WINE_MM_DRIVER* lpDrv = &MMDrvs[mld->mmdIndex]; + int size; + BOOLEAN keep = FALSE; + DWORD map = 0; - TRACE("(%p, %04x, %08lx, %08lx)\n", mld, uMsg, dwParam1, dwParam2); + if (*lParam == 0) + return WINMM_MAP_OK; - /* all those function calls are undocumented */ - switch (uMsg) { - case DRV_QUERYDRVENTRY: - lstrcpynA((LPSTR)dwParam1, lpDrv->drvname, LOWORD(dwParam2)); + /* FIXME: to add also (with seg/linear modifications to do): + * MCI_LIST, MCI_LOAD, MCI_QUALITY, MCI_RESERVE, MCI_RESTORE, MCI_SAVE + * MCI_SETAUDIO, MCI_SETTUNER, MCI_SETVIDEO + */ + switch (wMsg) { + case MCI_BREAK: + size = sizeof(MCI_BREAK_PARMS); break; - case DRV_QUERYDEVNODE: - *(LPDWORD)dwParam1 = 0L; /* should be DevNode */ + /* case MCI_CAPTURE */ + case MCI_CLOSE: + case MCI_CLOSE_DRIVER: + case MCI_CONFIGURE: + size = sizeof(MCI_GENERIC_PARMS); break; - case DRV_QUERYNAME: - WARN("NIY QueryName\n"); + /* case MCI_COPY: */ + case MCI_CUE: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_CUE_PARMS); break; + case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_CUE_PARMS); break;*/ FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM; + default: size = sizeof(MCI_GENERIC_PARMS); break; + } break; - case DRV_QUERYDRIVERIDS: - WARN("NIY call VxD\n"); - /* should call VxD MMDEVLDR with (DevNode, dwParam1 and dwParam2) as pmts - * dwParam1 is buffer and dwParam2 is sizeof buffer - * I don't know where the result is stored though - */ + /* case MCI_CUT:*/ + case MCI_DELETE: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_DELETE_PARMS16); map = 0x0F1111FB; break; + case MCI_DEVTYPE_WAVEFORM_AUDIO:size = sizeof(MCI_WAVE_DELETE_PARMS); break; + default: size = sizeof(MCI_GENERIC_PARMS); break; + } break; - case DRV_QUERYMAPPABLE: - return (lpDrv->bIsMapper) ? 2 : 0; - - case DRV_QUERYDSOUNDIFACE: /* Wine-specific: Retrieve DirectSound interface */ - return MMDRV_Message(mld, uMsg, dwParam1, dwParam2, TRUE); - - default: - WARN("Unknown call %04x\n", uMsg); - return MMSYSERR_INVALPARAM; - } - return 0L; -} - -/************************************************************************** - * MMDRV_InitPerType [internal] - */ -static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg) -{ - WINE_MM_DRIVER_PART* part = &lpDrv->parts[type]; - DWORD ret; - UINT count = 0; - int i, k; - - part->nIDMin = part->nIDMax = 0; - - /* for DRVM_INIT and DRVM_ENABLE, dwParam2 should be PnP node */ - /* the DRVM_ENABLE is only required when the PnP node is non zero */ - - if (lpDrv->bIs32 && part->u.fnMessage32) { - ret = part->u.fnMessage32(0, DRVM_INIT, 0L, 0L, 0L); - TRACE("DRVM_INIT => %08lx\n", ret); -#if 0 - ret = part->u.fnMessage32(0, DRVM_ENABLE, 0L, 0L, 0L); - TRACE("DRVM_ENABLE => %08lx\n", ret); -#endif - count = part->u.fnMessage32(0, wMsg, 0L, 0L, 0L); - } else if (!lpDrv->bIs32 && part->u.fnMessage16) { - ret = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, - 0, DRVM_INIT, 0L, 0L, 0L); - TRACE("DRVM_INIT => %08lx\n", ret); -#if 0 - ret = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, - 0, DRVM_ENABLE, 0L, 0L, 0L); - TRACE("DRVM_ENABLE => %08lx\n", ret); -#endif - count = MMDRV_CallTo16_word_wwlll((FARPROC16)part->u.fnMessage16, - 0, wMsg, 0L, 0L, 0L); - } else { - return FALSE; - } - - TRACE("Got %u dev for (%s:%s)\n", count, lpDrv->drvname, llTypes[type].typestr); - - /* got some drivers */ - if (lpDrv->bIsMapper) { - /* it seems native mappers return 0 devices :-( */ - if (llTypes[type].nMapper != -1) - ERR("Two mappers for type %s (%d, %s)\n", - llTypes[type].typestr, llTypes[type].nMapper, lpDrv->drvname); - if (count > 1) - ERR("Strange: mapper with %d > 1 devices\n", count); - llTypes[type].nMapper = MMDrvsHi; - } else { - if (count == 0) - return FALSE; - part->nIDMin = llTypes[type].wMaxId; - llTypes[type].wMaxId += count; - part->nIDMax = llTypes[type].wMaxId; - } - TRACE("Setting min=%d max=%d (ttop=%d) for (%s:%s)\n", - part->nIDMin, part->nIDMax, llTypes[type].wMaxId, - lpDrv->drvname, llTypes[type].typestr); - /* realloc translation table */ - llTypes[type].lpMlds = (LPWINE_MLD) - HeapReAlloc(GetProcessHeap(), 0, (llTypes[type].lpMlds) ? llTypes[type].lpMlds - 1 : NULL, - sizeof(WINE_MLD) * (llTypes[type].wMaxId + 1)) + 1; - /* re-build the translation table */ - if (llTypes[type].nMapper != -1) { - TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, -1, MMDrvs[llTypes[type].nMapper].drvname); - llTypes[type].lpMlds[-1].uDeviceID = (UINT16)-1; - llTypes[type].lpMlds[-1].type = type; - llTypes[type].lpMlds[-1].mmdIndex = llTypes[type].nMapper; - llTypes[type].lpMlds[-1].dwDriverInstance = 0; - } - for (i = k = 0; i <= MMDrvsHi; i++) { - while (MMDrvs[i].parts[type].nIDMin <= k && k < MMDrvs[i].parts[type].nIDMax) { - TRACE("%s:Trans[%d] -> %s\n", llTypes[type].typestr, k, MMDrvs[i].drvname); - llTypes[type].lpMlds[k].uDeviceID = k; - llTypes[type].lpMlds[k].type = type; - llTypes[type].lpMlds[k].mmdIndex = i; - llTypes[type].lpMlds[k].dwDriverInstance = 0; - k++; + /* case MCI_ESCAPE: */ + case MCI_FREEZE: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_FREEZE_PARMS); map = 0x0001111B; break; + case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS); map = 0x0001111B; break; + default: size = sizeof(MCI_GENERIC_PARMS); break; } - } - return TRUE; -} - -/************************************************************************** - * MMDRV_Install [internal] - */ -static BOOL MMDRV_Install(LPCSTR drvRegName, LPCSTR drvFileName, BOOL bIsMapper) -{ - int i, count = 0; - char buffer[128]; - LPWINE_MM_DRIVER lpDrv = &MMDrvs[MMDrvsHi]; - LPWINE_DRIVER d; - - TRACE("('%s', '%s', mapper=%c);\n", drvRegName, drvFileName, bIsMapper ? 'Y' : 'N'); - - /* be sure that size of MMDrvs matches the max number of loadable drivers !! - * if not just increase size of MMDrvs */ - assert(MMDrvsHi <= sizeof(MMDrvs)/sizeof(MMDrvs[0])); - - for (i = 0; i < MMDrvsHi; i++) { - if (!strcmp(drvRegName, MMDrvs[i].drvname)) return FALSE; - } + break; + case MCI_GETDEVCAPS: + keep = TRUE; + size = sizeof(MCI_GETDEVCAPS_PARMS); + break; + /* case MCI_INDEX: */ + case MCI_INFO: + { + LPMCI_INFO_PARMSA mip32a = (LPMCI_INFO_PARMSA)(*lParam); + LPMCI_INFO_PARMS16 mip16; - memset(lpDrv, 0, sizeof(*lpDrv)); + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_INFO_PARMS16); break; + default: size = sizeof(MCI_INFO_PARMS16); break; + } + mip16 = HeapAlloc( GetProcessHeap(), 0, size); + if (mip16) + { + mip16->dwCallback = mip32a->dwCallback; + mip16->lpstrReturn = MapLS( mip32a->lpstrReturn ); + mip16->dwRetSize = mip32a->dwRetSize; + if (uDevType == MCI_DEVTYPE_DIGITAL_VIDEO) { + ((LPMCI_DGV_INFO_PARMS16)mip16)->dwItem = ((LPMCI_DGV_INFO_PARMSA)mip32a)->dwItem; + } + } else { + return WINMM_MAP_NOMEM; + } + *lParam = MapLS(mip16); + } + return WINMM_MAP_OKMEM; + /* case MCI_MARK: */ + /* case MCI_MONITOR: */ + case MCI_OPEN: + case MCI_OPEN_DRIVER: + { + LPMCI_OPEN_PARMSA mop32a = (LPMCI_OPEN_PARMSA)(*lParam); + char* ptr = HeapAlloc( GetProcessHeap(), 0, + sizeof(LPMCI_OPEN_PARMSA) + sizeof(MCI_OPEN_PARMS16) + 2 * sizeof(DWORD)); + LPMCI_OPEN_PARMS16 mop16; - if (!(lpDrv->hDriver = OpenDriverA(drvFileName, 0, 0))) { - WARN("Couldn't open driver '%s'\n", drvFileName); - return FALSE; - } - d = DRIVER_FindFromHDrvr(lpDrv->hDriver); - lpDrv->bIs32 = (d->dwFlags & WINE_GDF_16BIT) ? FALSE : TRUE; - - /* Then look for xxxMessage functions */ -#define AA(_h,_w,_x,_y,_z) \ - func = (WINEMM_msgFunc##_y) _z ((_h), #_x); \ - if (func != NULL) \ - { lpDrv->parts[_w].u.fnMessage##_y = func; count++; \ - TRACE("Got %d bit func '%s'\n", _y, #_x); } - - if (lpDrv->bIs32) { - WINEMM_msgFunc32 func; - - if (d->d.d32.hModule) { -#define A(_x,_y) AA(d->d.d32.hModule,_x,_y,32,GetProcAddress) - A(MMDRV_AUX, auxMessage); - A(MMDRV_MIXER, mixMessage); - A(MMDRV_MIDIIN, midMessage); - A(MMDRV_MIDIOUT, modMessage); - A(MMDRV_WAVEIN, widMessage); - A(MMDRV_WAVEOUT, wodMessage); -#undef A + if (ptr) { + *(LPMCI_OPEN_PARMSA*)(ptr) = mop32a; + mop16 = (LPMCI_OPEN_PARMS16)(ptr + sizeof(LPMCI_OPEN_PARMSA)); + mop16->dwCallback = mop32a->dwCallback; + mop16->wDeviceID = mop32a->wDeviceID; + if (dwFlags & MCI_OPEN_TYPE) { + if (dwFlags & MCI_OPEN_TYPE_ID) { + /* dword "transparent" value */ + mop16->lpstrDeviceType = (SEGPTR)mop32a->lpstrDeviceType; + } else { + /* string */ + mop16->lpstrDeviceType = MapLS( mop32a->lpstrDeviceType ); + } + } else { + /* nuthin' */ + mop16->lpstrDeviceType = 0; + } + if (dwFlags & MCI_OPEN_ELEMENT) { + if (dwFlags & MCI_OPEN_ELEMENT_ID) { + mop16->lpstrElementName = (SEGPTR)mop32a->lpstrElementName; + } else { + mop16->lpstrElementName = MapLS( mop32a->lpstrElementName ); + } + } else { + mop16->lpstrElementName = 0; + } + if (dwFlags & MCI_OPEN_ALIAS) { + mop16->lpstrAlias = MapLS( mop32a->lpstrAlias ); + } else { + mop16->lpstrAlias = 0; + } + /* copy extended information if any... + * FIXME: this may seg fault if initial structure does not contain them and + * the reads after msip16 fail under LDT limits... + * NOTE: this should be split in two. First pass, while calling MCI_OPEN, and + * should not take care of extended parameters, and should be used by MCI_Open + * to fetch uDevType. When, this is known, the mapping for sending the + * MCI_OPEN_DRIVER shall be done depending on uDevType. + */ + memcpy(mop16 + 1, mop32a + 1, 2 * sizeof(DWORD)); + } else { + return WINMM_MAP_NOMEM; + } + *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_OPEN_PARMSA); } - } else { - WINEMM_msgFunc16 func; - - /* - * DESCRIPTION 'wave,aux,mixer:Creative Labs Sound Blaster 16 Driver' - * The beginning of the module description indicates the driver supports - * waveform, auxiliary, and mixer devices. Use one of the following - * device-type names, followed by a colon (:) to indicate the type of - * device your driver supports. If the driver supports more than one - * type of device, separate each device-type name with a comma (,). - * - * wave for waveform audio devices - * wavemapper for wave mappers - * midi for MIDI audio devices - * midimapper for midi mappers - * aux for auxiliary audio devices - * mixer for mixer devices + return WINMM_MAP_OKMEM; + /* case MCI_PASTE:*/ + case MCI_PAUSE: + size = sizeof(MCI_GENERIC_PARMS); + break; + case MCI_PLAY: + size = sizeof(MCI_PLAY_PARMS); + break; + case MCI_PUT: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; break; + case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS); map = 0x0001111B; break; + default: size = sizeof(MCI_GENERIC_PARMS); break; + } + break; + case MCI_REALIZE: + size = sizeof(MCI_GENERIC_PARMS); + break; + case MCI_RECORD: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECORD_PARMS16); map = 0x0F1111FB; break; + case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_RECORD_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM; + default: size = sizeof(MCI_RECORD_PARMS); break; + } + break; + case MCI_RESUME: + size = sizeof(MCI_GENERIC_PARMS); + break; + case MCI_SEEK: + switch (uDevType) { + case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SEEK_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM; + default: size = sizeof(MCI_SEEK_PARMS); break; + } + break; + case MCI_SET: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_SET_PARMS); break; + case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SET_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM; + case MCI_DEVTYPE_SEQUENCER: size = sizeof(MCI_SEQ_SET_PARMS); break; + /* FIXME: normally the 16 and 32 bit structures are byte by byte aligned, + * so not doing anything should work... */ - - if (d->d.d16.hDriver16) { - HMODULE16 hMod16 = GetDriverModuleHandle16(d->d.d16.hDriver16); - -#define A(_x,_y) AA(hMod16,_x,_y,16,GetProcAddress16) - A(MMDRV_AUX, auxMessage); - A(MMDRV_MIXER, mixMessage); - A(MMDRV_MIDIIN, midMessage); - A(MMDRV_MIDIOUT, modMessage); - A(MMDRV_WAVEIN, widMessage); - A(MMDRV_WAVEOUT, wodMessage); -#undef A + case MCI_DEVTYPE_WAVEFORM_AUDIO:size = sizeof(MCI_WAVE_SET_PARMS); break; + default: size = sizeof(MCI_SET_PARMS); break; } - } -#undef AA - - if (TRACE_ON(mmsys)) { - if ((lpDrv->bIs32) ? MMDRV_GetDescription32(drvFileName, buffer, sizeof(buffer)) : - MMDRV_GetDescription16(drvFileName, buffer, sizeof(buffer))) - TRACE("%s => %s\n", drvFileName, buffer); - else - TRACE("%s => No description\n", drvFileName); - } - - if (!count) { - CloseDriver(lpDrv->hDriver, 0, 0); - WARN("No message functions found\n"); - return FALSE; - } + break; + case MCI_SETAUDIO: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_SETAUDIO_PARMS16);map = 0x0000077FF; break; + case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SETAUDIO_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM; + default: size = sizeof(MCI_GENERIC_PARMS); break; + } + break; + /* case MCI_SETTIMECODE:*/ + /* case MCI_SIGNAL:*/ + case MCI_SPIN: + size = sizeof(MCI_SET_PARMS); + break; + case MCI_STATUS: + keep = TRUE; + switch (uDevType) { + /* FIXME: + * don't know if buffer for value is the one passed through lpstrDevice + * or is provided by MCI driver. + * Assuming solution 2: provided by MCI driver, so zeroing on entry + */ + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_STATUS_PARMS16); map = 0x0B6FF; break; + case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_STATUS_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM; + default: size = sizeof(MCI_STATUS_PARMS); break; + } + break; + case MCI_STEP: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_STEP_PARMS); break; + case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_STEP_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM; + case MCI_DEVTYPE_VIDEODISC: size = sizeof(MCI_VD_STEP_PARMS); break; + default: size = sizeof(MCI_GENERIC_PARMS); break; + } + break; + case MCI_STOP: + size = sizeof(MCI_SET_PARMS); + break; + case MCI_SYSINFO: + { + LPMCI_SYSINFO_PARMSA msip32a = (LPMCI_SYSINFO_PARMSA)(*lParam); + LPMCI_SYSINFO_PARMS16 msip16; + char* ptr = HeapAlloc( GetProcessHeap(), 0, + sizeof(LPMCI_SYSINFO_PARMSA) + sizeof(MCI_SYSINFO_PARMS16) ); - /* FIXME: being a mapper or not should be known by another way */ - /* it's known for NE drvs (the description is of the form '*mapper: *' - * I don't have any clue for PE drvs - */ - lpDrv->bIsMapper = bIsMapper; - lpDrv->drvname = strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(drvRegName) + 1), drvRegName); - - /* Finish init and get the count of the devices */ - MMDRV_InitPerType(lpDrv, MMDRV_AUX, AUXDM_GETNUMDEVS); - MMDRV_InitPerType(lpDrv, MMDRV_MIXER, MXDM_GETNUMDEVS); - MMDRV_InitPerType(lpDrv, MMDRV_MIDIIN, MIDM_GETNUMDEVS); - MMDRV_InitPerType(lpDrv, MMDRV_MIDIOUT, MODM_GETNUMDEVS); - MMDRV_InitPerType(lpDrv, MMDRV_WAVEIN, WIDM_GETNUMDEVS); - MMDRV_InitPerType(lpDrv, MMDRV_WAVEOUT, WODM_GETNUMDEVS); - /* FIXME: if all those func calls return FALSE, - * then the driver must be unloaded - */ + if (ptr) { + *(LPMCI_SYSINFO_PARMSA*)(ptr) = msip32a; + msip16 = (LPMCI_SYSINFO_PARMS16)(ptr + sizeof(LPMCI_SYSINFO_PARMSA)); + + msip16->dwCallback = msip32a->dwCallback; + msip16->lpstrReturn = MapLS( msip32a->lpstrReturn ); + msip16->dwRetSize = msip32a->dwRetSize; + msip16->dwNumber = msip32a->dwNumber; + msip16->wDeviceType = msip32a->wDeviceType; + } else { + return WINMM_MAP_NOMEM; + } + *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_SYSINFO_PARMSA); + } + return WINMM_MAP_OKMEM; + /* case MCI_UNDO: */ + case MCI_UNFREEZE: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; break; + case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS16); map = 0x0001111B; break; + default: size = sizeof(MCI_GENERIC_PARMS); break; + } + break; + case MCI_UPDATE: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_UPDATE_PARMS16); map = 0x000B1111B; break; + default: size = sizeof(MCI_GENERIC_PARMS); break; + } + break; + case MCI_WHERE: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; keep = TRUE; break; + case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS16); map = 0x0001111B; keep = TRUE; break; + default: size = sizeof(MCI_GENERIC_PARMS); break; + } + break; + case MCI_WINDOW: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_WINDOW_PARMS16); if (dwFlags & MCI_DGV_WINDOW_TEXT) map = 0x7FB; break; + case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_WINDOW_PARMS16); if (dwFlags & MCI_OVLY_WINDOW_TEXT) map = 0x7FB; break; + default: size = sizeof(MCI_GENERIC_PARMS); break; + } + break; + case DRV_OPEN: + { + LPMCI_OPEN_DRIVER_PARMSA modp32a = (LPMCI_OPEN_DRIVER_PARMSA)(*lParam); + LPMCI_OPEN_DRIVER_PARMS16 modp16; + char *ptr = HeapAlloc( GetProcessHeap(), 0, + sizeof(LPMCI_OPEN_DRIVER_PARMSA) + sizeof(MCI_OPEN_DRIVER_PARMS16)); - MMDrvsHi++; + if (ptr) { + *(LPMCI_OPEN_DRIVER_PARMSA*)(ptr) = modp32a; + modp16 = (LPMCI_OPEN_DRIVER_PARMS16)(ptr + sizeof(LPMCI_OPEN_DRIVER_PARMSA)); + modp16->wDeviceID = modp32a->wDeviceID; + modp16->lpstrParams = MapLS( modp32a->lpstrParams ); + /* other fields are gonna be filled by the driver, don't copy them */ + } else { + return WINMM_MAP_NOMEM; + } + *lParam = (LPARAM)MapLS(ptr) + sizeof(LPMCI_OPEN_DRIVER_PARMSA); + } + return WINMM_MAP_OKMEM; + case DRV_LOAD: + case DRV_ENABLE: + case DRV_CLOSE: + case DRV_DISABLE: + case DRV_FREE: + case DRV_CONFIGURE: + case DRV_QUERYCONFIGURE: + case DRV_INSTALL: + case DRV_REMOVE: + case DRV_EXITSESSION: + case DRV_EXITAPPLICATION: + case DRV_POWER: + return WINMM_MAP_OK; - return TRUE; + default: + WARN("Don't know how to map msg=%s\n", MCI_MessageToString(wMsg)); + return WINMM_MAP_MSGERROR; + } + return MCI_MsgMapper32To16_Create((void**)lParam, size, map, keep); } /************************************************************************** - * MMDRV_InitFromRegistry [internal] + * MCI_UnMapMsg32ATo16 [internal] */ -static BOOL MMDRV_InitFromRegistry(void) +WINMM_MapType MCI_UnMapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD lParam) { - HKEY hKey; - char buffer[256]; - char* p1; - char* p2; - DWORD type, size; - BOOL ret = FALSE; + int size = 0; + BOOLEAN kept = FALSE; /* there is no need to compute size when kept is FALSE */ + DWORD map = 0; - if (RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\WinMM", &hKey)) { - TRACE("Cannot open WinMM config key\n"); - return FALSE; - } + switch (wMsg) { + case MCI_BREAK: + break; + /* case MCI_CAPTURE */ + case MCI_CLOSE: + case MCI_CLOSE_DRIVER: + case MCI_CONFIGURE: + break; + /* case MCI_COPY: */ + case MCI_CUE: + break; + /* case MCI_CUT: */ + case MCI_DELETE: + break; + /* case MCI_ESCAPE: */ + case MCI_FREEZE: + break; + case MCI_GETDEVCAPS: + kept = TRUE; + size = sizeof(MCI_GETDEVCAPS_PARMS); + break; + /* case MCI_INDEX: */ + case MCI_INFO: + { + LPMCI_INFO_PARMS16 mip16 = (LPMCI_INFO_PARMS16)MapSL(lParam); + UnMapLS( lParam ); + UnMapLS( mip16->lpstrReturn ); + HeapFree( GetProcessHeap(), 0, mip16 ); + } + return WINMM_MAP_OK; + /* case MCI_MARK: */ + /* case MCI_MONITOR: */ + case MCI_OPEN: + case MCI_OPEN_DRIVER: + if (lParam) { + LPMCI_OPEN_PARMS16 mop16 = (LPMCI_OPEN_PARMS16)MapSL(lParam); + LPMCI_OPEN_PARMSA mop32a = *(LPMCI_OPEN_PARMSA*)((char*)mop16 - sizeof(LPMCI_OPEN_PARMSA)); + UnMapLS( lParam ); + mop32a->wDeviceID = mop16->wDeviceID; + if ((dwFlags & MCI_OPEN_TYPE) && !(dwFlags & MCI_OPEN_TYPE_ID)) + UnMapLS( mop16->lpstrDeviceType ); + if ((dwFlags & MCI_OPEN_ELEMENT) && !(dwFlags & MCI_OPEN_ELEMENT_ID)) + UnMapLS( mop16->lpstrElementName ); + if (dwFlags & MCI_OPEN_ALIAS) + UnMapLS( mop16->lpstrAlias ); + HeapFree( GetProcessHeap(), 0, (char*)mop16 - sizeof(LPMCI_OPEN_PARMSA) ); + } + return WINMM_MAP_OK; + /* case MCI_PASTE:*/ + case MCI_PAUSE: + break; + case MCI_PLAY: + break; + case MCI_PUT: + break; + case MCI_REALIZE: + break; + case MCI_RECORD: + break; + case MCI_RESUME: + break; + case MCI_SEEK: + break; + case MCI_SET: + break; + case MCI_SETAUDIO: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: map = 0x0000077FF; break; + case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_SETAUDIO_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM; + } + break; + /* case MCI_SETTIMECODE:*/ + /* case MCI_SIGNAL:*/ + case MCI_SPIN: + break; + case MCI_STATUS: + kept = TRUE; + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: + if (lParam) { + LPMCI_DGV_STATUS_PARMS16 mdsp16 = (LPMCI_DGV_STATUS_PARMS16)MapSL(lParam); + LPMCI_DGV_STATUS_PARMSA mdsp32a = *(LPMCI_DGV_STATUS_PARMSA*)((char*)mdsp16 - sizeof(LPMCI_DGV_STATUS_PARMSA)); + + UnMapLS( lParam ); + if (mdsp16) { + mdsp32a->dwReturn = mdsp16->dwReturn; + if (dwFlags & MCI_DGV_STATUS_DISKSPACE) { + TRACE("MCI_STATUS (DGV) lpstrDrive=%08lx\n", mdsp16->lpstrDrive); + TRACE("MCI_STATUS (DGV) lpstrDrive=%s\n", (LPSTR)MapSL(mdsp16->lpstrDrive)); + UnMapLS( mdsp16->lpstrDrive ); + } + HeapFree( GetProcessHeap(), 0, (char*)mdsp16 - sizeof(LPMCI_DGV_STATUS_PARMSA) ); + } else { + return WINMM_MAP_NOMEM; + } + } + return WINMM_MAP_OKMEM; + case MCI_DEVTYPE_VCR: /*size = sizeof(MCI_VCR_STATUS_PARMS); break;*/FIXME("NIY vcr\n"); return WINMM_MAP_NOMEM; + default: size = sizeof(MCI_STATUS_PARMS); break; + } + break; + case MCI_STEP: + break; + case MCI_STOP: + break; + case MCI_SYSINFO: + if (lParam) { + LPMCI_SYSINFO_PARMS16 msip16 = (LPMCI_SYSINFO_PARMS16)MapSL(lParam); + LPMCI_SYSINFO_PARMSA msip32a = *(LPMCI_SYSINFO_PARMSA*)((char*)msip16 - sizeof(LPMCI_SYSINFO_PARMSA)); - size = sizeof(buffer); - if (!RegQueryValueExA(hKey, "Drivers", 0, &type, (LPVOID)buffer, &size)) { - p1 = buffer; - while (p1) { - p2 = strchr(p1, ';'); - if (p2) *p2++ = '\0'; - ret |= MMDRV_Install(p1, p1, FALSE); - p1 = p2; + UnMapLS( lParam ); + if (msip16) { + msip16->dwCallback = msip32a->dwCallback; + UnMapLS( msip16->lpstrReturn ); + HeapFree( GetProcessHeap(), 0, (char*)msip16 - sizeof(LPMCI_SYSINFO_PARMSA) ); + } else { + return WINMM_MAP_NOMEM; + } } + return WINMM_MAP_OKMEM; + /* case MCI_UNDO: */ + case MCI_UNFREEZE: + break; + case MCI_UPDATE: + break; + case MCI_WHERE: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_RECT_PARMS16); map = 0x0001111B; kept = TRUE; break; + case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_RECT_PARMS16); map = 0x0001111B; kept = TRUE; break; + default: break; + } + break; + case MCI_WINDOW: + switch (uDevType) { + case MCI_DEVTYPE_DIGITAL_VIDEO: size = sizeof(MCI_DGV_WINDOW_PARMS16); if (dwFlags & MCI_DGV_WINDOW_TEXT) map = 0x7666; break; + case MCI_DEVTYPE_OVERLAY: size = sizeof(MCI_OVLY_WINDOW_PARMS16); if (dwFlags & MCI_OVLY_WINDOW_TEXT) map = 0x7666; break; + default: break; + } + /* FIXME: see map function */ + break; + + case DRV_OPEN: + if (lParam) { + LPMCI_OPEN_DRIVER_PARMS16 modp16 = (LPMCI_OPEN_DRIVER_PARMS16)MapSL(lParam); + LPMCI_OPEN_DRIVER_PARMSA modp32a = *(LPMCI_OPEN_DRIVER_PARMSA*)((char*)modp16 - sizeof(LPMCI_OPEN_DRIVER_PARMSA)); + + UnMapLS( lParam ); + modp32a->wCustomCommandTable = modp16->wCustomCommandTable; + modp32a->wType = modp16->wType; + UnMapLS( modp16->lpstrParams ); + HeapFree( GetProcessHeap(), 0, (char *)modp16 - sizeof(LPMCI_OPEN_DRIVER_PARMSA) ); + } + return WINMM_MAP_OK; + case DRV_LOAD: + case DRV_ENABLE: + case DRV_CLOSE: + case DRV_DISABLE: + case DRV_FREE: + case DRV_CONFIGURE: + case DRV_QUERYCONFIGURE: + case DRV_INSTALL: + case DRV_REMOVE: + case DRV_EXITSESSION: + case DRV_EXITAPPLICATION: + case DRV_POWER: + FIXME("This is a hack\n"); + return WINMM_MAP_OK; + default: + FIXME("Map/Unmap internal error on msg=%s\n", MCI_MessageToString(wMsg)); + return WINMM_MAP_MSGERROR; } - - /* finish with mappers */ - size = sizeof(buffer); - if (!RegQueryValueExA(hKey, "WaveMapper", 0, &type, (LPVOID)buffer, &size)) - ret |= MMDRV_Install("wavemapper", buffer, TRUE); - size = sizeof(buffer); - if (!RegQueryValueExA(hKey, "MidiMapper", 0, &type, (LPVOID)buffer, &size)) - ret |= MMDRV_Install("midimapper", buffer, TRUE); - - RegCloseKey(hKey); - - return ret; + return MCI_MsgMapper32To16_Destroy((void*)lParam, size, map, kept); } -/************************************************************************** - * MMDRV_InitHardcoded [internal] - */ -static BOOL MMDRV_InitHardcoded(void) -{ - /* first load hardware drivers */ - MMDRV_Install("wineoss.drv", "wineoss.drv", FALSE); - - /* finish with mappers */ - MMDRV_Install("wavemapper", "msacm.drv", TRUE); - MMDRV_Install("midimapper", "midimap.drv", TRUE); - - return TRUE; -} - -/************************************************************************** - * MMDRV_Init [internal] - */ -BOOL MMDRV_Init(void) -{ - /* FIXME: MMDRV_InitFromRegistry shall be MMDRV_Init in a near future */ - return MMDRV_InitFromRegistry() || MMDRV_InitHardcoded(); -} diff --git a/dlls/winmm/winemm.h b/dlls/winmm/winemm.h index aba847e24b1..e6d5d9295b3 100644 --- a/dlls/winmm/winemm.h +++ b/dlls/winmm/winemm.h @@ -57,6 +57,40 @@ typedef struct tagWINE_DRIVER struct tagWINE_DRIVER* lpNextItem; } WINE_DRIVER, *LPWINE_DRIVER; +typedef DWORD (CALLBACK *WINEMM_msgFunc16)(UINT16, WORD, DWORD, DWORD, DWORD); +typedef DWORD (CALLBACK *WINEMM_msgFunc32)(UINT , UINT, DWORD, DWORD, DWORD); + +/* for each loaded driver and each known type of driver, this structure contains + * the information needed to access it + */ +typedef struct tagWINE_MM_DRIVER_PART { + int nIDMin; /* lower bound of global indexes for this type */ + int nIDMax; /* hhigher bound of global indexes for this type */ + union { + WINEMM_msgFunc32 fnMessage32; /* pointer to fonction */ + WINEMM_msgFunc16 fnMessage16; + } u; +} WINE_MM_DRIVER_PART; + +#define MMDRV_AUX 0 +#define MMDRV_MIXER 1 +#define MMDRV_MIDIIN 2 +#define MMDRV_MIDIOUT 3 +#define MMDRV_WAVEIN 4 +#define MMDRV_WAVEOUT 5 +#define MMDRV_MAX 6 + +/* each low-level .drv will be associated with an instance of this structure */ +typedef struct tagWINE_MM_DRIVER { + HDRVR hDriver; + LPSTR drvname; /* name of the driver */ + BOOL bIs32 : 1, /* TRUE if 32 bit driver, FALSE for 16 */ + bIsMapper : 1; /* TRUE if mapper */ + WINE_MM_DRIVER_PART parts[MMDRV_MAX];/* Information for all known types */ +} WINE_MM_DRIVER, *LPWINE_MM_DRIVER; + +typedef WINMM_MapType (*MMDRV_MAPFUNC)(UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); + typedef struct tagWINE_MLD { /* EPP struct tagWINE_MLD* lpNext; */ /* not used so far */ UINT uDeviceID; @@ -83,26 +117,6 @@ typedef struct { WINE_MLD mld; } WINE_MIXER, *LPWINE_MIXER; -extern BOOL MMDRV_Init(void); -extern UINT MMDRV_GetNum(UINT); -extern LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags, - DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32); -extern void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld); -extern DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwParam2); -extern DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg); -extern LPWINE_MLD MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID); -extern LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType, BOOL bSrcCanBeID, UINT dstTyped); -extern DWORD MMDRV_Message(LPWINE_MLD mld, WORD wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32); -extern UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD dwParam1, DWORD dwParam2); - -#define MMDRV_AUX 0 -#define MMDRV_MIXER 1 -#define MMDRV_MIDIIN 2 -#define MMDRV_MIDIOUT 3 -#define MMDRV_WAVEIN 4 -#define MMDRV_WAVEOUT 5 -#define MMDRV_MAX 6 - #define WINE_MMTHREAD_CREATED 0x4153494C /* "BSIL" */ #define WINE_MMTHREAD_DELETED 0xDEADDEAD @@ -215,63 +229,114 @@ typedef struct tagWINE_MM_IDATA { typedef LONG (*MCIPROC16)(DWORD, HDRVR16, WORD, DWORD, DWORD); typedef LONG (*MCIPROC)(DWORD, HDRVR, DWORD, DWORD, DWORD); -extern LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr); -extern BOOL DRIVER_GetLibName(LPCSTR keyName, LPCSTR sectName, LPSTR buf, int sz); -extern LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCSTR fn, LPARAM lParam2); - -extern LPWINE_MCIDRIVER MCI_GetDriver(UINT16 uDevID); -extern UINT MCI_GetDriverFromString(LPCSTR str); -extern DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr); -extern const char* MCI_MessageToString(UINT16 wMsg); - -extern UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data); - -extern LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2, BOOL bIs32); - -extern DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32); -extern DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2); -extern DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2); - -void CALLBACK WINE_mmThreadEntryPoint(DWORD _pmt); - -void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32, const MMTIME16* mmt16); -void MMSYSTEM_MMTIME32to16(LPMMTIME16 mmt16, const MMTIME* mmt32); - -UINT MMSYSTEM_mixerOpen(LPHMIXER lphMix, UINT uDeviceID, DWORD dwCallback, - DWORD dwInstance, DWORD fdwOpen, BOOL bFrom32); -UINT MMSYSTEM_midiOutOpen(HMIDIOUT* lphMidiOut, UINT uDeviceID, DWORD dwCallback, - DWORD dwInstance, DWORD dwFlags, BOOL bFrom32); -UINT MMSYSTEM_midiInOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD dwCallback, - DWORD dwInstance, DWORD dwFlags, BOOL bFrom32); -MMRESULT MMSYSTEM_MidiStream_Open(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, - DWORD cMidi, DWORD dwCallback, - DWORD dwInstance, DWORD fdwOpen, BOOL bFrom32); -UINT MMSYSTEM_waveOpen(HANDLE* lphndl, UINT uDeviceID, UINT uType, - const LPWAVEFORMATEX lpFormat, DWORD dwCallback, - DWORD dwInstance, DWORD dwFlags, BOOL bFrom32); -WORD timeSetEventInternal(UINT wDelay, UINT wResol, - FARPROC16 lpFunc, DWORD dwUser, UINT wFlags); -HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, - DWORD dwOpenFlags, enum mmioProcType type); -LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc, - DWORD dwFlags, enum mmioProcType type); -LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1, - LPARAM lParam2, enum mmioProcType type); -LPWINE_MMIO MMIO_Get(HMMIO h); - -BOOL MULTIMEDIA_MciInit(void); -BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode); - -void TIME_MMTimeStart(void); -void TIME_MMTimeStop(void); - -/* temporary defines */ +LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr); +BOOL DRIVER_GetLibName(LPCSTR keyName, LPCSTR sectName, LPSTR buf, int sz); +LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCSTR fn, LPARAM lParam2); + +BOOL MMDRV_Init(void); +UINT MMDRV_GetNum(UINT); +LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags, + DWORD* dwCallback, DWORD* dwInstance, BOOL bFrom32); +void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld); +DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwParam2); +DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg); +LPWINE_MLD MMDRV_Get(HANDLE hndl, UINT type, BOOL bCanBeID); +LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType, BOOL bSrcCanBeID, UINT dstTyped); +DWORD MMDRV_Message(LPWINE_MLD mld, WORD wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32); +UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD dwParam1, DWORD dwParam2); +BOOL MMDRV_Is32(unsigned int); + +WINE_MCIDRIVER* MCI_GetDriver(UINT16 uDevID); +UINT MCI_GetDriverFromString(LPCSTR str); +DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr); +const char* MCI_MessageToString(UINT16 wMsg); +UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data); +LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2, BOOL bIs32); +DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32); +DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2); +DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2); + +void CALLBACK WINE_mmThreadEntryPoint(DWORD _pmt); + +void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32, const MMTIME16* mmt16); +void MMSYSTEM_MMTIME32to16(LPMMTIME16 mmt16, const MMTIME* mmt32); + +UINT MMSYSTEM_mixerOpen(LPHMIXER lphMix, UINT uDeviceID, DWORD dwCallback, + DWORD dwInstance, DWORD fdwOpen, BOOL bFrom32); +UINT MMSYSTEM_midiOutOpen(HMIDIOUT* lphMidiOut, UINT uDeviceID, DWORD dwCallback, + DWORD dwInstance, DWORD dwFlags, BOOL bFrom32); +UINT MMSYSTEM_midiInOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD dwCallback, + DWORD dwInstance, DWORD dwFlags, BOOL bFrom32); +MMRESULT MMSYSTEM_MidiStream_Open(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, + DWORD cMidi, DWORD dwCallback, + DWORD dwInstance, DWORD fdwOpen, BOOL bFrom32); +UINT MMSYSTEM_waveOpen(HANDLE* lphndl, UINT uDeviceID, UINT uType, + const LPWAVEFORMATEX lpFormat, DWORD dwCallback, + DWORD dwInstance, DWORD dwFlags, BOOL bFrom32); + +WORD timeSetEventInternal(UINT wDelay, UINT wResol, + FARPROC16 lpFunc, DWORD dwUser, UINT wFlags); + +HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, + DWORD dwOpenFlags, enum mmioProcType type); +LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc, + DWORD dwFlags, enum mmioProcType type); +LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1, + LPARAM lParam2, enum mmioProcType type); +LPWINE_MMIO MMIO_Get(HMMIO h); + +BOOL MULTIMEDIA_MciInit(void); +BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode); + +void TIME_MMTimeStart(void); +void TIME_MMTimeStop(void); + +/* temporary definitions */ WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2); WINMM_MapType DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2); WINMM_MapType MCI_MapMsg16To32A (WORD uDevType, WORD wMsg, DWORD* lParam); WINMM_MapType MCI_UnMapMsg16To32A(WORD uDevType, WORD wMsg, DWORD lParam); WINMM_MapType MCI_MapMsg32ATo16 (WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD* lParam); WINMM_MapType MCI_UnMapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD lParam); +void MMDRV_Callback(LPWINE_MLD mld, HDRVR hDev, UINT uMsg, DWORD dwParam1, DWORD dwParam2); + +WINMM_MapType MMDRV_Aux_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_Aux_UnMap16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_Aux_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_Aux_UnMap32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +void CALLBACK MMDRV_Aux_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2); + +WINMM_MapType MMDRV_Mixer_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_Mixer_UnMap16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_Mixer_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_Mixer_UnMap32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +void CALLBACK MMDRV_Mixer_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2); + +WINMM_MapType MMDRV_MidiIn_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_MidiIn_UnMap16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_MidiIn_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_MidiIn_UnMap32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +void CALLBACK MMDRV_MidiIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2); + +WINMM_MapType MMDRV_MidiOut_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_MidiOut_UnMap16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_MidiOut_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_MidiOut_UnMap32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +void CALLBACK MMDRV_MidiOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2); + +WINMM_MapType MMDRV_WaveIn_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_WaveIn_UnMap16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_WaveIn_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_WaveIn_UnMap32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +void CALLBACK MMDRV_WaveIn_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2); + +WINMM_MapType MMDRV_WaveOut_Map16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_WaveOut_UnMap16To32A (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_WaveOut_Map32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +WINMM_MapType MMDRV_WaveOut_UnMap32ATo16 (UINT wMsg, LPDWORD lpdwUser, LPDWORD lpParam1, LPDWORD lpParam2); +void CALLBACK MMDRV_WaveOut_Callback(HDRVR hDev, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2); + +BOOL MMDRV_GetDescription16(const char* fname, char* buf, int buflen); /* Global variables */ extern LPWINE_MM_IDATA WINMM_IData; -- 2.11.4.GIT