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

An attempt to get a sequencer leads to MidiUnavailableException if run with -Xfuture

XMLWordPrintable

    • generic
    • linux_ubuntu

      An attempt to get a sequencer from the system leads to MidiUnavailableException if run with -Xfuture option.

      =======================================8<==================================
      package testapp.sound.midi;

      import java.io.File;
      import java.net.URL;
      import javax.sound.midi.MidiSystem;
      import javax.sound.midi.Sequence;
      import javax.sound.midi.Sequencer;

      public class OpenSequencer {
          public static void main(String[] args) {
              OpenSequencer inst = new OpenSequencer();
              
              try {
                  inst.m1(args);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
          
          public void m1(String[] args) throws Exception {

              String midiFile = args[0];
              Sequence sequence = MidiSystem.getSequence(new File(midiFile));
          
              Sequencer sequencer = MidiSystem.getSequencer();
              sequencer.open();
              sequencer.setSequence(sequence);
          
              sequencer.start();
              Thread.sleep(sequence.getMicrosecondLength() / 1000);
              sequencer.stop();
              sequencer.close();
          }
      }
      =======================================8<==================================

      =======================================8<==================================
      $ java -version
      openjdk version "1.6.0-internal"
      OpenJDK Runtime Environment (build 1.6.0-internal-dherron_19_dec_2007_13_45-b00)
      Java HotSpot(TM) Client VM (build 11.0-b06, mixed mode)

      $ java -Xfuture -cp . testapp.sound.midi.OpenSequencer [VALID_FILE.MID]
      javax.sound.midi.MidiUnavailableException: Audio Device Unavailable
              at com.sun.media.sound.MixerSynth.implOpen(MixerSynth.java:163)
              at com.sun.media.sound.AbstractMidiDevice.doOpen(AbstractMidiDevice.java:162)
              at com.sun.media.sound.AbstractMidiDevice.openInternal(AbstractMidiDevice.java:152)
              at com.sun.media.sound.AbstractMidiDevice.getReceiverReferenceCounting(AbstractMidiDevice.java:357)
              at javax.sound.midi.MidiSystem.getReceiver(MidiSystem.java:261)
              at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:460)
              at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:366)
              at testapp.sound.midi.OpenSequencer.m1(OpenSequencer.java:25)
              at testapp.sound.midi.OpenSequencer.main(OpenSequencer.java:14)
      =======================================8<==================================

      If no -Xfuture option is provided, the code works fine.

            Unassigned Unassigned
            ashusher Alexander Shusherov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: