示例#1
0
 private void extractLibraryInfo() {
   libraries = new LinkedHashMap<String, LibraryInfo>();
   List<Device> devices = new ArrayList<Device>();
   List<Device> inputDevices = new ArrayList<Device>();
   for (AudioServerProvider lib : Lookup.SYSTEM.getAll(AudioServerProvider.class)) {
     LOG.log(Level.FINE, "Audio Library : {0}", lib.getLibraryName());
     devices.clear();
     inputDevices.clear();
     for (Device device : lib.findAll(Device.class)) {
       if (device.getMaxOutputChannels() > 0) {
         LOG.log(Level.FINE, "-- Found device : {0}", device.getName());
         devices.add(device);
       } else if (device.getMaxInputChannels() > 0) {
         LOG.log(Level.FINE, "-- Found input device : {0}", device.getName());
         inputDevices.add(device);
       }
     }
     libraries.put(
         lib.getLibraryName(),
         new LibraryInfo(
             lib,
             devices.toArray(new Device[devices.size()]),
             inputDevices.toArray(new Device[inputDevices.size()])));
   }
 }
示例#2
0
  private Device findDevice(LibraryInfo info, boolean usingDefault, boolean input) {
    String name = null;

    if (usingDefault) {
      name = input ? AudioSettings.getInputDeviceName() : AudioSettings.getDeviceName();
    } else {
      if (input) {
        name = inputDeviceName == null ? null : inputDeviceName.value;
      } else {
        name = deviceName == null ? null : deviceName.value;
      }
    }

    if (name == null || name.trim().isEmpty()) {
      return null;
    }

    Device[] devices = input ? info.inputDevices : info.devices;
    for (Device device : devices) {
      if (device.getName().equals(name)) {
        return device;
      }
    }
    for (Device device : devices) {
      if (device.getName().contains(name)) {
        return device;
      }
    }
    return null;
  }
示例#3
0
 private void validateDevices() {
   if (deviceName == null || inputDeviceName == null) {
     return;
   }
   LibraryInfo info = libraries.get(audioLib.value);
   if (info == null) {
     return;
   }
   Device primary = findDevice(info, false, false);
   if (primary != null && primary.getMaxInputChannels() > 0) {
     inputDeviceName.value = "";
   }
 }
示例#4
0
  private AudioServer createServer(BusClient bus) throws Exception {
    float srate = sampleRate.value;
    int buffersize = getBuffersize();

    boolean usingDefault = false;
    LibraryInfo info = libraries.get(audioLib.value);
    if (info == null) {
      info = libraries.get(AudioSettings.getLibrary());
      if (info == null) {
        throw new IllegalStateException("Audio library not found");
      }
      usingDefault = true;
    }
    LOG.log(
        Level.FINE,
        "Found audio library {0}\n{1}",
        new Object[] {info.provider.getLibraryName(), info.provider.getLibraryDescription()});

    Device device = findDevice(info, usingDefault, false);
    if (device != null) {
      LOG.log(Level.FINE, "Found device : {0}", device.getName());
    }
    Device inputDevice = null;
    if (device != null && device.getMaxInputChannels() == 0 && bus.getSourceCount() > 0) {
      inputDevice = findDevice(info, usingDefault, true);
      if (inputDevice != null) {
        LOG.log(Level.FINE, "Found input device : {0}", inputDevice.getName());
      }
    }

    ClientID clientID = new ClientID("PraxisLIVE-" + getAddress().getRootID());

    AudioConfiguration ctxt =
        new AudioConfiguration(
            srate,
            bus.getSourceCount(),
            bus.getSinkCount(),
            buffersize,
            createCheckedExts(device, inputDevice, clientID));
    return info.provider.createServer(ctxt, bus);
  }