jdk/src/share/classes/com/sun/media/sound/AuFileReader.java
changeset 21245 786207514920
parent 18215 b2afd66ce6db
equal deleted inserted replaced
21244:7c2ac5ca05a2 21245:786207514920
    46  * @author Kara Kytle
    46  * @author Kara Kytle
    47  * @author Jan Borgersen
    47  * @author Jan Borgersen
    48  * @author Florian Bomers
    48  * @author Florian Bomers
    49  */
    49  */
    50 public final class AuFileReader extends SunFileReader {
    50 public final class AuFileReader extends SunFileReader {
    51 
       
    52     /**
       
    53      * Constructs a new AuFileReader object.
       
    54      */
       
    55     public AuFileReader() {
       
    56     }
       
    57 
       
    58 
    51 
    59     // METHODS TO IMPLEMENT AudioFileReader
    52     // METHODS TO IMPLEMENT AudioFileReader
    60 
    53 
    61     /**
    54     /**
    62      * Obtains the audio file format of the input stream provided.  The stream must
    55      * Obtains the audio file format of the input stream provided.  The stream must
    88         int encoding_local = -1;
    81         int encoding_local = -1;
    89         int sampleRate     = -1;
    82         int sampleRate     = -1;
    90         int frameRate      = -1;
    83         int frameRate      = -1;
    91         int frameSize      = -1;
    84         int frameSize      = -1;
    92         int channels       = -1;
    85         int channels       = -1;
    93         int sampleSizeInBits = 0;
    86         final int sampleSizeInBits;
    94         int length = 0;
    87         int length = 0;
    95         int nread = 0;
    88         int nread = 0;
    96         AudioFormat.Encoding encoding = null;
    89         AudioFormat.Encoding encoding = null;
    97 
    90 
    98         DataInputStream dis = new DataInputStream( stream );
    91         DataInputStream dis = new DataInputStream( stream );
   116         headerSize     = (bigendian==true ? dis.readInt() : rllong(dis) );  nread += 4;
   109         headerSize     = (bigendian==true ? dis.readInt() : rllong(dis) );  nread += 4;
   117         dataSize       = (bigendian==true ? dis.readInt() : rllong(dis) );  nread += 4;
   110         dataSize       = (bigendian==true ? dis.readInt() : rllong(dis) );  nread += 4;
   118         encoding_local = (bigendian==true ? dis.readInt() : rllong(dis) );  nread += 4;
   111         encoding_local = (bigendian==true ? dis.readInt() : rllong(dis) );  nread += 4;
   119         sampleRate     = (bigendian==true ? dis.readInt() : rllong(dis) );  nread += 4;
   112         sampleRate     = (bigendian==true ? dis.readInt() : rllong(dis) );  nread += 4;
   120         channels       = (bigendian==true ? dis.readInt() : rllong(dis) );  nread += 4;
   113         channels       = (bigendian==true ? dis.readInt() : rllong(dis) );  nread += 4;
       
   114         if (channels <= 0) {
       
   115             dis.reset();
       
   116             throw new UnsupportedAudioFileException("Invalid number of channels");
       
   117         }
   121 
   118 
   122         frameRate = sampleRate;
   119         frameRate = sampleRate;
   123 
   120 
   124         switch (encoding_local) {
   121         switch (encoding_local) {
   125         case AuFileFormat.AU_ULAW_8:
   122         case AuFileFormat.AU_ULAW_8:
   370             }
   367             }
   371         }
   368         }
   372 
   369 
   373         return result;
   370         return result;
   374     }
   371     }
   375 
       
   376 
       
   377 
       
   378 }
   372 }