Java Code Examples for com.sun.media.sound.JDK13Services#getDefaultProviderClassName()

The following examples show how to use com.sun.media.sound.JDK13Services#getDefaultProviderClassName() . 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: 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 2
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 3
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 4
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 5
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");
}
 
Example 6
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 7
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 8
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 9
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 10
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 11
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 12
Source File: AudioSystem.java    From JDKSourceCode1.8 with MIT License 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 JDKSourceCode1.8 with MIT License 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: AudioSystem.java    From jdk8u60 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 15
Source File: MidiSystem.java    From jdk8u60 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 16
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 17
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 18
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 19
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 20
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;
}