Path: blob/master/src/java.desktop/share/classes/javax/sound/sampled/spi/MixerProvider.java
41161 views
/*1* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.sound.sampled.spi;2627import java.util.Arrays;2829import javax.sound.sampled.Mixer;3031/**32* A provider or factory for a particular mixer type. This mechanism allows the33* implementation to determine how resources are managed in creation /34* management of a mixer.35*36* @author Kara Kytle37* @since 1.338*/39public abstract class MixerProvider {4041/**42* Constructor for subclasses to call.43*/44protected MixerProvider() {}4546/**47* Indicates whether the mixer provider supports the mixer represented by48* the specified mixer info object.49* <p>50* The full set of mixer info objects that represent the mixers supported by51* this {@code MixerProvider} may be obtained through the52* {@code getMixerInfo} method.53*54* @param info an info object that describes the mixer for which support is55* queried56* @return {@code true} if the specified mixer is supported, otherwise57* {@code false}58* @throws NullPointerException if {@code info} is {@code null}59* @see #getMixerInfo()60*/61public boolean isMixerSupported(final Mixer.Info info) {62return Arrays.stream(getMixerInfo()).anyMatch(info::equals);63}6465/**66* Obtains the set of info objects representing the mixer or mixers provided67* by this MixerProvider.68* <p>69* The {@code isMixerSupported} method returns {@code true} for all the info70* objects returned by this method. The corresponding mixer instances for71* the info objects are returned by the {@code getMixer} method.72*73* @return a set of mixer info objects74* @see #getMixer(Mixer.Info)75* @see #isMixerSupported(Mixer.Info)76*/77public abstract Mixer.Info[] getMixerInfo();7879/**80* Obtains an instance of the mixer represented by the info object. If81* {@code null} is passed, then the default mixer will be returned.82* <p>83* The full set of the mixer info objects that represent the mixers84* supported by this {@code MixerProvider} may be obtained through the85* {@code getMixerInfo} method. Use the {@code isMixerSupported} method to86* test whether this {@code MixerProvider} supports a particular mixer.87*88* @param info an info object that describes the desired mixer, or89* {@code null} for the default mixer90* @return mixer instance91* @throws IllegalArgumentException if the info object specified does not92* match the info object for a mixer supported by this93* {@code MixerProvider}, or if this {@code MixerProvider} does not94* have default mixer, but default mixer has been requested95* @see #getMixerInfo()96* @see #isMixerSupported(Mixer.Info)97*/98public abstract Mixer getMixer(Mixer.Info info);99}100101102