Gregorio Litenstein
2018-06-28 17:51:16 UTC
Hey, Iâm one of the developers of Performous (cross-platform karaoke game),
weâve been using portaudio for a while on Unix/Mac/Windows.
Iâd initially written a really long post with an issue report but then I
realized a) It was, after pulling most of my hair out, an issue on our side
after all. And b) I sent it to the wrong address so I get it never actually
made it into the list. Anyway⊠Iâm back with a couple more real issues and
at least one fix.
First, we were facing issues with the display of unicode text in Windows;
essentially the same issue reported here:
https://lists.columbia.edu/pipermail/portaudio/2016-December/000961.html
I took a look at the hostapi implementations and noticed that only some
changed their behavior depending on whether UNICODE was defined or not.
while others always used CP_UTF8.
Initially I thought my issue might have been related to that, so I did some
testing and figured out that in recent versions of Windows, defining
UNICODE (i.e. having everything use CP_UTF8) made the text uniformly
garbled unless I checked the new setting âUse Unicode UTF-8 worldwideâ or
something like that. And by contrast, if that setting was off, CP_ACP
properly rendered the text.
it appears that what this setting actually does is set the codepage to
UTF-8 (65001).
With this in mind, I created a patch modifying the behavior so instead of
checking for the definition of UNICODE or _UNICODE, portaudio checks (at
runtime) for the current codepage using GetACP(); If itâs 65001 it uses
CP_UTF8, if not it uses CP_ACP. I tested it on a laptop running Windows 10
Single Language Spanish and the text rendered appropriately both with the
setting turned on and with the setting turned off.
I will attach the diff file here but TBH I have no idea whether it is
possible to attach files to these lists, so you can also get it from
Dropbox below. Iâm not opening a ticket/submitting a PR because Assembla is
paid.
https://www.dropbox.com/s/le6zyr1zjv6mank/pa_patch.diff?dl=1
Now, on to the âcouple more thingsâ⊠itâs actually just one thing. The
GetVersion() function is (still) giving erroneous results. If compiling
portaudio using mingw-w64 (and thus not using WinRT), WASAPI gets the
windows version using
dwVersion = fnGetVersion();
// Get the Windows version
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
switch (dwMajorVersion)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
break; // skip lower
case 6:
switch (dwMinorVersion)
{
case 0: version = WINDOWS_VISTA_SERVER2008; break;
case 1: version = WINDOWS_7_SERVER2008R2; break;
case 2: version = WINDOWS_8_SERVER2012; break;
case 3: version = WINDOWS_8_1_SERVER2012R2; break;
default: version = WINDOWS_FUTURE; break;
}
break;
case 10:
switch (dwMinorVersion)
{
case 0: version = WINDOWS_10_SERVER2016; break;
default: version = WINDOWS_FUTURE; break;
}
break;
default:
version = WINDOWS_FUTURE;
break;
}
But, from my tests, I noticed in practice Windows 10 (with latest updates)
returns the same value as Windows 8 (i.e. dwMajorVersion=6,
dwMinorVersion=2) and thus Win10 computers might end up using IAudioClient2.
All the best,
Gregorio.
P.S. Are you planning on a new stable release anytime soon?
weâve been using portaudio for a while on Unix/Mac/Windows.
Iâd initially written a really long post with an issue report but then I
realized a) It was, after pulling most of my hair out, an issue on our side
after all. And b) I sent it to the wrong address so I get it never actually
made it into the list. Anyway⊠Iâm back with a couple more real issues and
at least one fix.
First, we were facing issues with the display of unicode text in Windows;
essentially the same issue reported here:
https://lists.columbia.edu/pipermail/portaudio/2016-December/000961.html
I took a look at the hostapi implementations and noticed that only some
changed their behavior depending on whether UNICODE was defined or not.
while others always used CP_UTF8.
Initially I thought my issue might have been related to that, so I did some
testing and figured out that in recent versions of Windows, defining
UNICODE (i.e. having everything use CP_UTF8) made the text uniformly
garbled unless I checked the new setting âUse Unicode UTF-8 worldwideâ or
something like that. And by contrast, if that setting was off, CP_ACP
properly rendered the text.
it appears that what this setting actually does is set the codepage to
UTF-8 (65001).
With this in mind, I created a patch modifying the behavior so instead of
checking for the definition of UNICODE or _UNICODE, portaudio checks (at
runtime) for the current codepage using GetACP(); If itâs 65001 it uses
CP_UTF8, if not it uses CP_ACP. I tested it on a laptop running Windows 10
Single Language Spanish and the text rendered appropriately both with the
setting turned on and with the setting turned off.
I will attach the diff file here but TBH I have no idea whether it is
possible to attach files to these lists, so you can also get it from
Dropbox below. Iâm not opening a ticket/submitting a PR because Assembla is
paid.
https://www.dropbox.com/s/le6zyr1zjv6mank/pa_patch.diff?dl=1
Now, on to the âcouple more thingsâ⊠itâs actually just one thing. The
GetVersion() function is (still) giving erroneous results. If compiling
portaudio using mingw-w64 (and thus not using WinRT), WASAPI gets the
windows version using
dwVersion = fnGetVersion();
// Get the Windows version
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
switch (dwMajorVersion)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
break; // skip lower
case 6:
switch (dwMinorVersion)
{
case 0: version = WINDOWS_VISTA_SERVER2008; break;
case 1: version = WINDOWS_7_SERVER2008R2; break;
case 2: version = WINDOWS_8_SERVER2012; break;
case 3: version = WINDOWS_8_1_SERVER2012R2; break;
default: version = WINDOWS_FUTURE; break;
}
break;
case 10:
switch (dwMinorVersion)
{
case 0: version = WINDOWS_10_SERVER2016; break;
default: version = WINDOWS_FUTURE; break;
}
break;
default:
version = WINDOWS_FUTURE;
break;
}
But, from my tests, I noticed in practice Windows 10 (with latest updates)
returns the same value as Windows 8 (i.e. dwMajorVersion=6,
dwMinorVersion=2) and thus Win10 computers might end up using IAudioClient2.
All the best,
Gregorio.
P.S. Are you planning on a new stable release anytime soon?