From bbb01ae0d0861d9603903d7dad10b9cf04d07301 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Sun, 5 Jun 2005 19:18:52 +0000 Subject: [PATCH] Fix a problem where actual sample rate doesn't exactly match requested. --- dlls/winmm/winealsa/audio.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dlls/winmm/winealsa/audio.c b/dlls/winmm/winealsa/audio.c index 452220f713b..fe06431ac49 100644 --- a/dlls/winmm/winealsa/audio.c +++ b/dlls/winmm/winealsa/audio.c @@ -324,6 +324,12 @@ static const char * getFormat(WORD wFormatTag) return unknown; } +/* Allow 1% deviation for sample rates (some ES137x cards) */ +static BOOL NearMatch(int rate1, int rate2) +{ + return (((100 * (rate1 - rate2)) / rate1) == 0); +} + static DWORD bytes_to_mmtime(LPMMTIME lpTime, DWORD position, WAVEFORMATPCMEX* format) { @@ -1928,7 +1934,7 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) snd_pcm_close(pcm); return WAVERR_BADFORMAT; } - if (rate != wwo->format.Format.nSamplesPerSec) { + if (!NearMatch(rate, wwo->format.Format.nSamplesPerSec)) { if (dwFlags & WAVE_DIRECTSOUND) { WARN("changed sample rate from %ld Hz to %d Hz\n", wwo->format.Format.nSamplesPerSec, rate); wwo->format.Format.nSamplesPerSec = rate; @@ -3411,7 +3417,7 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) snd_pcm_close(pcm); return WAVERR_BADFORMAT; } - if (rate != wwi->format.Format.nSamplesPerSec) { + if (!NearMatch(rate, wwi->format.Format.nSamplesPerSec)) { WARN("Rate doesn't match (requested %ld Hz, got %d Hz)\n", wwi->format.Format.nSamplesPerSec, rate); snd_pcm_close(pcm); return WAVERR_BADFORMAT;