Commit b2ba933f authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Make multimedia threads high priority.

parent c7bd5fb1
...@@ -109,6 +109,7 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1, ...@@ -109,6 +109,7 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
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);
} }
SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL);
CloseHandle(handle); CloseHandle(handle);
return 0; return 0;
} }
......
...@@ -159,6 +159,7 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1, ...@@ -159,6 +159,7 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
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);
} }
SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL);
CloseHandle(handle); CloseHandle(handle);
return 0; return 0;
} }
......
...@@ -122,6 +122,7 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1, ...@@ -122,6 +122,7 @@ static DWORD MCI_SendCommandAsync(UINT wDevID, UINT wMsg, DWORD dwParam1,
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);
} }
SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL);
CloseHandle(handle); CloseHandle(handle);
return 0; return 0;
} }
......
...@@ -1946,6 +1946,7 @@ LRESULT WINAPI mmThreadCreate16(FARPROC16 fpThreadAddr, LPHANDLE16 lpHndl, DWORD ...@@ -1946,6 +1946,7 @@ LRESULT WINAPI mmThreadCreate16(FARPROC16 fpThreadAddr, LPHANDLE16 lpHndl, DWORD
CloseHandle(lpMMThd->hEvent); CloseHandle(lpMMThd->hEvent);
ret = 2; ret = 2;
} else { } else {
SetThreadPriority(lpMMThd->hThread, THREAD_PRIORITY_TIME_CRITICAL);
TRACE("Got a nice thread hndl=%p id=0x%08lx\n", lpMMThd->hThread, lpMMThd->dwThreadID); TRACE("Got a nice thread hndl=%p id=0x%08lx\n", lpMMThd->hThread, lpMMThd->dwThreadID);
ret = 0; ret = 0;
} }
......
...@@ -471,6 +471,7 @@ static BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSo ...@@ -471,6 +471,7 @@ static BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSo
wps->bLoop = (fdwSound & SND_LOOP) ? TRUE : FALSE; wps->bLoop = (fdwSound & SND_LOOP) ? TRUE : FALSE;
if ((handle = CreateThread(NULL, 0, proc_PlaySound, wps, 0, &id)) != 0) { if ((handle = CreateThread(NULL, 0, proc_PlaySound, wps, 0, &id)) != 0) {
wps->hThread = handle; wps->hThread = handle;
SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL);
return TRUE; return TRUE;
} }
} }
......
...@@ -2007,6 +2007,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -2007,6 +2007,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
if (!(dwFlags & WAVE_DIRECTSOUND)) { if (!(dwFlags & WAVE_DIRECTSOUND)) {
wwo->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL); wwo->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID)); wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID));
if (wwo->hThread)
SetThreadPriority(wwo->hThread, THREAD_PRIORITY_TIME_CRITICAL);
WaitForSingleObject(wwo->hStartUpEvent, INFINITE); WaitForSingleObject(wwo->hStartUpEvent, INFINITE);
CloseHandle(wwo->hStartUpEvent); CloseHandle(wwo->hStartUpEvent);
} else { } else {
...@@ -3474,6 +3476,8 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -3474,6 +3476,8 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
if (!(dwFlags & WAVE_DIRECTSOUND)) { if (!(dwFlags & WAVE_DIRECTSOUND)) {
wwi->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL); wwi->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
wwi->hThread = CreateThread(NULL, 0, widRecorder, (LPVOID)(DWORD)wDevID, 0, &(wwi->dwThreadID)); wwi->hThread = CreateThread(NULL, 0, widRecorder, (LPVOID)(DWORD)wDevID, 0, &(wwi->dwThreadID));
if (wwi->hThread)
SetThreadPriority(wwi->hThread, THREAD_PRIORITY_TIME_CRITICAL);
WaitForSingleObject(wwi->hStartUpEvent, INFINITE); WaitForSingleObject(wwi->hStartUpEvent, INFINITE);
CloseHandle(wwi->hStartUpEvent); CloseHandle(wwi->hStartUpEvent);
} else { } else {
......
...@@ -462,6 +462,7 @@ static DWORD midOpen(WORD wDevID, LPMIDIOPENDESC lpDesc, DWORD dwFlags) ...@@ -462,6 +462,7 @@ static DWORD midOpen(WORD wDevID, LPMIDIOPENDESC lpDesc, DWORD dwFlags)
midiCloseSeq(); midiCloseSeq();
return MMSYSERR_ERROR; return MMSYSERR_ERROR;
} }
SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL);
TRACE("Created thread for midi-in\n"); TRACE("Created thread for midi-in\n");
} }
......
...@@ -1208,6 +1208,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -1208,6 +1208,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
if (!(dwFlags & WAVE_DIRECTSOUND)) { if (!(dwFlags & WAVE_DIRECTSOUND)) {
wwo->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL); wwo->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID)); wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID));
if (wwo->hThread)
SetThreadPriority(wwo->hThread, THREAD_PRIORITY_TIME_CRITICAL);
WaitForSingleObject(wwo->hStartUpEvent, INFINITE); WaitForSingleObject(wwo->hStartUpEvent, INFINITE);
CloseHandle(wwo->hStartUpEvent); CloseHandle(wwo->hStartUpEvent);
} else { } else {
...@@ -1860,6 +1862,8 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -1860,6 +1862,8 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
if (!(dwFlags & WAVE_DIRECTSOUND)) { if (!(dwFlags & WAVE_DIRECTSOUND)) {
wwi->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL); wwi->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
wwi->hThread = CreateThread(NULL, 0, widRecorder, (LPVOID)(DWORD)wDevID, 0, &(wwi->dwThreadID)); wwi->hThread = CreateThread(NULL, 0, widRecorder, (LPVOID)(DWORD)wDevID, 0, &(wwi->dwThreadID));
if (wwi->hThread)
SetThreadPriority(wwi->hThread, THREAD_PRIORITY_TIME_CRITICAL);
WaitForSingleObject(wwi->hStartUpEvent, INFINITE); WaitForSingleObject(wwi->hStartUpEvent, INFINITE);
CloseHandle(wwi->hStartUpEvent); CloseHandle(wwi->hStartUpEvent);
} else { } else {
......
...@@ -894,6 +894,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -894,6 +894,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
if (!(dwFlags & WAVE_DIRECTSOUND)) { if (!(dwFlags & WAVE_DIRECTSOUND)) {
wwo->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); wwo->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID)); wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID));
if (wwo->hThread)
SetThreadPriority(wwo->hThread, THREAD_PRIORITY_TIME_CRITICAL);
WaitForSingleObject(wwo->hEvent, INFINITE); WaitForSingleObject(wwo->hEvent, INFINITE);
} else { } else {
wwo->hEvent = INVALID_HANDLE_VALUE; wwo->hEvent = INVALID_HANDLE_VALUE;
...@@ -1979,6 +1981,8 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -1979,6 +1981,8 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
wwi->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); wwi->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
wwi->hThread = CreateThread(NULL, 0, widRecorder, (LPVOID)(DWORD)wDevID, 0, &(wwi->dwThreadID)); wwi->hThread = CreateThread(NULL, 0, widRecorder, (LPVOID)(DWORD)wDevID, 0, &(wwi->dwThreadID));
if (wwi->hThread)
SetThreadPriority(wwi->hThread, THREAD_PRIORITY_TIME_CRITICAL);
WaitForSingleObject(wwi->hEvent, INFINITE); WaitForSingleObject(wwi->hEvent, INFINITE);
if (LIBAUDIOIO_NotifyClient(wDevID, WIM_OPEN, 0L, 0L) != MMSYSERR_NOERROR) { if (LIBAUDIOIO_NotifyClient(wDevID, WIM_OPEN, 0L, 0L) != MMSYSERR_NOERROR) {
......
...@@ -956,6 +956,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -956,6 +956,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
if (!(dwFlags & WAVE_DIRECTSOUND)) { if (!(dwFlags & WAVE_DIRECTSOUND)) {
wwo->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL); wwo->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID)); wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID));
if (wwo->hThread)
SetThreadPriority(wwo->hThread, THREAD_PRIORITY_TIME_CRITICAL);
WaitForSingleObject(wwo->hStartUpEvent, INFINITE); WaitForSingleObject(wwo->hStartUpEvent, INFINITE);
CloseHandle(wwo->hStartUpEvent); CloseHandle(wwo->hStartUpEvent);
} else { } else {
......
...@@ -1786,6 +1786,7 @@ MMRESULT MIDI_StreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, DWORD cMidi ...@@ -1786,6 +1786,7 @@ MMRESULT MIDI_StreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, DWORD cMidi
midiStreamClose((HMIDISTRM)hMidiOut); midiStreamClose((HMIDISTRM)hMidiOut);
return MMSYSERR_NOMEM; return MMSYSERR_NOMEM;
} }
SetThreadPriority(lpMidiStrm->hThread, THREAD_PRIORITY_TIME_CRITICAL);
/* wait for thread to have started, and for its queue to be created */ /* wait for thread to have started, and for its queue to be created */
{ {
...@@ -2797,6 +2798,7 @@ MMRESULT WINAPI mmTaskCreate(LPTASKCALLBACK cb, HANDLE* ph, DWORD client) ...@@ -2797,6 +2798,7 @@ MMRESULT WINAPI mmTaskCreate(LPTASKCALLBACK cb, HANDLE* ph, DWORD client)
if (hEvent) CloseHandle(hEvent); if (hEvent) CloseHandle(hEvent);
return TASKERR_OUTOFMEMORY; return TASKERR_OUTOFMEMORY;
} }
SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL);
if (ph) *ph = hEvent; if (ph) *ph = hEvent;
CloseHandle(hThread); CloseHandle(hThread);
return 0; return 0;
......
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