Simplify the global internal data handling.
This commit is contained in:
parent
fb8bad49d9
commit
1e3e87d430
106
dlls/winmm/mci.c
106
dlls/winmm/mci.c
@ -72,14 +72,13 @@ inline static LPSTR str_dup_upper( LPCSTR str )
|
|||||||
LPWINE_MCIDRIVER MCI_GetDriver(UINT16 wDevID)
|
LPWINE_MCIDRIVER MCI_GetDriver(UINT16 wDevID)
|
||||||
{
|
{
|
||||||
LPWINE_MCIDRIVER wmd = 0;
|
LPWINE_MCIDRIVER wmd = 0;
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
|
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
for (wmd = iData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
|
for (wmd = WINMM_IData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
|
||||||
if (wmd->wDeviceID == wDevID)
|
if (wmd->wDeviceID == wDevID)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
return wmd;
|
return wmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +88,6 @@ LPWINE_MCIDRIVER MCI_GetDriver(UINT16 wDevID)
|
|||||||
UINT MCI_GetDriverFromString(LPCSTR lpstrName)
|
UINT MCI_GetDriverFromString(LPCSTR lpstrName)
|
||||||
{
|
{
|
||||||
LPWINE_MCIDRIVER wmd;
|
LPWINE_MCIDRIVER wmd;
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
UINT ret = 0;
|
UINT ret = 0;
|
||||||
|
|
||||||
if (!lpstrName)
|
if (!lpstrName)
|
||||||
@ -98,8 +96,8 @@ UINT MCI_GetDriverFromString(LPCSTR lpstrName)
|
|||||||
if (!lstrcmpiA(lpstrName, "ALL"))
|
if (!lstrcmpiA(lpstrName, "ALL"))
|
||||||
return MCI_ALL_DEVICE_ID;
|
return MCI_ALL_DEVICE_ID;
|
||||||
|
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
for (wmd = iData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
|
for (wmd = WINMM_IData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
|
||||||
if (wmd->lpstrElementName && strcmp(wmd->lpstrElementName, lpstrName) == 0) {
|
if (wmd->lpstrElementName && strcmp(wmd->lpstrElementName, lpstrName) == 0) {
|
||||||
ret = wmd->wDeviceID;
|
ret = wmd->wDeviceID;
|
||||||
break;
|
break;
|
||||||
@ -113,7 +111,7 @@ UINT MCI_GetDriverFromString(LPCSTR lpstrName)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -284,12 +282,12 @@ static BOOL MCI_DumpCommandTable(UINT uTbl)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static UINT MCI_SetCommandTable(LPWINE_MM_IDATA iData, HANDLE hMem, UINT uDevType);
|
static UINT MCI_SetCommandTable(HANDLE hMem, UINT uDevType);
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* MCI_GetCommandTable [internal]
|
* MCI_GetCommandTable [internal]
|
||||||
*/
|
*/
|
||||||
static UINT MCI_GetCommandTable(LPWINE_MM_IDATA iData, UINT uDevType)
|
static UINT MCI_GetCommandTable(UINT uDevType)
|
||||||
{
|
{
|
||||||
UINT uTbl;
|
UINT uTbl;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
@ -303,7 +301,7 @@ static UINT MCI_GetCommandTable(LPWINE_MM_IDATA iData, UINT uDevType)
|
|||||||
|
|
||||||
/* well try to load id */
|
/* well try to load id */
|
||||||
if (uDevType >= MCI_DEVTYPE_FIRST && uDevType <= MCI_DEVTYPE_LAST) {
|
if (uDevType >= MCI_DEVTYPE_FIRST && uDevType <= MCI_DEVTYPE_LAST) {
|
||||||
if (LoadStringA(iData->hWinMM32Instance, uDevType, buf, sizeof(buf))) {
|
if (LoadStringA(WINMM_IData->hWinMM32Instance, uDevType, buf, sizeof(buf))) {
|
||||||
str = buf;
|
str = buf;
|
||||||
}
|
}
|
||||||
} else if (uDevType == 0) {
|
} else if (uDevType == 0) {
|
||||||
@ -311,15 +309,15 @@ static UINT MCI_GetCommandTable(LPWINE_MM_IDATA iData, UINT uDevType)
|
|||||||
}
|
}
|
||||||
uTbl = MCI_NO_COMMAND_TABLE;
|
uTbl = MCI_NO_COMMAND_TABLE;
|
||||||
if (str) {
|
if (str) {
|
||||||
HRSRC hRsrc = FindResourceA(iData->hWinMM32Instance, str, (LPCSTR)RT_RCDATAA);
|
HRSRC hRsrc = FindResourceA(WINMM_IData->hWinMM32Instance, str, (LPCSTR)RT_RCDATAA);
|
||||||
HANDLE hMem = 0;
|
HANDLE hMem = 0;
|
||||||
|
|
||||||
if (hRsrc) hMem = LoadResource(iData->hWinMM32Instance, hRsrc);
|
if (hRsrc) hMem = LoadResource(WINMM_IData->hWinMM32Instance, hRsrc);
|
||||||
if (hMem) {
|
if (hMem) {
|
||||||
uTbl = MCI_SetCommandTable(iData, hMem, uDevType);
|
uTbl = MCI_SetCommandTable(hMem, uDevType);
|
||||||
} else {
|
} else {
|
||||||
WARN("No command table found in resource %04x[%s]\n",
|
WARN("No command table found in resource %04x[%s]\n",
|
||||||
iData->hWinMM32Instance, str);
|
WINMM_IData->hWinMM32Instance, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRACE("=> %d\n", uTbl);
|
TRACE("=> %d\n", uTbl);
|
||||||
@ -329,8 +327,7 @@ static UINT MCI_GetCommandTable(LPWINE_MM_IDATA iData, UINT uDevType)
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* MCI_SetCommandTable [internal]
|
* MCI_SetCommandTable [internal]
|
||||||
*/
|
*/
|
||||||
static UINT MCI_SetCommandTable(LPWINE_MM_IDATA iData, HANDLE hMem,
|
static UINT MCI_SetCommandTable(HANDLE hMem, UINT uDevType)
|
||||||
UINT uDevType)
|
|
||||||
{
|
{
|
||||||
int uTbl;
|
int uTbl;
|
||||||
static BOOL bInitDone = FALSE;
|
static BOOL bInitDone = FALSE;
|
||||||
@ -345,7 +342,7 @@ static UINT MCI_SetCommandTable(LPWINE_MM_IDATA iData, HANDLE hMem,
|
|||||||
for (uTbl = 0; uTbl < MAX_MCICMDTABLE; uTbl++) {
|
for (uTbl = 0; uTbl < MAX_MCICMDTABLE; uTbl++) {
|
||||||
S_MciCmdTable[uTbl].hMem = 0;
|
S_MciCmdTable[uTbl].hMem = 0;
|
||||||
}
|
}
|
||||||
MCI_GetCommandTable(iData, 0);
|
MCI_GetCommandTable(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uTbl = 0; uTbl < MAX_MCICMDTABLE; uTbl++) {
|
for (uTbl = 0; uTbl < MAX_MCICMDTABLE; uTbl++) {
|
||||||
@ -415,7 +412,7 @@ static BOOL MCI_DeleteCommandTable(UINT uTbl)
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* MCI_UnLoadMciDriver [internal]
|
* MCI_UnLoadMciDriver [internal]
|
||||||
*/
|
*/
|
||||||
static BOOL MCI_UnLoadMciDriver(LPWINE_MM_IDATA iData, LPWINE_MCIDRIVER wmd)
|
static BOOL MCI_UnLoadMciDriver(LPWINE_MCIDRIVER wmd)
|
||||||
{
|
{
|
||||||
LPWINE_MCIDRIVER* tmp;
|
LPWINE_MCIDRIVER* tmp;
|
||||||
|
|
||||||
@ -427,14 +424,14 @@ static BOOL MCI_UnLoadMciDriver(LPWINE_MM_IDATA iData, LPWINE_MCIDRIVER wmd)
|
|||||||
if (wmd->dwPrivate != 0)
|
if (wmd->dwPrivate != 0)
|
||||||
WARN("Unloading mci driver with non nul dwPrivate field\n");
|
WARN("Unloading mci driver with non nul dwPrivate field\n");
|
||||||
|
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
for (tmp = &iData->lpMciDrvs; *tmp; tmp = &(*tmp)->lpNext) {
|
for (tmp = &WINMM_IData->lpMciDrvs; *tmp; tmp = &(*tmp)->lpNext) {
|
||||||
if (*tmp == wmd) {
|
if (*tmp == wmd) {
|
||||||
*tmp = wmd->lpNext;
|
*tmp = wmd->lpNext;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, wmd->lpstrDeviceType);
|
HeapFree(GetProcessHeap(), 0, wmd->lpstrDeviceType);
|
||||||
HeapFree(GetProcessHeap(), 0, wmd->lpstrAlias);
|
HeapFree(GetProcessHeap(), 0, wmd->lpstrAlias);
|
||||||
@ -483,8 +480,7 @@ static BOOL MCI_OpenMciDriver(LPWINE_MCIDRIVER wmd, LPCSTR drvTyp, LPARAM lp)
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* MCI_LoadMciDriver [internal]
|
* MCI_LoadMciDriver [internal]
|
||||||
*/
|
*/
|
||||||
static DWORD MCI_LoadMciDriver(LPWINE_MM_IDATA iData, LPCSTR _strDevTyp,
|
static DWORD MCI_LoadMciDriver(LPCSTR _strDevTyp, LPWINE_MCIDRIVER* lpwmd)
|
||||||
LPWINE_MCIDRIVER* lpwmd)
|
|
||||||
{
|
{
|
||||||
LPSTR strDevTyp = str_dup_upper(_strDevTyp);
|
LPSTR strDevTyp = str_dup_upper(_strDevTyp);
|
||||||
LPWINE_MCIDRIVER wmd = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wmd));
|
LPWINE_MCIDRIVER wmd = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wmd));
|
||||||
@ -501,12 +497,12 @@ static DWORD MCI_LoadMciDriver(LPWINE_MM_IDATA iData, LPCSTR _strDevTyp,
|
|||||||
wmd->hCreatorTask = GetCurrentTask();
|
wmd->hCreatorTask = GetCurrentTask();
|
||||||
wmd->CreatorThread = GetCurrentThreadId();
|
wmd->CreatorThread = GetCurrentThreadId();
|
||||||
|
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
/* wmd must be inserted in list before sending opening the driver, coz' it
|
/* wmd must be inserted in list before sending opening the driver, coz' it
|
||||||
* may want to lookup at wDevID
|
* may want to lookup at wDevID
|
||||||
*/
|
*/
|
||||||
wmd->lpNext = iData->lpMciDrvs;
|
wmd->lpNext = WINMM_IData->lpMciDrvs;
|
||||||
iData->lpMciDrvs = wmd;
|
WINMM_IData->lpMciDrvs = wmd;
|
||||||
|
|
||||||
for (modp.wDeviceID = MCI_MAGIC;
|
for (modp.wDeviceID = MCI_MAGIC;
|
||||||
MCI_GetDriver(modp.wDeviceID) != 0;
|
MCI_GetDriver(modp.wDeviceID) != 0;
|
||||||
@ -514,7 +510,7 @@ static DWORD MCI_LoadMciDriver(LPWINE_MM_IDATA iData, LPCSTR _strDevTyp,
|
|||||||
|
|
||||||
wmd->wDeviceID = modp.wDeviceID;
|
wmd->wDeviceID = modp.wDeviceID;
|
||||||
|
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
|
|
||||||
TRACE("wDevID=%04X \n", modp.wDeviceID);
|
TRACE("wDevID=%04X \n", modp.wDeviceID);
|
||||||
|
|
||||||
@ -555,7 +551,7 @@ static DWORD MCI_LoadMciDriver(LPWINE_MM_IDATA iData, LPCSTR _strDevTyp,
|
|||||||
*lpwmd = wmd;
|
*lpwmd = wmd;
|
||||||
return 0;
|
return 0;
|
||||||
errCleanUp:
|
errCleanUp:
|
||||||
MCI_UnLoadMciDriver(iData, wmd);
|
MCI_UnLoadMciDriver(wmd);
|
||||||
HeapFree(GetProcessHeap(), 0, strDevTyp);
|
HeapFree(GetProcessHeap(), 0, strDevTyp);
|
||||||
*lpwmd = 0;
|
*lpwmd = 0;
|
||||||
return dwRet;
|
return dwRet;
|
||||||
@ -803,9 +799,8 @@ static DWORD MCI_ParseOptArgs(LPDWORD data, int _offset, LPCSTR lpCmd,
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* MCI_HandleReturnValues [internal]
|
* MCI_HandleReturnValues [internal]
|
||||||
*/
|
*/
|
||||||
static DWORD MCI_HandleReturnValues(LPWINE_MM_IDATA iData, DWORD dwRet,
|
static DWORD MCI_HandleReturnValues(DWORD dwRet, LPWINE_MCIDRIVER wmd, LPCSTR lpCmd,
|
||||||
LPWINE_MCIDRIVER wmd, LPCSTR lpCmd, LPDWORD data,
|
LPDWORD data, LPSTR lpstrRet, UINT uRetLen)
|
||||||
LPSTR lpstrRet, UINT uRetLen)
|
|
||||||
{
|
{
|
||||||
if (lpstrRet) {
|
if (lpstrRet) {
|
||||||
switch (MCI_GetReturnType(lpCmd)) {
|
switch (MCI_GetReturnType(lpCmd)) {
|
||||||
@ -820,7 +815,7 @@ static DWORD MCI_HandleReturnValues(LPWINE_MM_IDATA iData, DWORD dwRet,
|
|||||||
case MCI_RESOURCE_RETURNED:
|
case MCI_RESOURCE_RETURNED:
|
||||||
/* return string which ID is HIWORD(data[1]),
|
/* return string which ID is HIWORD(data[1]),
|
||||||
* string is loaded from mmsystem.dll */
|
* string is loaded from mmsystem.dll */
|
||||||
LoadStringA(iData->hWinMM32Instance, HIWORD(data[1]),
|
LoadStringA(WINMM_IData->hWinMM32Instance, HIWORD(data[1]),
|
||||||
lpstrRet, uRetLen);
|
lpstrRet, uRetLen);
|
||||||
break;
|
break;
|
||||||
case MCI_RESOURCE_RETURNED|MCI_RESOURCE_DRIVER:
|
case MCI_RESOURCE_RETURNED|MCI_RESOURCE_DRIVER:
|
||||||
@ -882,7 +877,6 @@ DWORD WINAPI mciSendStringA(LPCSTR lpstrCommand, LPSTR lpstrRet,
|
|||||||
DWORD data[MCI_DATA_SIZE];
|
DWORD data[MCI_DATA_SIZE];
|
||||||
LPCSTR lpCmd = 0;
|
LPCSTR lpCmd = 0;
|
||||||
LPSTR devAlias = NULL;
|
LPSTR devAlias = NULL;
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
BOOL bAutoOpen = FALSE;
|
BOOL bAutoOpen = FALSE;
|
||||||
|
|
||||||
TRACE("('%s', %p, %d, %X)\n", lpstrCommand, lpstrRet, uRetLen, hwndCallback);
|
TRACE("('%s', %p, %d, %X)\n", lpstrCommand, lpstrRet, uRetLen, hwndCallback);
|
||||||
@ -961,10 +955,10 @@ DWORD WINAPI mciSendStringA(LPCSTR lpstrCommand, LPSTR lpstrRet,
|
|||||||
/* dwFlags |= MCI_OPEN_ALIAS; */
|
/* dwFlags |= MCI_OPEN_ALIAS; */
|
||||||
}
|
}
|
||||||
|
|
||||||
dwRet = MCI_LoadMciDriver(iData, devType, &wmd);
|
dwRet = MCI_LoadMciDriver(devType, &wmd);
|
||||||
HeapFree(GetProcessHeap(), 0, devType);
|
HeapFree(GetProcessHeap(), 0, devType);
|
||||||
if (dwRet) {
|
if (dwRet) {
|
||||||
MCI_UnLoadMciDriver(iData, wmd);
|
MCI_UnLoadMciDriver(wmd);
|
||||||
goto errCleanUp;
|
goto errCleanUp;
|
||||||
}
|
}
|
||||||
} else if (!(wmd = MCI_GetDriver(mciGetDeviceIDA(dev)))) {
|
} else if (!(wmd = MCI_GetDriver(mciGetDeviceIDA(dev)))) {
|
||||||
@ -990,13 +984,13 @@ DWORD WINAPI mciSendStringA(LPCSTR lpstrCommand, LPSTR lpstrRet,
|
|||||||
if (!lpCmd) {
|
if (!lpCmd) {
|
||||||
/* try the type specific command table */
|
/* try the type specific command table */
|
||||||
if (wmd->uTypeCmdTable == MCI_COMMAND_TABLE_NOT_LOADED)
|
if (wmd->uTypeCmdTable == MCI_COMMAND_TABLE_NOT_LOADED)
|
||||||
wmd->uTypeCmdTable = MCI_GetCommandTable(iData, wmd->wType);
|
wmd->uTypeCmdTable = MCI_GetCommandTable(wmd->wType);
|
||||||
if (wmd->uTypeCmdTable != MCI_NO_COMMAND_TABLE)
|
if (wmd->uTypeCmdTable != MCI_NO_COMMAND_TABLE)
|
||||||
lpCmd = MCI_FindCommand(wmd->uTypeCmdTable, verb);
|
lpCmd = MCI_FindCommand(wmd->uTypeCmdTable, verb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* try core command table */
|
/* try core command table */
|
||||||
if (!lpCmd) lpCmd = MCI_FindCommand(MCI_GetCommandTable(iData, 0), verb);
|
if (!lpCmd) lpCmd = MCI_FindCommand(MCI_GetCommandTable(0), verb);
|
||||||
|
|
||||||
if (!lpCmd) {
|
if (!lpCmd) {
|
||||||
TRACE("Command '%s' not found!\n", verb);
|
TRACE("Command '%s' not found!\n", verb);
|
||||||
@ -1043,13 +1037,13 @@ DWORD WINAPI mciSendStringA(LPCSTR lpstrCommand, LPSTR lpstrRet,
|
|||||||
|
|
||||||
if (strcmp(verb, "open") == 0) {
|
if (strcmp(verb, "open") == 0) {
|
||||||
if ((dwRet = MCI_FinishOpen(wmd, (LPMCI_OPEN_PARMSA)data, dwFlags)))
|
if ((dwRet = MCI_FinishOpen(wmd, (LPMCI_OPEN_PARMSA)data, dwFlags)))
|
||||||
MCI_UnLoadMciDriver(iData, wmd);
|
MCI_UnLoadMciDriver(wmd);
|
||||||
/* FIXME: notification is not properly shared across two opens */
|
/* FIXME: notification is not properly shared across two opens */
|
||||||
} else {
|
} else {
|
||||||
dwRet = MCI_SendCommand(wmd->wDeviceID, MCI_GetMessage(lpCmd), dwFlags, (DWORD)data, TRUE);
|
dwRet = MCI_SendCommand(wmd->wDeviceID, MCI_GetMessage(lpCmd), dwFlags, (DWORD)data, TRUE);
|
||||||
}
|
}
|
||||||
TRACE("=> 1/ %lx (%s)\n", dwRet, lpstrRet);
|
TRACE("=> 1/ %lx (%s)\n", dwRet, lpstrRet);
|
||||||
dwRet = MCI_HandleReturnValues(iData, dwRet, wmd, lpCmd, data, lpstrRet, uRetLen);
|
dwRet = MCI_HandleReturnValues(dwRet, wmd, lpCmd, data, lpstrRet, uRetLen);
|
||||||
TRACE("=> 2/ %lx (%s)\n", dwRet, lpstrRet);
|
TRACE("=> 2/ %lx (%s)\n", dwRet, lpstrRet);
|
||||||
|
|
||||||
errCleanUp:
|
errCleanUp:
|
||||||
@ -1109,7 +1103,6 @@ UINT WINAPI mciLoadCommandResource(HINSTANCE hInst, LPCWSTR resNameW, UINT type)
|
|||||||
HRSRC hRsrc = 0;
|
HRSRC hRsrc = 0;
|
||||||
HGLOBAL hMem;
|
HGLOBAL hMem;
|
||||||
UINT16 ret = MCI_NO_COMMAND_TABLE;
|
UINT16 ret = MCI_NO_COMMAND_TABLE;
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
|
|
||||||
TRACE("(%04x, %s, %d)!\n", hInst, debugstr_w(resNameW), type);
|
TRACE("(%04x, %s, %d)!\n", hInst, debugstr_w(resNameW), type);
|
||||||
|
|
||||||
@ -1134,7 +1127,7 @@ UINT WINAPI mciLoadCommandResource(HINSTANCE hInst, LPCWSTR resNameW, UINT type)
|
|||||||
if (!(hRsrc = FindResourceW(hInst, resNameW, (LPCWSTR)RT_RCDATAA))) {
|
if (!(hRsrc = FindResourceW(hInst, resNameW, (LPCWSTR)RT_RCDATAA))) {
|
||||||
WARN("No command table found in resource\n");
|
WARN("No command table found in resource\n");
|
||||||
} else if ((hMem = LoadResource(hInst, hRsrc))) {
|
} else if ((hMem = LoadResource(hInst, hRsrc))) {
|
||||||
ret = MCI_SetCommandTable(iData, hMem, type);
|
ret = MCI_SetCommandTable(hMem, type);
|
||||||
} else {
|
} else {
|
||||||
WARN("Couldn't load resource.\n");
|
WARN("Couldn't load resource.\n");
|
||||||
}
|
}
|
||||||
@ -2137,7 +2130,6 @@ static DWORD MCI_Open(DWORD dwParam, LPMCI_OPEN_PARMSA lpParms)
|
|||||||
char strDevTyp[128];
|
char strDevTyp[128];
|
||||||
DWORD dwRet;
|
DWORD dwRet;
|
||||||
LPWINE_MCIDRIVER wmd = NULL;
|
LPWINE_MCIDRIVER wmd = NULL;
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
|
|
||||||
TRACE("(%08lX, %p)\n", dwParam, lpParms);
|
TRACE("(%08lX, %p)\n", dwParam, lpParms);
|
||||||
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
||||||
@ -2159,7 +2151,7 @@ static DWORD MCI_Open(DWORD dwParam, LPMCI_OPEN_PARMSA lpParms)
|
|||||||
|
|
||||||
if (uDevType < MCI_DEVTYPE_FIRST ||
|
if (uDevType < MCI_DEVTYPE_FIRST ||
|
||||||
uDevType > MCI_DEVTYPE_LAST ||
|
uDevType > MCI_DEVTYPE_LAST ||
|
||||||
!LoadStringA(iData->hWinMM32Instance, uDevType, strDevTyp, sizeof(strDevTyp))) {
|
!LoadStringA(WINMM_IData->hWinMM32Instance, uDevType, strDevTyp, sizeof(strDevTyp))) {
|
||||||
dwRet = MCIERR_BAD_INTEGER;
|
dwRet = MCIERR_BAD_INTEGER;
|
||||||
goto errCleanUp;
|
goto errCleanUp;
|
||||||
}
|
}
|
||||||
@ -2233,7 +2225,7 @@ static DWORD MCI_Open(DWORD dwParam, LPMCI_OPEN_PARMSA lpParms)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((dwRet = MCI_LoadMciDriver(iData, strDevTyp, &wmd))) {
|
if ((dwRet = MCI_LoadMciDriver(strDevTyp, &wmd))) {
|
||||||
goto errCleanUp;
|
goto errCleanUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2251,7 +2243,7 @@ static DWORD MCI_Open(DWORD dwParam, LPMCI_OPEN_PARMSA lpParms)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
errCleanUp:
|
errCleanUp:
|
||||||
if (wmd) MCI_UnLoadMciDriver(iData, wmd);
|
if (wmd) MCI_UnLoadMciDriver(wmd);
|
||||||
|
|
||||||
if (dwParam & MCI_NOTIFY)
|
if (dwParam & MCI_NOTIFY)
|
||||||
mciDriverNotify(lpParms->dwCallback, 0, MCI_NOTIFY_FAILURE);
|
mciDriverNotify(lpParms->dwCallback, 0, MCI_NOTIFY_FAILURE);
|
||||||
@ -2265,24 +2257,23 @@ static DWORD MCI_Close(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms
|
|||||||
{
|
{
|
||||||
DWORD dwRet;
|
DWORD dwRet;
|
||||||
LPWINE_MCIDRIVER wmd;
|
LPWINE_MCIDRIVER wmd;
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
|
|
||||||
TRACE("(%04x, %08lX, %p)\n", wDevID, dwParam, lpParms);
|
TRACE("(%04x, %08lX, %p)\n", wDevID, dwParam, lpParms);
|
||||||
|
|
||||||
if (wDevID == MCI_ALL_DEVICE_ID) {
|
if (wDevID == MCI_ALL_DEVICE_ID) {
|
||||||
LPWINE_MCIDRIVER next;
|
LPWINE_MCIDRIVER next;
|
||||||
|
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
/* FIXME: shall I notify once after all is done, or for
|
/* FIXME: shall I notify once after all is done, or for
|
||||||
* each of the open drivers ? if the latest, which notif
|
* each of the open drivers ? if the latest, which notif
|
||||||
* to return when only one fails ?
|
* to return when only one fails ?
|
||||||
*/
|
*/
|
||||||
for (wmd = iData->lpMciDrvs; wmd; ) {
|
for (wmd = WINMM_IData->lpMciDrvs; wmd; ) {
|
||||||
next = wmd->lpNext;
|
next = wmd->lpNext;
|
||||||
MCI_Close(wmd->wDeviceID, dwParam, lpParms);
|
MCI_Close(wmd->wDeviceID, dwParam, lpParms);
|
||||||
wmd = next;
|
wmd = next;
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2292,7 +2283,7 @@ static DWORD MCI_Close(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms
|
|||||||
|
|
||||||
dwRet = MCI_SendCommandFrom32(wDevID, MCI_CLOSE_DRIVER, dwParam, (DWORD)lpParms);
|
dwRet = MCI_SendCommandFrom32(wDevID, MCI_CLOSE_DRIVER, dwParam, (DWORD)lpParms);
|
||||||
|
|
||||||
MCI_UnLoadMciDriver(iData, wmd);
|
MCI_UnLoadMciDriver(wmd);
|
||||||
|
|
||||||
if (dwParam & MCI_NOTIFY)
|
if (dwParam & MCI_NOTIFY)
|
||||||
mciDriverNotify(lpParms->dwCallback, wDevID,
|
mciDriverNotify(lpParms->dwCallback, wDevID,
|
||||||
@ -2328,7 +2319,6 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParm
|
|||||||
{
|
{
|
||||||
DWORD ret = MCIERR_INVALID_DEVICE_ID;
|
DWORD ret = MCIERR_INVALID_DEVICE_ID;
|
||||||
LPWINE_MCIDRIVER wmd;
|
LPWINE_MCIDRIVER wmd;
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
|
|
||||||
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
||||||
|
|
||||||
@ -2344,11 +2334,11 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParm
|
|||||||
lpParms->wDeviceType > MCI_DEVTYPE_LAST) {
|
lpParms->wDeviceType > MCI_DEVTYPE_LAST) {
|
||||||
if (dwFlags & MCI_SYSINFO_OPEN) {
|
if (dwFlags & MCI_SYSINFO_OPEN) {
|
||||||
TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers\n");
|
TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers\n");
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
for (wmd = iData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
|
for (wmd = WINMM_IData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
} else {
|
} else {
|
||||||
TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers\n");
|
TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers\n");
|
||||||
cnt = MCI_InstalledCount;
|
cnt = MCI_InstalledCount;
|
||||||
@ -2357,12 +2347,12 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParm
|
|||||||
if (dwFlags & MCI_SYSINFO_OPEN) {
|
if (dwFlags & MCI_SYSINFO_OPEN) {
|
||||||
TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers of type %u\n",
|
TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers of type %u\n",
|
||||||
lpParms->wDeviceType);
|
lpParms->wDeviceType);
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
for (wmd = iData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
|
for (wmd = WINMM_IData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
|
||||||
if (wmd->wType == lpParms->wDeviceType)
|
if (wmd->wType == lpParms->wDeviceType)
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
} else {
|
} else {
|
||||||
TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers of type %u\n",
|
TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers of type %u\n",
|
||||||
lpParms->wDeviceType);
|
lpParms->wDeviceType);
|
||||||
|
@ -352,12 +352,9 @@ static LRESULT send_message(struct IOProcList* ioProc, LPMMIOINFO mmioinfo,
|
|||||||
|
|
||||||
switch (ioProc->type) {
|
switch (ioProc->type) {
|
||||||
case MMIO_PROC_16:
|
case MMIO_PROC_16:
|
||||||
{
|
if (WINMM_IData && WINMM_IData->pFnMmioCallback16)
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
result = WINMM_IData->pFnMmioCallback16((SEGPTR)ioProc->pIOProc,
|
||||||
if (iData && iData->pFnMmioCallback16)
|
mmioinfo, wMsg, lp1, lp2);
|
||||||
result = iData->pFnMmioCallback16((SEGPTR)ioProc->pIOProc,
|
|
||||||
mmioinfo, wMsg, lp1, lp2);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MMIO_PROC_32A:
|
case MMIO_PROC_32A:
|
||||||
case MMIO_PROC_32W:
|
case MMIO_PROC_32W:
|
||||||
@ -434,18 +431,16 @@ static FOURCC MMIO_ParseExtA(LPCSTR szFileName)
|
|||||||
*
|
*
|
||||||
* Retrieves the mmio object from current process
|
* Retrieves the mmio object from current process
|
||||||
*/
|
*/
|
||||||
LPWINE_MMIO MMIO_Get(LPWINE_MM_IDATA iData, HMMIO h)
|
LPWINE_MMIO MMIO_Get(HMMIO h)
|
||||||
{
|
{
|
||||||
LPWINE_MMIO wm = NULL;
|
LPWINE_MMIO wm = NULL;
|
||||||
|
|
||||||
if (!iData) iData = MULTIMEDIA_GetIData();
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
|
for (wm = WINMM_IData->lpMMIO; wm; wm = wm->lpNext) {
|
||||||
EnterCriticalSection(&iData->cs);
|
|
||||||
for (wm = iData->lpMMIO; wm; wm = wm->lpNext) {
|
|
||||||
if (wm->info.hmmio == h)
|
if (wm->info.hmmio == h)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
return wm;
|
return wm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,17 +453,16 @@ static LPWINE_MMIO MMIO_Create(void)
|
|||||||
{
|
{
|
||||||
static WORD MMIO_counter = 0;
|
static WORD MMIO_counter = 0;
|
||||||
LPWINE_MMIO wm;
|
LPWINE_MMIO wm;
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
|
|
||||||
wm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MMIO));
|
wm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MMIO));
|
||||||
if (wm) {
|
if (wm) {
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
/* lookup next unallocated WORD handle, with a non NULL value */
|
/* lookup next unallocated WORD handle, with a non NULL value */
|
||||||
while (++MMIO_counter == 0 || MMIO_Get(iData, HMMIO_32(MMIO_counter)));
|
while (++MMIO_counter == 0 || MMIO_Get(HMMIO_32(MMIO_counter)));
|
||||||
wm->info.hmmio = HMMIO_32(MMIO_counter);
|
wm->info.hmmio = HMMIO_32(MMIO_counter);
|
||||||
wm->lpNext = iData->lpMMIO;
|
wm->lpNext = WINMM_IData->lpMMIO;
|
||||||
iData->lpMMIO = wm;
|
WINMM_IData->lpMMIO = wm;
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
}
|
}
|
||||||
return wm;
|
return wm;
|
||||||
}
|
}
|
||||||
@ -480,12 +474,11 @@ static LPWINE_MMIO MMIO_Create(void)
|
|||||||
*/
|
*/
|
||||||
static BOOL MMIO_Destroy(LPWINE_MMIO wm)
|
static BOOL MMIO_Destroy(LPWINE_MMIO wm)
|
||||||
{
|
{
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
LPWINE_MMIO* m;
|
LPWINE_MMIO* m;
|
||||||
|
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
/* search for the matching one... */
|
/* search for the matching one... */
|
||||||
m = &(iData->lpMMIO);
|
m = &(WINMM_IData->lpMMIO);
|
||||||
while (*m && *m != wm) m = &(*m)->lpNext;
|
while (*m && *m != wm) m = &(*m)->lpNext;
|
||||||
/* ...and destroy */
|
/* ...and destroy */
|
||||||
if (*m) {
|
if (*m) {
|
||||||
@ -493,7 +486,7 @@ static BOOL MMIO_Destroy(LPWINE_MMIO wm)
|
|||||||
HeapFree(GetProcessHeap(), 0, wm);
|
HeapFree(GetProcessHeap(), 0, wm);
|
||||||
wm = NULL;
|
wm = NULL;
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
return wm ? FALSE : TRUE;
|
return wm ? FALSE : TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -726,7 +719,7 @@ MMRESULT WINAPI mmioClose(HMMIO hmmio, UINT uFlags)
|
|||||||
|
|
||||||
TRACE("(%04X, %04X);\n", hmmio, uFlags);
|
TRACE("(%04X, %04X);\n", hmmio, uFlags);
|
||||||
|
|
||||||
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
|
if ((wm = MMIO_Get(hmmio)) == NULL)
|
||||||
return MMSYSERR_INVALHANDLE;
|
return MMSYSERR_INVALHANDLE;
|
||||||
|
|
||||||
if ((result = MMIO_Flush(wm, 0)) != MMSYSERR_NOERROR)
|
if ((result = MMIO_Flush(wm, 0)) != MMSYSERR_NOERROR)
|
||||||
@ -758,7 +751,7 @@ LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch)
|
|||||||
|
|
||||||
TRACE("(%04X, %p, %ld);\n", hmmio, pch, cch);
|
TRACE("(%04X, %p, %ld);\n", hmmio, pch, cch);
|
||||||
|
|
||||||
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
|
if ((wm = MMIO_Get(hmmio)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* unbuffered case first */
|
/* unbuffered case first */
|
||||||
@ -808,7 +801,7 @@ LONG WINAPI mmioWrite(HMMIO hmmio, HPCSTR pch, LONG cch)
|
|||||||
|
|
||||||
TRACE("(%04X, %p, %ld);\n", hmmio, pch, cch);
|
TRACE("(%04X, %p, %ld);\n", hmmio, pch, cch);
|
||||||
|
|
||||||
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
|
if ((wm = MMIO_Get(hmmio)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (wm->info.cchBuffer) {
|
if (wm->info.cchBuffer) {
|
||||||
@ -863,7 +856,7 @@ LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
|
|||||||
|
|
||||||
TRACE("(%04X, %08lX, %d);\n", hmmio, lOffset, iOrigin);
|
TRACE("(%04X, %08lX, %d);\n", hmmio, lOffset, iOrigin);
|
||||||
|
|
||||||
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
|
if ((wm = MMIO_Get(hmmio)) == NULL)
|
||||||
return MMSYSERR_INVALHANDLE;
|
return MMSYSERR_INVALHANDLE;
|
||||||
|
|
||||||
/* not buffered, direct seek on file */
|
/* not buffered, direct seek on file */
|
||||||
@ -928,7 +921,7 @@ MMRESULT WINAPI mmioGetInfo(HMMIO hmmio, MMIOINFO* lpmmioinfo, UINT uFlags)
|
|||||||
|
|
||||||
TRACE("(0x%04x,%p,0x%08x)\n",hmmio,lpmmioinfo,uFlags);
|
TRACE("(0x%04x,%p,0x%08x)\n",hmmio,lpmmioinfo,uFlags);
|
||||||
|
|
||||||
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
|
if ((wm = MMIO_Get(hmmio)) == NULL)
|
||||||
return MMSYSERR_INVALHANDLE;
|
return MMSYSERR_INVALHANDLE;
|
||||||
|
|
||||||
memcpy(lpmmioinfo, &wm->info, sizeof(MMIOINFO));
|
memcpy(lpmmioinfo, &wm->info, sizeof(MMIOINFO));
|
||||||
@ -948,7 +941,7 @@ MMRESULT WINAPI mmioSetInfo(HMMIO hmmio, const MMIOINFO* lpmmioinfo, UINT uFlags
|
|||||||
|
|
||||||
TRACE("(0x%04x,%p,0x%08x)\n",hmmio,lpmmioinfo,uFlags);
|
TRACE("(0x%04x,%p,0x%08x)\n",hmmio,lpmmioinfo,uFlags);
|
||||||
|
|
||||||
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
|
if ((wm = MMIO_Get(hmmio)) == NULL)
|
||||||
return MMSYSERR_INVALHANDLE;
|
return MMSYSERR_INVALHANDLE;
|
||||||
|
|
||||||
/* check pointers coherence */
|
/* check pointers coherence */
|
||||||
@ -976,7 +969,7 @@ MMRESULT WINAPI mmioSetBuffer(HMMIO hmmio, LPSTR pchBuffer, LONG cchBuffer, UINT
|
|||||||
TRACE("(hmmio=%04x, pchBuf=%p, cchBuf=%ld, uFlags=%#08x)\n",
|
TRACE("(hmmio=%04x, pchBuf=%p, cchBuf=%ld, uFlags=%#08x)\n",
|
||||||
hmmio, pchBuffer, cchBuffer, uFlags);
|
hmmio, pchBuffer, cchBuffer, uFlags);
|
||||||
|
|
||||||
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
|
if ((wm = MMIO_Get(hmmio)) == NULL)
|
||||||
return MMSYSERR_INVALHANDLE;
|
return MMSYSERR_INVALHANDLE;
|
||||||
|
|
||||||
return MMIO_SetBuffer(wm, pchBuffer, cchBuffer, uFlags);
|
return MMIO_SetBuffer(wm, pchBuffer, cchBuffer, uFlags);
|
||||||
@ -991,7 +984,7 @@ MMRESULT WINAPI mmioFlush(HMMIO hmmio, UINT uFlags)
|
|||||||
|
|
||||||
TRACE("(%04X, %04X)\n", hmmio, uFlags);
|
TRACE("(%04X, %04X)\n", hmmio, uFlags);
|
||||||
|
|
||||||
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
|
if ((wm = MMIO_Get(hmmio)) == NULL)
|
||||||
return MMSYSERR_INVALHANDLE;
|
return MMSYSERR_INVALHANDLE;
|
||||||
|
|
||||||
return MMIO_Flush(wm, uFlags);
|
return MMIO_Flush(wm, uFlags);
|
||||||
@ -1009,7 +1002,7 @@ MMRESULT WINAPI mmioAdvance(HMMIO hmmio, MMIOINFO* lpmmioinfo, UINT uFlags)
|
|||||||
/* NOTE: mmioAdvance16 heavily relies on parameters from lpmmioinfo we're using
|
/* NOTE: mmioAdvance16 heavily relies on parameters from lpmmioinfo we're using
|
||||||
* here. be sure if you change something here to check mmioAdvance16 as well
|
* here. be sure if you change something here to check mmioAdvance16 as well
|
||||||
*/
|
*/
|
||||||
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
|
if ((wm = MMIO_Get(hmmio)) == NULL)
|
||||||
return MMSYSERR_INVALHANDLE;
|
return MMSYSERR_INVALHANDLE;
|
||||||
|
|
||||||
if (!wm->info.cchBuffer)
|
if (!wm->info.cchBuffer)
|
||||||
@ -1116,7 +1109,7 @@ LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1,
|
|||||||
if (uMessage < MMIOM_USER)
|
if (uMessage < MMIOM_USER)
|
||||||
return MMSYSERR_INVALPARAM;
|
return MMSYSERR_INVALPARAM;
|
||||||
|
|
||||||
if ((wm = MMIO_Get(NULL, 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, type);
|
||||||
|
@ -68,7 +68,6 @@ BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
|
|||||||
WORD wHeapSize, DWORD dwReserved1, WORD wReserved2)
|
WORD wHeapSize, DWORD dwReserved1, WORD wReserved2)
|
||||||
{
|
{
|
||||||
HANDLE hndl;
|
HANDLE hndl;
|
||||||
LPWINE_MM_IDATA iData;
|
|
||||||
|
|
||||||
TRACE("0x%x 0x%lx\n", hinstDLL, fdwReason);
|
TRACE("0x%x 0x%lx\n", hinstDLL, fdwReason);
|
||||||
|
|
||||||
@ -84,14 +83,12 @@ BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
|
|||||||
ERR("Could not load sibling WinMM.dll\n");
|
ERR("Could not load sibling WinMM.dll\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
iData = MULTIMEDIA_GetIData();
|
WINMM_IData->hWinMM16Instance = hinstDLL;
|
||||||
iData->hWinMM16Instance = hinstDLL;
|
WINMM_IData->h16Module32 = hndl;
|
||||||
iData->h16Module32 = hndl;
|
WINMM_IData->pFnMmioCallback16 = mmioCallback16;
|
||||||
iData->pFnMmioCallback16 = mmioCallback16;
|
|
||||||
break;
|
break;
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
iData = MULTIMEDIA_GetIData();
|
FreeLibrary(WINMM_IData->h16Module32);
|
||||||
FreeLibrary(iData->h16Module32);
|
|
||||||
break;
|
break;
|
||||||
case DLL_THREAD_ATTACH:
|
case DLL_THREAD_ATTACH:
|
||||||
case DLL_THREAD_DETACH:
|
case DLL_THREAD_DETACH:
|
||||||
@ -2243,7 +2240,8 @@ MMRESULT16 WINAPI timeGetSystemTime16(LPMMTIME16 lpTime, UINT16 wSize)
|
|||||||
|
|
||||||
if (wSize >= sizeof(*lpTime)) {
|
if (wSize >= sizeof(*lpTime)) {
|
||||||
lpTime->wType = TIME_MS;
|
lpTime->wType = TIME_MS;
|
||||||
lpTime->u.ms = TIME_MMTimeStart()->mmSysTimeMS;
|
TIME_MMTimeStart();
|
||||||
|
lpTime->u.ms = WINMM_IData->mmSysTimeMS;
|
||||||
|
|
||||||
TRACE("=> %lu\n", lpTime->u.ms);
|
TRACE("=> %lu\n", lpTime->u.ms);
|
||||||
}
|
}
|
||||||
@ -2447,7 +2445,7 @@ static LRESULT MMIO_SetSegmentedBuffer(HMMIO hmmio, SEGPTR ptr)
|
|||||||
{
|
{
|
||||||
LPWINE_MMIO wm;
|
LPWINE_MMIO wm;
|
||||||
|
|
||||||
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
|
if ((wm = MMIO_Get(hmmio)) == NULL)
|
||||||
return MMSYSERR_INVALHANDLE;
|
return MMSYSERR_INVALHANDLE;
|
||||||
wm->segBuffer16 = ptr;
|
wm->segBuffer16 = ptr;
|
||||||
return MMSYSERR_NOERROR;
|
return MMSYSERR_NOERROR;
|
||||||
@ -2530,7 +2528,7 @@ MMRESULT16 WINAPI mmioGetInfo16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uF
|
|||||||
|
|
||||||
TRACE("(0x%04x,%p,0x%08x)\n", hmmio, lpmmioinfo, uFlags);
|
TRACE("(0x%04x,%p,0x%08x)\n", hmmio, lpmmioinfo, uFlags);
|
||||||
|
|
||||||
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
|
if ((wm = MMIO_Get(hmmio)) == NULL)
|
||||||
return MMSYSERR_INVALHANDLE;
|
return MMSYSERR_INVALHANDLE;
|
||||||
|
|
||||||
ret = mmioGetInfo(HMMIO_32(hmmio), &mmioinfo, uFlags);
|
ret = mmioGetInfo(HMMIO_32(hmmio), &mmioinfo, uFlags);
|
||||||
|
@ -180,14 +180,13 @@ static BOOL PlaySound_IsString(DWORD fdwSound, const void* psz)
|
|||||||
|
|
||||||
static void PlaySound_Free(WINE_PLAYSOUND* wps)
|
static void PlaySound_Free(WINE_PLAYSOUND* wps)
|
||||||
{
|
{
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
WINE_PLAYSOUND** p;
|
WINE_PLAYSOUND** p;
|
||||||
|
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
for (p = &iData->lpPlaySound; *p && *p != wps; p = &((*p)->lpNext));
|
for (p = &WINMM_IData->lpPlaySound; *p && *p != wps; p = &((*p)->lpNext));
|
||||||
if (*p) *p = (*p)->lpNext;
|
if (*p) *p = (*p)->lpNext;
|
||||||
if (iData->lpPlaySound == NULL) SetEvent(iData->psLastEvent);
|
if (WINMM_IData->lpPlaySound == NULL) SetEvent(WINMM_IData->psLastEvent);
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound);
|
if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound);
|
||||||
HeapFree(GetProcessHeap(), 0, wps);
|
HeapFree(GetProcessHeap(), 0, wps);
|
||||||
}
|
}
|
||||||
@ -236,7 +235,6 @@ static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod,
|
|||||||
static DWORD WINAPI proc_PlaySound(LPVOID arg)
|
static DWORD WINAPI proc_PlaySound(LPVOID arg)
|
||||||
{
|
{
|
||||||
WINE_PLAYSOUND* wps = (WINE_PLAYSOUND*)arg;
|
WINE_PLAYSOUND* wps = (WINE_PLAYSOUND*)arg;
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
BOOL bRet = FALSE;
|
BOOL bRet = FALSE;
|
||||||
HMMIO hmmio = 0;
|
HMMIO hmmio = 0;
|
||||||
MMCKINFO ckMainRIFF;
|
MMCKINFO ckMainRIFF;
|
||||||
@ -369,7 +367,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
|
|||||||
mmioSeek(hmmio, mmckInfo.dwDataOffset, SEEK_SET);
|
mmioSeek(hmmio, mmckInfo.dwDataOffset, SEEK_SET);
|
||||||
while (left)
|
while (left)
|
||||||
{
|
{
|
||||||
if (WaitForSingleObject(iData->psStopEvent, 0) == WAIT_OBJECT_0)
|
if (WaitForSingleObject(WINMM_IData->psStopEvent, 0) == WAIT_OBJECT_0)
|
||||||
{
|
{
|
||||||
wps->bLoop = FALSE;
|
wps->bLoop = FALSE;
|
||||||
break;
|
break;
|
||||||
@ -410,7 +408,6 @@ errCleanUp:
|
|||||||
BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode)
|
BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode)
|
||||||
{
|
{
|
||||||
WINE_PLAYSOUND* wps = NULL;
|
WINE_PLAYSOUND* wps = NULL;
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
|
|
||||||
TRACE("pszSound='%p' hmod=%04X fdwSound=%08lX\n",
|
TRACE("pszSound='%p' hmod=%04X fdwSound=%08lX\n",
|
||||||
pszSound, hmod, fdwSound);
|
pszSound, hmod, fdwSound);
|
||||||
@ -418,7 +415,7 @@ BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BO
|
|||||||
/* FIXME? I see no difference between SND_NOWAIT and SND_NOSTOP !
|
/* FIXME? I see no difference between SND_NOWAIT and SND_NOSTOP !
|
||||||
* there could be one if several sounds can be played at once...
|
* there could be one if several sounds can be played at once...
|
||||||
*/
|
*/
|
||||||
if ((fdwSound & (SND_NOWAIT | SND_NOSTOP)) && iData->lpPlaySound != NULL)
|
if ((fdwSound & (SND_NOWAIT | SND_NOSTOP)) && WINMM_IData->lpPlaySound != NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* alloc internal structure, if we need to play something */
|
/* alloc internal structure, if we need to play something */
|
||||||
@ -428,27 +425,27 @@ BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BO
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
/* since several threads can enter PlaySound in parallel, we're not
|
/* since several threads can enter PlaySound in parallel, we're not
|
||||||
* sure, at this point, that another thread didn't start a new playsound
|
* sure, at this point, that another thread didn't start a new playsound
|
||||||
*/
|
*/
|
||||||
while (iData->lpPlaySound != NULL)
|
while (WINMM_IData->lpPlaySound != NULL)
|
||||||
{
|
{
|
||||||
ResetEvent(iData->psLastEvent);
|
ResetEvent(WINMM_IData->psLastEvent);
|
||||||
/* FIXME: doc says we have to stop all instances of pszSound if it's non
|
/* FIXME: doc says we have to stop all instances of pszSound if it's non
|
||||||
* NULL... as of today, we stop all playing instances */
|
* NULL... as of today, we stop all playing instances */
|
||||||
SetEvent(iData->psStopEvent);
|
SetEvent(WINMM_IData->psStopEvent);
|
||||||
|
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
WaitForSingleObject(iData->psLastEvent, INFINITE);
|
WaitForSingleObject(WINMM_IData->psLastEvent, INFINITE);
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
|
|
||||||
ResetEvent(iData->psStopEvent);
|
ResetEvent(WINMM_IData->psStopEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wps) wps->lpNext = iData->lpPlaySound;
|
if (wps) wps->lpNext = WINMM_IData->lpPlaySound;
|
||||||
iData->lpPlaySound = wps;
|
WINMM_IData->lpPlaySound = wps;
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
|
|
||||||
if (!pszSound || (fdwSound & SND_PURGE)) return TRUE;
|
if (!pszSound || (fdwSound & SND_PURGE)) return TRUE;
|
||||||
|
|
||||||
@ -568,4 +565,3 @@ BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev,
|
|||||||
TRACE("Done\n");
|
TRACE("Done\n");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,25 +176,22 @@ static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg)
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* TIME_MMTimeStart
|
* TIME_MMTimeStart
|
||||||
*/
|
*/
|
||||||
LPWINE_MM_IDATA TIME_MMTimeStart(void)
|
void TIME_MMTimeStart(void)
|
||||||
{
|
{
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
if (IsBadWritePtr(WINMM_IData, sizeof(WINE_MM_IDATA))) {
|
||||||
|
|
||||||
if (IsBadWritePtr(iData, sizeof(WINE_MM_IDATA))) {
|
|
||||||
ERR("iData is not correctly set, please report. Expect failure.\n");
|
ERR("iData is not correctly set, please report. Expect failure.\n");
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
/* one could think it's possible to stop the service thread activity when no more
|
/* one could think it's possible to stop the service thread activity when no more
|
||||||
* mm timers are active, but this would require to keep mmSysTimeMS up-to-date
|
* mm timers are active, but this would require to keep mmSysTimeMS up-to-date
|
||||||
* without being incremented within the service thread callback.
|
* without being incremented within the service thread callback.
|
||||||
*/
|
*/
|
||||||
if (!iData->hMMTimer) {
|
if (!WINMM_IData->hMMTimer) {
|
||||||
iData->mmSysTimeMS = GetTickCount();
|
WINMM_IData->mmSysTimeMS = GetTickCount();
|
||||||
iData->lpTimerList = NULL;
|
WINMM_IData->lpTimerList = NULL;
|
||||||
iData->hMMTimer = CreateThread(NULL, 0, TIME_MMSysTimeThread, iData, 0, NULL);
|
WINMM_IData->hMMTimer = CreateThread(NULL, 0, TIME_MMSysTimeThread, WINMM_IData, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return iData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
@ -202,15 +199,13 @@ LPWINE_MM_IDATA TIME_MMTimeStart(void)
|
|||||||
*/
|
*/
|
||||||
void TIME_MMTimeStop(void)
|
void TIME_MMTimeStop(void)
|
||||||
{
|
{
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
if (IsBadWritePtr(WINMM_IData, sizeof(WINE_MM_IDATA))) {
|
||||||
|
ERR("WINMM_IData is not correctly set, please report. Expect failure.\n");
|
||||||
if (IsBadWritePtr(iData, sizeof(WINE_MM_IDATA))) {
|
|
||||||
ERR("iData is not correctly set, please report. Expect failure.\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (iData->hMMTimer) {
|
if (WINMM_IData->hMMTimer) {
|
||||||
HANDLE hMMTimer = iData->hMMTimer;
|
HANDLE hMMTimer = WINMM_IData->hMMTimer;
|
||||||
iData->hMMTimer = 0;
|
WINMM_IData->hMMTimer = 0;
|
||||||
WaitForSingleObject(hMMTimer, INFINITE);
|
WaitForSingleObject(hMMTimer, INFINITE);
|
||||||
CloseHandle(hMMTimer);
|
CloseHandle(hMMTimer);
|
||||||
}
|
}
|
||||||
@ -224,8 +219,9 @@ MMRESULT WINAPI timeGetSystemTime(LPMMTIME lpTime, UINT wSize)
|
|||||||
TRACE("(%p, %u);\n", lpTime, wSize);
|
TRACE("(%p, %u);\n", lpTime, wSize);
|
||||||
|
|
||||||
if (wSize >= sizeof(*lpTime)) {
|
if (wSize >= sizeof(*lpTime)) {
|
||||||
|
TIME_MMTimeStart();
|
||||||
lpTime->wType = TIME_MS;
|
lpTime->wType = TIME_MS;
|
||||||
lpTime->u.ms = TIME_MMTimeStart()->mmSysTimeMS;
|
lpTime->u.ms = WINMM_IData->mmSysTimeMS;
|
||||||
|
|
||||||
TRACE("=> %lu\n", lpTime->u.ms);
|
TRACE("=> %lu\n", lpTime->u.ms);
|
||||||
}
|
}
|
||||||
@ -242,7 +238,6 @@ WORD timeSetEventInternal(UINT wDelay, UINT wResol,
|
|||||||
WORD wNewID = 0;
|
WORD wNewID = 0;
|
||||||
LPWINE_TIMERENTRY lpNewTimer;
|
LPWINE_TIMERENTRY lpNewTimer;
|
||||||
LPWINE_TIMERENTRY lpTimer;
|
LPWINE_TIMERENTRY lpTimer;
|
||||||
LPWINE_MM_IDATA iData;
|
|
||||||
|
|
||||||
TRACE("(%u, %u, %p, %08lX, %04X);\n", wDelay, wResol, lpFunc, dwUser, wFlags);
|
TRACE("(%u, %u, %p, %08lX, %04X);\n", wDelay, wResol, lpFunc, dwUser, wFlags);
|
||||||
|
|
||||||
@ -253,7 +248,7 @@ WORD timeSetEventInternal(UINT wDelay, UINT wResol,
|
|||||||
if (wDelay < MMSYSTIME_MININTERVAL || wDelay > MMSYSTIME_MAXINTERVAL)
|
if (wDelay < MMSYSTIME_MININTERVAL || wDelay > MMSYSTIME_MAXINTERVAL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
iData = TIME_MMTimeStart();
|
TIME_MMTimeStart();
|
||||||
|
|
||||||
lpNewTimer->uCurTime = wDelay;
|
lpNewTimer->uCurTime = wDelay;
|
||||||
lpNewTimer->wDelay = wDelay;
|
lpNewTimer->wDelay = wDelay;
|
||||||
@ -262,17 +257,17 @@ WORD timeSetEventInternal(UINT wDelay, UINT wResol,
|
|||||||
lpNewTimer->dwUser = dwUser;
|
lpNewTimer->dwUser = dwUser;
|
||||||
lpNewTimer->wFlags = wFlags;
|
lpNewTimer->wFlags = wFlags;
|
||||||
|
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
|
|
||||||
for (lpTimer = iData->lpTimerList; lpTimer != NULL; lpTimer = lpTimer->lpNext) {
|
for (lpTimer = WINMM_IData->lpTimerList; lpTimer != NULL; lpTimer = lpTimer->lpNext) {
|
||||||
wNewID = max(wNewID, lpTimer->wTimerID);
|
wNewID = max(wNewID, lpTimer->wTimerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
lpNewTimer->lpNext = iData->lpTimerList;
|
lpNewTimer->lpNext = WINMM_IData->lpTimerList;
|
||||||
iData->lpTimerList = lpNewTimer;
|
WINMM_IData->lpTimerList = lpNewTimer;
|
||||||
lpNewTimer->wTimerID = wNewID + 1;
|
lpNewTimer->wTimerID = wNewID + 1;
|
||||||
|
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
|
|
||||||
TRACE("=> %u\n", wNewID + 1);
|
TRACE("=> %u\n", wNewID + 1);
|
||||||
|
|
||||||
@ -298,18 +293,17 @@ MMRESULT WINAPI timeSetEvent(UINT wDelay, UINT wResol, LPTIMECALLBACK lpFunc,
|
|||||||
MMRESULT WINAPI timeKillEvent(UINT wID)
|
MMRESULT WINAPI timeKillEvent(UINT wID)
|
||||||
{
|
{
|
||||||
LPWINE_TIMERENTRY* lpTimer;
|
LPWINE_TIMERENTRY* lpTimer;
|
||||||
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
|
|
||||||
MMRESULT ret = MMSYSERR_INVALPARAM;
|
MMRESULT ret = MMSYSERR_INVALPARAM;
|
||||||
|
|
||||||
TRACE("(%u)\n", wID);
|
TRACE("(%u)\n", wID);
|
||||||
EnterCriticalSection(&iData->cs);
|
EnterCriticalSection(&WINMM_IData->cs);
|
||||||
/* remove WINE_TIMERENTRY from list */
|
/* remove WINE_TIMERENTRY from list */
|
||||||
for (lpTimer = &iData->lpTimerList; *lpTimer; lpTimer = &(*lpTimer)->lpNext) {
|
for (lpTimer = &WINMM_IData->lpTimerList; *lpTimer; lpTimer = &(*lpTimer)->lpNext) {
|
||||||
if (wID == (*lpTimer)->wTimerID) {
|
if (wID == (*lpTimer)->wTimerID) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&iData->cs);
|
LeaveCriticalSection(&WINMM_IData->cs);
|
||||||
|
|
||||||
if (*lpTimer) {
|
if (*lpTimer) {
|
||||||
LPWINE_TIMERENTRY lpTemp = *lpTimer;
|
LPWINE_TIMERENTRY lpTemp = *lpTimer;
|
||||||
@ -373,5 +367,6 @@ DWORD WINAPI timeGetTime(void)
|
|||||||
DWORD count;
|
DWORD count;
|
||||||
ReleaseThunkLock(&count);
|
ReleaseThunkLock(&count);
|
||||||
RestoreThunkLock(count);
|
RestoreThunkLock(count);
|
||||||
return TIME_MMTimeStart()->mmSysTimeMS;
|
TIME_MMTimeStart();
|
||||||
|
return WINMM_IData->mmSysTimeMS;
|
||||||
}
|
}
|
||||||
|
@ -257,15 +257,17 @@ LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC
|
|||||||
DWORD dwFlags, enum mmioProcType type);
|
DWORD dwFlags, enum mmioProcType type);
|
||||||
LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1,
|
LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1,
|
||||||
LPARAM lParam2, enum mmioProcType type);
|
LPARAM lParam2, enum mmioProcType type);
|
||||||
LPWINE_MMIO MMIO_Get(LPWINE_MM_IDATA iData, HMMIO h);
|
LPWINE_MMIO MMIO_Get(HMMIO h);
|
||||||
|
|
||||||
BOOL MULTIMEDIA_MciInit(void);
|
BOOL MULTIMEDIA_MciInit(void);
|
||||||
LPWINE_MM_IDATA MULTIMEDIA_GetIData(void);
|
|
||||||
BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode);
|
BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode);
|
||||||
|
|
||||||
LPWINE_MM_IDATA TIME_MMTimeStart(void);
|
void TIME_MMTimeStart(void);
|
||||||
void TIME_MMTimeStop(void);
|
void TIME_MMTimeStop(void);
|
||||||
|
|
||||||
|
/* Global variables */
|
||||||
|
extern LPWINE_MM_IDATA WINMM_IData;
|
||||||
|
|
||||||
/* HANDLE16 -> HANDLE conversions */
|
/* HANDLE16 -> HANDLE conversions */
|
||||||
#define HDRVR_32(h16) ((HDRVR)(ULONG_PTR)(h16))
|
#define HDRVR_32(h16) ((HDRVR)(ULONG_PTR)(h16))
|
||||||
#define HMIDI_32(h16) ((HMIDI)(ULONG_PTR)(h16))
|
#define HMIDI_32(h16) ((HMIDI)(ULONG_PTR)(h16))
|
||||||
|
@ -72,36 +72,23 @@ void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32, const MMTIME16* mmt16)
|
|||||||
* G L O B A L S E T T I N G S
|
* G L O B A L S E T T I N G S
|
||||||
* ========================================================================*/
|
* ========================================================================*/
|
||||||
|
|
||||||
static LPWINE_MM_IDATA S_IData = NULL;
|
LPWINE_MM_IDATA WINMM_IData /* = NULL */;
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* MULTIMEDIA_GetIData [internal]
|
|
||||||
*/
|
|
||||||
LPWINE_MM_IDATA MULTIMEDIA_GetIData(void)
|
|
||||||
{
|
|
||||||
if (!S_IData) {
|
|
||||||
ERR("IData not found for pid=%08lx. Suicide !!!\n", GetCurrentProcessId());
|
|
||||||
DbgBreakPoint();
|
|
||||||
ExitProcess(0);
|
|
||||||
}
|
|
||||||
return S_IData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* MULTIMEDIA_CreateIData [internal]
|
* MULTIMEDIA_CreateIData [internal]
|
||||||
*/
|
*/
|
||||||
static BOOL MULTIMEDIA_CreateIData(HINSTANCE hInstDLL)
|
static BOOL MULTIMEDIA_CreateIData(HINSTANCE hInstDLL)
|
||||||
{
|
{
|
||||||
S_IData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MM_IDATA));
|
WINMM_IData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MM_IDATA));
|
||||||
|
|
||||||
if (!S_IData)
|
if (!WINMM_IData)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
S_IData->hWinMM32Instance = hInstDLL;
|
WINMM_IData->hWinMM32Instance = hInstDLL;
|
||||||
InitializeCriticalSection(&S_IData->cs);
|
InitializeCriticalSection(&WINMM_IData->cs);
|
||||||
S_IData->cs.DebugInfo = (void*)__FILE__ ": WinMM";
|
WINMM_IData->cs.DebugInfo = (void*)__FILE__ ": WinMM";
|
||||||
S_IData->psStopEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
|
WINMM_IData->psStopEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
|
||||||
S_IData->psLastEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
|
WINMM_IData->psLastEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
|
||||||
TRACE("Created IData (%p)\n", S_IData);
|
TRACE("Created IData (%p)\n", WINMM_IData);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,16 +97,16 @@ static BOOL MULTIMEDIA_CreateIData(HINSTANCE hInstDLL)
|
|||||||
*/
|
*/
|
||||||
static void MULTIMEDIA_DeleteIData(void)
|
static void MULTIMEDIA_DeleteIData(void)
|
||||||
{
|
{
|
||||||
if (S_IData) {
|
if (WINMM_IData) {
|
||||||
TIME_MMTimeStop();
|
TIME_MMTimeStop();
|
||||||
|
|
||||||
/* FIXME: should also free content and resources allocated
|
/* FIXME: should also free content and resources allocated
|
||||||
* inside S_IData */
|
* inside WINMM_IData */
|
||||||
CloseHandle(S_IData->psStopEvent);
|
CloseHandle(WINMM_IData->psStopEvent);
|
||||||
CloseHandle(S_IData->psLastEvent);
|
CloseHandle(WINMM_IData->psLastEvent);
|
||||||
DeleteCriticalSection(&S_IData->cs);
|
DeleteCriticalSection(&WINMM_IData->cs);
|
||||||
HeapFree(GetProcessHeap(), 0, S_IData);
|
HeapFree(GetProcessHeap(), 0, WINMM_IData);
|
||||||
S_IData = NULL;
|
WINMM_IData = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,7 +688,7 @@ BOOL WINAPI mciGetErrorStringA(DWORD dwError, LPSTR lpstrBuffer, UINT uLength)
|
|||||||
if (lpstrBuffer != NULL && uLength > 0 &&
|
if (lpstrBuffer != NULL && uLength > 0 &&
|
||||||
dwError >= MCIERR_BASE && dwError <= MCIERR_CUSTOM_DRIVER_BASE) {
|
dwError >= MCIERR_BASE && dwError <= MCIERR_CUSTOM_DRIVER_BASE) {
|
||||||
|
|
||||||
if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance,
|
if (LoadStringA(WINMM_IData->hWinMM32Instance,
|
||||||
dwError, lpstrBuffer, uLength) > 0) {
|
dwError, lpstrBuffer, uLength) > 0) {
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
@ -986,7 +973,7 @@ static UINT16 MIDI_GetErrorText(UINT16 uError, LPSTR lpText, UINT16 uSize)
|
|||||||
(/*uError >= MMSYSERR_BASE && */ uError <= MMSYSERR_LASTERROR) ||
|
(/*uError >= MMSYSERR_BASE && */ uError <= MMSYSERR_LASTERROR) ||
|
||||||
(uError >= MIDIERR_BASE && uError <= MIDIERR_LASTERROR)) {
|
(uError >= MIDIERR_BASE && uError <= MIDIERR_LASTERROR)) {
|
||||||
|
|
||||||
if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance,
|
if (LoadStringA(WINMM_IData->hWinMM32Instance,
|
||||||
uError, lpText, uSize) > 0) {
|
uError, lpText, uSize) > 0) {
|
||||||
ret = MMSYSERR_NOERROR;
|
ret = MMSYSERR_NOERROR;
|
||||||
}
|
}
|
||||||
@ -2286,7 +2273,7 @@ static UINT16 WAVE_GetErrorText(UINT16 uError, LPSTR lpText, UINT16 uSize)
|
|||||||
(/*uError >= MMSYSERR_BASE && */uError <= MMSYSERR_LASTERROR) ||
|
(/*uError >= MMSYSERR_BASE && */uError <= MMSYSERR_LASTERROR) ||
|
||||||
(uError >= WAVERR_BASE && uError <= WAVERR_LASTERROR)) {
|
(uError >= WAVERR_BASE && uError <= WAVERR_LASTERROR)) {
|
||||||
|
|
||||||
if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance,
|
if (LoadStringA(WINMM_IData->hWinMM32Instance,
|
||||||
uError, lpText, uSize) > 0) {
|
uError, lpText, uSize) > 0) {
|
||||||
ret = MMSYSERR_NOERROR;
|
ret = MMSYSERR_NOERROR;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user