Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4369044

javax.sound.sampled.AudioSystem.getAudioInputStream() works wrong with Cp037

XMLWordPrintable

    • mantis
    • sparc
    • solaris_2.6



      Name: dfR10049 Date: 09/07/2000




      javax.sound.sampled.AudioSystem.getAudioInputStream(URL url) incorrectly throws
      IOException if file encoding is different from ascii and url points
      to .aif file. It works good with this url in the ascii encoding
      and with another audioformat files in the Cp037 encoding.



      This is the test demonstrated the bug:

      -------------------------------------
      import javax.sound.sampled.*;
      import java.io.*;
      import java.net.*;

      public class SoundTest {

          public static void main(String args[]) {

              URL soundurl = null;
              BufferedWriter log = null;
              CharArrayWriter traceWriter = new CharArrayWriter();

              try {
                  log = new BufferedWriter(new
                          OutputStreamWriter(System.out, "ASCII"));
                  String soundname = new String (args[0].getBytes(), "ASCII");
                  soundurl = new URL(soundname);
                  log.write("url: " + soundurl + '\n');
              } catch (IOException e) {
                  try {
                      log.write("unexpected exception: " + e + '\n');
                      log.flush();
                  } catch (IOException e1) {
                  }
                  System.exit(1);
              }
          
              boolean thrown = false;

              try {
                  AudioSystem.getAudioInputStream(soundurl);
              } catch (UnsupportedAudioFileException e1) {
              } catch(IOException ioe) {
                  ioe.printStackTrace(new PrintWriter(traceWriter));
                  thrown = true;
              }
              
              try {
                  if (!thrown)
                      log.write("no exception" + '\n');
                  else {
                      log.write("IOException thrown" + '\n');
                      log.write(traceWriter.toString());
                  }
                  log.flush();
              } catch (IOException e) {
              }
          
          }
      }

      -------- output from the test ----------------
      #> java -Dfile.encoding=Cp037 SoundTest file:/home/fda/work/sound/sound.aif
      url: file:/home/fda/work/sound/sound.aif
      IOException thrown
      java.io.EOFException
              at java.io.DataInputStream.readInt(DataInputStream.java:343)
              at com.sun.media.sound.AiffFileReader.getCOMM(AiffFileReader.java:353)
              at com.sun.media.sound.AiffFileReader.getAudioInputStream(AiffFileReader.java:242)
              at com.sun.media.sound.AiffFileReader.getAudioInputStream(AiffFileReader.java:273)
              at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:707)
              at SoundTest.main(SoundTest.java:31)

      #> java -Dfile.encoding=Cp037 SoundTest file:/home/fda/work/sound/sound.au
      url: file:/home/fda/work/sound/sound.au
      no exception

      #> java -Dfile.encoding=Cp037 SoundTest file:/home/fda/work/sound/sound.wav
      url: file:/home/fda/work/sound/sound.wav
      no exception

      #> java SoundTest file:/home/fda/work/sound/sound.aif
      url: file:/home/fda/work/sound/sound.aif
      no exception


      ----------------------------------------------

      ======================================================================

      Name: vtR10009 Date: 09/02/2002


      This bug causes failure of JCK tests:
        api/javax_sound/sampled/AudioInputStream/index.html#getFormat
        api/javax_sound/sampled/AudioInputStream/index.html#getFrameLength
        api/javax_sound/sampled/AudioSystem/index.html#AudioSystem

      ======================================================================

            fbomerssunw Florian Bomers (Inactive)
            fdasunw Fda Fda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: