<Sound Dev> [9] Review Request: 8146144 Incorrect behaviour of AudioSystem.getTargetFormats/getTargetEncodings/isConversionSupported

Alex Menkov alexey.menkov at oracle.com
Wed Jan 13 09:33:23 UTC 2016

Looks good.


On 12.01.2016 23:26, Sergey Bylokhov wrote:
> Hi, Alex.
> Thanks for review.
> On 12/01/16 14:36, Alex Menkov wrote:
>> It would be better to check encoding first and then sample size or just
>> combine the checks (using && operator)
> I merged these checks:
> http://cr.openjdk.java.net/~serb/8146144/webrev.02
>> --alex
>> On 28.12.2015 15:37, Sergey Bylokhov wrote:
>>> Hello, Audio Guru.
>>> Please review the fix for jdk9.
>>> The change contains the fixes for two quite similar issues:
>>> - A few methods in AudioSystem class should work uniformly. For example
>>> AudioSystem.getAudioInputStream() does not throw an exception if the
>>> source/target formats are unsupported by our converters. The reason is
>>> simple, this method has such code:
>>>    if (sourceStream.getFormat().matches(targetFormat)) {
>>>      return sourceStream;
>>>    }
>>> So it returns the source stream without check of our converters. But if
>>> an exception was not thrown, means that
>>> AudioSystem.isConversionSupported() should return true for such formats,
>>> AudioSystem.getTargetFormats() should contain format which the matchs to
>>> the source format, and AudioSystem.getTargetEncodings() should contain
>>> the source encoding.
>>> All this were fixed in AudioSystem.java
>>> - Some of the methods in our converters also should work uniformly. Like
>>> getTargetFormats(encoding, sourceFormat) and getTargetEncodings(format)
>>> should have the same source checks, otherwise some of these methods can
>>> return encoding/format which are not present in the second method.
>>> For example PCMtoPCMCodec.java: getTargetEncodings() returns the list of
>>> PCM_SIGNED and PCM_UNSIGNED for any source formats of type
>>> PCM_SIG/UNSIG, but the getTargetFormats() returns some formats only for
>>> a specific sampleSize(8/16). As a fix an the checks are unified
>>> everywhere.
>>> - Another problem in the converters is that getAudioInputStream() do not
>>> throw an exception if the source and target encoding are the same. As a
>>> fix the isConversionSupported is added at the beginning of each method.
>>> So each converter will be responsible only for formats it know.
>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8146144
>>> Webrev can be found at:
>>> http://cr.openjdk.java.net/~serb/8146144/webrev.01

More information about the sound-dev mailing list