wasapi: Check for the supported Windows version explicitly in PaWasapi_Initialize() and avoid relying on existence on avrt.dll for detecting the compatible platform (user could provide avrt.dll stub that will break initialization of the library if OS version does not support WASAPI backend).
This commit is contained in:
parent
16884fc201
commit
999ca47aeb
|
@ -1207,6 +1207,8 @@ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WO
|
|||
}
|
||||
#endif
|
||||
// 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()
|
||||
{
|
||||
#ifndef PA_WINRT
|
||||
|
@ -1229,14 +1231,14 @@ static EWindowsVersion GetWindowsVersion()
|
|||
{
|
||||
OSVERSIONINFOW ver = { sizeof(OSVERSIONINFOW), 0, 0, 0, 0, {0} };
|
||||
|
||||
PRINT(("WASAPI: getting Windows version with RtlGetVersion()\n"));
|
||||
|
||||
if (fnRtlGetVersion(&ver) == NTSTATUS_SUCCESS)
|
||||
{
|
||||
dwMajorVersion = ver.dwMajorVersion;
|
||||
dwMinorVersion = ver.dwMinorVersion;
|
||||
dwBuild = ver.dwBuildNumber;
|
||||
}
|
||||
|
||||
PRINT(("WASAPI: getting Windows version with RtlGetVersion(): major=%d, minor=%d, build=%d\n", dwMajorVersion, dwMinorVersion, dwBuild));
|
||||
}
|
||||
|
||||
#undef NTSTATUS_SUCCESS
|
||||
|
@ -1249,17 +1251,15 @@ static EWindowsVersion GetWindowsVersion()
|
|||
|
||||
if ((fnGetVersion = (LPFN_GETVERSION)GetProcAddress(GetModuleHandleA("kernel32"), "GetVersion")) != NULL)
|
||||
{
|
||||
DWORD dwVersion;
|
||||
|
||||
PRINT(("WASAPI: getting Windows version with GetVersion()\n"));
|
||||
|
||||
dwVersion = fnGetVersion();
|
||||
DWORD dwVersion = fnGetVersion();
|
||||
|
||||
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
||||
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
|
||||
|
||||
if (dwVersion < 0x80000000)
|
||||
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;
|
||||
|
||||
#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())
|
||||
{
|
||||
PRINT(("WASAPI: No AVRT! (not VISTA?)\n"));
|
||||
PRINT(("WASAPI: avrt.dll missing! Windows integrity broken?\n"));
|
||||
return paNoError;
|
||||
}
|
||||
#endif
|
||||
|
@ -2349,11 +2356,11 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
|
|||
|
||||
// Fill basic interface info
|
||||
*hostApi = &paWasapi->inheritedHostApiRep;
|
||||
(*hostApi)->info.structVersion = 1;
|
||||
(*hostApi)->info.type = paWASAPI;
|
||||
(*hostApi)->info.name = "Windows WASAPI";
|
||||
(*hostApi)->info.structVersion = 1;
|
||||
(*hostApi)->info.type = paWASAPI;
|
||||
(*hostApi)->info.name = "Windows WASAPI";
|
||||
(*hostApi)->info.deviceCount = 0;
|
||||
(*hostApi)->info.defaultInputDevice = paNoDevice;
|
||||
(*hostApi)->info.defaultInputDevice = paNoDevice;
|
||||
(*hostApi)->info.defaultOutputDevice = paNoDevice;
|
||||
(*hostApi)->Terminate = Terminate;
|
||||
(*hostApi)->OpenStream = OpenStream;
|
||||
|
|
Loading…
Reference in New Issue