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

Sound: mark/reset not supported

XMLWordPrintable

      FULL PRODUCT VERSION :
      [gat@MyLaptop jGPS]$ /home/gat/JAVA/JDK15/jdk1.5.0_05/bin/java -version
      java version "1.5.0_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux MyLaptop 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Tried an on-line 'zip'ed file of sounds first. That set of sounds worked as expected.

      Since that file did not have the sounds needed, I created a set of sounds using freetts. I packaged the sounds into a zip file, and tried the program on those sounds. Then I get the mark/reset exception.
      This exception was reported to have been fixed for 1.5. This fails in 1.5, and 1.6.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run program. Need to edit S.java to point where the jGPSsounds.zip file is located. Also need sound file. I dont know how to attach this sound file.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      playback of sounds
      ACTUAL -
      java.io.IOException: mark/reset not supported
              at java.io.InputStream.reset(InputStream.java:331)
              at java.io.FilterInputStream.reset(FilterInputStream.java:204)
              at com.sun.media.sound.WaveFileReader.getFMT(WaveFileReader.java:258)
              at com.sun.media.sound.WaveFileReader.getAudioInputStream(WaveFileReader.java:160)
              at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1094)
              at S.<init>(S.java:77)
              at S.main(S.java:109)

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.io.IOException: mark/reset not supported
              at java.io.InputStream.reset(InputStream.java:331)
              at java.io.FilterInputStream.reset(FilterInputStream.java:204)
              at com.sun.media.sound.WaveFileReader.getFMT(WaveFileReader.java:258)
              at com.sun.media.sound.WaveFileReader.getAudioInputStream(WaveFileReader.java:160)
              at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1094)
              at S.<init>(S.java:77)
              at S.main(S.java:109)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * Soundings.java
       *
       * Created on November 24, 2005, 10:34 PM
       *
       * To change this template, choose Tools | Options and locate the template under
       * the Source Creation and Management node. Right-click the template and choose
       * Open. You can then make changes to the template in the Source Editor.
       */

      /**
       *
       * @author gat
       */

      import javax.sound.sampled.*;
      import javax.sound.midi.Sequence;
      import javax.sound.midi.Sequencer;
      import javax.sound.midi.InvalidMidiDataException;
      import java.io.File;
      import java.util.zip.ZipFile;
      import java.util.zip.ZipEntry;
      import java.util.Enumeration;
      import java.util.Iterator;
      import java.util.TreeMap;
      import java.io.BufferedInputStream;
      import java.io.FileInputStream;
      import java.io.InputStream;

      public class S implements Runnable, LineListener {
          
          /** Creates a new instance of Soundings */
          Sequencer sequencer;
          Object currentSound;
          
          public S() {
          }
          
          public S( String soundFile ) throws Exception {
              
              File zipfile = new File(soundFile);
              
              if ( zipfile == null || zipfile.exists() == false )
                  throw new Exception("Cannot find " + soundFile );
              if ( zipfile.isFile() == false )
                  throw new Exception( "this name ("+zipfile.getAbsolutePath()+")is not a file ;{" );
              
              ZipFile zf = new java.util.zip.ZipFile( zipfile );
              Enumeration zipentries = zf.entries();
              System.out.println("entryes ="+zipentries);
              Integer num;
              TreeMap numList = new TreeMap();
              while( zipentries.hasMoreElements() ) {
                  ZipEntry ze = (ZipEntry) zipentries.nextElement();
                  String zeName = ze.getName();
                  if ( zeName.endsWith( ".gat") ) {
                      System.out.println( zeName );
                      String prefix = zeName.substring( 0, zeName.length() - ".wav".length() );
                      try {
                          num = Integer.decode( prefix );
                      } catch ( java.lang.NumberFormatException e ){
                          continue;
                      } catch (Exception e) { e.printStackTrace();
                          num = null;
                          continue;
                      }
                      numList.put( num, ze );
                  }
              }
              Iterator en = numList.values().iterator();
              while( en.hasNext()) {
                  Object object = en.next();
                  if( object instanceof ZipEntry ) {
                      ZipEntry ze = (ZipEntry) object;
                      InputStream is = zf.getInputStream( ze );
                      try {
                          currentSound = AudioSystem.getAudioInputStream( is );
                      } catch(Exception e1) {
                          e1.printStackTrace();
                      }
                  }
                  if ( currentSound == null )
                      continue;
                  
              }
          }
          
          public static void main(String[] args) {
              
              try {
                  
                  if (AudioSystem.getMixer(null) == null) {
                      System.err.println("AudioSystem Unavailable, exiting!");
                      System.exit(1);
                  }
              } catch (Exception ex) { ex.printStackTrace(); System.exit(1); }
              
              
              String media = "/home/WorkingDirectory/jGPS/jGPS/jGPSsounds.zip";
              if (args.length > 0) {
                  File file = new File(args[0]);
                  if (file == null && !file.isDirectory()) {
                      System.out.println("usage: java Soundings SoundZipFile");
                  } else {
                      media = args[0];
                  }
              }
              try {
                  S soundings = new S( media );
              } catch (Exception e) { e.printStackTrace(); }
              System.exit( 11 );
              
          }
          public void run() {
          }
          public void
          update( LineEvent evt ) {
              System.out.println("Update: LineEvent ="+evt);
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      I have none

            serb Sergey Bylokhov
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: