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