For the class javax.sound.midi.MidiDevice, the behaviour on calls to open() and close() is not specified if used in combination with getReceiver(), getTransmitter, Receiver.close(), Transmitter.close(), MidiSystem.getReceiver() and MidiSystem.getTransmitter().
The specification should tell:
- MidiSystem.getReceiver() and MidiSystem.getTransmitter() open the underlying device implicitly.
- Receivers/Transmitters retrieved via MidiSystem close the underlying device implicitly if their close() method is called and the device hasn't been opened explicitly. If more than one Transmitter or Receiver (that implicitly opened the device) are open, the device is closed after the last Receiver or Transmitter has been closed (and the device hasn't been opened explicitly).
- Receivers and Transmitters retrieved via the device's getReceiver() and getTransmitter() methods do not open the underlying device implicitly. Closing such Receivers or Transmitters does not close the device implicitly. This is true even if there are Receivers or Transmitters for the same device that opened the device implicitly.
- a call to the device's open() method explicitly openes the device. After such a call, the device stays open even if all Transmitters or Receivers has been closed. (The only way to close a device after an explicit call to open() is an explicit call to close().)
- a call to the device's close() method closes all Transmitters and Receivers related to this device, then closes the device itself. This behaviour is independend on wether the Transmitters and Receivers opened the device implicitly or not. Furthermore, it is independant on wether the device has been opened explicitly via open().
checked in fix