winmm: Abort PlaySound in case of audio error.

This commit is contained in:
Jörg Höhle 2011-03-26 07:36:47 +01:00 committed by Alexandre Julliard
parent 15ad749ece
commit ca37dbcfe6
1 changed files with 6 additions and 4 deletions

View File

@ -179,7 +179,6 @@ static void CALLBACK PlaySound_Callback(HWAVEOUT hwo, UINT uMsg,
static void PlaySound_WaitDone(struct playsound_data* s)
{
for (;;) {
ResetEvent(s->hEvent);
if (InterlockedDecrement(&s->dwEventCount) >= 0) break;
InterlockedIncrement(&s->dwEventCount);
@ -437,17 +436,20 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
if (count < 1) break;
left -= count;
waveHdr[index].dwBufferLength = count;
waveHdr[index].dwFlags &= ~WHDR_DONE;
if (waveOutWrite(hWave, &waveHdr[index], sizeof(WAVEHDR)) == MMSYSERR_NOERROR) {
index ^= 1;
PlaySound_WaitDone(&s);
}
else FIXME("Couldn't play header\n");
else {
ERR("Aborting play loop, waveOutWrite error\n");
wps->bLoop = FALSE;
break;
}
}
bRet = TRUE;
} while (wps->bLoop);
PlaySound_WaitDone(&s); /* for last buffer */
PlaySound_WaitDone(&s); /* to balance first buffer */
waveOutReset(hWave);
waveOutUnprepareHeader(hWave, &waveHdr[0], sizeof(WAVEHDR));