FlexASIO_GUI icon indicating copy to clipboard operation
FlexASIO_GUI copied to clipboard

fix for #38

Open kgs233 opened this issue 1 year ago • 6 comments

portaudio-sharp uses LPStr as a string mapping method, this will lose some of the data for non-ANSI strings. Changing the string mapping of the name member of PaDeviceInfo in portaudio-sharp from LPStr(ANSI) to LPWStr(Unicode) solves the problem perfectly.Changing the string mapping of the name member of PaDeviceInfo in portaudio-sharp from LPStr(ANSI) to LPWStr(Unicode) solves the problem perfectly.

kgs233 avatar Sep 17 '24 06:09 kgs233

@vasilevp Do you want to review and merge it? I have moved almost entirely to MacOS and have not used flexASIO in ages, let alone worked on the repo...

flipswitchingmonkey avatar Sep 17 '24 08:09 flipswitchingmonkey

I think I may be mistaken about what's causing the problem, it's actually the fact that PortAudio no longer uses ANSI strings internally but Unicode strings instead, so that causes the old PortAudio-sharp string mapping to garble errors. However, the code that needs to be merged is fine, but the logic of the fix is a bit wrong.

kgs233 avatar Sep 17 '24 10:09 kgs233

PortAudio no longer uses ANSI strings internally but Unicode strings instead

PortAudio always returns device names as UTF-8, and as far as I know that has always been the case.

dechamps avatar Sep 17 '24 12:09 dechamps

PortAudio no longer uses ANSI strings internally but Unicode strings instead

PortAudio always returns device names as UTF-8, and as far as I know that has always been the case.

But I found something in PortAudio about ANSI string changing to UTF-8 string, so I'm guessing that a long time ago (when PortAudio-Sharp was developed) PortAudio used to use ANSI strings to return the device name.

kgs233 avatar Sep 17 '24 13:09 kgs233

@vasilevp Do you want to review and merge it? I have moved almost entirely to MacOS and have not used flexASIO in ages, let alone worked on the repo...

Hi! Bit late to the party...

I've also moved away from Windows some time ago (and stopped using flexASIO long before that).

I did, however, try to run this in a VM and got the following:

[output]
device = "Динамики (High Definition Audio Device)\u0000"

Note the \u0000 at the end that was not here before - looks like an off-by-1 error to me...

This trailing zero comes from Portaudio and only for this Cyrillic-named device in my case, so there's got to be some weirdness in there.

vasilevp avatar Jun 05 '25 16:06 vasilevp

@vasilevp Do you want to review and merge it? I have moved almost entirely to MacOS and have not used flexASIO in ages, let alone worked on the repo...

Hi! Bit late to the party...

I've also moved away from Windows some time ago (and stopped using flexASIO long before that).

I did, however, try to run this in a VM and got the following:

[output]
device = "Динамики (High Definition Audio Device)\u0000"

Note the \u0000 at the end that was not here before - looks like an off-by-1 error to me...

This trailing zero comes from Portaudio and only for this Cyrillic-named device in my case, so there's got to be some weirdness in there.

This is a P/Invoke issue, I upgraded the dependency library to support UTF-8 string, it's fixed now.

Also, along the way I fixed the issue where the program failed to start when configuration files were read incorrectly (#42), now it automatically resets them on configuration errors.

kgs233 avatar Jun 06 '25 01:06 kgs233