--- old/src/java.desktop/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java 2016-08-12 17:01:26.000000000 +0300 +++ new/src/java.desktop/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java 2016-08-12 17:01:26.000000000 +0300 @@ -32,9 +32,9 @@ import java.util.Objects; import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioFormat.Encoding; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.AudioFormat.Encoding; import javax.sound.sampled.spi.FormatConversionProvider; /** @@ -63,6 +63,7 @@ fsize = ((targetFormat.getSampleSizeInBits() + 7) / 8); } + @Override public int read() throws IOException { byte[] b = new byte[1]; int ret = read(b); @@ -71,6 +72,7 @@ return b[0] & 0xFF; } + @Override public int read(byte[] b, int off, int len) throws IOException { int flen = len / fsize; @@ -83,6 +85,7 @@ return ret * fsize; } + @Override public int available() throws IOException { int ret = stream.available(); if (ret < 0) @@ -90,22 +93,27 @@ return ret * fsize; } + @Override public void close() throws IOException { stream.close(); } + @Override public synchronized void mark(int readlimit) { stream.mark(readlimit * fsize); } + @Override public boolean markSupported() { return stream.markSupported(); } + @Override public synchronized void reset() throws IOException { stream.reset(); } + @Override public long skip(long n) throws IOException { long ret = stream.skip(n / fsize); if (ret < 0) @@ -141,30 +149,37 @@ .isBigEndian()); } + @Override public int available() throws IOException { return (ais.available() / sourceChannels) * targetChannels; } + @Override public void close() throws IOException { ais.close(); } + @Override public AudioFormat getFormat() { return targetFormat; } + @Override public long getFrameLength() { return ais.getFrameLength(); } + @Override public void mark(int readlimit) { ais.mark((readlimit / targetChannels) * sourceChannels); } + @Override public boolean markSupported() { return ais.markSupported(); } + @Override public int read(float[] b, int off, int len) throws IOException { int len2 = (len / targetChannels) * sourceChannels; if (conversion_buffer == null || conversion_buffer.length < len2) @@ -212,10 +227,12 @@ return (ret / sourceChannels) * targetChannels; } + @Override public void reset() throws IOException { ais.reset(); } + @Override public long skip(long len) throws IOException { long ret = ais.skip((len / targetChannels) * sourceChannels); if (ret < 0) @@ -305,22 +322,27 @@ ibuffer_len = buffer_len; } + @Override public int available() throws IOException { return 0; } + @Override public void close() throws IOException { ais.close(); } + @Override public AudioFormat getFormat() { return targetFormat; } + @Override public long getFrameLength() { return AudioSystem.NOT_SPECIFIED; // ais.getFrameLength(); } + @Override public void mark(int readlimit) { ais.mark((int) (readlimit * pitch[0])); mark_ibuffer_index = ibuffer_index; @@ -337,6 +359,7 @@ } } + @Override public boolean markSupported() { return ais.markSupported(); } @@ -381,6 +404,7 @@ } + @Override public int read(float[] b, int off, int len) throws IOException { if (cbuffer == null || cbuffer[0].length < len / nrofchannels) { @@ -431,6 +455,7 @@ return len - remain * nrofchannels; } + @Override public void reset() throws IOException { ais.reset(); if (mark_ibuffer == null) @@ -447,6 +472,7 @@ } + @Override public long skip(long len) throws IOException { if (len < 0) return 0; @@ -474,8 +500,9 @@ Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT}; + @Override public AudioInputStream getAudioInputStream(Encoding targetEncoding, - AudioInputStream sourceStream) { + AudioInputStream sourceStream) { if (!isConversionSupported(targetEncoding, sourceStream.getFormat())) { throw new IllegalArgumentException( "Unsupported conversion: " + sourceStream.getFormat() @@ -496,8 +523,9 @@ return getAudioInputStream(targetFormat, sourceStream); } + @Override public AudioInputStream getAudioInputStream(AudioFormat targetFormat, - AudioInputStream sourceStream) { + AudioInputStream sourceStream) { if (!isConversionSupported(targetFormat, sourceStream.getFormat())) throw new IllegalArgumentException("Unsupported conversion: " + sourceStream.getFormat().toString() + " to " @@ -526,16 +554,19 @@ .getFrameLength()); } + @Override public Encoding[] getSourceEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT }; } + @Override public Encoding[] getTargetEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, Encoding.PCM_FLOAT }; } + @Override public Encoding[] getTargetEncodings(AudioFormat sourceFormat) { if (AudioFloatConverter.getConverter(sourceFormat) == null) return new Encoding[0]; @@ -543,14 +574,15 @@ Encoding.PCM_FLOAT }; } + @Override public AudioFormat[] getTargetFormats(Encoding targetEncoding, - AudioFormat sourceFormat) { + AudioFormat sourceFormat) { Objects.requireNonNull(targetEncoding); if (AudioFloatConverter.getConverter(sourceFormat) == null) return new AudioFormat[0]; int channels = sourceFormat.getChannels(); - ArrayList formats = new ArrayList(); + ArrayList formats = new ArrayList<>(); if (targetEncoding.equals(Encoding.PCM_SIGNED)) formats.add(new AudioFormat(Encoding.PCM_SIGNED, @@ -598,8 +630,9 @@ return formats.toArray(new AudioFormat[formats.size()]); } + @Override public boolean isConversionSupported(AudioFormat targetFormat, - AudioFormat sourceFormat) { + AudioFormat sourceFormat) { Objects.requireNonNull(targetFormat); if (AudioFloatConverter.getConverter(sourceFormat) == null) return false; @@ -612,8 +645,9 @@ return true; } + @Override public boolean isConversionSupported(Encoding targetEncoding, - AudioFormat sourceFormat) { + AudioFormat sourceFormat) { Objects.requireNonNull(targetEncoding); if (AudioFloatConverter.getConverter(sourceFormat) == null) return false;