private boolean setupSpeaker(String device) throws LineUnavailableException {

    Mixer.Info[] aInfos = AudioSystem.getMixerInfo();

    for (int i = 0; i < aInfos.length; i++) {
      Mixer.Info mixerInfo = aInfos[i];

      if (GetDataLines.equals(device, mixerInfo) == false) {
        if (Logger.logLevel >= Logger.LOG_MOREINFO) {
          Logger.println("Skipping:  " + mixerInfo.getName() + "," + mixerInfo.getDescription());
        }

        continue;
      }

      try {
        Mixer mixer = AudioSystem.getMixer(mixerInfo);

        Line.Info[] infos = mixer.getSourceLineInfo();

        for (int j = 0; j < infos.length; j++) {
          Line line = (Line) mixer.getLine(infos[j]);

          if (line instanceof SourceDataLine) {
            speaker = (SourceDataLine) line;

            if (Logger.logLevel >= Logger.LOG_INFO) {
              Logger.println("Found speaker:  " + j);
            }
            break;
          }
        }
      } catch (Exception e) {
        if (Logger.logLevel >= Logger.LOG_MOREINFO) {
          Logger.println("Exception:  " + e.getMessage());
        }
      }
    }

    return speaker != null;
  }
  public Mixer getMixer(Mixer.Info info) {
    // if the default device is asked, we provide the mixer
    // with SourceDataLine's
    if (info == null) {
      for (int i = 0; i < infos.length; i++) {
        Mixer mixer = getDevice(infos[i]);
        if (mixer.getSourceLineInfo().length > 0) {
          return mixer;
        }
      }
    }
    // otherwise get the first mixer that matches
    // the requested info object
    for (int i = 0; i < infos.length; i++) {
      if (infos[i].equals(info)) {
        return getDevice(infos[i]);
      }
    }

    throw new IllegalArgumentException(
        "Mixer " + info.toString() + " not supported by this provider.");
  }
Example #3
0
 private static void d1() {
   Mixer.Info[] fmi = AudioSystem.getMixerInfo();
   for (Mixer.Info mi : fmi) {
     Mixer mixer = AudioSystem.getMixer(mi);
     Line.Info[] isl = mixer.getSourceLineInfo();
     Line.Info[] itl = mixer.getTargetLineInfo();
     // if( itl.length > 0)
     {
       error.log("--------------------------------------------------------------");
       error.log("Src Count " + isl.length + " Target size " + itl.length);
       error.log(mi.toString());
       error.log("Name " + mi.getName());
       error.log("Version " + mi.getVersion());
       error.log("Vendor " + mi.getVendor());
       error.log("Description " + mi.getDescription());
       error.log("~~~");
       dumpLines(isl, "  >> SourceLine  : ");
       dumpLines(itl, "  >> TargetLine  : ");
     }
   }
 }
    @Override
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      Component component =
          super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

      Mixer.Info mi = (Mixer.Info) value;

      if (mi != null) {
        String text = mi.getName();

        if (!"Unknown Version".equals(mi.getVersion())) {
          text += ' ' + mi.getVersion();
        }
        if (!"Unknown Vendor".equals(mi.getVendor())) {
          text += " by " + mi.getVendor();
        }
        setText(text);
      }
      return component;
    }
Example #5
0
  public String toString() {
    Mixer.Info info = mixer.getMixerInfo();

    String s = "\nMixer [" + id + "]";
    s += "\n\t Name: " + info.getName();
    s += "\n\t Desc: " + info.getDescription();
    s += "\n\t Ven : " + info.getVendor();
    s += "\n\t Ver : " + info.getVersion();
    s += "\n\t Str : " + info.toString();

    Line.Info[] infos = mixer.getSourceLineInfo();
    s += "\n\nSourceLine count : " + infos.length;
    for (int i = 0; i < infos.length; i++) {
      if (infos[i] instanceof DataLine.Info) {
        s += "\n\t\tData Line Source [" + i + "]";
        s += "\n\t\t\t Str : " + infos[i].toString();
      } else if (infos[i] instanceof Port.Info) {
        s += "\n\t\tPort Source [" + i + "]";
        s += "\n\t\t\t Name: " + ((Port.Info) infos[i]).getName();
        s += "\n\t\t\t is Src: " + ((Port.Info) infos[i]).isSource();
        s += "\n\t\t\t Str : " + infos[i].toString();
      } else /*if(infos[i]!=null)*/ {
        s += "\n\t\tSource [" + i + "]";
        s += "\n\t\t\t Str : " + infos[i].toString();
      }
    }
    s += "\n\nOUTPUT\n";
    for (int i = 0; i < formats.length; i++) {
      try {
        SourceDataLine out = getOutputLine(formats[i]);
        out.close();
        s += "\n" + formats[i].toString();
      } catch (Exception e) {
        //        s+="\n"+e.getMessage();
      }
    }

    infos = mixer.getTargetLineInfo();
    s += "\n\nTargetLine count : " + infos.length;
    for (int i = 0; i < infos.length; i++) {
      if (infos[i] instanceof DataLine.Info) {
        s += "\n\t\tData Line Target [" + i + "]";
        s += "\n\t\t\t Str : " + infos[i].toString();
      } else if (infos[i] instanceof Port.Info) {
        s += "\n\t\tPort Target [" + i + "]";
        s += "\n\t\t\t Name: " + ((Port.Info) infos[i]).getName();
        s += "\n\t\t\t is Src: " + ((Port.Info) infos[i]).isSource();
        s += "\n\t\t\t Str : " + infos[i].toString();
      } else /*if(infos[i]!=null)*/ {
        s += "\n\t\tTarget [" + i + "]";
        s += "\n\t\t\t Str : " + infos[i].toString();
      }
    }

    s += "\n\nINPUT\n";
    for (int i = 0; i < formats.length; i++) {
      try {
        TargetDataLine out = getInputLine(formats[i]);
        out.close();
        s += "\n" + formats[i].toString();
      } catch (Exception e) {
        //        s+="\n"+e.getMessage();
      }
    }

    return s;
  }