<Sound Dev> [PATCH] 8177951: Charset problem when the name of the sound device contains Chinese character.

Sergey Bylokhov sergey.bylokhov at oracle.com
Mon Jun 26 08:19:59 UTC 2017


Thank you for the patch! I'll take a look and provide a feadback soon.    

----- cqjjjzr at 126.com wrote:

> Hello everyone.
> 
> In the last E-Mail I talked about a bug of JavaSound API. first I
> apologize for the bad format(super long line).
> 
> Yesterday I said I can't compile the modified JDK because of the
> compiler problem, but today I changed my compiling environment to a
> VS2010 Express and I compiled the modified JDK successfully.
> 
> To my surprise, the patch works very well, at least on my machine,
> I'll show you guys a picture of that: https://imgur.com/a/zcb6p
> 
> All changes in the patch is applied to
> jdk/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_DirectSound.cpp.
> In the patch I added a function ANSIToUTF8 to convert the ANSI string
> to a UTF-8 encoded Unicode string, and then I changed DS_GetDescEnum
> function to let it use the convert function if the compiler is in the
> Multi-Byte mode.
> 
> The patch is in this E-Mail:
> http://mail.openjdk.java.net/pipermail/sound-dev/2017-June/000564.html
> There is a test to make sure the patch works correctly. It's showed in
> the picture. Because your systems is in different languages, I can't
> write a full-automatic unit test(a test with something like assert,
> etc.).  Just as the picture, if the patch works correctly, non-ASCII
> characters are displayed correctly, or them will be messy code.
> Here's the code in the picture, just compile and run it without any
> argument:
> 
> 
> import javax.sound.sampled.*;
> import java.util.Arrays;
> 
> 
> import static javax.sound.sampled.AudioFormat.Encoding.PCM_SIGNED;
> 
> 
> public class SoundEnumerator {
>     public static void main(String[] args) throws
> LineUnavailableException {
>         Mixer.Info[] mis = AudioSystem.getMixerInfo();
>         for (Mixer.Info mi : mis) {
>             Mixer m = AudioSystem.getMixer(mi);
>             if (isMixerUsable(m)) {
>                 System.out.println(mi.getName());
>             }
>         }
>     }
> 
> 
>     private static boolean isMixerUsable(Mixer m) throws
> LineUnavailableException {
>         final int[] count = {0};
>         Arrays.stream(m.getSourceLineInfo())
>                 .filter((it) -> it instanceof SourceDataLine.Info)
>                 .filter((it) -> {
>                     try {
>                         return m.getLine(it) instanceof
> SourceDataLine;
>                     } catch (LineUnavailableException e) {
>                         return false;
>                     }
>                 })
>                 .forEach((it) -> Arrays.stream(((DataLine.Info)
> it).getFormats())
>                         .filter((af) -> !af.isBigEndian())
>                         .filter((af) -> af.getEncoding() ==
> PCM_SIGNED)
>                         .filter((af) -> af.getSampleSizeInBits() !=
> 24)
>                         .forEach((af) -> count[0]++));
>         return count[0] != 0;
>     }
> }
> \
> 
> Now I want to commit this little patch to the central OpenJDK
> mercurial repo, any suggestion about how to do this?
> 
> Cheers,
> Charlie Jiang


More information about the sound-dev mailing list