Andrew Eikum : wineoss.drv: Set reasonable defaults if driver reports invalid values.
Alexandre Julliard
julliard at winehq.org
Mon Jan 28 13:43:20 CST 2013
Module: wine
Branch: master
Commit: 6da3ce276bd76a5242c8340c50042c95ea74a787
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6da3ce276bd76a5242c8340c50042c95ea74a787
Author: Andrew Eikum <aeikum at codeweavers.com>
Date: Mon Jan 28 08:52:55 2013 -0600
wineoss.drv: Set reasonable defaults if driver reports invalid values.
---
dlls/wineoss.drv/mmdevdrv.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c
index ea6d452..2c81404 100644
--- a/dlls/wineoss.drv/mmdevdrv.c
+++ b/dlls/wineoss.drv/mmdevdrv.c
@@ -1307,8 +1307,19 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
return E_FAIL;
}
- fmt->Format.nChannels = This->ai.max_channels;
- fmt->Format.nSamplesPerSec = This->ai.max_rate;
+ /* some OSS drivers are buggy, so set reasonable defaults if
+ * the reported values seem wacky */
+ fmt->Format.nChannels = max(This->ai.max_channels, This->ai.min_channels);
+ if(fmt->Format.nChannels == 0 || fmt->Format.nChannels > 8)
+ fmt->Format.nChannels = 2;
+
+ if(This->ai.max_rate == 0)
+ fmt->Format.nSamplesPerSec = 44100;
+ else
+ fmt->Format.nSamplesPerSec = min(This->ai.max_rate, 44100);
+ if(fmt->Format.nSamplesPerSec < This->ai.min_rate)
+ fmt->Format.nSamplesPerSec = This->ai.min_rate;
+
fmt->dwChannelMask = get_channel_mask(fmt->Format.nChannels);
fmt->Format.nBlockAlign = (fmt->Format.wBitsPerSample *
More information about the wine-cvs
mailing list