the remaining part for 16/32 splitting. this one was a bit more complicated this patch also fixes buffer handling in mmio (now 32 bit calls to mmio will no longer allocate a 16 bit (segmented) buffer) btw: this patch is the last one for removing the mmsystem entry points when compiling with win16 disabled however, the code still allows to load 16 bit drivers (and still has the code to do, for example, 32 <=> 16 data structure mapping) this will still cause problems (for example while compiling for mingw) Alexandre, do you have some global plans for splitting further... not linking on compilation unit will not be sufficient, we need a finer grain control but #ifdef the code for that wouldn't be a good idea IMO any other suggestions ? A+
Name: mm1632_3 ChangeLog: keep on moving 16 bit code out of winmm License: X11 GenDate: 2002/10/12 16:46:54 UTC ModifiedFiles: dlls/winmm/mmio.c dlls/winmm/mmsystem.c dlls/winmm/mmsystem.spec dlls/winmm/winemm.h AddedFiles: =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/mmio.c,v retrieving revision 1.34 diff -u -u -r1.34 mmio.c --- dlls/winmm/mmio.c 9 Aug 2002 19:51:01 -0000 1.34 +++ dlls/winmm/mmio.c 12 Oct 2002 16:46:48 -0000 @@ -24,11 +24,12 @@ /* Still to be done: * + correct handling of global/local IOProcs * + mode of mmio objects is not used (read vs write vs readwrite) - * + optimization of internal buffers (seg / lin) - * + even in 32 bit only, a seg ptr IO buffer is allocated (after this is - * fixed, we'll have a proper 32/16 separation) * + thread safeness * + rename operation is broken + * + * Note: + * In internal info struct (wm->info), the dwReserved1 field is used + * to store the segmented address of the wm->info.pchBuffer buffer. */ #include <ctype.h> @@ -39,9 +40,6 @@ #include "mmsystem.h" #include "windef.h" - -#include "wine/mmsystem16.h" -#include "wine/winbase16.h" #include "heap.h" #include "winemm.h" @@ -230,8 +228,6 @@ } -enum mmioProcType {MMIO_PROC_16,MMIO_PROC_32A,MMIO_PROC_32W}; - struct IOProcList { struct IOProcList*pNext; /* Next item in linked list */ @@ -270,8 +266,8 @@ /**************************************************************** * MMIO_InstallIOProc [INTERNAL] */ -static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc, - DWORD dwFlags, enum mmioProcType type) +LPMMIOPROC MMSYSTEM_mmioInstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc, + DWORD dwFlags, enum mmioProcType type) { LPMMIOPROC lpProc = NULL; struct IOProcList* pListNode; @@ -397,7 +393,7 @@ static LRESULT MMIO_SendMessage(LPWINE_MMIO wm, DWORD wMsg, LPARAM lParam1, LPARAM lParam2, enum mmioProcType type) { - MMIOINFO16 mmioInfo16; + MMIOINFO16 mmioInfo16; LRESULT result; SEGPTR segmmioInfo16; LPARAM lp1 = lParam1, lp2 = lParam2; @@ -626,9 +622,9 @@ * MMIO_SetBuffer [INTERNAL] */ static MMRESULT MMIO_SetBuffer(WINE_MMIO* wm, void* pchBuffer, LONG cchBuffer, - UINT uFlags, BOOL bFrom32) + UINT uFlags) { - TRACE("(%p %p %ld %u %d)\n", wm, pchBuffer, cchBuffer, uFlags, bFrom32); + TRACE("(%p %p %ld %u)\n", wm, pchBuffer, cchBuffer, uFlags); if (uFlags) return MMSYSERR_INVALPARAM; if (cchBuffer > 0xFFFF) @@ -637,36 +633,32 @@ if (MMIO_Flush(wm, 0) != MMSYSERR_NOERROR) return MMIOERR_CANNOTWRITE; - if (wm->hMem && (wm->info.dwFlags & MMIO_ALLOCBUF)) { - GlobalUnlock16(wm->hMem); - GlobalFree16(wm->hMem); - wm->hMem = 0; + /* free previous buffer if allocated */ + if (wm->info.dwFlags & MMIO_ALLOCBUF) { + HeapFree(GetProcessHeap(), 0, wm->info.pchBuffer); + wm->info.pchBuffer = NULL; wm->info.dwFlags &= ~MMIO_ALLOCBUF; } + /* free segmented ptr mapping, if any */ + if (wm->info.dwReserved1 != 0L) + { + UnMapLS(wm->info.dwReserved1); + wm->info.dwReserved1 = 0L; + } + if (pchBuffer) { - if (bFrom32) { - wm->info.pchBuffer = pchBuffer; - wm->buffer16 = 0; - } else { - wm->info.pchBuffer = MapSL((SEGPTR)pchBuffer); - wm->buffer16 = (SEGPTR)pchBuffer; - } - wm->hMem = 0; + wm->info.pchBuffer = pchBuffer; } else if (cchBuffer) { - if (!(wm->hMem = GlobalAlloc16(GMEM_MOVEABLE, cchBuffer))) + if (!(wm->info.pchBuffer = HeapAlloc(GetProcessHeap(), 0, cchBuffer))) return MMIOERR_OUTOFMEMORY; wm->info.dwFlags |= MMIO_ALLOCBUF; } else { wm->info.pchBuffer = NULL; - wm->hMem = 0; - wm->buffer16 = 0; } - if (wm->hMem) { - wm->buffer16 = K32WOWGlobalLock16(wm->hMem); - wm->info.pchBuffer = MapSL(wm->buffer16); - } + if (wm->ioProc->type == MMIO_PROC_16) + wm->info.dwReserved1 = MapLS(wm->info.pchBuffer); wm->info.cchBuffer = cchBuffer; wm->info.pchNext = wm->info.pchBuffer; @@ -679,10 +671,10 @@ } /************************************************************************** - * MMIO_Open [internal] + * MMSYSTEM_mmioOpen [internal] */ -static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, - DWORD dwOpenFlags, enum mmioProcType type) +HMMIO MMSYSTEM_mmioOpen(LPSTR szFileName, MMIOINFO* refmminfo, + DWORD dwOpenFlags, enum mmioProcType type) { LPWINE_MMIO wm; @@ -723,8 +715,8 @@ else { wm->info.fccIOProc = refmminfo->fccIOProc; wm->info.pIOProc = refmminfo->pIOProc; - MMIO_InstallIOProc(wm->info.fccIOProc, wm->info.pIOProc, - MMIO_INSTALLPROC, type); + MMSYSTEM_mmioInstallIOProc(wm->info.fccIOProc, wm->info.pIOProc, + MMIO_INSTALLPROC, type); if (!(wm->ioProc = MMIO_FindProcNode(wm->info.fccIOProc))) goto error2; assert(wm->ioProc->pIOProc == refmminfo->pIOProc); wm->info.pIOProc = wm->ioProc->pIOProc; @@ -735,13 +727,13 @@ wm->ioProc->count++; if (dwOpenFlags & MMIO_ALLOCBUF) { - if ((refmminfo->wErrorRet = MMIO_SetBuffer(wm, NULL, MMIO_DEFAULTBUFFER, 0, - type != MMIO_PROC_16))) + if ((refmminfo->wErrorRet = MMIO_SetBuffer(wm, NULL, MMIO_DEFAULTBUFFER, 0))) goto error1; } else if (wm->info.fccIOProc == FOURCC_MEM) { - refmminfo->wErrorRet = MMIO_SetBuffer(wm, refmminfo->pchBuffer, - refmminfo->cchBuffer, 0, - type != MMIO_PROC_16); + void* ptr; + + ptr = (type == MMIO_PROC_16) ? MapSL((DWORD)refmminfo->pchBuffer) : refmminfo->pchBuffer; + refmminfo->wErrorRet = MMIO_SetBuffer(wm, ptr, refmminfo->cchBuffer, 0); if (refmminfo->wErrorRet != MMSYSERR_NOERROR) goto error1; wm->bBufferLoaded = TRUE; @@ -777,7 +769,7 @@ LPSTR szFn = HEAP_strdupWtoA(GetProcessHeap(), 0, szFileName); if (lpmmioinfo) { - ret = MMIO_Open(szFn, lpmmioinfo, dwOpenFlags, MMIO_PROC_32W); + ret = MMSYSTEM_mmioOpen(szFn, lpmmioinfo, dwOpenFlags, MMIO_PROC_32W); } else { MMIOINFO mmioinfo; @@ -786,7 +778,7 @@ mmioinfo.pchBuffer = NULL; mmioinfo.cchBuffer = 0; - ret = MMIO_Open(szFn, &mmioinfo, dwOpenFlags, MMIO_PROC_32W); + ret = MMSYSTEM_mmioOpen(szFn, &mmioinfo, dwOpenFlags, MMIO_PROC_32W); } HeapFree(GetProcessHeap(), 0, szFn); @@ -802,7 +794,7 @@ HMMIO ret; if (lpmmioinfo) { - ret = MMIO_Open(szFileName, lpmmioinfo, dwOpenFlags, MMIO_PROC_32A); + ret = MMSYSTEM_mmioOpen(szFileName, lpmmioinfo, dwOpenFlags, MMIO_PROC_32A); } else { MMIOINFO mmioinfo; @@ -811,51 +803,12 @@ mmioinfo.pchBuffer = NULL; mmioinfo.cchBuffer = 0; - ret = MMIO_Open(szFileName, &mmioinfo, dwOpenFlags, MMIO_PROC_32A); + ret = MMSYSTEM_mmioOpen(szFileName, &mmioinfo, dwOpenFlags, MMIO_PROC_32A); } return ret; } /************************************************************************** - * mmioOpen [MMSYSTEM.1210] - */ -HMMIO16 WINAPI mmioOpen16(LPSTR szFileName, MMIOINFO16* lpmmioinfo16, - DWORD dwOpenFlags) -{ - HMMIO ret; - MMIOINFO mmio; - - if (lpmmioinfo16) { - MMIOINFO mmioinfo; - - memset(&mmioinfo, 0, sizeof(mmioinfo)); - - mmioinfo.dwFlags = lpmmioinfo16->dwFlags; - mmioinfo.fccIOProc = lpmmioinfo16->fccIOProc; - mmioinfo.pIOProc = (LPMMIOPROC)lpmmioinfo16->pIOProc; - mmioinfo.cchBuffer = lpmmioinfo16->cchBuffer; - mmioinfo.pchBuffer = lpmmioinfo16->pchBuffer; - mmioinfo.adwInfo[0] = lpmmioinfo16->adwInfo[0]; - mmioinfo.adwInfo[1] = lpmmioinfo16->adwInfo[1]; - mmioinfo.adwInfo[2] = lpmmioinfo16->adwInfo[2]; - mmioinfo.adwInfo[3] = lpmmioinfo16->adwInfo[3]; - - ret = MMIO_Open(szFileName, &mmioinfo, dwOpenFlags, MMIO_PROC_16); - - mmioGetInfo16(HMMIO_16(mmioinfo.hmmio), lpmmioinfo16, 0); - lpmmioinfo16->wErrorRet = HMMIO_16(ret); - } else { - mmio.fccIOProc = 0; - mmio.pIOProc = NULL; - mmio.pchBuffer = NULL; - mmio.cchBuffer = 0; - ret = MMIO_Open(szFileName, &mmio, dwOpenFlags, FALSE); - } - return HMMIO_16(ret); -} - - -/************************************************************************** * mmioClose [WINMM.@] */ MMRESULT WINAPI mmioClose(HMMIO hmmio, UINT uFlags) @@ -873,13 +826,13 @@ result = MMIO_SendMessage(wm, MMIOM_CLOSE, uFlags, 0, MMIO_PROC_32A); - MMIO_SetBuffer(wm, NULL, 0, 0, TRUE); + MMIO_SetBuffer(wm, NULL, 0, 0); wm->ioProc->count--; if (wm->bTmpIOProc) - MMIO_InstallIOProc(wm->info.fccIOProc, NULL, - MMIO_REMOVEPROC, wm->ioProc->type); + MMSYSTEM_mmioInstallIOProc(wm->info.fccIOProc, NULL, + MMIO_REMOVEPROC, wm->ioProc->type); MMIO_Destroy(wm); @@ -887,14 +840,6 @@ } /************************************************************************** - * mmioClose [MMSYSTEM.1211] - */ -MMRESULT16 WINAPI mmioClose16(HMMIO16 hmmio, UINT16 uFlags) -{ - return mmioClose(HMMIO_32(hmmio), uFlags); -} - -/************************************************************************** * mmioRead [WINMM.@] */ LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch) @@ -944,14 +889,6 @@ } /************************************************************************** - * mmioRead [MMSYSTEM.1212] - */ -LONG WINAPI mmioRead16(HMMIO16 hmmio, HPSTR pch, LONG cch) -{ - return mmioRead(HMMIO_32(hmmio), pch, cch); -} - -/************************************************************************** * mmioWrite [WINMM.@] */ LONG WINAPI mmioWrite(HMMIO hmmio, HPCSTR pch, LONG cch) @@ -1006,14 +943,6 @@ } /************************************************************************** - * mmioWrite [MMSYSTEM.1213] - */ -LONG WINAPI mmioWrite16(HMMIO16 hmmio, HPCSTR pch, LONG cch) -{ - return mmioWrite(HMMIO_32(hmmio),pch,cch); -} - -/************************************************************************** * mmioSeek [WINMM.@] */ LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin) @@ -1079,52 +1008,6 @@ } /************************************************************************** - * mmioSeek [MMSYSTEM.1214] - */ -LONG WINAPI mmioSeek16(HMMIO16 hmmio, LONG lOffset, INT16 iOrigin) -{ - return mmioSeek(HMMIO_32(hmmio), lOffset, iOrigin); -} - -/************************************************************************** - * mmioGetInfo [MMSYSTEM.1215] - */ -MMRESULT16 WINAPI mmioGetInfo16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags) -{ - LPWINE_MMIO wm; - - TRACE("(0x%04x,%p,0x%08x)\n",hmmio,lpmmioinfo,uFlags); - - if ((wm = MMIO_Get(NULL, HMMIO_32(hmmio))) == NULL) - return MMSYSERR_INVALHANDLE; - - if (!wm->buffer16) - return MMSYSERR_ERROR; - - lpmmioinfo->dwFlags = wm->info.dwFlags; - lpmmioinfo->fccIOProc = wm->info.fccIOProc; - lpmmioinfo->pIOProc = (LPMMIOPROC16)wm->info.pIOProc; - lpmmioinfo->wErrorRet = wm->info.wErrorRet; - lpmmioinfo->hTask = wm->info.hTask; - lpmmioinfo->cchBuffer = wm->info.cchBuffer; - lpmmioinfo->pchBuffer = (void*)wm->buffer16; - lpmmioinfo->pchNext = (void*)(wm->buffer16 + (wm->info.pchNext - wm->info.pchBuffer)); - lpmmioinfo->pchEndRead = (void*)(wm->buffer16 + (wm->info.pchEndRead - wm->info.pchBuffer)); - lpmmioinfo->pchEndWrite = (void*)(wm->buffer16 + (wm->info.pchEndWrite - wm->info.pchBuffer)); - lpmmioinfo->lBufOffset = wm->info.lBufOffset; - lpmmioinfo->lDiskOffset = wm->info.lDiskOffset; - lpmmioinfo->adwInfo[0] = wm->info.adwInfo[0]; - lpmmioinfo->adwInfo[1] = wm->info.adwInfo[1]; - lpmmioinfo->adwInfo[2] = wm->info.adwInfo[2]; - lpmmioinfo->adwInfo[3] = wm->info.adwInfo[3]; - lpmmioinfo->dwReserved1 = 0; - lpmmioinfo->dwReserved2 = 0; - lpmmioinfo->hmmio = HMMIO_16(wm->info.hmmio); - - return MMSYSERR_NOERROR; -} - -/************************************************************************** * mmioGetInfo [WINMM.@] */ MMRESULT WINAPI mmioGetInfo(HMMIO hmmio, MMIOINFO* lpmmioinfo, UINT uFlags) @@ -1142,39 +1025,6 @@ } /************************************************************************** - * mmioSetInfo [MMSYSTEM.1216] - */ -MMRESULT16 WINAPI mmioSetInfo16(HMMIO16 hmmio, const MMIOINFO16* lpmmioinfo, UINT16 uFlags) -{ - LPWINE_MMIO wm; - - TRACE("(0x%04x,%p,0x%08x)\n",hmmio,lpmmioinfo,uFlags); - - if ((wm = MMIO_Get(NULL, HMMIO_32(hmmio))) == NULL) - return MMSYSERR_INVALHANDLE; - - /* check if seg and lin buffers are the same */ - if (wm->info.cchBuffer != lpmmioinfo->cchBuffer || - wm->info.pchBuffer != MapSL(wm->buffer16)) - return MMSYSERR_INVALPARAM; - - /* check pointers coherence */ - if (lpmmioinfo->pchNext < lpmmioinfo->pchBuffer || - lpmmioinfo->pchNext > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer || - lpmmioinfo->pchEndRead < lpmmioinfo->pchBuffer || - lpmmioinfo->pchEndRead > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer || - lpmmioinfo->pchEndWrite < lpmmioinfo->pchBuffer || - lpmmioinfo->pchEndWrite > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer) - return MMSYSERR_INVALPARAM; - - wm->info.pchNext = wm->info.pchBuffer + (lpmmioinfo->pchNext - lpmmioinfo->pchBuffer); - wm->info.pchEndRead = wm->info.pchBuffer + (lpmmioinfo->pchEndRead - lpmmioinfo->pchBuffer); - wm->info.pchEndWrite = wm->info.pchBuffer + (lpmmioinfo->pchEndWrite - lpmmioinfo->pchBuffer); - - return MMSYSERR_NOERROR; -} - -/************************************************************************** * mmioSetInfo [WINMM.@] */ MMRESULT WINAPI mmioSetInfo(HMMIO hmmio, const MMIOINFO* lpmmioinfo, UINT uFlags) @@ -1214,24 +1064,7 @@ if ((wm = MMIO_Get(NULL, hmmio)) == NULL) return MMSYSERR_INVALHANDLE; - return MMIO_SetBuffer(wm, pchBuffer, cchBuffer, uFlags, TRUE); -} - -/************************************************************************** - * mmioSetBuffer [MMSYSTEM.1217] - */ -MMRESULT16 WINAPI mmioSetBuffer16(HMMIO16 hmmio, LPSTR segpchBuffer, - LONG cchBuffer, UINT16 uFlags) -{ - LPWINE_MMIO wm; - - TRACE("(hmmio=%04x, segpchBuf=%p, cchBuf=%ld, uFlags=%#08x)\n", - hmmio, segpchBuffer, cchBuffer, uFlags); - - if ((wm = MMIO_Get(NULL, HMMIO_32(hmmio))) == NULL) - return MMSYSERR_INVALHANDLE; - - return MMIO_SetBuffer(wm, segpchBuffer, cchBuffer, uFlags, FALSE); + return MMIO_SetBuffer(wm, pchBuffer, cchBuffer, uFlags); } /************************************************************************** @@ -1250,14 +1083,6 @@ } /************************************************************************** - * mmioFlush [MMSYSTEM.1218] - */ -MMRESULT16 WINAPI mmioFlush16(HMMIO16 hmmio, UINT16 uFlags) -{ - return mmioFlush(HMMIO_32(hmmio), uFlags); -} - -/************************************************************************** * mmioAdvance [WINMM.@] */ MMRESULT WINAPI mmioAdvance(HMMIO hmmio, MMIOINFO* lpmmioinfo, UINT uFlags) @@ -1266,6 +1091,9 @@ TRACE("hmmio=%04X, lpmmioinfo=%p, uFlags=%04X\n", hmmio, lpmmioinfo, uFlags); + /* NOTE: mmioAdvance16 heavily relies on parameters from lpmmioinfo we're using + * here. be sure if you change something here to check mmioAdvance16 as well + */ if ((wm = MMIO_Get(NULL, hmmio)) == NULL) return MMSYSERR_INVALHANDLE; @@ -1286,7 +1114,8 @@ return MMIOERR_CANNOTWRITE; if (lpmmioinfo) { - wm->dwFileSize = max(wm->dwFileSize, lpmmioinfo->lBufOffset + (lpmmioinfo->pchNext - lpmmioinfo->pchBuffer)); + wm->dwFileSize = max(wm->dwFileSize, lpmmioinfo->lBufOffset + + (lpmmioinfo->pchNext - lpmmioinfo->pchBuffer)); } MMIO_GrabNextBuffer(wm, uFlags == MMIO_READ); @@ -1302,40 +1131,6 @@ return MMSYSERR_NOERROR; } -/*********************************************************************** - * mmioAdvance [MMSYSTEM.1219] - */ -MMRESULT16 WINAPI mmioAdvance16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags) -{ - LPWINE_MMIO wm; - - TRACE("hmmio=%04X, lpmmioinfo=%p, uFlags=%04X\n", hmmio, lpmmioinfo, uFlags); - - if ((wm = MMIO_Get(NULL, HMMIO_32(hmmio))) == NULL) - return MMSYSERR_INVALHANDLE; - - if (!wm->info.cchBuffer) - return MMIOERR_UNBUFFERED; - - if (uFlags != MMIO_READ && uFlags != MMIO_WRITE) - return MMSYSERR_INVALPARAM; - - if (MMIO_Flush(wm, 0) != MMSYSERR_NOERROR) - return MMIOERR_CANNOTWRITE; - - MMIO_GrabNextBuffer(wm, uFlags == MMIO_READ); - - lpmmioinfo->pchNext = lpmmioinfo->pchBuffer; - lpmmioinfo->pchEndRead = lpmmioinfo->pchBuffer + - (wm->info.pchEndRead - wm->info.pchBuffer); - lpmmioinfo->pchEndWrite = lpmmioinfo->pchBuffer + - (wm->info.pchEndWrite - wm->info.pchBuffer); - lpmmioinfo->lDiskOffset = wm->info.lDiskOffset; - lpmmioinfo->lBufOffset = wm->info.lBufOffset; - - return MMSYSERR_NOERROR; -} - /************************************************************************** * mmioStringToFOURCCA [WINMM.@] */ @@ -1372,30 +1167,12 @@ } /************************************************************************** - * mmioStringToFOURCC [MMSYSTEM.1220] - */ -FOURCC WINAPI mmioStringToFOURCC16(LPCSTR sz, UINT16 uFlags) -{ - return mmioStringToFOURCCA(sz, uFlags); -} - -/************************************************************************** - * mmioInstallIOProc [MMSYSTEM.1221] - */ -LPMMIOPROC16 WINAPI mmioInstallIOProc16(FOURCC fccIOProc, LPMMIOPROC16 pIOProc, - DWORD dwFlags) -{ - return (LPMMIOPROC16)MMIO_InstallIOProc(fccIOProc, (LPMMIOPROC)pIOProc, - dwFlags, MMIO_PROC_16); -} - -/************************************************************************** * mmioInstallIOProcA [WINMM.@] */ LPMMIOPROC WINAPI mmioInstallIOProcA(FOURCC fccIOProc, LPMMIOPROC pIOProc, DWORD dwFlags) { - return MMIO_InstallIOProc(fccIOProc, pIOProc, dwFlags, MMIO_PROC_32A); + return MMSYSTEM_mmioInstallIOProc(fccIOProc, pIOProc, dwFlags, MMIO_PROC_32A); } /************************************************************************** @@ -1404,26 +1181,28 @@ LPMMIOPROC WINAPI mmioInstallIOProcW(FOURCC fccIOProc, LPMMIOPROC pIOProc, DWORD dwFlags) { - return MMIO_InstallIOProc(fccIOProc, pIOProc, dwFlags, MMIO_PROC_32W); + return MMSYSTEM_mmioInstallIOProc(fccIOProc, pIOProc, dwFlags, MMIO_PROC_32W); } -/************************************************************************** - * mmioSendMessage [MMSYSTEM.1222] +/****************************************************************** + * MMSYSTEM_mmioSendMessage + * + * */ -LRESULT WINAPI mmioSendMessage16(HMMIO16 hmmio, UINT16 uMessage, - LPARAM lParam1, LPARAM lParam2) +LRESULT MMSYSTEM_mmioSendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1, + LPARAM lParam2, enum mmioProcType type) { LPWINE_MMIO wm; - TRACE("(%04X, %u, %ld, %ld)\n", hmmio, uMessage, lParam1, lParam2); + TRACE("(%04X, %u, %ld, %ld, %d)\n", hmmio, uMessage, lParam1, lParam2, type); if (uMessage < MMIOM_USER) return MMSYSERR_INVALPARAM; - if ((wm = MMIO_Get(NULL, HMMIO_32(hmmio))) == NULL) + if ((wm = MMIO_Get(NULL, hmmio)) == NULL) return MMSYSERR_INVALHANDLE; - return MMIO_SendMessage(wm, uMessage, lParam1, lParam2, MMIO_PROC_16); + return MMIO_SendMessage(wm, uMessage, lParam1, lParam2, type); } /************************************************************************** @@ -1432,17 +1211,7 @@ LRESULT WINAPI mmioSendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1, LPARAM lParam2) { - LPWINE_MMIO wm; - - TRACE("(%04X, %u, %ld, %ld)\n", hmmio, uMessage, lParam1, lParam2); - - if (uMessage < MMIOM_USER) - return MMSYSERR_INVALPARAM; - - if ((wm = MMIO_Get(NULL, hmmio)) == NULL) - return MMSYSERR_INVALHANDLE; - - return MMIO_SendMessage(wm, uMessage, lParam1, lParam2, MMIO_PROC_32A); + return MMSYSTEM_mmioSendMessage(hmmio, uMessage, lParam1, lParam2, MMIO_PROC_32A); } /************************************************************************** @@ -1550,15 +1319,6 @@ } /************************************************************************** - * mmioDescend [MMSYSTEM.1223] - */ -MMRESULT16 WINAPI mmioDescend16(HMMIO16 hmmio, LPMMCKINFO lpck, - const MMCKINFO* lpckParent, UINT16 uFlags) -{ - return mmioDescend(HMMIO_32(hmmio), lpck, lpckParent, uFlags); -} - -/************************************************************************** * mmioAscend [WINMM.@] */ MMRESULT WINAPI mmioAscend(HMMIO hmmio, LPMMCKINFO lpck, UINT uFlags) @@ -1593,14 +1353,6 @@ } /************************************************************************** - * mmioAscend [MMSYSTEM.1224] - */ -MMRESULT16 WINAPI mmioAscend16(HMMIO16 hmmio, MMCKINFO* lpck, UINT16 uFlags) -{ - return mmioAscend(HMMIO_32(hmmio),lpck,uFlags); -} - -/************************************************************************** * mmioCreateChunk [WINMM.@] */ MMRESULT WINAPI mmioCreateChunk(HMMIO hmmio, MMCKINFO* lpck, UINT uFlags) @@ -1640,50 +1392,6 @@ } /************************************************************************** - * mmioCreateChunk [MMSYSTEM.1225] - */ -MMRESULT16 WINAPI mmioCreateChunk16(HMMIO16 hmmio, MMCKINFO* lpck, UINT16 uFlags) -{ - return mmioCreateChunk(HMMIO_32(hmmio), lpck, uFlags); -} - -/************************************************************************** - * mmioRename [MMSYSTEM.1226] - */ -MMRESULT16 WINAPI mmioRename16(LPCSTR szFileName, LPCSTR szNewFileName, - MMIOINFO16* lpmmioinfo, DWORD dwRenameFlags) -{ - UINT16 result = MMSYSERR_ERROR; - LPMMIOPROC16 ioProc; - - TRACE("('%s', '%s', %p, %08lX);\n", - szFileName, szNewFileName, lpmmioinfo, dwRenameFlags); - - /* If both params are NULL, then parse the file name */ - if (lpmmioinfo && lpmmioinfo->fccIOProc == 0 && lpmmioinfo->pIOProc == NULL) - lpmmioinfo->fccIOProc = MMIO_ParseExt(szFileName); - - /* Handle any unhandled/error case from above. Assume DOS file */ - if (!lpmmioinfo || (lpmmioinfo->fccIOProc == 0 && lpmmioinfo->pIOProc == NULL)) - ioProc = (LPMMIOPROC16)mmioDosIOProc; - /* if just the four character code is present, look up IO proc */ - else if (lpmmioinfo->pIOProc == NULL) - ioProc = mmioInstallIOProc16(lpmmioinfo->fccIOProc, NULL, MMIO_FINDPROC); - else - ioProc = lpmmioinfo->pIOProc; - - /* FIXME: ioProc is likely a segmented address, thus needing a - * thunk somewhere. The main issue is that Wine's current thunking - * 32 to 16 only supports pascal calling convention - */ - if (ioProc) - result = (ioProc)(0, MMIOM_RENAME, - (LPARAM)szFileName, (LPARAM)szNewFileName); - - return result; -} - -/************************************************************************** * mmioRenameA [WINMM.@] */ MMRESULT WINAPI mmioRenameA(LPCSTR szFileName, LPCSTR szNewFileName, @@ -1704,8 +1412,8 @@ ioProc = (LPMMIOPROC)mmioDosIOProc; /* if just the four character code is present, look up IO proc */ else if (lpmmioinfo->pIOProc == NULL) - ioProc = MMIO_InstallIOProc(lpmmioinfo->fccIOProc, NULL, - MMIO_FINDPROC, MMIO_PROC_32A); + ioProc = MMSYSTEM_mmioInstallIOProc(lpmmioinfo->fccIOProc, NULL, + MMIO_FINDPROC, MMIO_PROC_32A); else /* use relevant ioProc */ ioProc = lpmmioinfo->pIOProc; @@ -1730,3 +1438,4 @@ HeapFree(GetProcessHeap(),0,sznFn); return ret; } + Index: dlls/winmm/mmsystem.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/mmsystem.c,v retrieving revision 1.72 diff -u -u -r1.72 mmsystem.c --- dlls/winmm/mmsystem.c 10 Oct 2002 23:28:22 -0000 1.72 +++ dlls/winmm/mmsystem.c 12 Oct 2002 16:26:26 -0000 @@ -2276,3 +2276,296 @@ return mciFreeCommandResource(uTable); } + +/************************************************************************** + * mmioOpen [MMSYSTEM.1210] + */ +HMMIO16 WINAPI mmioOpen16(LPSTR szFileName, MMIOINFO16* lpmmioinfo16, + DWORD dwOpenFlags) +{ + HMMIO ret; + MMIOINFO mmio; + + if (lpmmioinfo16) { + MMIOINFO mmioinfo; + + memset(&mmioinfo, 0, sizeof(mmioinfo)); + + mmioinfo.dwFlags = lpmmioinfo16->dwFlags; + mmioinfo.fccIOProc = lpmmioinfo16->fccIOProc; + mmioinfo.pIOProc = (LPMMIOPROC)lpmmioinfo16->pIOProc; + mmioinfo.cchBuffer = lpmmioinfo16->cchBuffer; + mmioinfo.pchBuffer = lpmmioinfo16->pchBuffer; + mmioinfo.adwInfo[0] = lpmmioinfo16->adwInfo[0]; + mmioinfo.adwInfo[1] = lpmmioinfo16->adwInfo[1]; + mmioinfo.adwInfo[2] = lpmmioinfo16->adwInfo[2]; + mmioinfo.adwInfo[3] = lpmmioinfo16->adwInfo[3]; + + ret = MMSYSTEM_mmioOpen(szFileName, &mmioinfo, dwOpenFlags, MMIO_PROC_16); + + mmioGetInfo16(HMMIO_16(mmioinfo.hmmio), lpmmioinfo16, 0); + lpmmioinfo16->wErrorRet = HMMIO_16(ret); + } else { + mmio.fccIOProc = 0; + mmio.pIOProc = NULL; + mmio.pchBuffer = NULL; + mmio.cchBuffer = 0; + ret = MMSYSTEM_mmioOpen(szFileName, &mmio, dwOpenFlags, MMIO_PROC_32A); + } + return HMMIO_16(ret); +} + +/************************************************************************** + * mmioClose [MMSYSTEM.1211] + */ +MMRESULT16 WINAPI mmioClose16(HMMIO16 hmmio, UINT16 uFlags) +{ + return mmioClose(HMMIO_32(hmmio), uFlags); +} + +/************************************************************************** + * mmioRead [MMSYSTEM.1212] + */ +LONG WINAPI mmioRead16(HMMIO16 hmmio, HPSTR pch, LONG cch) +{ + return mmioRead(HMMIO_32(hmmio), pch, cch); +} + +/************************************************************************** + * mmioWrite [MMSYSTEM.1213] + */ +LONG WINAPI mmioWrite16(HMMIO16 hmmio, HPCSTR pch, LONG cch) +{ + return mmioWrite(HMMIO_32(hmmio),pch,cch); +} + +/************************************************************************** + * mmioSeek [MMSYSTEM.1214] + */ +LONG WINAPI mmioSeek16(HMMIO16 hmmio, LONG lOffset, INT16 iOrigin) +{ + return mmioSeek(HMMIO_32(hmmio), lOffset, iOrigin); +} + +/************************************************************************** + * mmioGetInfo [MMSYSTEM.1215] + */ +MMRESULT16 WINAPI mmioGetInfo16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags) +{ + MMIOINFO mmioinfo; + MMRESULT ret; + + TRACE("(0x%04x,%p,0x%08x)\n", hmmio, lpmmioinfo, uFlags); + + ret = mmioGetInfo(HMMIO_32(hmmio), &mmioinfo, uFlags); + if (ret != MMSYSERR_NOERROR) return ret; + + if (!mmioinfo.dwReserved1) + return MMSYSERR_ERROR; /* FIXME */ + + lpmmioinfo->dwFlags = mmioinfo.dwFlags; + lpmmioinfo->fccIOProc = mmioinfo.fccIOProc; + lpmmioinfo->pIOProc = (LPMMIOPROC16)mmioinfo.pIOProc; /* FIXME ??? */ + lpmmioinfo->wErrorRet = mmioinfo.wErrorRet; + lpmmioinfo->hTask = mmioinfo.hTask; + lpmmioinfo->cchBuffer = mmioinfo.cchBuffer; + lpmmioinfo->pchBuffer = (void*)mmioinfo.dwReserved1; + lpmmioinfo->pchNext = (void*)(mmioinfo.dwReserved1 + (mmioinfo.pchNext - mmioinfo.pchBuffer)); + lpmmioinfo->pchEndRead = (void*)(mmioinfo.dwReserved1 + (mmioinfo.pchEndRead - mmioinfo.pchBuffer)); + lpmmioinfo->pchEndWrite = (void*)(mmioinfo.dwReserved1 + (mmioinfo.pchEndWrite - mmioinfo.pchBuffer)); + lpmmioinfo->lBufOffset = mmioinfo.lBufOffset; + lpmmioinfo->lDiskOffset = mmioinfo.lDiskOffset; + lpmmioinfo->adwInfo[0] = mmioinfo.adwInfo[0]; + lpmmioinfo->adwInfo[1] = mmioinfo.adwInfo[1]; + lpmmioinfo->adwInfo[2] = mmioinfo.adwInfo[2]; + lpmmioinfo->adwInfo[3] = mmioinfo.adwInfo[3]; + lpmmioinfo->dwReserved1 = 0; + lpmmioinfo->dwReserved2 = 0; + lpmmioinfo->hmmio = HMMIO_16(mmioinfo.hmmio); + + return MMSYSERR_NOERROR; +} + +/************************************************************************** + * mmioSetInfo [MMSYSTEM.1216] + */ +MMRESULT16 WINAPI mmioSetInfo16(HMMIO16 hmmio, const MMIOINFO16* lpmmioinfo, UINT16 uFlags) +{ + MMIOINFO mmioinfo; + MMRESULT ret; + + TRACE("(0x%04x,%p,0x%08x)\n",hmmio,lpmmioinfo,uFlags); + + ret = mmioGetInfo(HMMIO_32(hmmio), &mmioinfo, 0); + if (ret != MMSYSERR_NOERROR) return ret; + + /* check if seg and lin buffers are the same */ + if (mmioinfo.cchBuffer != lpmmioinfo->cchBuffer + /* FIXME || wm->info.pchBuffer != MapSL(wm->buffer16) */) + return MMSYSERR_INVALPARAM; + + /* check pointers coherence */ + if (lpmmioinfo->pchNext < lpmmioinfo->pchBuffer || + lpmmioinfo->pchNext > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer || + lpmmioinfo->pchEndRead < lpmmioinfo->pchBuffer || + lpmmioinfo->pchEndRead > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer || + lpmmioinfo->pchEndWrite < lpmmioinfo->pchBuffer || + lpmmioinfo->pchEndWrite > lpmmioinfo->pchBuffer + lpmmioinfo->cchBuffer) + return MMSYSERR_INVALPARAM; + + mmioinfo.pchNext = mmioinfo.pchBuffer + (lpmmioinfo->pchNext - lpmmioinfo->pchBuffer); + mmioinfo.pchEndRead = mmioinfo.pchBuffer + (lpmmioinfo->pchEndRead - lpmmioinfo->pchBuffer); + mmioinfo.pchEndWrite = mmioinfo.pchBuffer + (lpmmioinfo->pchEndWrite - lpmmioinfo->pchBuffer); + + return mmioSetInfo(HMMIO_32(hmmio), &mmioinfo, uFlags); +} + +/************************************************************************** + * mmioSetBuffer [MMSYSTEM.1217] + */ +MMRESULT16 WINAPI mmioSetBuffer16(HMMIO16 hmmio, LPSTR pchBuffer, + LONG cchBuffer, UINT16 uFlags) +{ + return mmioSetBuffer(HMMIO_32(hmmio), pchBuffer, cchBuffer, uFlags); +} + +/************************************************************************** + * mmioFlush [MMSYSTEM.1218] + */ +MMRESULT16 WINAPI mmioFlush16(HMMIO16 hmmio, UINT16 uFlags) +{ + return mmioFlush(HMMIO_32(hmmio), uFlags); +} + +/*********************************************************************** + * mmioAdvance [MMSYSTEM.1219] + */ +MMRESULT16 WINAPI mmioAdvance16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags) +{ + MMIOINFO mmioinfo; + LRESULT ret; + + /* FIXME: this heavily relies on mmioAdvance implementation (for choosing which + * fields to init + */ + if (lpmmioinfo) + { + mmioinfo.pchBuffer = MapSL((DWORD)lpmmioinfo->pchBuffer); + mmioinfo.pchNext = MapSL((DWORD)lpmmioinfo->pchNext); + mmioinfo.dwFlags = lpmmioinfo->dwFlags; + mmioinfo.lBufOffset = lpmmioinfo->lBufOffset; + ret = mmioAdvance(HMMIO_32(hmmio), &mmioinfo, uFlags); + } + else + ret = mmioAdvance(HMMIO_32(hmmio), NULL, uFlags); + + if (ret != MMSYSERR_NOERROR) return ret; + + if (lpmmioinfo) + { + lpmmioinfo->dwFlags = mmioinfo.dwFlags; + lpmmioinfo->pchNext = (void*)(lpmmioinfo->pchBuffer + (mmioinfo.pchNext - mmioinfo.pchBuffer)); + lpmmioinfo->pchEndRead = (void*)(lpmmioinfo->pchBuffer + (mmioinfo.pchEndRead - mmioinfo.pchBuffer)); + lpmmioinfo->pchEndWrite = (void*)(lpmmioinfo->pchBuffer + (mmioinfo.pchEndWrite - mmioinfo.pchBuffer)); + lpmmioinfo->lBufOffset = mmioinfo.lBufOffset; + lpmmioinfo->lDiskOffset = mmioinfo.lDiskOffset; + } + + return MMSYSERR_NOERROR; +} + +/************************************************************************** + * mmioStringToFOURCC [MMSYSTEM.1220] + */ +FOURCC WINAPI mmioStringToFOURCC16(LPCSTR sz, UINT16 uFlags) +{ + return mmioStringToFOURCCA(sz, uFlags); +} + +/************************************************************************** + * mmioInstallIOProc [MMSYSTEM.1221] + */ +LPMMIOPROC16 WINAPI mmioInstallIOProc16(FOURCC fccIOProc, LPMMIOPROC16 pIOProc, + DWORD dwFlags) +{ + return (LPMMIOPROC16)MMSYSTEM_mmioInstallIOProc(fccIOProc, (LPMMIOPROC)pIOProc, + dwFlags, MMIO_PROC_16); +} + +/************************************************************************** + * mmioSendMessage [MMSYSTEM.1222] + */ +LRESULT WINAPI mmioSendMessage16(HMMIO16 hmmio, UINT16 uMessage, + LPARAM lParam1, LPARAM lParam2) +{ + return MMSYSTEM_mmioSendMessage(HMMIO_32(hmmio), uMessage, + lParam1, lParam2, MMIO_PROC_16); +} + +/************************************************************************** + * mmioDescend [MMSYSTEM.1223] + */ +MMRESULT16 WINAPI mmioDescend16(HMMIO16 hmmio, LPMMCKINFO lpck, + const MMCKINFO* lpckParent, UINT16 uFlags) +{ + return mmioDescend(HMMIO_32(hmmio), lpck, lpckParent, uFlags); +} + +/************************************************************************** + * mmioAscend [MMSYSTEM.1224] + */ +MMRESULT16 WINAPI mmioAscend16(HMMIO16 hmmio, MMCKINFO* lpck, UINT16 uFlags) +{ + return mmioAscend(HMMIO_32(hmmio),lpck,uFlags); +} + +/************************************************************************** + * mmioCreateChunk [MMSYSTEM.1225] + */ +MMRESULT16 WINAPI mmioCreateChunk16(HMMIO16 hmmio, MMCKINFO* lpck, UINT16 uFlags) +{ + return mmioCreateChunk(HMMIO_32(hmmio), lpck, uFlags); +} + +/************************************************************************** + * mmioRename [MMSYSTEM.1226] + */ +MMRESULT16 WINAPI mmioRename16(LPCSTR szFileName, LPCSTR szNewFileName, + MMIOINFO16* lpmmioinfo, DWORD dwRenameFlags) +{ + /* this completly broken anyway, so get rif of it */ +#if 0 + UINT16 result = MMSYSERR_ERROR; + LPMMIOPROC16 ioProc; + + TRACE("('%s', '%s', %p, %08lX);\n", + szFileName, szNewFileName, lpmmioinfo, dwRenameFlags); + + /* If both params are NULL, then parse the file name */ + if (lpmmioinfo && lpmmioinfo->fccIOProc == 0 && lpmmioinfo->pIOProc == NULL) + lpmmioinfo->fccIOProc = MMIO_ParseExt(szFileName); + + /* Handle any unhandled/error case from above. Assume DOS file */ + if (!lpmmioinfo || (lpmmioinfo->fccIOProc == 0 && lpmmioinfo->pIOProc == NULL)) + ioProc = (LPMMIOPROC16)mmioDosIOProc; + /* if just the four character code is present, look up IO proc */ + else if (lpmmioinfo->pIOProc == NULL) + ioProc = mmioInstallIOProc16(lpmmioinfo->fccIOProc, NULL, MMIO_FINDPROC); + else + ioProc = lpmmioinfo->pIOProc; + + /* FIXME: ioProc is likely a segmented address, thus needing a + * thunk somewhere. The main issue is that Wine's current thunking + * 32 to 16 only supports pascal calling convention + */ + if (ioProc) + result = (ioProc)(0, MMIOM_RENAME, + (LPARAM)szFileName, (LPARAM)szNewFileName); + return result; +#else + FIXME("('%s', '%s', %p, %08lX): stub\n", + szFileName, szNewFileName, lpmmioinfo, dwRenameFlags); + return MMSYSERR_ERROR; +#endif +} + Index: dlls/winmm/mmsystem.spec =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/mmsystem.spec,v retrieving revision 1.11 diff -u -u -r1.11 mmsystem.spec --- dlls/winmm/mmsystem.spec 21 Jun 2002 19:15:50 -0000 1.11 +++ dlls/winmm/mmsystem.spec 12 Oct 2002 08:35:14 -0000 @@ -153,7 +153,7 @@ 1214 pascal mmioSeek(word long word) mmioSeek16 1215 pascal mmioGetInfo(word ptr word) mmioGetInfo16 1216 pascal mmioSetInfo(word ptr word) mmioSetInfo16 -1217 pascal mmioSetBuffer(word segptr long word) mmioSetBuffer16 +1217 pascal mmioSetBuffer(word ptr long word) mmioSetBuffer16 1218 pascal mmioFlush(word word) mmioFlush16 1219 pascal mmioAdvance(word ptr word) mmioAdvance16 1220 pascal mmioStringToFOURCC(str word) mmioStringToFOURCC16 Index: dlls/winmm/winemm.h =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/winemm.h,v retrieving revision 1.24 diff -u -u -r1.24 winemm.h --- dlls/winmm/winemm.h 10 Oct 2002 23:28:22 -0000 1.24 +++ dlls/winmm/winemm.h 12 Oct 2002 09:09:04 -0000 @@ -145,12 +145,12 @@ struct tagWINE_TIMERENTRY* lpNext; } WINE_TIMERENTRY, *LPWINE_TIMERENTRY; +enum mmioProcType {MMIO_PROC_16,MMIO_PROC_32A,MMIO_PROC_32W}; + typedef struct tagWINE_MMIO { MMIOINFO info; struct IOProcList* ioProc; BOOL bTmpIOProc; - HANDLE hMem; - SEGPTR buffer16; struct tagWINE_MMIO* lpNext; BOOL bBufferLoaded; DWORD dwFileSize; @@ -232,6 +232,12 @@ DWORD dwInstance, DWORD dwFlags, BOOL bFrom32); WORD timeSetEventInternal(UINT wDelay, UINT wResol, FARPROC16 lpFunc, DWORD dwUser, UINT wFlags); +HMMIO MMSYSTEM_mmioOpen(LPSTR szFileName, MMIOINFO* refmminfo, + DWORD dwOpenFlags, enum mmioProcType type); +LPMMIOPROC MMSYSTEM_mmioInstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc, + DWORD dwFlags, enum mmioProcType type); +LRESULT MMSYSTEM_mmioSendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1, + LPARAM lParam2, enum mmioProcType type); BOOL MULTIMEDIA_MciInit(void); LPWINE_MM_IDATA MULTIMEDIA_GetIData(void);