Fixed thread handle leaks.
This commit is contained in:
parent
6c8ee62340
commit
76659e9e9f
|
@ -84,6 +84,7 @@ static DWORD CALLBACK MCI_SCAStarter(LPVOID arg)
|
|||
static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
|
||||
DWORD_PTR dwParam2, UINT size)
|
||||
{
|
||||
HANDLE handle;
|
||||
struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA) + size);
|
||||
|
||||
if (sca == 0)
|
||||
|
@ -103,10 +104,11 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
|
|||
sca->dwParam2 = dwParam2;
|
||||
}
|
||||
|
||||
if (CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL) == 0) {
|
||||
if ((handle = CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL)) == 0) {
|
||||
WARN("Couldn't allocate thread for async command handling, sending synchronously\n");
|
||||
return MCI_SCAStarter(&sca);
|
||||
}
|
||||
CloseHandle(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -127,6 +127,7 @@ static DWORD CALLBACK MCI_SCAStarter(LPVOID arg)
|
|||
static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
|
||||
DWORD dwParam2, UINT size)
|
||||
{
|
||||
HANDLE handle;
|
||||
struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA) + size);
|
||||
|
||||
if (sca == 0)
|
||||
|
@ -146,10 +147,11 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
|
|||
sca->dwParam2 = dwParam2;
|
||||
}
|
||||
|
||||
if (CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL) == 0) {
|
||||
if ((handle = CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL)) == 0) {
|
||||
WARN("Couldn't allocate thread for async command handling, sending synchonously\n");
|
||||
return MCI_SCAStarter(&sca);
|
||||
}
|
||||
CloseHandle(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,7 @@ static DWORD CALLBACK MCI_SCAStarter(LPVOID arg)
|
|||
static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
|
||||
DWORD dwParam2, UINT size)
|
||||
{
|
||||
HANDLE handle;
|
||||
struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA) + size);
|
||||
|
||||
if (sca == 0)
|
||||
|
@ -116,10 +117,11 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
|
|||
sca->dwParam2 = dwParam2;
|
||||
}
|
||||
|
||||
if (CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL) == 0) {
|
||||
if ((handle = CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL)) == 0) {
|
||||
WARN("Couldn't allocate thread for async command handling, sending synchonously\n");
|
||||
return MCI_SCAStarter(&sca);
|
||||
}
|
||||
CloseHandle(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -190,6 +190,7 @@ static void PlaySound_Free(WINE_PLAYSOUND* wps)
|
|||
if (WINMM_IData->lpPlaySound == NULL) SetEvent(WINMM_IData->psLastEvent);
|
||||
LeaveCriticalSection(&WINMM_IData->cs);
|
||||
if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound);
|
||||
if (wps->hThread) CloseHandle(wps->hThread);
|
||||
HeapFree(GetProcessHeap(), 0, wps);
|
||||
}
|
||||
|
||||
|
@ -456,9 +457,12 @@ BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BO
|
|||
if (fdwSound & SND_ASYNC)
|
||||
{
|
||||
DWORD id;
|
||||
HANDLE handle;
|
||||
wps->bLoop = (fdwSound & SND_LOOP) ? TRUE : FALSE;
|
||||
if (CreateThread(NULL, 0, proc_PlaySound, wps, 0, &id) != 0)
|
||||
if ((handle = CreateThread(NULL, 0, proc_PlaySound, wps, 0, &id)) != 0) {
|
||||
wps->hThread = handle;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else return proc_PlaySound(wps);
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ typedef struct tagWINE_PLAYSOUND {
|
|||
LPCWSTR pszSound;
|
||||
HMODULE hMod;
|
||||
DWORD fdwSound;
|
||||
HANDLE hThread;
|
||||
struct tagWINE_PLAYSOUND* lpNext;
|
||||
} WINE_PLAYSOUND, *LPWINE_PLAYSOUND;
|
||||
|
||||
|
|
Loading…
Reference in New Issue