Issue 417 - Allow UTF-8 characters for Mac audio device names.

This commit is contained in:
wb2osz 2022-09-25 22:30:19 +01:00
parent 30869c7afc
commit 429d095665
1 changed files with 17 additions and 3 deletions

View File

@ -213,7 +213,21 @@ static int pa_devNN(char *deviceStr, char *_devName, size_t length, int *_devNo)
while(*cPtr) { while(*cPtr) {
cVal = *cPtr++; cVal = *cPtr++;
if(cVal == ':') break; if(cVal == ':') break;
if(((cVal >= ' ') && (cVal <= '~')) && (count < length)) {
// See Issue 417.
// Originally this copied only printable ASCII characters (space thru ~).
// That is a problem for some locales that use UTF-8 characters in the device name.
// original: if(((cVal >= ' ') && (cVal <= '~')) && (count < length)) {
// At first I was thinking we should keep the test for < ' ' but then I
// remembered that char type can be signed or unsigned depending on implementation.
// If characters are signed then a value above 0x7f would be considered negative.
// It seems to me that the test for buffer full is off by one.
// count could reach length, leaving no room for a nul terminator.
// Compare has been changed so count is limited to length minus 1.
if(count < length - 1) {
_devName[count++] = cVal; _devName[count++] = cVal;
} }
@ -1149,7 +1163,7 @@ int audio_put (int a, int c)
static double start = 0, end = 0, diff = 0; static double start = 0, end = 0, diff = 0;
if(adev[a].outbuf_len == 0) if(adev[a].outbuf_len == 0)
start = dtime_now(); start = dtime_monotonic();
#endif #endif
if(c >= 0) { if(c >= 0) {
@ -1178,7 +1192,7 @@ int audio_put (int a, int c)
#ifdef __TIMED__ #ifdef __TIMED__
count += frames; count += frames;
if(c < 0) { // When the Ax25 frames are flushed. if(c < 0) { // When the Ax25 frames are flushed.
end = dtime_now(); end = dtime_monotonic();
diff = end - start; diff = end - start;
if(count) if(count)
dw_printf ("Transfer Time:%3.9f No of Frames:%d Per frame:%3.9f speed:%f\n", dw_printf ("Transfer Time:%3.9f No of Frames:%d Per frame:%3.9f speed:%f\n",