Compare commits

...
Sign in to create a new pull request.

View file

@ -1207,6 +1207,8 @@ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WO
} }
#endif #endif
// Get Windows version // Get Windows version
// note: We are trying to get Windows version starting from Windows Vista. Earlier OS versions
// will fall into WINDOWS_UNKNOWN case.
static EWindowsVersion GetWindowsVersion() static EWindowsVersion GetWindowsVersion()
{ {
#ifndef PA_WINRT #ifndef PA_WINRT
@ -1229,14 +1231,14 @@ static EWindowsVersion GetWindowsVersion()
{ {
OSVERSIONINFOW ver = { sizeof(OSVERSIONINFOW), 0, 0, 0, 0, {0} }; OSVERSIONINFOW ver = { sizeof(OSVERSIONINFOW), 0, 0, 0, 0, {0} };
PRINT(("WASAPI: getting Windows version with RtlGetVersion()\n"));
if (fnRtlGetVersion(&ver) == NTSTATUS_SUCCESS) if (fnRtlGetVersion(&ver) == NTSTATUS_SUCCESS)
{ {
dwMajorVersion = ver.dwMajorVersion; dwMajorVersion = ver.dwMajorVersion;
dwMinorVersion = ver.dwMinorVersion; dwMinorVersion = ver.dwMinorVersion;
dwBuild = ver.dwBuildNumber; dwBuild = ver.dwBuildNumber;
} }
PRINT(("WASAPI: getting Windows version with RtlGetVersion(): major=%d, minor=%d, build=%d\n", dwMajorVersion, dwMinorVersion, dwBuild));
} }
#undef NTSTATUS_SUCCESS #undef NTSTATUS_SUCCESS
@ -1249,17 +1251,15 @@ static EWindowsVersion GetWindowsVersion()
if ((fnGetVersion = (LPFN_GETVERSION)GetProcAddress(GetModuleHandleA("kernel32"), "GetVersion")) != NULL) if ((fnGetVersion = (LPFN_GETVERSION)GetProcAddress(GetModuleHandleA("kernel32"), "GetVersion")) != NULL)
{ {
DWORD dwVersion; DWORD dwVersion = fnGetVersion();
PRINT(("WASAPI: getting Windows version with GetVersion()\n"));
dwVersion = fnGetVersion();
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
if (dwVersion < 0x80000000) if (dwVersion < 0x80000000)
dwBuild = (DWORD)(HIWORD(dwVersion)); dwBuild = (DWORD)(HIWORD(dwVersion));
PRINT(("WASAPI: getting Windows version with GetVersion(): major=%d, minor=%d, build=%d\n", dwMajorVersion, dwMinorVersion, dwBuild));
} }
} }
@ -2319,9 +2319,16 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
PaWasapiHostApiRepresentation *paWasapi; PaWasapiHostApiRepresentation *paWasapi;
#ifndef PA_WINRT #ifndef PA_WINRT
// Fail safely for any Windows version below Windows Vista
if (GetWindowsVersion() == WINDOWS_UNKNOWN)
{
PRINT(("WASAPI: Unsupported Windows version!\n"));
return paNoError;
}
if (!SetupAVRT()) if (!SetupAVRT())
{ {
PRINT(("WASAPI: No AVRT! (not VISTA?)\n")); PRINT(("WASAPI: avrt.dll missing! Windows integrity broken?\n"));
return paNoError; return paNoError;
} }
#endif #endif
@ -2349,11 +2356,11 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
// Fill basic interface info // Fill basic interface info
*hostApi = &paWasapi->inheritedHostApiRep; *hostApi = &paWasapi->inheritedHostApiRep;
(*hostApi)->info.structVersion = 1; (*hostApi)->info.structVersion = 1;
(*hostApi)->info.type = paWASAPI; (*hostApi)->info.type = paWASAPI;
(*hostApi)->info.name = "Windows WASAPI"; (*hostApi)->info.name = "Windows WASAPI";
(*hostApi)->info.deviceCount = 0; (*hostApi)->info.deviceCount = 0;
(*hostApi)->info.defaultInputDevice = paNoDevice; (*hostApi)->info.defaultInputDevice = paNoDevice;
(*hostApi)->info.defaultOutputDevice = paNoDevice; (*hostApi)->info.defaultOutputDevice = paNoDevice;
(*hostApi)->Terminate = Terminate; (*hostApi)->Terminate = Terminate;
(*hostApi)->OpenStream = OpenStream; (*hostApi)->OpenStream = OpenStream;