Commit 56f2c580 authored by Jörg Höhle's avatar Jörg Höhle Committed by Alexandre Julliard

winealsa: CreateEvent and CreateThread return NULL on error, not INVALID_HANDLE_VALUE.

parent 3a5c79fa
...@@ -127,7 +127,7 @@ void ALSA_WaitRingMessage(ALSA_MSG_RING* omr, DWORD sleep) ...@@ -127,7 +127,7 @@ void ALSA_WaitRingMessage(ALSA_MSG_RING* omr, DWORD sleep)
*/ */
int ALSA_AddRingMessage(ALSA_MSG_RING* omr, enum win_wm_message msg, DWORD_PTR param, BOOL wait) int ALSA_AddRingMessage(ALSA_MSG_RING* omr, enum win_wm_message msg, DWORD_PTR param, BOOL wait)
{ {
HANDLE hEvent = INVALID_HANDLE_VALUE; HANDLE hEvent = NULL;
EnterCriticalSection(&omr->msg_crst); EnterCriticalSection(&omr->msg_crst);
if ((omr->msg_toget == ((omr->msg_tosave + 1) % omr->ring_buffer_size))) if ((omr->msg_toget == ((omr->msg_tosave + 1) % omr->ring_buffer_size)))
...@@ -151,7 +151,7 @@ int ALSA_AddRingMessage(ALSA_MSG_RING* omr, enum win_wm_message msg, DWORD_PTR p ...@@ -151,7 +151,7 @@ int ALSA_AddRingMessage(ALSA_MSG_RING* omr, enum win_wm_message msg, DWORD_PTR p
if (wait) if (wait)
{ {
hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
if (hEvent == INVALID_HANDLE_VALUE) if (!hEvent)
{ {
ERR("can't create event !?\n"); ERR("can't create event !?\n");
LeaveCriticalSection(&omr->msg_crst); LeaveCriticalSection(&omr->msg_crst);
...@@ -173,7 +173,7 @@ int ALSA_AddRingMessage(ALSA_MSG_RING* omr, enum win_wm_message msg, DWORD_PTR p ...@@ -173,7 +173,7 @@ int ALSA_AddRingMessage(ALSA_MSG_RING* omr, enum win_wm_message msg, DWORD_PTR p
{ {
omr->messages[omr->msg_tosave].msg = msg; omr->messages[omr->msg_tosave].msg = msg;
omr->messages[omr->msg_tosave].param = param; omr->messages[omr->msg_tosave].param = param;
omr->messages[omr->msg_tosave].hEvent = INVALID_HANDLE_VALUE; omr->messages[omr->msg_tosave].hEvent = NULL;
omr->msg_tosave = (omr->msg_tosave + 1) % omr->ring_buffer_size; omr->msg_tosave = (omr->msg_tosave + 1) % omr->ring_buffer_size;
} }
LeaveCriticalSection(&omr->msg_crst); LeaveCriticalSection(&omr->msg_crst);
......
...@@ -515,7 +515,7 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -515,7 +515,7 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
SetThreadPriority(wwi->hThread, THREAD_PRIORITY_TIME_CRITICAL); SetThreadPriority(wwi->hThread, THREAD_PRIORITY_TIME_CRITICAL);
WaitForSingleObject(wwi->hStartUpEvent, INFINITE); WaitForSingleObject(wwi->hStartUpEvent, INFINITE);
CloseHandle(wwi->hStartUpEvent); CloseHandle(wwi->hStartUpEvent);
wwi->hStartUpEvent = INVALID_HANDLE_VALUE; wwi->hStartUpEvent = NULL;
HeapFree( GetProcessHeap(), 0, hw_params ); HeapFree( GetProcessHeap(), 0, hw_params );
HeapFree( GetProcessHeap(), 0, sw_params ); HeapFree( GetProcessHeap(), 0, sw_params );
...@@ -554,7 +554,7 @@ static DWORD widClose(WORD wDevID) ...@@ -554,7 +554,7 @@ static DWORD widClose(WORD wDevID)
WARN("buffers still playing !\n"); WARN("buffers still playing !\n");
ret = WAVERR_STILLPLAYING; ret = WAVERR_STILLPLAYING;
} else { } else {
if (wwi->hThread != INVALID_HANDLE_VALUE) { if (wwi->hThread) {
ALSA_AddRingMessage(&wwi->msgRing, WINE_WM_CLOSING, 0, TRUE); ALSA_AddRingMessage(&wwi->msgRing, WINE_WM_CLOSING, 0, TRUE);
} }
ALSA_DestroyRingMessage(&wwi->msgRing); ALSA_DestroyRingMessage(&wwi->msgRing);
......
...@@ -782,18 +782,16 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -782,18 +782,16 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
wwo->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL); wwo->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD_PTR)wDevID, 0, &(wwo->dwThreadID)); wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD_PTR)wDevID, 0, &(wwo->dwThreadID));
if (wwo->hThread) if (!wwo->hThread) {
SetThreadPriority(wwo->hThread, THREAD_PRIORITY_TIME_CRITICAL);
else
{
ERR("Thread creation for the wodPlayer failed!\n"); ERR("Thread creation for the wodPlayer failed!\n");
CloseHandle(wwo->hStartUpEvent); CloseHandle(wwo->hStartUpEvent);
retcode = MMSYSERR_NOMEM; retcode = MMSYSERR_NOMEM;
goto errexit; goto errexit;
} }
SetThreadPriority(wwo->hThread, THREAD_PRIORITY_TIME_CRITICAL);
WaitForSingleObject(wwo->hStartUpEvent, INFINITE); WaitForSingleObject(wwo->hStartUpEvent, INFINITE);
CloseHandle(wwo->hStartUpEvent); CloseHandle(wwo->hStartUpEvent);
wwo->hStartUpEvent = INVALID_HANDLE_VALUE; wwo->hStartUpEvent = NULL;
TRACE("handle=%p\n", pcm); TRACE("handle=%p\n", pcm);
TRACE("wBitsPerSample=%u, nAvgBytesPerSec=%u, nSamplesPerSec=%u, nChannels=%u nBlockAlign=%u!\n", TRACE("wBitsPerSample=%u, nAvgBytesPerSec=%u, nSamplesPerSec=%u, nChannels=%u nBlockAlign=%u!\n",
...@@ -856,7 +854,7 @@ static DWORD wodClose(WORD wDevID) ...@@ -856,7 +854,7 @@ static DWORD wodClose(WORD wDevID)
WARN("buffers still playing !\n"); WARN("buffers still playing !\n");
ret = WAVERR_STILLPLAYING; ret = WAVERR_STILLPLAYING;
} else { } else {
if (wwo->hThread != INVALID_HANDLE_VALUE) { if (wwo->hThread) {
ALSA_AddRingMessage(&wwo->msgRing, WINE_WM_CLOSING, 0, TRUE); ALSA_AddRingMessage(&wwo->msgRing, WINE_WM_CLOSING, 0, TRUE);
} }
ALSA_DestroyRingMessage(&wwo->msgRing); ALSA_DestroyRingMessage(&wwo->msgRing);
......
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