winmm: Get rid of the WINE_MM_IDATA global structure, there's only one instance anyway.

This commit is contained in:
Alexandre Julliard 2007-06-07 17:50:28 +02:00
parent 0383e4e499
commit 1e178be862
7 changed files with 118 additions and 129 deletions

View File

@ -84,6 +84,8 @@ static const WCHAR wszMci [] = {'M','C','I',0};
static const WCHAR wszOpen [] = {'o','p','e','n',0};
static const WCHAR wszSystemIni[] = {'s','y','s','t','e','m','.','i','n','i',0};
static WINE_MCIDRIVER *MciDrivers;
/* dup a string and uppercase it */
static inline LPWSTR str_dup_upper( LPCWSTR str )
{
@ -104,12 +106,12 @@ LPWINE_MCIDRIVER MCI_GetDriver(UINT16 wDevID)
{
LPWINE_MCIDRIVER wmd = 0;
EnterCriticalSection(&WINMM_IData.cs);
for (wmd = WINMM_IData.lpMciDrvs; wmd; wmd = wmd->lpNext) {
EnterCriticalSection(&WINMM_cs);
for (wmd = MciDrivers; wmd; wmd = wmd->lpNext) {
if (wmd->wDeviceID == wDevID)
break;
}
LeaveCriticalSection(&WINMM_IData.cs);
LeaveCriticalSection(&WINMM_cs);
return wmd;
}
@ -127,8 +129,8 @@ UINT MCI_GetDriverFromString(LPCWSTR lpstrName)
if (!strcmpiW(lpstrName, wszAll))
return MCI_ALL_DEVICE_ID;
EnterCriticalSection(&WINMM_IData.cs);
for (wmd = WINMM_IData.lpMciDrvs; wmd; wmd = wmd->lpNext) {
EnterCriticalSection(&WINMM_cs);
for (wmd = MciDrivers; wmd; wmd = wmd->lpNext) {
if (wmd->lpstrElementName && strcmpW(wmd->lpstrElementName, lpstrName) == 0) {
ret = wmd->wDeviceID;
break;
@ -142,7 +144,7 @@ UINT MCI_GetDriverFromString(LPCWSTR lpstrName)
break;
}
}
LeaveCriticalSection(&WINMM_IData.cs);
LeaveCriticalSection(&WINMM_cs);
return ret;
}
@ -679,7 +681,7 @@ static UINT MCI_GetCommandTable(UINT uDevType)
/* well try to load id */
if (uDevType >= MCI_DEVTYPE_FIRST && uDevType <= MCI_DEVTYPE_LAST) {
if (LoadStringW(WINMM_IData.hWinMM32Instance, uDevType, buf, sizeof(buf) / sizeof(WCHAR))) {
if (LoadStringW(hWinMM32Instance, uDevType, buf, sizeof(buf) / sizeof(WCHAR))) {
str = buf;
}
} else if (uDevType == 0) {
@ -688,15 +690,15 @@ static UINT MCI_GetCommandTable(UINT uDevType)
}
uTbl = MCI_NO_COMMAND_TABLE;
if (str) {
HRSRC hRsrc = FindResourceW(WINMM_IData.hWinMM32Instance, str, (LPCWSTR)RT_RCDATA);
HRSRC hRsrc = FindResourceW(hWinMM32Instance, str, (LPCWSTR)RT_RCDATA);
HANDLE hMem = 0;
if (hRsrc) hMem = LoadResource(WINMM_IData.hWinMM32Instance, hRsrc);
if (hRsrc) hMem = LoadResource(hWinMM32Instance, hRsrc);
if (hMem) {
uTbl = MCI_SetCommandTable(LockResource(hMem), uDevType);
} else {
WARN("No command table found in resource %p[%s]\n",
WINMM_IData.hWinMM32Instance, debugstr_w(str));
hWinMM32Instance, debugstr_w(str));
}
}
TRACE("=> %d\n", uTbl);
@ -799,14 +801,14 @@ static BOOL MCI_UnLoadMciDriver(LPWINE_MCIDRIVER wmd)
if (wmd->dwPrivate != 0)
WARN("Unloading mci driver with non nul dwPrivate field\n");
EnterCriticalSection(&WINMM_IData.cs);
for (tmp = &WINMM_IData.lpMciDrvs; *tmp; tmp = &(*tmp)->lpNext) {
EnterCriticalSection(&WINMM_cs);
for (tmp = &MciDrivers; *tmp; tmp = &(*tmp)->lpNext) {
if (*tmp == wmd) {
*tmp = wmd->lpNext;
break;
}
}
LeaveCriticalSection(&WINMM_IData.cs);
LeaveCriticalSection(&WINMM_cs);
HeapFree(GetProcessHeap(), 0, wmd->lpstrDeviceType);
HeapFree(GetProcessHeap(), 0, wmd->lpstrAlias);
@ -871,12 +873,12 @@ static DWORD MCI_LoadMciDriver(LPCWSTR _strDevTyp, LPWINE_MCIDRIVER* lpwmd)
wmd->dwYieldData = VK_CANCEL;
wmd->CreatorThread = GetCurrentThreadId();
EnterCriticalSection(&WINMM_IData.cs);
EnterCriticalSection(&WINMM_cs);
/* wmd must be inserted in list before sending opening the driver, coz' it
* may want to lookup at wDevID
*/
wmd->lpNext = WINMM_IData.lpMciDrvs;
WINMM_IData.lpMciDrvs = wmd;
wmd->lpNext = MciDrivers;
MciDrivers = wmd;
for (modp.wDeviceID = MCI_MAGIC;
MCI_GetDriver(modp.wDeviceID) != 0;
@ -884,7 +886,7 @@ static DWORD MCI_LoadMciDriver(LPCWSTR _strDevTyp, LPWINE_MCIDRIVER* lpwmd)
wmd->wDeviceID = modp.wDeviceID;
LeaveCriticalSection(&WINMM_IData.cs);
LeaveCriticalSection(&WINMM_cs);
TRACE("wDevID=%04X\n", modp.wDeviceID);
@ -1194,8 +1196,7 @@ static DWORD MCI_HandleReturnValues(DWORD dwRet, LPWINE_MCIDRIVER wmd, DWORD ret
case MCI_RESOURCE_RETURNED:
/* return string which ID is HIWORD(data[1]),
* string is loaded from mmsystem.dll */
LoadStringW(WINMM_IData.hWinMM32Instance, HIWORD(data[1]),
lpstrRet, uRetLen);
LoadStringW(hWinMM32Instance, HIWORD(data[1]), lpstrRet, uRetLen);
break;
case MCI_RESOURCE_RETURNED|MCI_RESOURCE_DRIVER:
/* return string which ID is HIWORD(data[1]),
@ -1654,7 +1655,7 @@ static DWORD MCI_Open(DWORD dwParam, LPMCI_OPEN_PARMSW lpParms)
if (uDevType < MCI_DEVTYPE_FIRST ||
uDevType > MCI_DEVTYPE_LAST ||
!LoadStringW(WINMM_IData.hWinMM32Instance, uDevType,
!LoadStringW(hWinMM32Instance, uDevType,
strDevTyp, sizeof(strDevTyp) / sizeof(WCHAR))) {
dwRet = MCIERR_BAD_INTEGER;
goto errCleanUp;
@ -1769,17 +1770,17 @@ static DWORD MCI_Close(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms
if (wDevID == MCI_ALL_DEVICE_ID) {
LPWINE_MCIDRIVER next;
EnterCriticalSection(&WINMM_IData.cs);
EnterCriticalSection(&WINMM_cs);
/* FIXME: shall I notify once after all is done, or for
* each of the open drivers ? if the latest, which notif
* to return when only one fails ?
*/
for (wmd = WINMM_IData.lpMciDrvs; wmd; ) {
for (wmd = MciDrivers; wmd; ) {
next = wmd->lpNext;
MCI_Close(wmd->wDeviceID, dwParam, lpParms);
wmd = next;
}
LeaveCriticalSection(&WINMM_IData.cs);
LeaveCriticalSection(&WINMM_cs);
return 0;
}
@ -1840,11 +1841,11 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
if (lpParms->wDeviceType < MCI_DEVTYPE_FIRST || lpParms->wDeviceType > MCI_DEVTYPE_LAST) {
if (dwFlags & MCI_SYSINFO_OPEN) {
TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers\n");
EnterCriticalSection(&WINMM_IData.cs);
for (wmd = WINMM_IData.lpMciDrvs; wmd; wmd = wmd->lpNext) {
EnterCriticalSection(&WINMM_cs);
for (wmd = MciDrivers; wmd; wmd = wmd->lpNext) {
cnt++;
}
LeaveCriticalSection(&WINMM_IData.cs);
LeaveCriticalSection(&WINMM_cs);
} else {
TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers\n");
if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, wszHklmMci,
@ -1858,11 +1859,11 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
} else {
if (dwFlags & MCI_SYSINFO_OPEN) {
TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers of type %u\n", lpParms->wDeviceType);
EnterCriticalSection(&WINMM_IData.cs);
for (wmd = WINMM_IData.lpMciDrvs; wmd; wmd = wmd->lpNext) {
EnterCriticalSection(&WINMM_cs);
for (wmd = MciDrivers; wmd; wmd = wmd->lpNext) {
if (wmd->wType == lpParms->wDeviceType) cnt++;
}
LeaveCriticalSection(&WINMM_IData.cs);
LeaveCriticalSection(&WINMM_cs);
} else {
TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers of type %u\n", lpParms->wDeviceType);
FIXME("Don't know how to get # of MCI devices of a given type\n");
@ -2143,8 +2144,7 @@ BOOL WINAPI mciGetErrorStringW(MCIERROR wError, LPWSTR lpstrBuffer, UINT uLength
if (lpstrBuffer != NULL && uLength > 0 &&
wError >= MCIERR_BASE && wError <= MCIERR_CUSTOM_DRIVER_BASE) {
if (LoadStringW(WINMM_IData.hWinMM32Instance,
wError, lpstrBuffer, uLength) > 0) {
if (LoadStringW(hWinMM32Instance, wError, lpstrBuffer, uLength) > 0) {
ret = TRUE;
}
}
@ -2161,8 +2161,7 @@ BOOL WINAPI mciGetErrorStringA(MCIERROR dwError, LPSTR lpstrBuffer, UINT uLength
if (lpstrBuffer != NULL && uLength > 0 &&
dwError >= MCIERR_BASE && dwError <= MCIERR_CUSTOM_DRIVER_BASE) {
if (LoadStringA(WINMM_IData.hWinMM32Instance,
dwError, lpstrBuffer, uLength) > 0) {
if (LoadStringA(hWinMM32Instance, dwError, lpstrBuffer, uLength) > 0) {
ret = TRUE;
}
}

View File

@ -47,6 +47,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mmio);
LRESULT (*pFnMmioCallback16)(DWORD,LPMMIOINFO,UINT,LPARAM,LPARAM) /* = NULL */;
static WINE_MMIO *MMIOList;
/**************************************************************************
* mmioDosIOProc [internal]
*/
@ -440,12 +442,12 @@ LPWINE_MMIO MMIO_Get(HMMIO h)
{
LPWINE_MMIO wm = NULL;
EnterCriticalSection(&WINMM_IData.cs);
for (wm = WINMM_IData.lpMMIO; wm; wm = wm->lpNext) {
EnterCriticalSection(&WINMM_cs);
for (wm = MMIOList; wm; wm = wm->lpNext) {
if (wm->info.hmmio == h)
break;
}
LeaveCriticalSection(&WINMM_IData.cs);
LeaveCriticalSection(&WINMM_cs);
return wm;
}
@ -461,13 +463,13 @@ static LPWINE_MMIO MMIO_Create(void)
wm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MMIO));
if (wm) {
EnterCriticalSection(&WINMM_IData.cs);
EnterCriticalSection(&WINMM_cs);
/* lookup next unallocated WORD handle, with a non NULL value */
while (++MMIO_counter == 0 || MMIO_Get((HMMIO)(ULONG_PTR)MMIO_counter));
wm->info.hmmio = (HMMIO)(ULONG_PTR)MMIO_counter;
wm->lpNext = WINMM_IData.lpMMIO;
WINMM_IData.lpMMIO = wm;
LeaveCriticalSection(&WINMM_IData.cs);
wm->lpNext = MMIOList;
MMIOList = wm;
LeaveCriticalSection(&WINMM_cs);
}
return wm;
}
@ -481,9 +483,9 @@ static BOOL MMIO_Destroy(LPWINE_MMIO wm)
{
LPWINE_MMIO* m;
EnterCriticalSection(&WINMM_IData.cs);
EnterCriticalSection(&WINMM_cs);
/* search for the matching one... */
m = &(WINMM_IData.lpMMIO);
m = &MMIOList;
while (*m && *m != wm) m = &(*m)->lpNext;
/* ...and destroy */
if (*m) {
@ -491,7 +493,7 @@ static BOOL MMIO_Destroy(LPWINE_MMIO wm)
HeapFree(GetProcessHeap(), 0, wm);
wm = NULL;
}
LeaveCriticalSection(&WINMM_IData.cs);
LeaveCriticalSection(&WINMM_cs);
return wm ? FALSE : TRUE;
}

View File

@ -77,7 +77,6 @@ BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
ERR("Could not load sibling WinMM.dll\n");
return FALSE;
}
WINMM_IData.hWinMM16Instance = hinstDLL;
/* hook in our 16 bit function pointers */
pFnGetMMThread16 = WINMM_GetmmThread;
pFnOpenDriver16 = DRIVER_OpenDriver16;
@ -89,7 +88,6 @@ BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
MMDRV_Init16();
break;
case DLL_PROCESS_DETACH:
WINMM_IData.hWinMM16Instance = 0;
pFnGetMMThread16 = NULL;
pFnOpenDriver16 = NULL;
pFnCloseDriver16 = NULL;

View File

@ -37,6 +37,19 @@
WINE_DEFAULT_DEBUG_CHANNEL(winmm);
typedef struct tagWINE_PLAYSOUND
{
unsigned bLoop : 1,
bAlloc : 1;
LPCWSTR pszSound;
HMODULE hMod;
DWORD fdwSound;
HANDLE hThread;
struct tagWINE_PLAYSOUND* lpNext;
} WINE_PLAYSOUND;
static WINE_PLAYSOUND *PlaySoundList;
static HMMIO get_mmioFromFile(LPCWSTR lpszName)
{
HMMIO ret;
@ -194,11 +207,11 @@ static void PlaySound_Free(WINE_PLAYSOUND* wps)
{
WINE_PLAYSOUND** p;
EnterCriticalSection(&WINMM_IData.cs);
for (p = &WINMM_IData.lpPlaySound; *p && *p != wps; p = &((*p)->lpNext));
EnterCriticalSection(&WINMM_cs);
for (p = &PlaySoundList; *p && *p != wps; p = &((*p)->lpNext));
if (*p) *p = (*p)->lpNext;
if (WINMM_IData.lpPlaySound == NULL) SetEvent(WINMM_IData.psLastEvent);
LeaveCriticalSection(&WINMM_IData.cs);
if (PlaySoundList == NULL) SetEvent(psLastEvent);
LeaveCriticalSection(&WINMM_cs);
if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound);
if (wps->hThread) CloseHandle(wps->hThread);
HeapFree(GetProcessHeap(), 0, wps);
@ -382,7 +395,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
mmioSeek(hmmio, mmckInfo.dwDataOffset, SEEK_SET);
while (left)
{
if (WaitForSingleObject(WINMM_IData.psStopEvent, 0) == WAIT_OBJECT_0)
if (WaitForSingleObject(psStopEvent, 0) == WAIT_OBJECT_0)
{
wps->bLoop = FALSE;
break;
@ -430,7 +443,7 @@ static BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSo
/* 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)) && WINMM_IData.lpPlaySound != NULL)
if ((fdwSound & (SND_NOWAIT | SND_NOSTOP)) && PlaySoundList != NULL)
return FALSE;
/* alloc internal structure, if we need to play something */
@ -440,27 +453,27 @@ static BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSo
return FALSE;
}
EnterCriticalSection(&WINMM_IData.cs);
EnterCriticalSection(&WINMM_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 (WINMM_IData.lpPlaySound != NULL)
while (PlaySoundList != NULL)
{
ResetEvent(WINMM_IData.psLastEvent);
ResetEvent(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(WINMM_IData.psStopEvent);
SetEvent(psStopEvent);
LeaveCriticalSection(&WINMM_IData.cs);
WaitForSingleObject(WINMM_IData.psLastEvent, INFINITE);
EnterCriticalSection(&WINMM_IData.cs);
LeaveCriticalSection(&WINMM_cs);
WaitForSingleObject(psLastEvent, INFINITE);
EnterCriticalSection(&WINMM_cs);
ResetEvent(WINMM_IData.psStopEvent);
ResetEvent(psStopEvent);
}
if (wps) wps->lpNext = WINMM_IData.lpPlaySound;
WINMM_IData.lpPlaySound = wps;
LeaveCriticalSection(&WINMM_IData.cs);
if (wps) wps->lpNext = PlaySoundList;
PlaySoundList = wps;
LeaveCriticalSection(&WINMM_cs);
if (!pszSound || (fdwSound & SND_PURGE)) return TRUE;

View File

@ -49,6 +49,18 @@
WINE_DEFAULT_DEBUG_CHANNEL(mmtime);
typedef struct tagWINE_TIMERENTRY {
UINT wDelay;
UINT wResol;
LPTIMECALLBACK lpFunc; /* can be lots of things */
DWORD dwUser;
UINT16 wFlags;
UINT16 wTimerID;
DWORD dwTriggerTime;
struct tagWINE_TIMERENTRY* lpNext;
} WINE_TIMERENTRY, *LPWINE_TIMERENTRY;
static HANDLE TIME_hMMTimer;
static LPWINE_TIMERENTRY TIME_TimersList;
static CRITICAL_SECTION TIME_cbcrst;
@ -120,7 +132,7 @@ static void TIME_TriggerCallBack(LPWINE_TIMERENTRY lpTimer)
/**************************************************************************
* TIME_MMSysTimeCallback
*/
static int TIME_MMSysTimeCallback(LPWINE_MM_IDATA iData)
static int TIME_MMSysTimeCallback(void)
{
static int nSizeLpTimers;
static LPWINE_TIMERENTRY lpTimers;
@ -147,7 +159,7 @@ static LPWINE_TIMERENTRY lpTimers;
idx = 0;
cur_time = GetTickCount();
EnterCriticalSection(&iData->cs);
EnterCriticalSection(&WINMM_cs);
for (ptimer = &TIME_TimersList; *ptimer != NULL; ) {
timer = *ptimer;
next_ptimer = &timer->lpNext;
@ -200,7 +212,7 @@ static LPWINE_TIMERENTRY lpTimers;
ptimer = next_ptimer;
}
LeaveCriticalSection(&iData->cs);
LeaveCriticalSection(&WINMM_cs);
EnterCriticalSection(&TIME_cbcrst);
while (idx > 0) TIME_TriggerCallBack(&lpTimers[--idx]);
@ -225,7 +237,6 @@ static LPWINE_TIMERENTRY lpTimers;
*/
static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg)
{
LPWINE_MM_IDATA iData = (LPWINE_MM_IDATA)arg;
int sleep_time, ret;
char readme[16];
struct pollfd pfd;
@ -243,7 +254,7 @@ static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg)
while (! TIME_TimeToDie)
{
sleep_time = TIME_MMSysTimeCallback(iData);
sleep_time = TIME_MMSysTimeCallback();
if (sleep_time == 0)
continue;
@ -279,7 +290,7 @@ void TIME_MMTimeStart(void)
fcntl(TIME_fdWake[1], F_SETFL, O_NONBLOCK);
}
TIME_TimeToDie = FALSE;
TIME_hMMTimer = CreateThread(NULL, 0, TIME_MMSysTimeThread, &WINMM_IData, 0, NULL);
TIME_hMMTimer = CreateThread(NULL, 0, TIME_MMSysTimeThread, NULL, 0, NULL);
SetThreadPriority(TIME_hMMTimer, THREAD_PRIORITY_TIME_CRITICAL);
InitializeCriticalSection(&TIME_cbcrst);
TIME_cbcrst.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": WINMM.TIME_cbcrst");
@ -356,7 +367,7 @@ WORD TIME_SetEventInternal(UINT wDelay, UINT wResol,
lpNewTimer->dwUser = dwUser;
lpNewTimer->wFlags = wFlags;
EnterCriticalSection(&WINMM_IData.cs);
EnterCriticalSection(&WINMM_cs);
for (lpTimer = TIME_TimersList; lpTimer != NULL; lpTimer = lpTimer->lpNext) {
wNewID = max(wNewID, lpTimer->wTimerID);
@ -366,7 +377,7 @@ WORD TIME_SetEventInternal(UINT wDelay, UINT wResol,
TIME_TimersList = lpNewTimer;
lpNewTimer->wTimerID = wNewID + 1;
LeaveCriticalSection(&WINMM_IData.cs);
LeaveCriticalSection(&WINMM_cs);
/* Wake the service thread in case there is work to be done */
write(TIME_fdWake[1], &c, sizeof(c));
@ -397,7 +408,7 @@ MMRESULT WINAPI timeKillEvent(UINT wID)
LPWINE_TIMERENTRY lpSelf = NULL, *lpTimer;
TRACE("(%u)\n", wID);
EnterCriticalSection(&WINMM_IData.cs);
EnterCriticalSection(&WINMM_cs);
/* remove WINE_TIMERENTRY from list */
for (lpTimer = &TIME_TimersList; *lpTimer; lpTimer = &(*lpTimer)->lpNext) {
if (wID == (*lpTimer)->wTimerID) {
@ -407,7 +418,7 @@ MMRESULT WINAPI timeKillEvent(UINT wID)
break;
}
}
LeaveCriticalSection(&WINMM_IData.cs);
LeaveCriticalSection(&WINMM_cs);
if (!lpSelf)
{

View File

@ -153,17 +153,6 @@ typedef struct tagWINE_MCIDRIVER {
#define WINE_TIMER_IS32 0x80
typedef struct tagWINE_TIMERENTRY {
UINT wDelay;
UINT wResol;
LPTIMECALLBACK lpFunc; /* can be lots of things */
DWORD dwUser;
UINT16 wFlags;
UINT16 wTimerID;
DWORD dwTriggerTime;
struct tagWINE_TIMERENTRY* lpNext;
} WINE_TIMERENTRY, *LPWINE_TIMERENTRY;
enum mmioProcType {MMIO_PROC_16,MMIO_PROC_32A,MMIO_PROC_32W};
struct IOProcList
@ -185,35 +174,6 @@ typedef struct tagWINE_MMIO {
DWORD dwFileSize;
} WINE_MMIO, *LPWINE_MMIO;
typedef struct tagWINE_PLAYSOUND {
unsigned bLoop : 1,
bAlloc : 1;
LPCWSTR pszSound;
HMODULE hMod;
DWORD fdwSound;
HANDLE hThread;
struct tagWINE_PLAYSOUND* lpNext;
} WINE_PLAYSOUND, *LPWINE_PLAYSOUND;
typedef struct tagWINE_MM_IDATA {
/* winmm part */
HANDLE hWinMM32Instance;
HANDLE hWinMM16Instance;
CRITICAL_SECTION cs;
/* mci part */
LPWINE_MCIDRIVER lpMciDrvs;
/* low level drivers (unused yet) */
/* LPWINE_WAVE lpWave; */
/* LPWINE_MIDI lpMidi; */
/* LPWINE_MIXER lpMixer; */
/* mmio part */
LPWINE_MMIO lpMMIO;
/* playsound and sndPlaySound */
WINE_PLAYSOUND* lpPlaySound;
HANDLE psLastEvent;
HANDLE psStopEvent;
} WINE_MM_IDATA, *LPWINE_MM_IDATA;
/* function prototypes */
typedef LONG (*MCIPROC)(DWORD, HDRVR, DWORD, DWORD, DWORD);
@ -285,7 +245,10 @@ void TIME_MMTimeStart(void);
void TIME_MMTimeStop(void);
/* Global variables */
extern WINE_MM_IDATA WINMM_IData;
extern CRITICAL_SECTION WINMM_cs;
extern HINSTANCE hWinMM32Instance;
extern HANDLE psLastEvent;
extern HANDLE psStopEvent;
/* pointers to 16 bit functions (if sibling MMSYSTEM.DLL is loaded
* NULL otherwise

View File

@ -64,21 +64,26 @@ void (WINAPI *pFnRestoreThunkLock)(DWORD);
* G L O B A L S E T T I N G S
* ========================================================================*/
WINE_MM_IDATA WINMM_IData;
HINSTANCE hWinMM32Instance;
HANDLE psLastEvent;
HANDLE psStopEvent;
static CRITICAL_SECTION_DEBUG critsect_debug =
{
0, 0, &WINMM_cs,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": WINMM_cs") }
};
CRITICAL_SECTION WINMM_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
/**************************************************************************
* WINMM_CreateIData [internal]
*/
static BOOL WINMM_CreateIData(HINSTANCE hInstDLL)
{
memset( &WINMM_IData, 0, sizeof WINMM_IData );
WINMM_IData.hWinMM32Instance = hInstDLL;
InitializeCriticalSection(&WINMM_IData.cs);
WINMM_IData.cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": WINE_MM_IDATA.cs");
WINMM_IData.psStopEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
WINMM_IData.psLastEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
TRACE("Initialized IData (%p)\n", &WINMM_IData);
hWinMM32Instance = hInstDLL;
psStopEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
psLastEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
return TRUE;
}
@ -91,10 +96,9 @@ static void WINMM_DeleteIData(void)
/* FIXME: should also free content and resources allocated
* inside WINMM_IData */
CloseHandle(WINMM_IData.psStopEvent);
CloseHandle(WINMM_IData.psLastEvent);
WINMM_IData.cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&WINMM_IData.cs);
CloseHandle(psStopEvent);
CloseHandle(psLastEvent);
DeleteCriticalSection(&WINMM_cs);
}
/******************************************************************
@ -888,8 +892,7 @@ UINT WINAPI midiOutGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize)
* a warning for the test was always true */
(/*uError >= MMSYSERR_BASE && */ uError <= MMSYSERR_LASTERROR) ||
(uError >= MIDIERR_BASE && uError <= MIDIERR_LASTERROR)) {
if (LoadStringW(WINMM_IData.hWinMM32Instance,
uError, lpText, uSize) > 0) {
if (LoadStringW(hWinMM32Instance, uError, lpText, uSize) > 0) {
ret = MMSYSERR_NOERROR;
}
}
@ -2199,7 +2202,7 @@ UINT WINAPI waveOutGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize)
* a warning for the test was always true */
(/*uError >= MMSYSERR_BASE && */ uError <= MMSYSERR_LASTERROR) ||
(uError >= WAVERR_BASE && uError <= WAVERR_LASTERROR)) {
if (LoadStringW(WINMM_IData.hWinMM32Instance,
if (LoadStringW(hWinMM32Instance,
uError, lpText, uSize) > 0) {
ret = MMSYSERR_NOERROR;
}