< prev index next >

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

Print this page

        

@@ -38,11 +38,10 @@
  *
  * @author Jan Borgersen
  */
 public final class PCMtoPCMCodec extends SunCodec {
 
-
     private static final AudioFormat.Encoding[] inputEncodings = {
         AudioFormat.Encoding.PCM_SIGNED,
         AudioFormat.Encoding.PCM_UNSIGNED,
     };
 

@@ -57,12 +56,11 @@
     public PCMtoPCMCodec() {
 
         super( inputEncodings, outputEncodings);
     }
 
-    // NEW CODE
-
+    @Override
     public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat) {
 
         final int sampleSize = sourceFormat.getSampleSizeInBits();
         AudioFormat.Encoding encoding = sourceFormat.getEncoding();
         if (sampleSize == 8) {

@@ -86,13 +84,11 @@
             }
         }
         return new AudioFormat.Encoding[0];
     }
 
-
-    /**
-     */
+    @Override
     public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
         Objects.requireNonNull(targetEncoding);
 
         // filter out targetEncoding from the old getOutputFormats( sourceFormat ) method
 

@@ -111,13 +107,11 @@
         }
 
         return formatArray;
     }
 
-
-    /**
-     */
+    @Override
     public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream) {
 
         if( isConversionSupported(targetEncoding, sourceStream.getFormat()) ) {
 
             AudioFormat sourceFormat = sourceStream.getFormat();

@@ -134,35 +128,28 @@
         } else {
             throw new IllegalArgumentException("Unsupported conversion: " + sourceStream.getFormat().toString() + " to " + targetEncoding.toString() );
         }
 
     }
-    /**
-     * use old code
-     */
+
+    @Override
     public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream){
         if (!isConversionSupported(targetFormat, sourceStream.getFormat()))
             throw new IllegalArgumentException("Unsupported conversion: "
                                                + sourceStream.getFormat().toString() + " to "
                                                + targetFormat.toString());
         return getConvertedStream( targetFormat, sourceStream );
     }
 
-
-
-
-    // OLD CODE
-
     /**
      * Opens the codec with the specified parameters.
      * @param stream stream from which data to be processed should be read
      * @param outputFormat desired data format of the stream after processing
      * @return stream from which processed data may be read
      * @throws IllegalArgumentException if the format combination supplied is
      * not supported.
      */
-    /*  public AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {*/
     private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {
 
         AudioInputStream cs = null;
 
         AudioFormat inputFormat = stream.getFormat();

@@ -170,25 +157,22 @@
         if( inputFormat.matches(outputFormat) ) {
 
             cs = stream;
         } else {
 
-            cs = (AudioInputStream) (new PCMtoPCMCodecStream(stream, outputFormat));
+            cs = new PCMtoPCMCodecStream(stream, outputFormat);
         }
         return cs;
     }
 
-
-
     /**
      * Obtains the set of output formats supported by the codec
      * given a particular input format.
      * If no output formats are supported for this input format,
      * returns an array of length 0.
      * @return array of supported output formats.
      */
-    /*  public AudioFormat[] getOutputFormats(AudioFormat inputFormat) { */
     private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
 
         Vector<AudioFormat> formats = new Vector<>();
         AudioFormat format;
 

@@ -348,11 +332,10 @@
         }
 
         return formatArray;
     }
 
-
     class PCMtoPCMCodecStream extends AudioInputStream {
 
         private final int PCM_SWITCH_SIGNED_8BIT                = 1;
         private final int PCM_SWITCH_ENDIAN                             = 2;
         private final int PCM_SWITCH_SIGNED_LE                  = 3;

@@ -458,11 +441,11 @@
 
         /**
          * Note that this only works for sign conversions.
          * Other conversions require a read of at least 2 bytes.
          */
-
+        @Override
         public int read() throws IOException {
 
             // $$jb: do we want to implement this function?
 
             int temp;

@@ -487,16 +470,17 @@
             } else {
                 throw new IOException("cannot read a single byte if frame size > 1");
             }
         }
 
-
+        @Override
         public int read(byte[] b) throws IOException {
 
             return read(b, 0, b.length);
         }
 
+        @Override
         public int read(byte[] b, int off, int len) throws IOException {
 
 
             int i;
 

@@ -587,11 +571,7 @@
                     b[i] = b[i+1];
                     b[i+1] = temp;
                 }
             }
         }
-
-
-
     } // end class PCMtoPCMCodecStream
-
 } // end class PCMtoPCMCodec
< prev index next >