< prev index next >

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

Print this page

        

*** 32,42 **** 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; /** * WAVE file reader for files using format WAVE_FORMAT_EXTENSIBLE (0xFFFE). * --- 32,41 ----
*** 165,175 **** return sb.substring(0, sb.length() - 1); } @Override ! AudioFileFormat getAudioFileFormatImpl(final InputStream stream) throws UnsupportedAudioFileException, IOException { RIFFReader riffiterator = new RIFFReader(stream); if (!riffiterator.getFormat().equals("RIFF")) throw new UnsupportedAudioFileException(); --- 164,174 ---- return sb.substring(0, sb.length() - 1); } @Override ! StandardFileFormat getAudioFileFormatImpl(final InputStream stream) throws UnsupportedAudioFileException, IOException { RIFFReader riffiterator = new RIFFReader(stream); if (!riffiterator.getFormat().equals("RIFF")) throw new UnsupportedAudioFileException();
*** 247,278 **** audioformat = new AudioFormat(Encoding.PCM_FLOAT, samplerate, bits, channels, framesize, samplerate, false, p); } else { throw new UnsupportedAudioFileException(); } ! long frameLength = dataSize / audioformat.getFrameSize(); ! if (frameLength > Integer.MAX_VALUE) { ! frameLength = AudioSystem.NOT_SPECIFIED; ! } ! return new AudioFileFormat(AudioFileFormat.Type.WAVE, audioformat, ! (int) frameLength); } @Override public AudioInputStream getAudioInputStream(final InputStream stream) throws UnsupportedAudioFileException, IOException { ! 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 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(); } --- 246,273 ---- audioformat = new AudioFormat(Encoding.PCM_FLOAT, samplerate, bits, channels, framesize, samplerate, false, p); } else { throw new UnsupportedAudioFileException(); } ! return new StandardFileFormat(AudioFileFormat.Type.WAVE, audioformat, ! dataSize / audioformat.getFrameSize()); } @Override public AudioInputStream getAudioInputStream(final InputStream stream) throws UnsupportedAudioFileException, IOException { ! 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")) { return new AudioInputStream(chunk, af, length); } } throw new UnsupportedAudioFileException(); }
< prev index next >