From 20547de0120c0983de5da939874d1aa2bace4b14 Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Fri, 9 Apr 2004 19:05:09 +0000 Subject: [PATCH] Patch the fragment size if it does not match the current sound format. This saves us from triggering a kernel freeze on some OSS 2.4 + SoundBlaster 16 systems. --- dlls/winmm/wineoss/audio.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/dlls/winmm/wineoss/audio.c b/dlls/winmm/wineoss/audio.c index 09592056432..c19b48014f7 100644 --- a/dlls/winmm/wineoss/audio.c +++ b/dlls/winmm/wineoss/audio.c @@ -1780,6 +1780,18 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) wwo->dwWrittenTotal = 0; wwo->bNeedPost = TRUE; + TRACE("fd=%d fragstotal=%d fragsize=%d BufferSize=%ld\n", + wwo->ossdev->fd, info.fragstotal, info.fragsize, wwo->dwBufferSize); + if (wwo->dwFragmentSize % wwo->format.wf.nBlockAlign) { + ERR("Fragment doesn't contain an integral number of data blocks fragsize=%ld BlockAlign=%d\n",wwo->dwFragmentSize,wwo->format.wf.nBlockAlign); + /* Some SoundBlaster 16 cards return an incorrect (odd) fragment + * size for 16 bit sound. This will cause a system crash when we try + * to write just the specified odd number of bytes. So if we + * detect something is wrong we'd better fix it. + */ + wwo->dwFragmentSize-=wwo->dwFragmentSize % wwo->format.wf.nBlockAlign; + } + OSS_InitRingMessage(&wwo->msgRing); wwo->hStartUpEvent = CreateEventA(NULL, FALSE, FALSE, NULL); @@ -1788,11 +1800,6 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) CloseHandle(wwo->hStartUpEvent); wwo->hStartUpEvent = INVALID_HANDLE_VALUE; - TRACE("fd=%d fragmentSize=%ld\n", - wwo->ossdev->fd, wwo->dwFragmentSize); - if (wwo->dwFragmentSize % wwo->format.wf.nBlockAlign) - ERR("Fragment doesn't contain an integral number of data blocks\n"); - TRACE("wBitsPerSample=%u, nAvgBytesPerSec=%lu, nSamplesPerSec=%lu, nChannels=%u nBlockAlign=%u!\n", wwo->format.wBitsPerSample, wwo->format.wf.nAvgBytesPerSec, wwo->format.wf.nSamplesPerSec, wwo->format.wf.nChannels,