Exemplo n.º 1
0
  private static Line getLine(String propName, Line.Info info) throws LineUnavailableException {

    List<?> mixerProviders = ProviderService.getProviders(mixerProviderPath);

    if (propName != null) {
      String propVal = System.getProperty(propName);
      if (propVal != null) {
        Mixer m = getMixer(propVal, info, mixerProviders);
        if (m != null) {
          Line l = m.getLine(info);
          if (l != null) {
            return l;
          }
        }
      }

      Properties soundProperties = ProviderService.getSoundProperties();
      propVal = soundProperties.getProperty(propName);
      if (propVal != null) {
        Mixer m = getMixer(propVal, info, mixerProviders);
        if (m != null) {
          Line l = m.getLine(info);
          if (l != null) {
            return l;
          }
        }
      }
    }

    for (Iterator providers = ProviderService.getProviders(mixerProviderPath).iterator();
        providers.hasNext(); ) {
      try {
        MixerProvider pr = (MixerProvider) (providers.next());
        Mixer.Info[] mixinfos = pr.getMixerInfo();
        for (Mixer.Info mixinfo : mixinfos) {
          try {
            Mixer mix = pr.getMixer(mixinfo);
            return mix.getLine(info);
          } catch (IllegalArgumentException e) {
            // continue
          }
        }
      } catch (ClassCastException e) {
      }
    }
    // sound.11=Could not get line
    throw new IllegalArgumentException(Messages.getString("sound.11")); // $NON-NLS-1$
  }
Exemplo n.º 2
0
  private static Mixer getMixer(String propVal, Line.Info info, List<?> mixerProviders) {

    int index = propVal.indexOf("#"); // $NON-NLS-1$
    String className;
    String mixName;
    if (index == -1) {
      className = propVal.trim();
      mixName = ""; // $NON-NLS-1$
    } else {
      className = propVal.substring(0, index).trim();
      if (index == propVal.length()) {
        mixName = ""; // $NON-NLS-1$
      } else {
        mixName = propVal.substring(index + 1).trim();
      }
    }
    Mixer.Info[] minfos = null;
    if (!className.equals("")) { // $NON-NLS-1$
      for (Iterator providers = mixerProviders.iterator(); providers.hasNext(); ) {
        try {
          MixerProvider pr = (MixerProvider) (providers.next());
          if (className.equals(pr.getClass().getName())) {
            minfos = pr.getMixerInfo();
            break;
          }
        } catch (ClassCastException e) {
        }
      }
    }
    if (minfos == null) {
      minfos = getMixerInfo();
    }

    if (!mixName.equals("")) { // $NON-NLS-1$
      for (Mixer.Info minfo : minfos) {
        if (mixName.equals(minfo.getName())) {
          return getMixer(minfo);
        }
      }
    }
    if (minfos.length > 0) {
      return getMixer(minfos[0]);
    }
    return null;
  }
Exemplo n.º 3
0
  public static boolean isLineSupported(Line.Info info) {

    for (Iterator providers = ProviderService.getProviders(mixerProviderPath).iterator();
        providers.hasNext(); ) {
      try {
        MixerProvider pr = (MixerProvider) providers.next();
        Mixer.Info[] mixinfos = pr.getMixerInfo();
        for (Mixer.Info mixinfo : mixinfos) {
          Mixer mix = pr.getMixer(mixinfo);
          if (mix.isLineSupported(info)) {
            return true;
          }
        }
      } catch (ClassCastException e) {
      }
    }
    return false;
  }
Exemplo n.º 4
0
 public static Line.Info[] getTargetLineInfo(Line.Info info) {
   List<Line.Info> result = new ArrayList<Line.Info>();
   for (Iterator providers = ProviderService.getProviders(mixerProviderPath).iterator();
       providers.hasNext(); ) {
     try {
       MixerProvider pr = (MixerProvider) providers.next();
       Mixer.Info[] mixinfos = pr.getMixerInfo();
       for (Mixer.Info mixinfo : mixinfos) {
         Mixer mix = pr.getMixer(mixinfo);
         Line.Info[] linfos = mix.getTargetLineInfo(info);
         for (Line.Info linfo : linfos) {
           result.add(linfo);
         }
       }
     } catch (ClassCastException e) {
     }
   }
   Line.Info[] temp = new Line.Info[result.size()];
   return result.toArray(temp);
 }