winmm: Transform the mmio proc kind into a boolean (to distinguish between ANSI and Unicode).

This commit is contained in:
Eric Pouech 2009-10-14 21:56:13 +02:00 committed by Alexandre Julliard
parent e5b4559d2e
commit 99c4b22bab
2 changed files with 44 additions and 61 deletions

View File

@ -227,8 +227,8 @@ static LRESULT CALLBACK mmioMemIOProc(LPMMIOINFO lpmmioinfo, UINT uMessage,
*/ */
static struct IOProcList defaultProcs[] = { static struct IOProcList defaultProcs[] = {
{&defaultProcs[1], FOURCC_DOS, (LPMMIOPROC)mmioDosIOProc, MMIO_PROC_32A, 0}, {&defaultProcs[1], FOURCC_DOS, (LPMMIOPROC)mmioDosIOProc, FALSE, 0},
{NULL, FOURCC_MEM, (LPMMIOPROC)mmioMemIOProc, MMIO_PROC_32A, 0}, {NULL, FOURCC_MEM, (LPMMIOPROC)mmioMemIOProc, FALSE, 0},
}; };
static struct IOProcList* pIOProcListAnchor = &defaultProcs[0]; static struct IOProcList* pIOProcListAnchor = &defaultProcs[0];
@ -254,13 +254,13 @@ static struct IOProcList* MMIO_FindProcNode(FOURCC fccIOProc)
* MMIO_InstallIOProc [INTERNAL] * MMIO_InstallIOProc [INTERNAL]
*/ */
static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc, static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
DWORD dwFlags, enum mmioProcType type) DWORD dwFlags, BOOL is_unicode)
{ {
LPMMIOPROC lpProc = NULL; LPMMIOPROC lpProc = NULL;
struct IOProcList* pListNode; struct IOProcList* pListNode;
struct IOProcList** ppListNode; struct IOProcList** ppListNode;
TRACE("(%08x, %p, %08X, %i)\n", fccIOProc, pIOProc, dwFlags, type); TRACE("(%08x, %p, %08X, %s)\n", fccIOProc, pIOProc, dwFlags, is_unicode ? "unicode" : "ansi");
if (dwFlags & MMIO_GLOBALPROC) if (dwFlags & MMIO_GLOBALPROC)
FIXME("Global procedures not implemented\n"); FIXME("Global procedures not implemented\n");
@ -274,7 +274,7 @@ static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
/* Fill in this node */ /* Fill in this node */
pListNode->fourCC = fccIOProc; pListNode->fourCC = fccIOProc;
pListNode->pIOProc = pIOProc; pListNode->pIOProc = pIOProc;
pListNode->type = type; pListNode->is_unicode = is_unicode;
pListNode->count = 0; pListNode->count = 0;
/* Stick it on the end of the list */ /* Stick it on the end of the list */
@ -339,7 +339,7 @@ static LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC pIOProc,
*/ */
static LRESULT send_message(struct IOProcList* ioProc, LPMMIOINFO mmioinfo, static LRESULT send_message(struct IOProcList* ioProc, LPMMIOINFO mmioinfo,
DWORD wMsg, LPARAM lParam1, DWORD wMsg, LPARAM lParam1,
LPARAM lParam2, enum mmioProcType type) LPARAM lParam2, BOOL is_unicode)
{ {
LRESULT result = MMSYSERR_ERROR; LRESULT result = MMSYSERR_ERROR;
LPARAM lp1 = lParam1, lp2 = lParam2; LPARAM lp1 = lParam1, lp2 = lParam2;
@ -349,24 +349,17 @@ static LRESULT send_message(struct IOProcList* ioProc, LPMMIOINFO mmioinfo,
result = MMSYSERR_INVALPARAM; result = MMSYSERR_INVALPARAM;
} }
switch (ioProc->type) { if (ioProc->is_unicode != is_unicode) {
case MMIO_PROC_32A:
case MMIO_PROC_32W:
if (ioProc->type != type) {
/* map (lParam1, lParam2) into (lp1, lp2) 32 A<=>W */ /* map (lParam1, lParam2) into (lp1, lp2) 32 A<=>W */
FIXME("NIY 32 A<=>W mapping\n"); FIXME("NIY 32 A<=>W mapping\n");
} }
result = (ioProc->pIOProc)((LPSTR)mmioinfo, wMsg, lp1, lp2); result = (ioProc->pIOProc)((LPSTR)mmioinfo, wMsg, lp1, lp2);
#if 0 #if 0
if (ioProc->type != type) { if (ioProc->is_unicode != is_unicode) {
/* unmap (lParam1, lParam2) into (lp1, lp2) 32 A<=>W */ /* unmap (lParam1, lParam2) into (lp1, lp2) 32 A<=>W */
} }
#endif #endif
break;
default:
FIXME("Internal error\n");
}
return result; return result;
} }
@ -499,11 +492,10 @@ static MMRESULT MMIO_Flush(WINE_MMIO* wm, UINT uFlags)
/* not quite sure what to do here, but I'll guess */ /* not quite sure what to do here, but I'll guess */
if (wm->info.dwFlags & MMIO_DIRTY) { if (wm->info.dwFlags & MMIO_DIRTY) {
/* FIXME: error handling */ /* FIXME: error handling */
send_message(wm->ioProc, &wm->info, MMIOM_SEEK, send_message(wm->ioProc, &wm->info, MMIOM_SEEK, wm->info.lBufOffset, SEEK_SET, FALSE);
wm->info.lBufOffset, SEEK_SET, MMIO_PROC_32A);
send_message(wm->ioProc, &wm->info, MMIOM_WRITE, send_message(wm->ioProc, &wm->info, MMIOM_WRITE,
(LPARAM)wm->info.pchBuffer, (LPARAM)wm->info.pchBuffer,
wm->info.pchNext - wm->info.pchBuffer, MMIO_PROC_32A); wm->info.pchNext - wm->info.pchBuffer, FALSE);
} }
if (uFlags & MMIO_EMPTYBUF) if (uFlags & MMIO_EMPTYBUF)
wm->info.pchNext = wm->info.pchEndRead = wm->info.pchBuffer; wm->info.pchNext = wm->info.pchEndRead = wm->info.pchBuffer;
@ -522,7 +514,7 @@ static LONG MMIO_GrabNextBuffer(LPWINE_MMIO wm, int for_read)
TRACE("bo=%x do=%x of=%lx\n", TRACE("bo=%x do=%x of=%lx\n",
wm->info.lBufOffset, wm->info.lDiskOffset, wm->info.lBufOffset, wm->info.lDiskOffset,
send_message(wm->ioProc, &wm->info, MMIOM_SEEK, 0, SEEK_CUR, MMIO_PROC_32A)); send_message(wm->ioProc, &wm->info, MMIOM_SEEK, 0, SEEK_CUR, FALSE));
wm->info.lBufOffset = wm->info.lDiskOffset; wm->info.lBufOffset = wm->info.lDiskOffset;
wm->info.pchNext = wm->info.pchBuffer; wm->info.pchNext = wm->info.pchBuffer;
@ -532,7 +524,7 @@ static LONG MMIO_GrabNextBuffer(LPWINE_MMIO wm, int for_read)
wm->bBufferLoaded = TRUE; wm->bBufferLoaded = TRUE;
if (for_read) { if (for_read) {
size = send_message(wm->ioProc, &wm->info, MMIOM_READ, size = send_message(wm->ioProc, &wm->info, MMIOM_READ,
(LPARAM)wm->info.pchBuffer, size, MMIO_PROC_32A); (LPARAM)wm->info.pchBuffer, size, FALSE);
if (size > 0) if (size > 0)
wm->info.pchEndRead += size; wm->info.pchEndRead += size;
else else
@ -586,13 +578,12 @@ static MMRESULT MMIO_SetBuffer(WINE_MMIO* wm, void* pchBuffer, LONG cchBuffer,
/************************************************************************** /**************************************************************************
* MMIO_Open [internal] * MMIO_Open [internal]
*/ */
static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags, static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags, BOOL is_unicode)
enum mmioProcType type)
{ {
LPWINE_MMIO wm; LPWINE_MMIO wm;
MMIOINFO mmioinfo; MMIOINFO mmioinfo;
TRACE("('%s', %p, %08X, %d);\n", szFileName, refmminfo, dwOpenFlags, type); TRACE("('%s', %p, %08X, %s);\n", szFileName, refmminfo, dwOpenFlags, is_unicode ? "unicode" : "ansi");
if (!refmminfo) { if (!refmminfo) {
refmminfo = &mmioinfo; refmminfo = &mmioinfo;
@ -601,7 +592,7 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags,
mmioinfo.pIOProc = NULL; mmioinfo.pIOProc = NULL;
mmioinfo.pchBuffer = NULL; mmioinfo.pchBuffer = NULL;
mmioinfo.cchBuffer = 0; mmioinfo.cchBuffer = 0;
type = MMIO_PROC_32A; is_unicode = FALSE;
} }
if (dwOpenFlags & (MMIO_PARSE|MMIO_EXIST)) { if (dwOpenFlags & (MMIO_PARSE|MMIO_EXIST)) {
@ -642,7 +633,7 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags,
else { else {
wm->info.fccIOProc = refmminfo->fccIOProc; wm->info.fccIOProc = refmminfo->fccIOProc;
MMIO_InstallIOProc(wm->info.fccIOProc, refmminfo->pIOProc, MMIO_InstallIOProc(wm->info.fccIOProc, refmminfo->pIOProc,
MMIO_INSTALLPROC, type); MMIO_INSTALLPROC, is_unicode);
if (!(wm->ioProc = MMIO_FindProcNode(wm->info.fccIOProc))) goto error2; if (!(wm->ioProc = MMIO_FindProcNode(wm->info.fccIOProc))) goto error2;
assert(wm->ioProc->pIOProc == refmminfo->pIOProc); assert(wm->ioProc->pIOProc == refmminfo->pIOProc);
wm->bTmpIOProc = TRUE; wm->bTmpIOProc = TRUE;
@ -670,7 +661,7 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags,
/* call IO proc to actually open file */ /* call IO proc to actually open file */
refmminfo->wErrorRet = send_message(wm->ioProc, &wm->info, MMIOM_OPEN, refmminfo->wErrorRet = send_message(wm->ioProc, &wm->info, MMIOM_OPEN,
(LPARAM)szFileName, 0, MMIO_PROC_32A); (LPARAM)szFileName, 0, FALSE);
/* grab file size, when possible */ /* grab file size, when possible */
wm->dwFileSize = GetFileSize((HANDLE)wm->info.adwInfo[0], NULL); wm->dwFileSize = GetFileSize((HANDLE)wm->info.adwInfo[0], NULL);
@ -701,7 +692,7 @@ HMMIO WINAPI mmioOpenW(LPWSTR szFileName, MMIOINFO* lpmmioinfo,
WideCharToMultiByte( CP_ACP, 0, szFileName, -1, szFn, len, NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, szFileName, -1, szFn, len, NULL, NULL );
} }
ret = MMIO_Open(szFn, lpmmioinfo, dwOpenFlags, MMIO_PROC_32W); ret = MMIO_Open(szFn, lpmmioinfo, dwOpenFlags, TRUE);
HeapFree(GetProcessHeap(), 0, szFn); HeapFree(GetProcessHeap(), 0, szFn);
return ret; return ret;
@ -713,7 +704,7 @@ HMMIO WINAPI mmioOpenW(LPWSTR szFileName, MMIOINFO* lpmmioinfo,
HMMIO WINAPI mmioOpenA(LPSTR szFileName, MMIOINFO* lpmmioinfo, HMMIO WINAPI mmioOpenA(LPSTR szFileName, MMIOINFO* lpmmioinfo,
DWORD dwOpenFlags) DWORD dwOpenFlags)
{ {
return MMIO_Open(szFileName, lpmmioinfo, dwOpenFlags, MMIO_PROC_32A); return MMIO_Open(szFileName, lpmmioinfo, dwOpenFlags, FALSE);
} }
/************************************************************************** /**************************************************************************
@ -732,8 +723,7 @@ MMRESULT WINAPI mmioClose(HMMIO hmmio, UINT uFlags)
if ((result = MMIO_Flush(wm, 0)) != MMSYSERR_NOERROR) if ((result = MMIO_Flush(wm, 0)) != MMSYSERR_NOERROR)
return result; return result;
result = send_message(wm->ioProc, &wm->info, MMIOM_CLOSE, result = send_message(wm->ioProc, &wm->info, MMIOM_CLOSE, uFlags, 0, FALSE);
uFlags, 0, MMIO_PROC_32A);
MMIO_SetBuffer(wm, NULL, 0, 0); MMIO_SetBuffer(wm, NULL, 0, 0);
@ -741,7 +731,7 @@ MMRESULT WINAPI mmioClose(HMMIO hmmio, UINT uFlags)
if (wm->bTmpIOProc) if (wm->bTmpIOProc)
MMIO_InstallIOProc(wm->info.fccIOProc, wm->ioProc->pIOProc, MMIO_InstallIOProc(wm->info.fccIOProc, wm->ioProc->pIOProc,
MMIO_REMOVEPROC, wm->ioProc->type); MMIO_REMOVEPROC, wm->ioProc->is_unicode);
MMIO_Destroy(wm); MMIO_Destroy(wm);
@ -763,8 +753,7 @@ LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch)
/* unbuffered case first */ /* unbuffered case first */
if (!wm->info.pchBuffer) if (!wm->info.pchBuffer)
return send_message(wm->ioProc, &wm->info, MMIOM_READ, return send_message(wm->ioProc, &wm->info, MMIOM_READ, (LPARAM)pch, cch, FALSE);
(LPARAM)pch, cch, MMIO_PROC_32A);
/* first try from current buffer */ /* first try from current buffer */
if (wm->info.pchNext != wm->info.pchEndRead) { if (wm->info.pchNext != wm->info.pchEndRead) {
@ -844,8 +833,7 @@ LONG WINAPI mmioWrite(HMMIO hmmio, HPCSTR pch, LONG cch)
} }
count = bytesW; count = bytesW;
} else { } else {
count = send_message(wm->ioProc, &wm->info, MMIOM_WRITE, count = send_message(wm->ioProc, &wm->info, MMIOM_WRITE, (LPARAM)pch, cch, FALSE);
(LPARAM)pch, cch, MMIO_PROC_32A);
wm->info.lBufOffset = wm->info.lDiskOffset; wm->info.lBufOffset = wm->info.lDiskOffset;
} }
@ -868,8 +856,7 @@ LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
/* not buffered, direct seek on file */ /* not buffered, direct seek on file */
if (!wm->info.pchBuffer) if (!wm->info.pchBuffer)
return send_message(wm->ioProc, &wm->info, MMIOM_SEEK, return send_message(wm->ioProc, &wm->info, MMIOM_SEEK, lOffset, iOrigin, FALSE);
lOffset, iOrigin, MMIO_PROC_32A);
switch (iOrigin) { switch (iOrigin) {
case SEEK_SET: case SEEK_SET:
@ -908,7 +895,7 @@ LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
/* this also sets the wm->info.lDiskOffset field */ /* this also sets the wm->info.lDiskOffset field */
send_message(wm->ioProc, &wm->info, MMIOM_SEEK, send_message(wm->ioProc, &wm->info, MMIOM_SEEK,
(offset / wm->info.cchBuffer) * wm->info.cchBuffer, (offset / wm->info.cchBuffer) * wm->info.cchBuffer,
SEEK_SET, MMIO_PROC_32A) == -1) SEEK_SET, FALSE) == -1)
return -1; return -1;
MMIO_GrabNextBuffer(wm, TRUE); MMIO_GrabNextBuffer(wm, TRUE);
} }
@ -1017,11 +1004,9 @@ MMRESULT WINAPI mmioAdvance(HMMIO hmmio, MMIOINFO* lpmmioinfo, UINT uFlags)
if (uFlags == MMIO_WRITE && (lpmmioinfo->dwFlags & MMIO_DIRTY)) if (uFlags == MMIO_WRITE && (lpmmioinfo->dwFlags & MMIO_DIRTY))
{ {
send_message(wm->ioProc, &wm->info, MMIOM_SEEK, send_message(wm->ioProc, &wm->info, MMIOM_SEEK, lpmmioinfo->lBufOffset, SEEK_SET, FALSE);
lpmmioinfo->lBufOffset, SEEK_SET, MMIO_PROC_32A); send_message(wm->ioProc, &wm->info, MMIOM_WRITE, (LPARAM)lpmmioinfo->pchBuffer,
send_message(wm->ioProc, &wm->info, MMIOM_WRITE, lpmmioinfo->pchNext - lpmmioinfo->pchBuffer, FALSE);
(LPARAM)lpmmioinfo->pchBuffer,
lpmmioinfo->pchNext - lpmmioinfo->pchBuffer, MMIO_PROC_32A);
lpmmioinfo->dwFlags &= ~MMIO_DIRTY; lpmmioinfo->dwFlags &= ~MMIO_DIRTY;
} }
if (MMIO_Flush(wm, 0) != MMSYSERR_NOERROR) if (MMIO_Flush(wm, 0) != MMSYSERR_NOERROR)
@ -1085,7 +1070,7 @@ FOURCC WINAPI mmioStringToFOURCCW(LPCWSTR sz, UINT uFlags)
LPMMIOPROC WINAPI mmioInstallIOProcA(FOURCC fccIOProc, LPMMIOPROC WINAPI mmioInstallIOProcA(FOURCC fccIOProc,
LPMMIOPROC pIOProc, DWORD dwFlags) LPMMIOPROC pIOProc, DWORD dwFlags)
{ {
return MMIO_InstallIOProc(fccIOProc, pIOProc, dwFlags, MMIO_PROC_32A); return MMIO_InstallIOProc(fccIOProc, pIOProc, dwFlags, FALSE);
} }
/************************************************************************** /**************************************************************************
@ -1094,7 +1079,7 @@ LPMMIOPROC WINAPI mmioInstallIOProcA(FOURCC fccIOProc,
LPMMIOPROC WINAPI mmioInstallIOProcW(FOURCC fccIOProc, LPMMIOPROC WINAPI mmioInstallIOProcW(FOURCC fccIOProc,
LPMMIOPROC pIOProc, DWORD dwFlags) LPMMIOPROC pIOProc, DWORD dwFlags)
{ {
return MMIO_InstallIOProc(fccIOProc, pIOProc, dwFlags, MMIO_PROC_32W); return MMIO_InstallIOProc(fccIOProc, pIOProc, dwFlags, TRUE);
} }
/****************************************************************** /******************************************************************
@ -1103,11 +1088,11 @@ LPMMIOPROC WINAPI mmioInstallIOProcW(FOURCC fccIOProc,
* *
*/ */
static LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1, static LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1,
LPARAM lParam2, enum mmioProcType type) LPARAM lParam2, BOOL is_unicode)
{ {
LPWINE_MMIO wm; LPWINE_MMIO wm;
TRACE("(%p, %u, %ld, %ld, %d)\n", hmmio, uMessage, lParam1, lParam2, type); TRACE("(%p, %u, %ld, %ld, %s)\n", hmmio, uMessage, lParam1, lParam2, is_unicode ? "unicode" : "ansi");
if (uMessage < MMIOM_USER) if (uMessage < MMIOM_USER)
return MMSYSERR_INVALPARAM; return MMSYSERR_INVALPARAM;
@ -1115,7 +1100,7 @@ static LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1,
if ((wm = MMIO_Get(hmmio)) == NULL) if ((wm = MMIO_Get(hmmio)) == NULL)
return MMSYSERR_INVALHANDLE; return MMSYSERR_INVALHANDLE;
return send_message(wm->ioProc, &wm->info, uMessage, lParam1, lParam2, type); return send_message(wm->ioProc, &wm->info, uMessage, lParam1, lParam2, is_unicode);
} }
/************************************************************************** /**************************************************************************
@ -1124,7 +1109,7 @@ static LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1,
LRESULT WINAPI mmioSendMessage(HMMIO hmmio, UINT uMessage, LRESULT WINAPI mmioSendMessage(HMMIO hmmio, UINT uMessage,
LPARAM lParam1, LPARAM lParam2) LPARAM lParam1, LPARAM lParam2)
{ {
return MMIO_SendMessage(hmmio, uMessage, lParam1, lParam2, MMIO_PROC_32A); return MMIO_SendMessage(hmmio, uMessage, lParam1, lParam2, FALSE);
} }
/************************************************************************** /**************************************************************************
@ -1329,7 +1314,7 @@ MMRESULT WINAPI mmioRenameA(LPCSTR szFileName, LPCSTR szNewFileName,
ioProc = &tmp; ioProc = &tmp;
tmp.fourCC = lpmmioinfo->fccIOProc; tmp.fourCC = lpmmioinfo->fccIOProc;
tmp.pIOProc = lpmmioinfo->pIOProc; tmp.pIOProc = lpmmioinfo->pIOProc;
tmp.type = MMIO_PROC_32A; tmp.is_unicode = FALSE;
tmp.count = 1; tmp.count = 1;
} }
@ -1337,7 +1322,7 @@ MMRESULT WINAPI mmioRenameA(LPCSTR szFileName, LPCSTR szNewFileName,
* or make a copy of it because it's const ??? * or make a copy of it because it's const ???
*/ */
return send_message(ioProc, (MMIOINFO*)lpmmioinfo, MMIOM_RENAME, return send_message(ioProc, (MMIOINFO*)lpmmioinfo, MMIOM_RENAME,
(LPARAM)szFileName, (LPARAM)szNewFileName, MMIO_PROC_32A); (LPARAM)szFileName, (LPARAM)szNewFileName, FALSE);
} }
/************************************************************************** /**************************************************************************

View File

@ -153,14 +153,12 @@ typedef struct tagWINE_MCIDRIVER {
#define WINE_TIMER_IS32 0x80 #define WINE_TIMER_IS32 0x80
enum mmioProcType {MMIO_PROC_32A,MMIO_PROC_32W};
struct IOProcList struct IOProcList
{ {
struct IOProcList*pNext; /* Next item in linked list */ struct IOProcList*pNext; /* Next item in linked list */
FOURCC fourCC; /* four-character code identifying IOProc */ FOURCC fourCC; /* four-character code identifying IOProc */
LPMMIOPROC pIOProc; /* pointer to IProc */ LPMMIOPROC pIOProc; /* pointer to IProc */
enum mmioProcType type; /* 16, 32A or 32W */ BOOL is_unicode; /* 32A or 32W */
int count; /* number of objects linked to it */ int count; /* number of objects linked to it */
}; };