Java 类javax.sound.midi.spi.MidiDeviceProvider 实例源码

项目:OpenJSharp    文件:JDK13Services.java   
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
项目:OpenJSharp    文件:MidiSystem.java   
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
    @param deviceName The name of the MidiDevice to be returned.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.

    @return A MidiDevice matching the requirements, or null if none is found.
*/
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, provider, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, provider, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:OpenJSharp    文件:MidiSystem.java   
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
项目:OpenJSharp    文件:MidiSystem.java   
/** Return a MidiDevice with a given name from a list of
    MidiDeviceProviders.
    @param deviceName The name of the MidiDevice to be returned.
    @param providers The List of MidiDeviceProviders to check for
    MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A Mixer matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getNamedDevice(deviceName, provider,
                                           deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
项目:OpenJSharp    文件:MidiSystem.java   
/** From a given MidiDeviceProvider, return the first appropriate device.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice is considered appropriate, or null if no
    appropriate device is found.
*/
private static MidiDevice getFirstDevice(MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(provider, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(provider, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:OpenJSharp    文件:MidiSystem.java   
/** From a List of MidiDeviceProviders, return the first appropriate
    MidiDevice.
    @param providers The List of MidiDeviceProviders to search.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice that is considered appropriate, or null
    if none is found.
 */
private static MidiDevice getFirstDevice(List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getFirstDevice(provider, deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
项目:jdk8u-jdk    文件:JDK13Services.java   
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
项目:jdk8u-jdk    文件:MidiSystem.java   
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
    @param deviceName The name of the MidiDevice to be returned.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.

    @return A MidiDevice matching the requirements, or null if none is found.
*/
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, provider, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, provider, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:jdk8u-jdk    文件:MidiSystem.java   
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
项目:jdk8u-jdk    文件:MidiSystem.java   
/** Return a MidiDevice with a given name from a list of
    MidiDeviceProviders.
    @param deviceName The name of the MidiDevice to be returned.
    @param providers The List of MidiDeviceProviders to check for
    MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A Mixer matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getNamedDevice(deviceName, provider,
                                           deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
项目:jdk8u-jdk    文件:MidiSystem.java   
/** From a given MidiDeviceProvider, return the first appropriate device.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice is considered appropriate, or null if no
    appropriate device is found.
*/
private static MidiDevice getFirstDevice(MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(provider, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(provider, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:jdk8u-jdk    文件:MidiSystem.java   
/** From a List of MidiDeviceProviders, return the first appropriate
    MidiDevice.
    @param providers The List of MidiDeviceProviders to search.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice that is considered appropriate, or null
    if none is found.
 */
private static MidiDevice getFirstDevice(List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getFirstDevice(provider, deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
项目:openjdk-jdk10    文件:JDK13Services.java   
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
项目:openjdk-jdk10    文件:MidiSystem.java   
/**
 * Return a MidiDevice with a given name from a given MidiDeviceProvider.
 *
 * @param  deviceName The name of the MidiDevice to be returned
 * @param  provider The MidiDeviceProvider to check for MidiDevices
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A MidiDevice matching the requirements, or null if none is found
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class<?> deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, provider, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, provider, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:openjdk-jdk10    文件:MidiSystem.java   
/**
 * Return a MidiDevice with a given name from a list of MidiDeviceProviders.
 *
 * @param  deviceName The name of the MidiDevice to be returned
 * @param  providers The List of MidiDeviceProviders to check for
 *         MidiDevices
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A Mixer matching the requirements, or null if none is found
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         List<MidiDeviceProvider> providers,
                                         Class<?> deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, providers, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, providers, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:openjdk-jdk10    文件:MidiSystem.java   
/**
 * From a given MidiDeviceProvider, return the first appropriate device.
 *
 * @param  provider The MidiDeviceProvider to check for MidiDevices
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A MidiDevice is considered appropriate, or null if no appropriate
 *         device is found
 */
private static MidiDevice getFirstDevice(MidiDeviceProvider provider,
                                         Class<?> deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(provider, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(provider, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:openjdk-jdk10    文件:MidiSystem.java   
/**
 * From a List of MidiDeviceProviders, return the first appropriate
 * MidiDevice.
 *
 * @param  providers The List of MidiDeviceProviders to search
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A MidiDevice that is considered appropriate, or null if none is
 *         found
 */
private static MidiDevice getFirstDevice(List<MidiDeviceProvider> providers,
                                         Class<?> deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(providers, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(providers, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:openjdk-jdk10    文件:DefaultDevices.java   
public static void main(String[] args) throws Exception {
    boolean allOk = true;
    MidiDevice.Info[] infos;

    out("\nTesting MidiDevices retrieved via MidiSystem");
    infos = MidiSystem.getMidiDeviceInfo();
    allOk &= testDevices(infos, null);

    out("\nTesting MidiDevices retrieved from MidiDeviceProviders");
    List providers = JDK13Services.getProviders(MidiDeviceProvider.class);
    for (int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider)providers.get(i);
        infos = provider.getDeviceInfo();
        allOk &= testDevices(infos, provider.getClass().getName());
    }

    if (!allOk) {
        throw new Exception("Test failed");
    } else {
        out("Test passed");
    }
}
项目:openjdk-jdk10    文件:UnsupportedInfo.java   
public static void main(final String[] args) {
    final MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
    for (final MidiDeviceProvider mdp : load(MidiDeviceProvider.class)) {
        for (final MidiDevice.Info info : infos) {
            if (mdp.isDeviceSupported(info)) {
                if (mdp.getDevice(info) == null) {
                    throw new RuntimeException("MidiDevice is null");
                }
            } else {
                try {
                    mdp.getDevice(info);
                    throw new RuntimeException(
                            "IllegalArgumentException expected");
                } catch (final IllegalArgumentException ignored) {
                    // expected
                }
            }
        }
    }
}
项目:openjdk9    文件:JDK13Services.java   
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
项目:openjdk9    文件:MidiSystem.java   
/**
 * Return a MidiDevice with a given name from a given MidiDeviceProvider.
 *
 * @param  deviceName The name of the MidiDevice to be returned
 * @param  provider The MidiDeviceProvider to check for MidiDevices
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A MidiDevice matching the requirements, or null if none is found
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class<?> deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, provider, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, provider, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:openjdk9    文件:MidiSystem.java   
/**
 * Return a MidiDevice with a given name from a given MidiDeviceProvider.
 *
 * @param  deviceName The name of the MidiDevice to be returned
 * @param  provider The MidiDeviceProvider to check for MidiDevices
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A MidiDevice matching the requirements, or null if none is found
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class<?> deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
项目:openjdk9    文件:MidiSystem.java   
/**
 * Return a MidiDevice with a given name from a list of MidiDeviceProviders.
 *
 * @param  deviceName The name of the MidiDevice to be returned
 * @param  providers The List of MidiDeviceProviders to check for
 *         MidiDevices
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A Mixer matching the requirements, or null if none is found
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         List<MidiDeviceProvider> providers,
                                         Class<?> deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, providers, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, providers, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:openjdk9    文件:MidiSystem.java   
/**
 * Return a MidiDevice with a given name from a list of MidiDeviceProviders.
 *
 * @param  deviceName The name of the MidiDevice to be returned
 * @param  providers The List of MidiDeviceProviders to check for
 *         MidiDevices
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A Mixer matching the requirements, or null if none is found
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         List<MidiDeviceProvider> providers,
                                         Class<?> deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = providers.get(i);
        MidiDevice device = getNamedDevice(deviceName, provider,
                                           deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
项目:openjdk9    文件:MidiSystem.java   
/**
 * From a given MidiDeviceProvider, return the first appropriate device.
 *
 * @param  provider The MidiDeviceProvider to check for MidiDevices
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A MidiDevice is considered appropriate, or null if no appropriate
 *         device is found
 */
private static MidiDevice getFirstDevice(MidiDeviceProvider provider,
                                         Class<?> deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(provider, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(provider, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:openjdk9    文件:MidiSystem.java   
/**
 * From a List of MidiDeviceProviders, return the first appropriate
 * MidiDevice.
 *
 * @param  providers The List of MidiDeviceProviders to search
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A MidiDevice that is considered appropriate, or null if none is
 *         found
 */
private static MidiDevice getFirstDevice(List<MidiDeviceProvider> providers,
                                         Class<?> deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(providers, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(providers, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:openjdk9    文件:MidiSystem.java   
/**
 * From a List of MidiDeviceProviders, return the first appropriate
 * MidiDevice.
 *
 * @param  providers The List of MidiDeviceProviders to search
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return A MidiDevice that is considered appropriate, or null if none is
 *         found
 */
private static MidiDevice getFirstDevice(List<MidiDeviceProvider> providers,
                                         Class<?> deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = providers.get(i);
        MidiDevice device = getFirstDevice(provider, deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
项目:openjdk9    文件:UnsupportedInfo.java   
public static void main(final String[] args) {
    final MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
    for (final MidiDeviceProvider mdp : load(MidiDeviceProvider.class)) {
        for (final MidiDevice.Info info : infos) {
            if (mdp.isDeviceSupported(info)) {
                if (mdp.getDevice(info) == null) {
                    throw new RuntimeException("MidiDevice is null");
                }
            } else {
                try {
                    mdp.getDevice(info);
                    throw new RuntimeException(
                            "IllegalArgumentException expected");
                } catch (final IllegalArgumentException ignored) {
                    // expected
                }
            }
        }
    }
}
项目:Java8CN    文件:MidiSystem.java   
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
    @param deviceName The name of the MidiDevice to be returned.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.

    @return A MidiDevice matching the requirements, or null if none is found.
*/
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, provider, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, provider, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:Java8CN    文件:MidiSystem.java   
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
项目:Java8CN    文件:MidiSystem.java   
/** Return a MidiDevice with a given name from a list of
    MidiDeviceProviders.
    @param deviceName The name of the MidiDevice to be returned.
    @param providers The List of MidiDeviceProviders to check for
    MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A Mixer matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getNamedDevice(deviceName, provider,
                                           deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
项目:Java8CN    文件:MidiSystem.java   
/** From a given MidiDeviceProvider, return the first appropriate device.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice is considered appropriate, or null if no
    appropriate device is found.
*/
private static MidiDevice getFirstDevice(MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(provider, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(provider, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:Java8CN    文件:MidiSystem.java   
/** From a List of MidiDeviceProviders, return the first appropriate
    MidiDevice.
    @param providers The List of MidiDeviceProviders to search.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice that is considered appropriate, or null
    if none is found.
 */
private static MidiDevice getFirstDevice(List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getFirstDevice(provider, deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
项目:jdk8u_jdk    文件:JDK13Services.java   
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
项目:jdk8u_jdk    文件:MidiSystem.java   
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
    @param deviceName The name of the MidiDevice to be returned.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.

    @return A MidiDevice matching the requirements, or null if none is found.
*/
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getNamedDevice(deviceName, provider, deviceClass,
                             false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getNamedDevice(deviceName, provider, deviceClass,
                                 true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:jdk8u_jdk    文件:MidiSystem.java   
/** Return a MidiDevice with a given name from a given MidiDeviceProvider.
  @param deviceName The name of the MidiDevice to be returned.
  @param provider The MidiDeviceProvider to check for MidiDevices.
  @param deviceClass The requested device type, one of Synthesizer.class,
  Sequencer.class, Receiver.class or Transmitter.class.

  @return A MidiDevice matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         MidiDeviceProvider provider,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    MidiDevice.Info[] infos = provider.getDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
        if (infos[i].getName().equals(deviceName)) {
            MidiDevice device = provider.getDevice(infos[i]);
            if (isAppropriateDevice(device, deviceClass,
                                    allowSynthesizer, allowSequencer)) {
                return device;
            }
        }
    }
    return null;
}
项目:jdk8u_jdk    文件:MidiSystem.java   
/** Return a MidiDevice with a given name from a list of
    MidiDeviceProviders.
    @param deviceName The name of the MidiDevice to be returned.
    @param providers The List of MidiDeviceProviders to check for
    MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A Mixer matching the requirements, or null if none is found.
 */
private static MidiDevice getNamedDevice(String deviceName,
                                         List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getNamedDevice(deviceName, provider,
                                           deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
项目:jdk8u_jdk    文件:MidiSystem.java   
/** From a given MidiDeviceProvider, return the first appropriate device.
    @param provider The MidiDeviceProvider to check for MidiDevices.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice is considered appropriate, or null if no
    appropriate device is found.
*/
private static MidiDevice getFirstDevice(MidiDeviceProvider provider,
                                         Class deviceClass) {
    MidiDevice device;
    // try to get MIDI port
    device = getFirstDevice(provider, deviceClass,
                            false, false);
    if (device != null) {
        return device;
    }

    if (deviceClass == Receiver.class) {
        // try to get Synthesizer
        device = getFirstDevice(provider, deviceClass,
                                true, false);
        if (device != null) {
            return device;
        }
    }

    return null;
}
项目:jdk8u_jdk    文件:MidiSystem.java   
/** From a List of MidiDeviceProviders, return the first appropriate
    MidiDevice.
    @param providers The List of MidiDeviceProviders to search.
    @param deviceClass The requested device type, one of Synthesizer.class,
    Sequencer.class, Receiver.class or Transmitter.class.
    @return A MidiDevice that is considered appropriate, or null
    if none is found.
 */
private static MidiDevice getFirstDevice(List providers,
                                         Class deviceClass,
                                         boolean allowSynthesizer,
                                         boolean allowSequencer) {
    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        MidiDevice device = getFirstDevice(provider, deviceClass,
                                           allowSynthesizer,
                                           allowSequencer);
        if (device != null) {
            return device;
        }
    }
    return null;
}
项目:lookaside_java-1.8.0-openjdk    文件:JDK13Services.java   
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}