diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c index 5491fc22c87..0bf8d4092c0 100644 --- a/dlls/winmm/mmio.c +++ b/dlls/winmm/mmio.c @@ -44,6 +44,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mmio); +LRESULT (*pFnMmioCallback16)(SEGPTR,LPMMIOINFO,UINT,LPARAM,LPARAM) /* = NULL */; + /************************************************************************** * mmioDosIOProc [internal] */ @@ -71,9 +73,7 @@ static LRESULT CALLBACK mmioDosIOProc(LPMMIOINFO lpmmioinfo, UINT uMessage, } /* if filename NULL, assume open file handle in adwInfo[0] */ - if (!szFileName) { - lpmmioinfo->adwInfo[0] = DosFileHandleToWin32Handle(lpmmioinfo->adwInfo[0]); - } else { + if (szFileName) { OFSTRUCT ofs; lpmmioinfo->adwInfo[0] = (DWORD)OpenFile(szFileName, &ofs, lpmmioinfo->dwFlags & 0xFFFF); } @@ -352,9 +352,9 @@ static LRESULT send_message(struct IOProcList* ioProc, LPMMIOINFO mmioinfo, switch (ioProc->type) { case MMIO_PROC_16: - if (WINMM_IData && WINMM_IData->pFnMmioCallback16) - result = WINMM_IData->pFnMmioCallback16((SEGPTR)ioProc->pIOProc, - mmioinfo, wMsg, lp1, lp2); + if (pFnMmioCallback16) + result = pFnMmioCallback16((SEGPTR)ioProc->pIOProc, + mmioinfo, wMsg, lp1, lp2); break; case MMIO_PROC_32A: case MMIO_PROC_32W: @@ -579,9 +579,6 @@ static MMRESULT MMIO_SetBuffer(WINE_MMIO* wm, void* pchBuffer, LONG cchBuffer, wm->info.pchBuffer = NULL; } - if (wm->ioProc->type == MMIO_PROC_16) - wm->info.dwReserved1 = MapLS(wm->info.pchBuffer); - wm->info.cchBuffer = cchBuffer; wm->info.pchNext = wm->info.pchBuffer; wm->info.pchEndRead = wm->info.pchBuffer; diff --git a/dlls/winmm/mmsystem.c b/dlls/winmm/mmsystem.c index 96d9c131b5b..43171b09891 100644 --- a/dlls/winmm/mmsystem.c +++ b/dlls/winmm/mmsystem.c @@ -49,9 +49,7 @@ extern LONG CALLBACK MMSYSTEM_CallTo16_long_l (FARPROC16,LONG); extern LONG CALLBACK MMSYSTEM_CallTo16_long_lwll (LPMMIOPROC16,LONG,WORD,LONG,LONG); /* ### stop build ### */ -static LRESULT CALLBACK mmioCallback16(SEGPTR cb16, - LPMMIOINFO lpmmioinfo, UINT uMessage, - LPARAM lParam1, LPARAM lParam2); +static LRESULT MMIO_Callback16(SEGPTR, LPMMIOINFO, UINT, LPARAM, LPARAM); /* ################################################### * # LIBRARY # @@ -85,10 +83,12 @@ BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds, } WINMM_IData->hWinMM16Instance = hinstDLL; WINMM_IData->h16Module32 = hndl; - WINMM_IData->pFnMmioCallback16 = mmioCallback16; + /* hook in our 16 bit function pointers */ + pFnMmioCallback16 = MMIO_Callback16; break; case DLL_PROCESS_DETACH: FreeLibrary(WINMM_IData->h16Module32); + pFnMmioCallback16 = NULL; break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: @@ -2511,13 +2511,12 @@ static LRESULT MMIO_UnMap32To16(DWORD wMsg, LPARAM lParam1, LPARAM lParam2, } /****************************************************************** - * mmioCallback16 + * MMIO_Callback16 * * */ -static LRESULT CALLBACK mmioCallback16(SEGPTR cb16, - LPMMIOINFO lpmmioinfo, UINT uMessage, - LPARAM lParam1, LPARAM lParam2) +static LRESULT MMIO_Callback16(SEGPTR cb16, LPMMIOINFO lpmmioinfo, UINT uMessage, + LPARAM lParam1, LPARAM lParam2) { LRESULT result; MMIOINFO16 mmioInfo16; @@ -2552,8 +2551,6 @@ static LRESULT CALLBACK mmioCallback16(SEGPTR cb16, /****************************************************************** * MMIO_ResetSegmentedData * - * - * */ static LRESULT MMIO_SetSegmentedBuffer(HMMIO hmmio, SEGPTR ptr) { @@ -2583,7 +2580,10 @@ HMMIO16 WINAPI mmioOpen16(LPSTR szFileName, MMIOINFO16* lpmmioinfo16, mmioinfo.pIOProc = (LPMMIOPROC)lpmmioinfo16->pIOProc; mmioinfo.cchBuffer = lpmmioinfo16->cchBuffer; mmioinfo.pchBuffer = MapSL((DWORD)lpmmioinfo16->pchBuffer); - mmioinfo.adwInfo[0] = lpmmioinfo16->adwInfo[0]; + mmioinfo.adwInfo[0] = lpmmioinfo16->adwInfo[0]; + /* if we don't have a file name, it's likely a passed open file descriptor */ + if (!szFileName) + mmioinfo.adwInfo[0] = DosFileHandleToWin32Handle(mmioinfo.adwInfo[0]); mmioinfo.adwInfo[1] = lpmmioinfo16->adwInfo[1]; mmioinfo.adwInfo[2] = lpmmioinfo16->adwInfo[2]; mmioinfo.adwInfo[3] = lpmmioinfo16->adwInfo[3]; diff --git a/dlls/winmm/winemm.h b/dlls/winmm/winemm.h index e6d5d9295b3..6a58f0291a5 100644 --- a/dlls/winmm/winemm.h +++ b/dlls/winmm/winemm.h @@ -217,7 +217,6 @@ typedef struct tagWINE_MM_IDATA { /* LPWINE_MIXER lpMixer; */ /* mmio part */ LPWINE_MMIO lpMMIO; - LRESULT (CALLBACK* pFnMmioCallback16)(SEGPTR,LPMMIOINFO,UINT,LPARAM,LPARAM); /* playsound and sndPlaySound */ WINE_PLAYSOUND* lpPlaySound; HANDLE psLastEvent; @@ -341,6 +340,11 @@ BOOL MMDRV_GetDescription16(const char* fname, char* buf, int buflen); /* Global variables */ extern LPWINE_MM_IDATA WINMM_IData; +/* pointers to 16 bit functions (if sibling MMSYSTEM.DLL is loaded + * NULL otherwise + */ +extern LRESULT (*pFnMmioCallback16)(SEGPTR,LPMMIOINFO,UINT,LPARAM,LPARAM); + /* HANDLE16 -> HANDLE conversions */ #define HDRVR_32(h16) ((HDRVR)(ULONG_PTR)(h16)) #define HMIDI_32(h16) ((HMIDI)(ULONG_PTR)(h16))