<Sound Dev> [9] Review Request: 8146144 Incorrect behaviour of AudioSystem.getTargetFormats/getTargetEncodings/isConversionSupported
Sergey Bylokhov
Sergey.Bylokhov at oracle.com
Mon Dec 28 12:37:21 UTC 2015
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
--
Best regards, Sergey.
More information about the sound-dev
mailing list