com.sun.media.sound.JDK13Services Java Examples

The following examples show how to use com.sun.media.sound.JDK13Services. 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: DefaultDevices.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #2
Source File: ProviderCacheing.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    boolean allCached = true;
    for (int i = 0; i < providerClasses.length; i++) {
        List list0 = JDK13Services.getProviders(providerClasses[i]);
        List list1 = JDK13Services.getProviders(providerClasses[i]);
        if (list0 == list1) {
            out("Providers should not be cached for " + providerClasses[i]);
            allCached = false;
        }
    }

    if (! allCached) {
        throw new Exception("Test failed");
    } else {
        out("Test passed");
    }
}
 
Example #3
Source File: ProviderCacheing.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    boolean allCached = true;
    for (int i = 0; i < providerClasses.length; i++) {
        List list0 = JDK13Services.getProviders(providerClasses[i]);
        List list1 = JDK13Services.getProviders(providerClasses[i]);
        if (list0 == list1) {
            out("Providers should not be cached for " + providerClasses[i]);
            allCached = false;
        }
    }

    if (! allCached) {
        throw new Exception("Test failed");
    } else {
        out("Test passed");
    }
}
 
Example #4
Source File: DefaultMixers.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    boolean allOk = true;
    Mixer.Info[] infos;

    out("Testing Mixers retrieved via AudioSystem");
    infos = AudioSystem.getMixerInfo();
    allOk &= testMixers(infos, null);

    out("Testing MixerProviders");
    List providers = JDK13Services.getProviders(MixerProvider.class);
    for (int i = 0; i < providers.size(); i++) {
        MixerProvider provider = (MixerProvider) providers.get(i);
        infos = provider.getMixerInfo();
        allOk &= testMixers(infos, provider.getClass().getName());
    }

    if (! allOk) {
        throw new Exception("Test failed");
    } else {
        out("Test passed");
    }
}
 
Example #5
Source File: AudioSystem.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default Mixer that provides lines
 * of the specified type.
 *
 * @param providers the installed mixer providers
 * @param info The requested line type
 * TargetDataLine.class, Clip.class or Port.class.
 * @return a Mixer that matches the requirements, or null if no default mixer found
 */
private static Mixer getDefaultMixer(List providers, Line.Info info) {
    Class lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #6
Source File: MidiSystem.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default MidiDevice of the specified
 * type.
 *
 * @param deviceClass The requested device type, one of Synthesizer.class,
 * Sequencer.class, Receiver.class or Transmitter.class.
 * @throws  IllegalArgumentException on failure.
 */
private static MidiDevice getDefaultDevice(Class deviceClass) {
    List providers = getMidiDeviceProviders();
    String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass);
    String instanceName = JDK13Services.getDefaultInstanceName(deviceClass);
    MidiDevice device;

    if (providerClassName != null) {
        MidiDeviceProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                device = getNamedDevice(instanceName, defaultProvider, deviceClass);
                if (device != null) {
                    return device;
                }
            }
            device = getFirstDevice(defaultProvider, deviceClass);
            if (device != null) {
                return device;
            }
        }
    }

    /* Provider class not specified or cannot be found, or
       provider class specified, and no appropriate device available or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        device = getNamedDevice(instanceName, providers, deviceClass);
        if (device != null) {
            return device;
        }
    }

    /* No default are specified, or if something is specified, everything
       failed. */
    device = getFirstDevice(providers, deviceClass);
    if (device != null) {
        return device;
    }
    throw new IllegalArgumentException("Requested device not installed");
}
 
Example #7
Source File: AudioSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default Mixer that provides lines
 * of the specified type.
 *
 * @param providers the installed mixer providers
 * @param info The requested line type
 * TargetDataLine.class, Clip.class or Port.class.
 * @return a Mixer that matches the requirements, or null if no default mixer found
 */
private static Mixer getDefaultMixer(List providers, Line.Info info) {
    Class lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #8
Source File: MidiSystem.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default MidiDevice of the specified
 * type.
 *
 * @param deviceClass The requested device type, one of Synthesizer.class,
 * Sequencer.class, Receiver.class or Transmitter.class.
 * @throws  IllegalArgumentException on failure.
 */
private static MidiDevice getDefaultDevice(Class deviceClass) {
    List providers = getMidiDeviceProviders();
    String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass);
    String instanceName = JDK13Services.getDefaultInstanceName(deviceClass);
    MidiDevice device;

    if (providerClassName != null) {
        MidiDeviceProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                device = getNamedDevice(instanceName, defaultProvider, deviceClass);
                if (device != null) {
                    return device;
                }
            }
            device = getFirstDevice(defaultProvider, deviceClass);
            if (device != null) {
                return device;
            }
        }
    }

    /* Provider class not specified or cannot be found, or
       provider class specified, and no appropriate device available or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        device = getNamedDevice(instanceName, providers, deviceClass);
        if (device != null) {
            return device;
        }
    }

    /* No default are specified, or if something is specified, everything
       failed. */
    device = getFirstDevice(providers, deviceClass);
    if (device != null) {
        return device;
    }
    throw new IllegalArgumentException("Requested device not installed");
}
 
Example #9
Source File: AudioSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default Mixer that provides lines
 * of the specified type.
 *
 * @param providers the installed mixer providers
 * @param info The requested line type
 * TargetDataLine.class, Clip.class or Port.class.
 * @return a Mixer that matches the requirements, or null if no default mixer found
 */
private static Mixer getDefaultMixer(List providers, Line.Info info) {
    Class lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #10
Source File: AudioSystem.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default Mixer that provides lines
 * of the specified type.
 *
 * @param providers the installed mixer providers
 * @param info The requested line type
 * TargetDataLine.class, Clip.class or Port.class.
 * @return a Mixer that matches the requirements, or null if no default mixer found
 */
private static Mixer getDefaultMixer(List providers, Line.Info info) {
    Class lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #11
Source File: AudioSystem.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default Mixer that provides lines
 * of the specified type.
 *
 * @param providers the installed mixer providers
 * @param info The requested line type
 * TargetDataLine.class, Clip.class or Port.class.
 * @return a Mixer that matches the requirements, or null if no default mixer found
 */
private static Mixer getDefaultMixer(List providers, Line.Info info) {
    Class lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #12
Source File: AudioSystem.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default Mixer that provides lines
 * of the specified type.
 *
 * @param providers the installed mixer providers
 * @param info The requested line type
 * TargetDataLine.class, Clip.class or Port.class.
 * @return a Mixer that matches the requirements, or null if no default mixer found
 */
private static Mixer getDefaultMixer(List providers, Line.Info info) {
    Class lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #13
Source File: MidiSystem.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default MidiDevice of the specified
 * type.
 *
 * @param deviceClass The requested device type, one of Synthesizer.class,
 * Sequencer.class, Receiver.class or Transmitter.class.
 * @throws  IllegalArgumentException on failure.
 */
private static MidiDevice getDefaultDevice(Class deviceClass) {
    List providers = getMidiDeviceProviders();
    String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass);
    String instanceName = JDK13Services.getDefaultInstanceName(deviceClass);
    MidiDevice device;

    if (providerClassName != null) {
        MidiDeviceProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                device = getNamedDevice(instanceName, defaultProvider, deviceClass);
                if (device != null) {
                    return device;
                }
            }
            device = getFirstDevice(defaultProvider, deviceClass);
            if (device != null) {
                return device;
            }
        }
    }

    /* Provider class not specified or cannot be found, or
       provider class specified, and no appropriate device available or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        device = getNamedDevice(instanceName, providers, deviceClass);
        if (device != null) {
            return device;
        }
    }

    /* No default are specified, or if something is specified, everything
       failed. */
    device = getFirstDevice(providers, deviceClass);
    if (device != null) {
        return device;
    }
    throw new IllegalArgumentException("Requested device not installed");
}
 
Example #14
Source File: MidiSystem.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default MidiDevice of the specified
 * type.
 *
 * @param deviceClass The requested device type, one of Synthesizer.class,
 * Sequencer.class, Receiver.class or Transmitter.class.
 * @throws  IllegalArgumentException on failure.
 */
private static MidiDevice getDefaultDevice(Class deviceClass) {
    List providers = getMidiDeviceProviders();
    String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass);
    String instanceName = JDK13Services.getDefaultInstanceName(deviceClass);
    MidiDevice device;

    if (providerClassName != null) {
        MidiDeviceProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                device = getNamedDevice(instanceName, defaultProvider, deviceClass);
                if (device != null) {
                    return device;
                }
            }
            device = getFirstDevice(defaultProvider, deviceClass);
            if (device != null) {
                return device;
            }
        }
    }

    /* Provider class not specified or cannot be found, or
       provider class specified, and no appropriate device available or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        device = getNamedDevice(instanceName, providers, deviceClass);
        if (device != null) {
            return device;
        }
    }

    /* No default are specified, or if something is specified, everything
       failed. */
    device = getFirstDevice(providers, deviceClass);
    if (device != null) {
        return device;
    }
    throw new IllegalArgumentException("Requested device not installed");
}
 
Example #15
Source File: AudioSystem.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default Mixer that provides lines
 * of the specified type.
 *
 * @param providers the installed mixer providers
 * @param info The requested line type
 * TargetDataLine.class, Clip.class or Port.class.
 * @return a Mixer that matches the requirements, or null if no default mixer found
 */
private static Mixer getDefaultMixer(List providers, Line.Info info) {
    Class lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #16
Source File: MidiSystem.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/** Attempts to locate and return a default MidiDevice of the specified
 * type.
 *
 * @param deviceClass The requested device type, one of Synthesizer.class,
 * Sequencer.class, Receiver.class or Transmitter.class.
 * @throws  IllegalArgumentException on failure.
 */
private static MidiDevice getDefaultDevice(Class deviceClass) {
    List providers = getMidiDeviceProviders();
    String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass);
    String instanceName = JDK13Services.getDefaultInstanceName(deviceClass);
    MidiDevice device;

    if (providerClassName != null) {
        MidiDeviceProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                device = getNamedDevice(instanceName, defaultProvider, deviceClass);
                if (device != null) {
                    return device;
                }
            }
            device = getFirstDevice(defaultProvider, deviceClass);
            if (device != null) {
                return device;
            }
        }
    }

    /* Provider class not specified or cannot be found, or
       provider class specified, and no appropriate device available or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        device = getNamedDevice(instanceName, providers, deviceClass);
        if (device != null) {
            return device;
        }
    }

    /* No default are specified, or if something is specified, everything
       failed. */
    device = getFirstDevice(providers, deviceClass);
    if (device != null) {
        return device;
    }
    throw new IllegalArgumentException("Requested device not installed");
}
 
Example #17
Source File: AudioSystem.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/** Attempts to locate and return a default Mixer that provides lines
 * of the specified type.
 *
 * @param providers the installed mixer providers
 * @param info The requested line type
 * TargetDataLine.class, Clip.class or Port.class.
 * @return a Mixer that matches the requirements, or null if no default mixer found
 */
private static Mixer getDefaultMixer(List providers, Line.Info info) {
    Class lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #18
Source File: MidiSystem.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Attempts to locate and return a default MidiDevice of the specified type.
 *
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @return default MidiDevice of the specified type.
 * @throws IllegalArgumentException on failure
 */
private static MidiDevice getDefaultDevice(Class<?> deviceClass) {
    List<MidiDeviceProvider> providers = getMidiDeviceProviders();
    String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass);
    String instanceName = JDK13Services.getDefaultInstanceName(deviceClass);
    MidiDevice device;

    if (providerClassName != null) {
        MidiDeviceProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                device = getNamedDevice(instanceName, defaultProvider, deviceClass);
                if (device != null) {
                    return device;
                }
            }
            device = getFirstDevice(defaultProvider, deviceClass);
            if (device != null) {
                return device;
            }
        }
    }

    /*
     *  - Provider class not specified or cannot be found, or
     *  - provider class specified, and no appropriate device available, or
     *  - provider class and instance specified and instance cannot be found
     *    or is not appropriate
     */
    if (instanceName != null) {
        device = getNamedDevice(instanceName, providers, deviceClass);
        if (device != null) {
            return device;
        }
    }

    /*
     * No defaults are specified, or if something is specified, everything
     * failed
     */
    device = getFirstDevice(providers, deviceClass);
    if (device != null) {
        return device;
    }
    throw new IllegalArgumentException("Requested device not installed");
}
 
Example #19
Source File: AudioSystem.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Attempts to locate and return a default Mixer that provides lines of the
 * specified type.
 *
 * @param  providers the installed mixer providers
 * @param  info The requested line type TargetDataLine.class, Clip.class or
 *         Port.class
 * @return a Mixer that matches the requirements, or null if no default
 *         mixer found
 */
private static Mixer getDefaultMixer(List<MixerProvider> providers, Line.Info info) {
    Class<?> lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /*
     *  - Provider class not specified, or
     *  - provider class cannot be found, or
     *  - provider class and instance specified and instance cannot be found
     *    or is not appropriate
     */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /*
     * No defaults are specified, or if something is specified, everything
     * failed
     */
    return null;
}
 
Example #20
Source File: MidiSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default MidiDevice of the specified
 * type.
 *
 * @param deviceClass The requested device type, one of Synthesizer.class,
 * Sequencer.class, Receiver.class or Transmitter.class.
 * @throws  IllegalArgumentException on failure.
 */
private static MidiDevice getDefaultDevice(Class deviceClass) {
    List providers = getMidiDeviceProviders();
    String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass);
    String instanceName = JDK13Services.getDefaultInstanceName(deviceClass);
    MidiDevice device;

    if (providerClassName != null) {
        MidiDeviceProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                device = getNamedDevice(instanceName, defaultProvider, deviceClass);
                if (device != null) {
                    return device;
                }
            }
            device = getFirstDevice(defaultProvider, deviceClass);
            if (device != null) {
                return device;
            }
        }
    }

    /* Provider class not specified or cannot be found, or
       provider class specified, and no appropriate device available or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        device = getNamedDevice(instanceName, providers, deviceClass);
        if (device != null) {
            return device;
        }
    }

    /* No default are specified, or if something is specified, everything
       failed. */
    device = getFirstDevice(providers, deviceClass);
    if (device != null) {
        return device;
    }
    throw new IllegalArgumentException("Requested device not installed");
}
 
Example #21
Source File: MidiSystem.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Attempts to locate and return a default MidiDevice of the specified type.
 *
 * @param  deviceClass The requested device type, one of Synthesizer.class,
 *         Sequencer.class, Receiver.class or Transmitter.class
 * @throws IllegalArgumentException on failure
 */
private static MidiDevice getDefaultDevice(Class<?> deviceClass) {
    List<MidiDeviceProvider> providers = getMidiDeviceProviders();
    String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass);
    String instanceName = JDK13Services.getDefaultInstanceName(deviceClass);
    MidiDevice device;

    if (providerClassName != null) {
        MidiDeviceProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                device = getNamedDevice(instanceName, defaultProvider, deviceClass);
                if (device != null) {
                    return device;
                }
            }
            device = getFirstDevice(defaultProvider, deviceClass);
            if (device != null) {
                return device;
            }
        }
    }

    /* Provider class not specified or cannot be found, or
       provider class specified, and no appropriate device available or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        device = getNamedDevice(instanceName, providers, deviceClass);
        if (device != null) {
            return device;
        }
    }

    /* No default are specified, or if something is specified, everything
       failed. */
    device = getFirstDevice(providers, deviceClass);
    if (device != null) {
        return device;
    }
    throw new IllegalArgumentException("Requested device not installed");
}
 
Example #22
Source File: AudioSystem.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Attempts to locate and return a default Mixer that provides lines of the
 * specified type.
 *
 * @param  providers the installed mixer providers
 * @param  info The requested line type TargetDataLine.class, Clip.class or
 *         Port.class
 * @return a Mixer that matches the requirements, or null if no default
 *         mixer found
 */
private static Mixer getDefaultMixer(List<MixerProvider> providers, Line.Info info) {
    Class<?> lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #23
Source File: AudioSystem.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default Mixer that provides lines
 * of the specified type.
 *
 * @param providers the installed mixer providers
 * @param info The requested line type
 * TargetDataLine.class, Clip.class or Port.class.
 * @return a Mixer that matches the requirements, or null if no default mixer found
 */
private static Mixer getDefaultMixer(List providers, Line.Info info) {
    Class lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #24
Source File: MidiSystem.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default MidiDevice of the specified
 * type.
 *
 * @param deviceClass The requested device type, one of Synthesizer.class,
 * Sequencer.class, Receiver.class or Transmitter.class.
 * @throws  IllegalArgumentException on failure.
 */
private static MidiDevice getDefaultDevice(Class deviceClass) {
    List providers = getMidiDeviceProviders();
    String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass);
    String instanceName = JDK13Services.getDefaultInstanceName(deviceClass);
    MidiDevice device;

    if (providerClassName != null) {
        MidiDeviceProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                device = getNamedDevice(instanceName, defaultProvider, deviceClass);
                if (device != null) {
                    return device;
                }
            }
            device = getFirstDevice(defaultProvider, deviceClass);
            if (device != null) {
                return device;
            }
        }
    }

    /* Provider class not specified or cannot be found, or
       provider class specified, and no appropriate device available or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        device = getNamedDevice(instanceName, providers, deviceClass);
        if (device != null) {
            return device;
        }
    }

    /* No default are specified, or if something is specified, everything
       failed. */
    device = getFirstDevice(providers, deviceClass);
    if (device != null) {
        return device;
    }
    throw new IllegalArgumentException("Requested device not installed");
}
 
Example #25
Source File: AudioSystem.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default Mixer that provides lines
 * of the specified type.
 *
 * @param providers the installed mixer providers
 * @param info The requested line type
 * TargetDataLine.class, Clip.class or Port.class.
 * @return a Mixer that matches the requirements, or null if no default mixer found
 */
private static Mixer getDefaultMixer(List providers, Line.Info info) {
    Class lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #26
Source File: MidiSystem.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default MidiDevice of the specified
 * type.
 *
 * @param deviceClass The requested device type, one of Synthesizer.class,
 * Sequencer.class, Receiver.class or Transmitter.class.
 * @throws  IllegalArgumentException on failure.
 */
private static MidiDevice getDefaultDevice(Class deviceClass) {
    List providers = getMidiDeviceProviders();
    String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass);
    String instanceName = JDK13Services.getDefaultInstanceName(deviceClass);
    MidiDevice device;

    if (providerClassName != null) {
        MidiDeviceProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                device = getNamedDevice(instanceName, defaultProvider, deviceClass);
                if (device != null) {
                    return device;
                }
            }
            device = getFirstDevice(defaultProvider, deviceClass);
            if (device != null) {
                return device;
            }
        }
    }

    /* Provider class not specified or cannot be found, or
       provider class specified, and no appropriate device available or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        device = getNamedDevice(instanceName, providers, deviceClass);
        if (device != null) {
            return device;
        }
    }

    /* No default are specified, or if something is specified, everything
       failed. */
    device = getFirstDevice(providers, deviceClass);
    if (device != null) {
        return device;
    }
    throw new IllegalArgumentException("Requested device not installed");
}
 
Example #27
Source File: MidiSystem.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/** Attempts to locate and return a default MidiDevice of the specified
 * type.
 *
 * @param deviceClass The requested device type, one of Synthesizer.class,
 * Sequencer.class, Receiver.class or Transmitter.class.
 * @throws  IllegalArgumentException on failure.
 */
private static MidiDevice getDefaultDevice(Class deviceClass) {
    List providers = getMidiDeviceProviders();
    String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass);
    String instanceName = JDK13Services.getDefaultInstanceName(deviceClass);
    MidiDevice device;

    if (providerClassName != null) {
        MidiDeviceProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                device = getNamedDevice(instanceName, defaultProvider, deviceClass);
                if (device != null) {
                    return device;
                }
            }
            device = getFirstDevice(defaultProvider, deviceClass);
            if (device != null) {
                return device;
            }
        }
    }

    /* Provider class not specified or cannot be found, or
       provider class specified, and no appropriate device available or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        device = getNamedDevice(instanceName, providers, deviceClass);
        if (device != null) {
            return device;
        }
    }

    /* No default are specified, or if something is specified, everything
       failed. */
    device = getFirstDevice(providers, deviceClass);
    if (device != null) {
        return device;
    }
    throw new IllegalArgumentException("Requested device not installed");
}
 
Example #28
Source File: AudioSystem.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/** Attempts to locate and return a default Mixer that provides lines
 * of the specified type.
 *
 * @param providers the installed mixer providers
 * @param info The requested line type
 * TargetDataLine.class, Clip.class or Port.class.
 * @return a Mixer that matches the requirements, or null if no default mixer found
 */
private static Mixer getDefaultMixer(List providers, Line.Info info) {
    Class lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #29
Source File: AudioSystem.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default Mixer that provides lines
 * of the specified type.
 *
 * @param providers the installed mixer providers
 * @param info The requested line type
 * TargetDataLine.class, Clip.class or Port.class.
 * @return a Mixer that matches the requirements, or null if no default mixer found
 */
private static Mixer getDefaultMixer(List providers, Line.Info info) {
    Class lineClass = info.getLineClass();
    String providerClassName = JDK13Services.getDefaultProviderClassName(lineClass);
    String instanceName = JDK13Services.getDefaultInstanceName(lineClass);
    Mixer mixer;

    if (providerClassName != null) {
        MixerProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                mixer = getNamedMixer(instanceName, defaultProvider, info);
                if (mixer != null) {
                    return mixer;
                }
            } else {
                mixer = getFirstMixer(defaultProvider, info,
                                      false /* mixing not required*/);
                if (mixer != null) {
                    return mixer;
                }
            }

        }
    }

    /* Provider class not specified or
       provider class cannot be found, or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        mixer = getNamedMixer(instanceName, providers, info);
        if (mixer != null) {
            return mixer;
        }
    }


    /* No default are specified, or if something is specified, everything
       failed. */
    return null;
}
 
Example #30
Source File: MidiSystem.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/** Attempts to locate and return a default MidiDevice of the specified
 * type.
 *
 * @param deviceClass The requested device type, one of Synthesizer.class,
 * Sequencer.class, Receiver.class or Transmitter.class.
 * @throws  IllegalArgumentException on failure.
 */
private static MidiDevice getDefaultDevice(Class deviceClass) {
    List providers = getMidiDeviceProviders();
    String providerClassName = JDK13Services.getDefaultProviderClassName(deviceClass);
    String instanceName = JDK13Services.getDefaultInstanceName(deviceClass);
    MidiDevice device;

    if (providerClassName != null) {
        MidiDeviceProvider defaultProvider = getNamedProvider(providerClassName, providers);
        if (defaultProvider != null) {
            if (instanceName != null) {
                device = getNamedDevice(instanceName, defaultProvider, deviceClass);
                if (device != null) {
                    return device;
                }
            }
            device = getFirstDevice(defaultProvider, deviceClass);
            if (device != null) {
                return device;
            }
        }
    }

    /* Provider class not specified or cannot be found, or
       provider class specified, and no appropriate device available or
       provider class and instance specified and instance cannot be found or is not appropriate */
    if (instanceName != null) {
        device = getNamedDevice(instanceName, providers, deviceClass);
        if (device != null) {
            return device;
        }
    }

    /* No default are specified, or if something is specified, everything
       failed. */
    device = getFirstDevice(providers, deviceClass);
    if (device != null) {
        return device;
    }
    throw new IllegalArgumentException("Requested device not installed");
}