< prev index next >

src/java.desktop/share/classes/com/sun/media/sound/WaveFloatFileReader.java

Print this page

        

@@ -30,22 +30,21 @@
 
 import javax.sound.sampled.AudioFileFormat;
 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.UnsupportedAudioFileException;
 
 /**
  * Floating-point encoded (format 3) WAVE file loader.
  *
  * @author Karl Helgason
  */
 public final class WaveFloatFileReader extends SunFileReader {
 
     @Override
-    AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+    StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
         RIFFReader riffiterator = new RIFFReader(stream);
         if (!riffiterator.getFormat().equals("RIFF"))
             throw new UnsupportedAudioFileException();

@@ -86,33 +85,28 @@
             throw new UnsupportedAudioFileException();
         }
         AudioFormat audioformat = new AudioFormat(
                 Encoding.PCM_FLOAT, samplerate, bits, channels,
                 framesize, samplerate, false);
-        long frameLength = dataSize / audioformat.getFrameSize();
-        if (frameLength > Integer.MAX_VALUE) {
-            frameLength = AudioSystem.NOT_SPECIFIED;
-        }
-
-        return new AudioFileFormat(AudioFileFormat.Type.WAVE, audioformat,
-                                   (int) frameLength);
+        return new StandardFileFormat(AudioFileFormat.Type.WAVE, audioformat,
+                                      dataSize / audioformat.getFrameSize());
     }
 
     @Override
     public AudioInputStream getAudioInputStream(final InputStream stream)
             throws UnsupportedAudioFileException, IOException {
 
-        final AudioFileFormat format = getAudioFileFormat(stream);
+        final StandardFileFormat format = getAudioFileFormat(stream);
+        final AudioFormat af = format.getFormat();
+        final long length = format.getLongFrameLength();
         // 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
         final RIFFReader riffiterator = new RIFFReader(stream);
         while (riffiterator.hasNextChunk()) {
             RIFFReader chunk = riffiterator.nextChunk();
             if (chunk.getFormat().equals("data")) {
-                final AudioFormat af = format.getFormat();
-                final long length = chunk.getSize() / af.getFrameSize();
                 return new AudioInputStream(chunk, af, length);
             }
         }
         throw new UnsupportedAudioFileException();
     }
< prev index next >