< prev index next >
src/java.desktop/share/classes/com/sun/media/sound/WaveFileReader.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -43,11 +43,11 @@
* @author Florian Bomers
*/
public final class WaveFileReader extends SunFileReader {
@Override
- AudioFileFormat getAudioFileFormatImpl(final InputStream stream)
+ StandardFileFormat getAudioFileFormatImpl(final InputStream stream)
throws UnsupportedAudioFileException, IOException {
// assumes sream is rewound
int nread = 0;
@@ -62,13 +62,13 @@
AudioFormat.Encoding encoding = null;
DataInputStream dis = new DataInputStream( stream );
int magic = dis.readInt();
- int fileLength = rllong(dis);
+ long /* unsigned int */ fileLength = rllong(dis) & 0xffffffffL;
int waveMagic = dis.readInt();
- int totallength;
+ long totallength;
if (fileLength <= 0) {
fileLength = AudioSystem.NOT_SPECIFIED;
totallength = AudioSystem.NOT_SPECIFIED;
} else {
totallength = fileLength + 8;
@@ -184,21 +184,20 @@
// we've reached the end of the file without finding the 'data' chunk
throw new UnsupportedAudioFileException("Not a valid WAV file");
}
}
// this is the length of the data chunk
- int dataLength = rllong(dis); nread += 4;
+ long /* unsigned int */ dataLength = rllong(dis) & 0xffffffffL; nread += 4;
// now build the new AudioFileFormat and return
-
+ final int frameSize = calculatePCMFrameSize(sampleSizeInBits, channels);
AudioFormat format = new AudioFormat(encoding,
(float)sampleRate,
sampleSizeInBits, channels,
- calculatePCMFrameSize(sampleSizeInBits, channels),
+ frameSize,
(float)sampleRate, false);
- return new WaveFileFormat(AudioFileFormat.Type.WAVE,
- totallength,
- format,
- dataLength / format.getFrameSize());
+ long frameLength = dataLength / format.getFrameSize();
+ return new WaveFileFormat(AudioFileFormat.Type.WAVE, totallength,
+ format, frameLength);
}
}
< prev index next >