diff --git a/dlls/winmm/mciavi/mciavi.c b/dlls/winmm/mciavi/mciavi.c index cd863ddc623..d35ad174014 100644 --- a/dlls/winmm/mciavi/mciavi.c +++ b/dlls/winmm/mciavi/mciavi.c @@ -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; } diff --git a/dlls/winmm/mciseq/mcimidi.c b/dlls/winmm/mciseq/mcimidi.c index 846428b6058..dcc03874451 100644 --- a/dlls/winmm/mciseq/mcimidi.c +++ b/dlls/winmm/mciseq/mcimidi.c @@ -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; } diff --git a/dlls/winmm/mciwave/mciwave.c b/dlls/winmm/mciwave/mciwave.c index 9ef3430a298..fed84a7336c 100644 --- a/dlls/winmm/mciwave/mciwave.c +++ b/dlls/winmm/mciwave/mciwave.c @@ -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; } diff --git a/dlls/winmm/playsound.c b/dlls/winmm/playsound.c index 6854c65b78d..e2e928b8dc8 100644 --- a/dlls/winmm/playsound.c +++ b/dlls/winmm/playsound.c @@ -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); diff --git a/dlls/winmm/winemm.h b/dlls/winmm/winemm.h index 5ed142365c1..1447cd1ba4d 100644 --- a/dlls/winmm/winemm.h +++ b/dlls/winmm/winemm.h @@ -193,6 +193,7 @@ typedef struct tagWINE_PLAYSOUND { LPCWSTR pszSound; HMODULE hMod; DWORD fdwSound; + HANDLE hThread; struct tagWINE_PLAYSOUND* lpNext; } WINE_PLAYSOUND, *LPWINE_PLAYSOUND;