Пример #1
0
  private void createMixerChildren(JavaMixer.MixerNode mixerNode) {
    Mixer mixer = mixerNode.getMixer();
    Line.Info[] infosToCheck = getPortInfo(mixer);
    for (Line.Info anInfosToCheck : infosToCheck) {
      if (mixer.isLineSupported(anInfosToCheck)) {
        Port port = null;
        DataLine dLine = null;

        int maxLines = mixer.getMaxLines(anInfosToCheck);
        // Workaround to prevent a JVM crash on Mac OS X (Intel) 1.5.0_07 JVM
        if (maxLines > 0) {
          try {
            if (anInfosToCheck instanceof Port.Info) {
              port = (Port) mixer.getLine(anInfosToCheck);
              port.open();
            } else if (anInfosToCheck instanceof DataLine.Info) {
              dLine = (DataLine) mixer.getLine(anInfosToCheck);
              if (!dLine.isOpen()) {
                dLine.open();
              }
            }
          } catch (LineUnavailableException e) {
            e.printStackTrace();
          } catch (Exception e) {
            // Do Nothing
          }
        }
        if (port != null) {
          JavaMixer.PortNode portNode = new JavaMixer.PortNode(port);
          createPortChildren(portNode);
          mixerNode.add(portNode);
        } else if (dLine != null) {
          JavaMixer.PortNode portNode = new JavaMixer.PortNode(dLine);
          createPortChildren(portNode);
          mixerNode.add(portNode);
        }
      }
    }
  }
Пример #2
0
 public static void main(String[] args) {
   Port frame = new Port();
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setSize(400, 320);
   frame.setVisible(true);
 }