Fix (some) bad behavior with buffer underrun.

This commit is contained in:
Eric Pouech 1999-10-31 01:53:47 +00:00 committed by Alexandre Julliard
parent 6036ad7f6f
commit 3b8e9b43d4
1 changed files with 7 additions and 1 deletions

View File

@ -254,6 +254,8 @@ static void wodPlayer_Notify(WINE_WAVEOUT* wwo, WORD uDevID, BOOL force)
/* get effective number of written bytes */
if (!force) {
int c;
if (ioctl(wwo->unixdev, SNDCTL_DSP_GETOPTR, &cinfo) == -1) {
perror("ioctl SNDCTL_DSP_GETOPTR");
wwo->hThread = 0;
@ -261,7 +263,11 @@ static void wodPlayer_Notify(WINE_WAVEOUT* wwo, WORD uDevID, BOOL force)
ExitThread(-1);
}
TRACE("Played %d bytes (played=%ld) on fd %d\n", cinfo.bytes, wwo->dwPlayed, wwo->unixdev);
wwo->wFragsUsedInQueue -= cinfo.bytes / wwo->dwFragmentSize - wwo->dwPlayed / wwo->dwFragmentSize;
c = cinfo.bytes / wwo->dwFragmentSize - wwo->dwPlayed / wwo->dwFragmentSize;
if (wwo->wFragsUsedInQueue > c)
wwo->wFragsUsedInQueue -= c;
else
wwo->wFragsUsedInQueue = 0;
wwo->dwPlayed = cinfo.bytes;
}
if (force || cinfo.bytes > wwo->dwNotifiedBytes) {