jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java
changeset 36454 d2853d1fc614
parent 35687 78e8e8fea09b
child 36918 7f6b24ece62a
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java	Wed Feb 17 11:44:07 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java	Thu Feb 18 22:11:29 2016 +0300
@@ -255,16 +255,17 @@
     public AudioInputStream getAudioInputStream(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
-        AudioFileFormat format = getAudioFileFormat(stream);
+        final AudioFileFormat format = getAudioFileFormat(stream);
         // we've got everything, the stream is supported and it is at the
         // beginning of the header, so find the data chunk again and return an
         // AudioInputStream
-        RIFFReader riffiterator = new RIFFReader(stream);
+        final RIFFReader riffiterator = new RIFFReader(stream);
         while (riffiterator.hasNextChunk()) {
             RIFFReader chunk = riffiterator.nextChunk();
             if (chunk.getFormat().equals("data")) {
-                return new AudioInputStream(chunk, format.getFormat(), chunk
-                        .getSize());
+                final AudioFormat af = format.getFormat();
+                final long length = chunk.getSize() / af.getFrameSize();
+                return new AudioInputStream(chunk, af, length);
             }
         }
         throw new UnsupportedAudioFileException();