Save This Page
Home » openjdk-7 » com.sun.media » sound » [javadoc | source]
com.sun.media.sound
abstract class: AbstractMidiDevice [javadoc | source]
java.lang.Object
   com.sun.media.sound.AbstractMidiDevice

All Implemented Interfaces:
    ReferenceCountingDevice, MidiDevice

Direct Known Subclasses:
    MidiOutDevice, MidiInDevice, RealTimeSequencer

Abstract AbstractMidiDevice class representing functionality shared by MidiInDevice and MidiOutDevice objects.
Nested Class Summary:
abstract protected class  AbstractMidiDevice.AbstractReceiver  Base class for Receivers. Subclasses that use Receivers must use this base class, since it contains magic necessary to manage implicit closing the device. This is necessary for Receivers retrieved via MidiSystem.getReceiver() (which opens the device implicitely). 
protected class  AbstractMidiDevice.BasicTransmitter  Transmitter base class. This class especially makes sure the device is closed if it has been opened implicitly by a call to MidiSystem.getTransmitter(). The logic of doing so is actually in closeInternal(). Also, it has some optimizations regarding sending to the Receivers, for known Receivers, and managing itself in the TransmitterList. 
class  AbstractMidiDevice.TransmitterList  a class to manage a list of transmitters 
Field Summary
protected  boolean open     
protected  long id    This is the device handle returned from native code 
Constructor:
 protected AbstractMidiDevice(Info info) 
    Constructs an AbstractMidiDevice with the specified info object.
    Parameters:
    info - the description of the device
Method from com.sun.media.sound.AbstractMidiDevice Summary:
close,   closeInternal,   createReceiver,   createTransmitter,   doClose,   finalize,   getDeviceInfo,   getId,   getMaxReceivers,   getMaxTransmitters,   getMicrosecondPosition,   getReceiver,   getReceiverReferenceCounting,   getReceivers,   getTransmitter,   getTransmitterList,   getTransmitterReferenceCounting,   getTransmitters,   hasReceivers,   hasTransmitters,   implClose,   implOpen,   isOpen,   open
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sun.media.sound.AbstractMidiDevice Detail:
 public  void close() 
 public  void closeInternal(Object object) 
    Close the device for an object that implicitely opened it. This method is intended to be used by Transmitter.close() and Receiver.close(). Those methods should pass this for the object parameter. Since Transmitters or Receivers do not know if their device has been opened implicitely because of them, they call this method in any case. This method now is able to seperate Receivers/Transmitters that opened the device implicitely from those that didn't by looking up the R/T in the openKeepingObjects list. Only if the R/T is contained there, the reference count is reduced.
 protected Receiver createReceiver() throws MidiUnavailableException 
    Create a Receiver object. throwing an exception here means that Receivers aren't enabled. Subclasses that use Receivers should override this method with one that returns objects implementing Receiver. Classes overriding this method should also override hasReceivers() to return true.
 protected Transmitter createTransmitter() throws MidiUnavailableException 
    Create a Transmitter object. throwing an exception here means that Transmitters aren't enabled. Subclasses that use Transmitters should override this method with one that returns objects implementing Transmitters. Classes overriding this method should also override hasTransmitters() to return true.
 public  void doClose() 
 protected  void finalize() 
    close this device if discarded by the garbage collector
 public Info getDeviceInfo() 
 long getId() 
 public final int getMaxReceivers() 
    Return the maximum number of Receivers supported by this device. Depending on the return value of hasReceivers(), this method returns either 0 or -1. Subclasses should rather override hasReceivers() than override this method.
 public final int getMaxTransmitters() 
    Return the maximum number of Transmitters supported by this device. Depending on the return value of hasTransmitters(), this method returns either 0 or -1. Subclasses should override hasTransmitters().
 public long getMicrosecondPosition() 
    This implementation always returns -1. Devices that actually provide this should over-ride this method.
 public final Receiver getReceiver() throws MidiUnavailableException 
    Retrieve a Receiver for this device. This method returns the value returned by createReceiver(), if it doesn't throw an exception. Subclasses should rather override createReceiver() than override this method. If createReceiver returns a Receiver, it is added to the internal list of Receivers (see getReceiversList)
 public Receiver getReceiverReferenceCounting() throws MidiUnavailableException 
    Retrieve a Receiver and open the device implicitly. This method is called by MidiSystem.getReceiver().
 public final List<Receiver> getReceivers() 
 public final Transmitter getTransmitter() throws MidiUnavailableException 
    This implementation uses createTransmitter, which may throw an exception. If a transmitter is returned in createTransmitter, it is added to the internal TransmitterList
 protected TransmitterList getTransmitterList() 
    Return the internal list of Transmitters, possibly creating it first.
 public Transmitter getTransmitterReferenceCounting() throws MidiUnavailableException 
    Retrieve a Transmitter and open the device implicitly. This method is called by MidiSystem.getTransmitter().
 public final List<Transmitter> getTransmitters() 
 protected boolean hasReceivers() 
    Returns if this device supports Receivers. Subclasses that use Receivers should override this method to return true. They also should override createReceiver().
 protected boolean hasTransmitters() 
    Returns if this device supports Transmitters. Subclasses that use Transmitters should override this method to return true. They also should override createTransmitter().
 protected  void implClose() 
 abstract protected  void implOpen() throws MidiUnavailableException
 public boolean isOpen() 
 public  void open() throws MidiUnavailableException 
    Open the device from an aplication program. Setting the open reference count to -1 here prevents Transmitters and Receivers that opened the the device implicitly from closing it. The only way to close the device after this call is a call to close().