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

MidiSystem.getSequencer() generates exception with obscure message

    XMLWordPrintable

Details

    Description

      Name: izR10247 Date: 11/18/2003



      Java Sound spec states for method MidiSystem.getSequencer():
      "Obtains the default Sequencer, connected to a default device.
      The returned Sequencer instance is connected to the default Synthesizer,
      as returned by getSynthesizer(). If there is no Synthesizer available, or
      the default Synthesizer cannot be opened, the sequencer is connected to
      the default Receiver, as returned by getReceiver()
      ...
      Throws:
               MidiUnavailableException - if the sequencer is not available
               due to resource restrictions, or there is no Receiver
               available by any installed MidiDevice, or no sequencer is
               installed in the system."

      But J2SE 1.5 b28 implementation does not return Sequencer connected to the
      default Synthesizer and throws exception with obscure message:
      "MIDI OUT transmitter not available". Note that default Secuencer is
      available
      as well as Synthesizer respectively and this could mislead the users since
      MidiUnavailableException might be really thrown in case of resource
      restrictions.

      To reproduce this problem please
      run test 'MyTest' using script 'MyTest.sh' below,
      note that this problem is not reproducible
      on windows platform:

      =============== MyTest.java source begin ===============
      import javax.sound.midi.*;
      import javax.sound.sampled.AudioPermission;

      public class MyTest {

          public static void main(String argv[]) {

              Sequencer seq = null;
              MidiDevice.Info[] infos;
              try {
                  infos = MidiSystem.getMidiDeviceInfo();
                  System.out.println("Here is list of our MidiDevices:");
                  for(int i=0;i<infos.length;i++) {
                      System.out.println("== Device #" + i + "==");
                      System.out.println("Vendor:\t\t\t" + infos[i].getVendor());
                      System.out.println("Description:\t\t" + infos[i].getDescription());
                      System.out.println("Version:\t\t" + infos[i].getVersion());
                      System.out.println("Name:\t\t\t" + infos[i].getName());
                      if(MidiSystem.getMidiDevice(infos[i]) instanceof Sequencer) {
                          System.out.println("*** We found that this is sequencer: ***\n\t"
                              + MidiSystem.getMidiDevice(infos[i]).getClass().getName());
                      } else {
                          if(MidiSystem.getMidiDevice(infos[i]) instanceof Synthesizer) {
                              System.out.println("*** We found that this is synthesizer: ***\n\t"
                                  + MidiSystem.getMidiDevice(infos[i]).getClass().getName());

                          }
                      }
                      System.out.println("\n");
                  }
                  System.out.println("Now we are trying to get default sequencer:");
                  seq = MidiSystem.getSequencer();
                  System.out.println("Default sequencer is:" + seq);
              } catch (MidiUnavailableException mue) {
                  System.out.println("We've tried to get default sequencer but following exception was thrown:");
                  System.out.println("MidiUnavailableException was thrown: " + mue);
                  mue.printStackTrace();
              }
          }
      }
      =============== MyTest.java source end =================
      =============== MyTest.sh begin ========================
      #!/bin/bash
      export JDK='/net/linux-15/export/home/java/jdk1.5.0/sparc'
      # Generating info about operating system
      uname -a
      # Source compilation
      $JDK/bin/javac MyTest.java
      # Test running
      $JDK/bin/java -showversion MyTest
      =============== MyTest.sh end ==========================
      =============== MyTest output begin ====================
      bash-2.05$ ./MyTest.sh
      SunOS novo48 5.9 Generic_112233-07 sun4u sparc SUNW,Ultra-60
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b28)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b28, mixed mode)

      Here is list of our MidiDevices:
      == Device #0==
      Vendor: Sun Microsystems
      Software sequencer / synthesizer module
      Version: Version 1.0
      Name: Java Sound Sequencer
      *** We found that this is sequencer: ***
              com.sun.media.sound.MixerSequencer


      == Device #1==
      Vendor: Sun Microsystems
      Software sequencer
      Version: Version 1.0
      Name: Real Time Sequencer
      *** We found that this is sequencer: ***
              com.sun.media.sound.RealTimeSequencer


      == Device #2==
      Vendor: Sun Microsystems
      Software wavetable synthesizer and receiver
      Version: Version 1.0
      Name: Java Sound Synthesizer
      *** We found that this is synthesizer: ***
              com.sun.media.sound.MixerSynth


      Now we are trying to get default sequencer:
      We've tried to get default sequencer but following exception was thrown:
      MidiUnavailableException was thrown:
      javax.sound.midi.MidiUnavailableException: MIDI OUT transmitter not available
      javax.sound.midi.MidiUnavailableException: MIDI OUT transmitter not available
              at com.sun.media.sound.AbstractMidiDevice.createTransmitter(AbstractMidiDevice.java:410)
              at com.sun.media.sound.AbstractMidiDevice.getTransmitter(AbstractMidiDevice.java:281)
              at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:438)
              at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:348)
              at MyTest.main(MyTest.java:32)
      =============== MyTest output end ======================
      ======================================================================</TEXTAREA>
      </td>
                          </tr>
                          <TR>
                            <TD colspan="2" bgcolor="#BFBFBF"> </td>
                          </tr>

      <a name="comments"></a>
                          <!-- COMMENTS -->
                          <TR>
                            <TD bgcolor="#BFBFBF" align="left" valign="bottom" height="24">
      <img src="/bugz/images/dot.gif" width="10">Comments
      </td>
                            <TD bgcolor="#BFBFBF" align="left" valign="bottom" height="24">
      <!-- BEGIN:TBR Mohan
        <A href="javascript:doDateStampSubmit(document.editbug_general, 'comments');"><font size="-1">[ Date Stamp ]</font></A>
      <img src="/bugz/images/dot.gif" width="18">
      END:TBR -->
      <A href="javascript:doFullPageSubmit(document.editbug_general, 'comments');"><font size="-1">[ Full Page ]</font></a>
      <img src="/bugz/images/dot.gif" width="22">
      <FONT size="-1" color="darkblue">--- Enter SUN Proprietary data here ---</font>
      </td>
                          </tr>

                          <TR>
                            <TD bgcolor="#BFBFBF" colspan="2" nowrap align="left">
      <img src="/bugz/images/dot.gif" width="5">
                              <TEXTAREA rows="6" cols="95" wrap="virtual" name="comments" align="left" bgcolor="white">

      Name: izR10247 Date: 11/24/2003


      Yes. Your evaluation is right. Bug is reproducible
      with old (not jdk1.5.0) rt.jar classpath only.
      So, please feel free to close the bug as not a bug.




      ======================================================================
      ###@###.### 2003-11-24

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: