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

Cannot write AudioInputStream with unspecified length

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.2
    • 1.3.0
    • client-libs
    • mantis
    • x86
    • windows_nt



      Name: rlT66838 Date: 07/07/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      My program contains the following lines:

        //line is an instance of TargetDataLine
        AudioInputStream ais = new AudioInputStream(line);
        AudioSystem.write(ais, AudioFileFormat.Type.AU, out);

      This yields the following exception:

        java.io.IOException: stream length not specified
      at com.sun.media.sound.AuFileWriter.write(Unknown Source)
      at javax.sound.sampled.AudioSystem.write(Unknown Source)
      at Capture.run(Capture.java:67)

      The API documentation states:

      "Some file types require that the length be written into the file header; such
      files cannot be written from start to finish unless the length is known in
      advance. An attempt to write a file of such a type will fail with an
      IOException if the length in the audio file type is AudioSystem.NOT_SPECIFIED."

      However, AU files do not require their length to be written into the file
      header (according to e.g.
      http://www.opennc.org/public/pubs/external/auformat.html). Hence the API
      documentation does not explain why the exception is thrown.

      If I decompile AuFileWriter it turns out that there is a simple check of the
      length and if this equals -1 (AudioSystem.NOT_SPECIFIED), an exception is
      thrown. I believe this is incorrect behaviour.
      (Review ID: 106960)
      ======================================================================

            fbomerssunw Florian Bomers (Inactive)
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: