Java Code Examples for javax.sound.midi.spi.MidiDeviceProvider#isDeviceSupported()

The following examples show how to use javax.sound.midi.spi.MidiDeviceProvider#isDeviceSupported() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnsupportedInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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
                }
            }
        }
    }
}
 
Example 2
Source File: MidiSystem.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 3
Source File: MidiSystem.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 4
Source File: MidiSystem.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 5
Source File: MidiSystem.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 6
Source File: MidiSystem.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 7
Source File: MidiSystem.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 8
Source File: MidiSystem.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 9
Source File: MidiSystem.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 10
Source File: MidiSystem.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 11
Source File: MidiSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 12
Source File: MidiSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 13
Source File: MidiSystem.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 14
Source File: MidiSystem.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 15
Source File: MidiSystem.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 16
Source File: MidiSystem.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param info a device information object representing the desired device.
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 * due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent
 * a MIDI device installed on the system
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException {
    List providers = getMidiDeviceProviders();

    for(int i = 0; i < providers.size(); i++) {
        MidiDeviceProvider provider = (MidiDeviceProvider) providers.get(i);
        if (provider.isDeviceSupported(info)) {
            MidiDevice device = provider.getDevice(info);
            return device;
        }
    }
    throw new IllegalArgumentException("Requested device not installed: " + info);
}
 
Example 17
Source File: MidiSystem.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param  info a device information object representing the desired device
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 *         due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent a
 *         MIDI device installed on the system
 * @throws NullPointerException if {@code info} is {@code null}
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(final MidiDevice.Info info)
        throws MidiUnavailableException {
    Objects.requireNonNull(info);
    for (final MidiDeviceProvider provider : getMidiDeviceProviders()) {
        if (provider.isDeviceSupported(info)) {
            return provider.getDevice(info);
        }
    }
    throw new IllegalArgumentException(String.format(
            "Requested device not installed: %s", info));
}
 
Example 18
Source File: MidiSystem.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Obtains the requested MIDI device.
 *
 * @param  info a device information object representing the desired device
 * @return the requested device
 * @throws MidiUnavailableException if the requested device is not available
 *         due to resource restrictions
 * @throws IllegalArgumentException if the info object does not represent a
 *         MIDI device installed on the system
 * @throws NullPointerException if {@code info} is {@code null}
 * @see #getMidiDeviceInfo
 */
public static MidiDevice getMidiDevice(final MidiDevice.Info info)
        throws MidiUnavailableException {
    Objects.requireNonNull(info);
    for (final MidiDeviceProvider provider : getMidiDeviceProviders()) {
        if (provider.isDeviceSupported(info)) {
            return provider.getDevice(info);
        }
    }
    throw new IllegalArgumentException(String.format(
            "Requested device not installed: %s", info));
}