src/share/classes/com/sun/media/sound/AuFileReader.java
Print this page
@@ -47,17 +47,10 @@
* @author Jan Borgersen
* @author Florian Bomers
*/
public final class AuFileReader extends SunFileReader {
- /**
- * Constructs a new AuFileReader object.
- */
- public AuFileReader() {
- }
-
-
// METHODS TO IMPLEMENT AudioFileReader
/**
* Obtains the audio file format of the input stream provided. The stream must
* point to valid audio file data. In general, audio file providers may
@@ -88,11 +81,11 @@
int encoding_local = -1;
int sampleRate = -1;
int frameRate = -1;
int frameSize = -1;
int channels = -1;
- int sampleSizeInBits = 0;
+ final int sampleSizeInBits;
int length = 0;
int nread = 0;
AudioFormat.Encoding encoding = null;
DataInputStream dis = new DataInputStream( stream );
@@ -116,10 +109,14 @@
headerSize = (bigendian==true ? dis.readInt() : rllong(dis) ); nread += 4;
dataSize = (bigendian==true ? dis.readInt() : rllong(dis) ); nread += 4;
encoding_local = (bigendian==true ? dis.readInt() : rllong(dis) ); nread += 4;
sampleRate = (bigendian==true ? dis.readInt() : rllong(dis) ); nread += 4;
channels = (bigendian==true ? dis.readInt() : rllong(dis) ); nread += 4;
+ if (channels <= 0) {
+ dis.reset();
+ throw new UnsupportedAudioFileException("Invalid number of channels");
+ }
frameRate = sampleRate;
switch (encoding_local) {
case AuFileFormat.AU_ULAW_8:
@@ -370,9 +367,6 @@
}
}
return result;
}
-
-
-
}