Commit 1e3e87d4 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Simplify the global internal data handling.

parent fb8bad49
......@@ -352,12 +352,9 @@ static LRESULT send_message(struct IOProcList* ioProc, LPMMIOINFO mmioinfo,
switch (ioProc->type) {
case MMIO_PROC_16:
{
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
if (iData && iData->pFnMmioCallback16)
result = iData->pFnMmioCallback16((SEGPTR)ioProc->pIOProc,
mmioinfo, wMsg, lp1, lp2);
}
if (WINMM_IData && WINMM_IData->pFnMmioCallback16)
result = WINMM_IData->pFnMmioCallback16((SEGPTR)ioProc->pIOProc,
mmioinfo, wMsg, lp1, lp2);
break;
case MMIO_PROC_32A:
case MMIO_PROC_32W:
......@@ -434,18 +431,16 @@ static FOURCC MMIO_ParseExtA(LPCSTR szFileName)
*
* 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;
if (!iData) iData = MULTIMEDIA_GetIData();
EnterCriticalSection(&iData->cs);
for (wm = iData->lpMMIO; wm; wm = wm->lpNext) {
EnterCriticalSection(&WINMM_IData->cs);
for (wm = WINMM_IData->lpMMIO; wm; wm = wm->lpNext) {
if (wm->info.hmmio == h)
break;
}
LeaveCriticalSection(&iData->cs);
LeaveCriticalSection(&WINMM_IData->cs);
return wm;
}
......@@ -458,17 +453,16 @@ static LPWINE_MMIO MMIO_Create(void)
{
static WORD MMIO_counter = 0;
LPWINE_MMIO wm;
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
wm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MMIO));
if (wm) {
EnterCriticalSection(&iData->cs);
EnterCriticalSection(&WINMM_IData->cs);
/* 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->lpNext = iData->lpMMIO;
iData->lpMMIO = wm;
LeaveCriticalSection(&iData->cs);
wm->lpNext = WINMM_IData->lpMMIO;
WINMM_IData->lpMMIO = wm;
LeaveCriticalSection(&WINMM_IData->cs);
}
return wm;
}
......@@ -480,12 +474,11 @@ static LPWINE_MMIO MMIO_Create(void)
*/
static BOOL MMIO_Destroy(LPWINE_MMIO wm)
{
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
LPWINE_MMIO* m;
EnterCriticalSection(&iData->cs);
EnterCriticalSection(&WINMM_IData->cs);
/* search for the matching one... */
m = &(iData->lpMMIO);
m = &(WINMM_IData->lpMMIO);
while (*m && *m != wm) m = &(*m)->lpNext;
/* ...and destroy */
if (*m) {
......@@ -493,7 +486,7 @@ static BOOL MMIO_Destroy(LPWINE_MMIO wm)
HeapFree(GetProcessHeap(), 0, wm);
wm = NULL;
}
LeaveCriticalSection(&iData->cs);
LeaveCriticalSection(&WINMM_IData->cs);
return wm ? FALSE : TRUE;
}
......@@ -726,7 +719,7 @@ MMRESULT WINAPI mmioClose(HMMIO hmmio, UINT uFlags)
TRACE("(%04X, %04X);\n", hmmio, uFlags);
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
if ((wm = MMIO_Get(hmmio)) == NULL)
return MMSYSERR_INVALHANDLE;
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);
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
if ((wm = MMIO_Get(hmmio)) == NULL)
return -1;
/* unbuffered case first */
......@@ -808,7 +801,7 @@ LONG WINAPI mmioWrite(HMMIO hmmio, HPCSTR pch, LONG cch)
TRACE("(%04X, %p, %ld);\n", hmmio, pch, cch);
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
if ((wm = MMIO_Get(hmmio)) == NULL)
return -1;
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);
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
if ((wm = MMIO_Get(hmmio)) == NULL)
return MMSYSERR_INVALHANDLE;
/* 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);
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
if ((wm = MMIO_Get(hmmio)) == NULL)
return MMSYSERR_INVALHANDLE;
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);
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
if ((wm = MMIO_Get(hmmio)) == NULL)
return MMSYSERR_INVALHANDLE;
/* 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",
hmmio, pchBuffer, cchBuffer, uFlags);
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
if ((wm = MMIO_Get(hmmio)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMIO_SetBuffer(wm, pchBuffer, cchBuffer, uFlags);
......@@ -991,7 +984,7 @@ MMRESULT WINAPI mmioFlush(HMMIO hmmio, UINT uFlags)
TRACE("(%04X, %04X)\n", hmmio, uFlags);
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
if ((wm = MMIO_Get(hmmio)) == NULL)
return MMSYSERR_INVALHANDLE;
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
* 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;
if (!wm->info.cchBuffer)
......@@ -1116,7 +1109,7 @@ LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1,
if (uMessage < MMIOM_USER)
return MMSYSERR_INVALPARAM;
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
if ((wm = MMIO_Get(hmmio)) == NULL)
return MMSYSERR_INVALHANDLE;
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)
{
HANDLE hndl;
LPWINE_MM_IDATA iData;
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");
return FALSE;
}
iData = MULTIMEDIA_GetIData();
iData->hWinMM16Instance = hinstDLL;
iData->h16Module32 = hndl;
iData->pFnMmioCallback16 = mmioCallback16;
WINMM_IData->hWinMM16Instance = hinstDLL;
WINMM_IData->h16Module32 = hndl;
WINMM_IData->pFnMmioCallback16 = mmioCallback16;
break;
case DLL_PROCESS_DETACH:
iData = MULTIMEDIA_GetIData();
FreeLibrary(iData->h16Module32);
FreeLibrary(WINMM_IData->h16Module32);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
......@@ -2243,7 +2240,8 @@ MMRESULT16 WINAPI timeGetSystemTime16(LPMMTIME16 lpTime, UINT16 wSize)
if (wSize >= sizeof(*lpTime)) {
lpTime->wType = TIME_MS;
lpTime->u.ms = TIME_MMTimeStart()->mmSysTimeMS;
TIME_MMTimeStart();
lpTime->u.ms = WINMM_IData->mmSysTimeMS;
TRACE("=> %lu\n", lpTime->u.ms);
}
......@@ -2447,7 +2445,7 @@ static LRESULT MMIO_SetSegmentedBuffer(HMMIO hmmio, SEGPTR ptr)
{
LPWINE_MMIO wm;
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
if ((wm = MMIO_Get(hmmio)) == NULL)
return MMSYSERR_INVALHANDLE;
wm->segBuffer16 = ptr;
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);
if ((wm = MMIO_Get(NULL, hmmio)) == NULL)
if ((wm = MMIO_Get(hmmio)) == NULL)
return MMSYSERR_INVALHANDLE;
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)
{
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
WINE_PLAYSOUND** p;
EnterCriticalSection(&iData->cs);
for (p = &iData->lpPlaySound; *p && *p != wps; p = &((*p)->lpNext));
EnterCriticalSection(&WINMM_IData->cs);
for (p = &WINMM_IData->lpPlaySound; *p && *p != wps; p = &((*p)->lpNext));
if (*p) *p = (*p)->lpNext;
if (iData->lpPlaySound == NULL) SetEvent(iData->psLastEvent);
LeaveCriticalSection(&iData->cs);
if (WINMM_IData->lpPlaySound == NULL) SetEvent(WINMM_IData->psLastEvent);
LeaveCriticalSection(&WINMM_IData->cs);
if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound);
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)
{
WINE_PLAYSOUND* wps = (WINE_PLAYSOUND*)arg;
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
BOOL bRet = FALSE;
HMMIO hmmio = 0;
MMCKINFO ckMainRIFF;
......@@ -369,7 +367,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
mmioSeek(hmmio, mmckInfo.dwDataOffset, SEEK_SET);
while (left)
{
if (WaitForSingleObject(iData->psStopEvent, 0) == WAIT_OBJECT_0)
if (WaitForSingleObject(WINMM_IData->psStopEvent, 0) == WAIT_OBJECT_0)
{
wps->bLoop = FALSE;
break;
......@@ -410,7 +408,6 @@ errCleanUp:
BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode)
{
WINE_PLAYSOUND* wps = NULL;
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
TRACE("pszSound='%p' hmod=%04X fdwSound=%08lX\n",
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 !
* 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;
/* 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;
}
EnterCriticalSection(&iData->cs);
EnterCriticalSection(&WINMM_IData->cs);
/* since several threads can enter PlaySound in parallel, we're not
* 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
* NULL... as of today, we stop all playing instances */
SetEvent(iData->psStopEvent);
SetEvent(WINMM_IData->psStopEvent);
LeaveCriticalSection(&iData->cs);
WaitForSingleObject(iData->psLastEvent, INFINITE);
EnterCriticalSection(&iData->cs);
LeaveCriticalSection(&WINMM_IData->cs);
WaitForSingleObject(WINMM_IData->psLastEvent, INFINITE);
EnterCriticalSection(&WINMM_IData->cs);
ResetEvent(iData->psStopEvent);
ResetEvent(WINMM_IData->psStopEvent);
}
if (wps) wps->lpNext = iData->lpPlaySound;
iData->lpPlaySound = wps;
LeaveCriticalSection(&iData->cs);
if (wps) wps->lpNext = WINMM_IData->lpPlaySound;
WINMM_IData->lpPlaySound = wps;
LeaveCriticalSection(&WINMM_IData->cs);
if (!pszSound || (fdwSound & SND_PURGE)) return TRUE;
......@@ -568,4 +565,3 @@ BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev,
TRACE("Done\n");
return TRUE;
}
......@@ -176,25 +176,22 @@ static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg)
/**************************************************************************
* TIME_MMTimeStart
*/
LPWINE_MM_IDATA TIME_MMTimeStart(void)
void TIME_MMTimeStart(void)
{
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
if (IsBadWritePtr(iData, sizeof(WINE_MM_IDATA))) {
if (IsBadWritePtr(WINMM_IData, sizeof(WINE_MM_IDATA))) {
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
* mm timers are active, but this would require to keep mmSysTimeMS up-to-date
* without being incremented within the service thread callback.
*/
if (!iData->hMMTimer) {
iData->mmSysTimeMS = GetTickCount();
iData->lpTimerList = NULL;
iData->hMMTimer = CreateThread(NULL, 0, TIME_MMSysTimeThread, iData, 0, NULL);
if (!WINMM_IData->hMMTimer) {
WINMM_IData->mmSysTimeMS = GetTickCount();
WINMM_IData->lpTimerList = 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)
{
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
if (IsBadWritePtr(iData, sizeof(WINE_MM_IDATA))) {
ERR("iData is not correctly set, please report. Expect failure.\n");
if (IsBadWritePtr(WINMM_IData, sizeof(WINE_MM_IDATA))) {
ERR("WINMM_IData is not correctly set, please report. Expect failure.\n");
return;
}
if (iData->hMMTimer) {
HANDLE hMMTimer = iData->hMMTimer;
iData->hMMTimer = 0;
if (WINMM_IData->hMMTimer) {
HANDLE hMMTimer = WINMM_IData->hMMTimer;
WINMM_IData->hMMTimer = 0;
WaitForSingleObject(hMMTimer, INFINITE);
CloseHandle(hMMTimer);
}
......@@ -224,8 +219,9 @@ MMRESULT WINAPI timeGetSystemTime(LPMMTIME lpTime, UINT wSize)
TRACE("(%p, %u);\n", lpTime, wSize);
if (wSize >= sizeof(*lpTime)) {
TIME_MMTimeStart();
lpTime->wType = TIME_MS;
lpTime->u.ms = TIME_MMTimeStart()->mmSysTimeMS;
lpTime->u.ms = WINMM_IData->mmSysTimeMS;
TRACE("=> %lu\n", lpTime->u.ms);
}
......@@ -242,7 +238,6 @@ WORD timeSetEventInternal(UINT wDelay, UINT wResol,
WORD wNewID = 0;
LPWINE_TIMERENTRY lpNewTimer;
LPWINE_TIMERENTRY lpTimer;
LPWINE_MM_IDATA iData;
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)
return 0;
iData = TIME_MMTimeStart();
TIME_MMTimeStart();
lpNewTimer->uCurTime = wDelay;
lpNewTimer->wDelay = wDelay;
......@@ -262,17 +257,17 @@ WORD timeSetEventInternal(UINT wDelay, UINT wResol,
lpNewTimer->dwUser = dwUser;
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);
}
lpNewTimer->lpNext = iData->lpTimerList;
iData->lpTimerList = lpNewTimer;
lpNewTimer->lpNext = WINMM_IData->lpTimerList;
WINMM_IData->lpTimerList = lpNewTimer;
lpNewTimer->wTimerID = wNewID + 1;
LeaveCriticalSection(&iData->cs);
LeaveCriticalSection(&WINMM_IData->cs);
TRACE("=> %u\n", wNewID + 1);
......@@ -298,18 +293,17 @@ MMRESULT WINAPI timeSetEvent(UINT wDelay, UINT wResol, LPTIMECALLBACK lpFunc,
MMRESULT WINAPI timeKillEvent(UINT wID)
{
LPWINE_TIMERENTRY* lpTimer;
LPWINE_MM_IDATA iData = MULTIMEDIA_GetIData();
MMRESULT ret = MMSYSERR_INVALPARAM;
TRACE("(%u)\n", wID);
EnterCriticalSection(&iData->cs);
EnterCriticalSection(&WINMM_IData->cs);
/* 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) {
break;
}
}
LeaveCriticalSection(&iData->cs);
LeaveCriticalSection(&WINMM_IData->cs);
if (*lpTimer) {
LPWINE_TIMERENTRY lpTemp = *lpTimer;
......@@ -373,5 +367,6 @@ DWORD WINAPI timeGetTime(void)
DWORD count;
ReleaseThunkLock(&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);
LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1,
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);
LPWINE_MM_IDATA MULTIMEDIA_GetIData(void);
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);
/* Global variables */
extern LPWINE_MM_IDATA WINMM_IData;
/* HANDLE16 -> HANDLE conversions */
#define HDRVR_32(h16) ((HDRVR)(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
* ========================================================================*/
static LPWINE_MM_IDATA S_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;
}
LPWINE_MM_IDATA WINMM_IData /* = NULL */;
/**************************************************************************
* MULTIMEDIA_CreateIData [internal]
*/
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;
S_IData->hWinMM32Instance = hInstDLL;
InitializeCriticalSection(&S_IData->cs);
S_IData->cs.DebugInfo = (void*)__FILE__ ": WinMM";
S_IData->psStopEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
S_IData->psLastEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
TRACE("Created IData (%p)\n", S_IData);
WINMM_IData->hWinMM32Instance = hInstDLL;
InitializeCriticalSection(&WINMM_IData->cs);
WINMM_IData->cs.DebugInfo = (void*)__FILE__ ": WinMM";
WINMM_IData->psStopEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
WINMM_IData->psLastEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
TRACE("Created IData (%p)\n", WINMM_IData);
return TRUE;
}
......@@ -110,16 +97,16 @@ static BOOL MULTIMEDIA_CreateIData(HINSTANCE hInstDLL)
*/
static void MULTIMEDIA_DeleteIData(void)
{
if (S_IData) {
if (WINMM_IData) {
TIME_MMTimeStop();
/* FIXME: should also free content and resources allocated
* inside S_IData */
CloseHandle(S_IData->psStopEvent);
CloseHandle(S_IData->psLastEvent);
DeleteCriticalSection(&S_IData->cs);
HeapFree(GetProcessHeap(), 0, S_IData);
S_IData = NULL;
* inside WINMM_IData */
CloseHandle(WINMM_IData->psStopEvent);
CloseHandle(WINMM_IData->psLastEvent);
DeleteCriticalSection(&WINMM_IData->cs);
HeapFree(GetProcessHeap(), 0, WINMM_IData);
WINMM_IData = NULL;
}
}
......@@ -701,7 +688,7 @@ BOOL WINAPI mciGetErrorStringA(DWORD dwError, LPSTR lpstrBuffer, UINT uLength)
if (lpstrBuffer != NULL && uLength > 0 &&
dwError >= MCIERR_BASE && dwError <= MCIERR_CUSTOM_DRIVER_BASE) {
if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance,
if (LoadStringA(WINMM_IData->hWinMM32Instance,
dwError, lpstrBuffer, uLength) > 0) {
ret = TRUE;
}
......@@ -986,7 +973,7 @@ static UINT16 MIDI_GetErrorText(UINT16 uError, LPSTR lpText, UINT16 uSize)
(/*uError >= MMSYSERR_BASE && */ uError <= MMSYSERR_LASTERROR) ||
(uError >= MIDIERR_BASE && uError <= MIDIERR_LASTERROR)) {
if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance,
if (LoadStringA(WINMM_IData->hWinMM32Instance,
uError, lpText, uSize) > 0) {
ret = MMSYSERR_NOERROR;
}
......@@ -2286,7 +2273,7 @@ static UINT16 WAVE_GetErrorText(UINT16 uError, LPSTR lpText, UINT16 uSize)
(/*uError >= MMSYSERR_BASE && */uError <= MMSYSERR_LASTERROR) ||
(uError >= WAVERR_BASE && uError <= WAVERR_LASTERROR)) {
if (LoadStringA(MULTIMEDIA_GetIData()->hWinMM32Instance,
if (LoadStringA(WINMM_IData->hWinMM32Instance,
uError, lpText, uSize) > 0) {
ret = MMSYSERR_NOERROR;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment