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

Alex Menkov alexey.menkov at oracle.com
Tue Jan 12 11:36:47 UTC 2016


Hi Sergey,

Overall looks good, one minor note.

AlawCodec.java and UlawCodec.java
in getOutputFormats method order of the checks looks strange (1st sample 
size, then encoding)
It would be better to check encoding first and then sample size or just 
combine the checks (using && operator)

--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