< prev index next >
src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java
Print this page
@@ -32,11 +32,10 @@
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).
*
@@ -165,11 +164,11 @@
return sb.substring(0, sb.length() - 1);
}
@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();
@@ -247,32 +246,28 @@
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);
+ 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 >