Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/sound/sampled/Mixer.java
38918 views
/*1* Copyright (c) 1999, 2013, 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;262728/**29* A mixer is an audio device with one or more lines. It need not be30* designed for mixing audio signals. A mixer that actually mixes audio31* has multiple input (source) lines and at least one output (target) line.32* The former are often instances of classes that implement33* <code>{@link SourceDataLine}</code>,34* and the latter, <code>{@link TargetDataLine}</code>. <code>{@link Port}</code>35* objects, too, are either source lines or target lines.36* A mixer can accept prerecorded, loopable sound as input, by having37* some of its source lines be instances of objects that implement the38* <code>{@link Clip}</code> interface.39* <p>40* Through methods of the <code>Line</code> interface, which <code>Mixer</code> extends,41* a mixer might provide a set of controls that are global to the mixer. For example,42* the mixer can have a master gain control. These global controls are distinct43* from the controls belonging to each of the mixer's individual lines.44* <p>45* Some mixers, especially46* those with internal digital mixing capabilities, may provide47* additional capabilities by implementing the <code>DataLine</code> interface.48* <p>49* A mixer can support synchronization of its lines. When one line in50* a synchronized group is started or stopped, the other lines in the group51* automatically start or stop simultaneously with the explicitly affected one.52*53* @author Kara Kytle54* @since 1.355*/56public interface Mixer extends Line {5758/**59* Obtains information about this mixer, including the product's name,60* version, vendor, etc.61* @return a mixer info object that describes this mixer62* @see Mixer.Info63*/64public Info getMixerInfo();656667/**68* Obtains information about the set of source lines supported69* by this mixer.70* Some source lines may only be available when this mixer is open.71* @return array of <code>Line.Info</code> objects representing source lines72* for this mixer. If no source lines are supported,73* an array of length 0 is returned.74*/75public Line.Info[] getSourceLineInfo();7677/**78* Obtains information about the set of target lines supported79* by this mixer.80* Some target lines may only be available when this mixer is open.81* @return array of <code>Line.Info</code> objects representing target lines82* for this mixer. If no target lines are supported,83* an array of length 0 is returned.84*/85public Line.Info[] getTargetLineInfo();868788/**89* Obtains information about source lines of a particular type supported90* by the mixer.91* Some source lines may only be available when this mixer is open.92* @param info a <code>Line.Info</code> object describing lines about which information93* is queried94* @return an array of <code>Line.Info</code> objects describing source lines matching95* the type requested. If no matching source lines are supported, an array of length 096* is returned.97*/98public Line.Info[] getSourceLineInfo(Line.Info info);99100101/**102* Obtains information about target lines of a particular type supported103* by the mixer.104* Some target lines may only be available when this mixer is open.105* @param info a <code>Line.Info</code> object describing lines about which information106* is queried107* @return an array of <code>Line.Info</code> objects describing target lines matching108* the type requested. If no matching target lines are supported, an array of length 0109* is returned.110*/111public Line.Info[] getTargetLineInfo(Line.Info info);112113114/**115* Indicates whether the mixer supports a line (or lines) that match116* the specified <code>Line.Info</code> object.117* Some lines may only be supported when this mixer is open.118* @param info describes the line for which support is queried119* @return <code>true</code> if at least one matching line is120* supported, <code>false</code> otherwise121*/122public boolean isLineSupported(Line.Info info);123124/**125* Obtains a line that is available for use and that matches the description126* in the specified <code>Line.Info</code> object.127*128* <p>If a <code>DataLine</code> is requested, and <code>info</code>129* is an instance of <code>DataLine.Info</code> specifying at130* least one fully qualified audio format, the last one131* will be used as the default format of the returned132* <code>DataLine</code>.133*134* @param info describes the desired line135* @return a line that is available for use and that matches the description136* in the specified {@code Line.Info} object137* @throws LineUnavailableException if a matching line138* is not available due to resource restrictions139* @throws IllegalArgumentException if this mixer does140* not support any lines matching the description141* @throws SecurityException if a matching line142* is not available due to security restrictions143*/144public Line getLine(Line.Info info) throws LineUnavailableException;145146//$$fb 2002-04-12: fix for 4667258: behavior of Mixer.getMaxLines(Line.Info) method doesn't match the spec147/**148* Obtains the approximate maximum number of lines of the requested type that can be open149* simultaneously on the mixer.150*151* Certain types of mixers do not have a hard bound and may allow opening more lines.152* Since certain lines are a shared resource, a mixer may not be able to open the maximum153* number of lines if another process has opened lines of this mixer.154*155* The requested type is any line that matches the description in156* the provided <code>Line.Info</code> object. For example, if the info157* object represents a speaker158* port, and the mixer supports exactly one speaker port, this method159* should return 1. If the info object represents a source data line160* and the mixer supports the use of 32 source data lines simultaneously,161* the return value should be 32.162* If there is no limit, this function returns <code>AudioSystem.NOT_SPECIFIED</code>.163* @param info a <code>Line.Info</code> that describes the line for which164* the number of supported instances is queried165* @return the maximum number of matching lines supported, or <code>AudioSystem.NOT_SPECIFIED</code>166*/167public int getMaxLines(Line.Info info);168169170/**171* Obtains the set of all source lines currently open to this mixer.172*173* @return the source lines currently open to the mixer.174* If no source lines are currently open to this mixer, an175* array of length 0 is returned.176* @throws SecurityException if the matching lines177* are not available due to security restrictions178*/179public Line[] getSourceLines();180181/**182* Obtains the set of all target lines currently open from this mixer.183*184* @return target lines currently open from the mixer.185* If no target lines are currently open from this mixer, an186* array of length 0 is returned.187* @throws SecurityException if the matching lines188* are not available due to security restrictions189*/190public Line[] getTargetLines();191192/**193* Synchronizes two or more lines. Any subsequent command that starts or stops194* audio playback or capture for one of these lines will exert the195* same effect on the other lines in the group, so that they start or stop playing or196* capturing data simultaneously.197*198* @param lines the lines that should be synchronized199* @param maintainSync <code>true</code> if the synchronization200* must be precisely maintained (i.e., the synchronization must be sample-accurate)201* at all times during operation of the lines , or <code>false</code>202* if precise synchronization is required only during start and stop operations203*204* @throws IllegalArgumentException if the lines cannot be synchronized.205* This may occur if the lines are of different types or have different206* formats for which this mixer does not support synchronization, or if207* all lines specified do not belong to this mixer.208*/209public void synchronize(Line[] lines, boolean maintainSync);210211/**212* Releases synchronization for the specified lines. The array must213* be identical to one for which synchronization has already been214* established; otherwise an exception may be thrown. However, <code>null</code>215* may be specified, in which case all currently synchronized lines that belong216* to this mixer are unsynchronized.217* @param lines the synchronized lines for which synchronization should be218* released, or <code>null</code> for all this mixer's synchronized lines219*220* @throws IllegalArgumentException if the lines cannot be unsynchronized.221* This may occur if the argument specified does not exactly match a set222* of lines for which synchronization has already been established.223*/224public void unsynchronize(Line[] lines);225226227/**228* Reports whether this mixer supports synchronization of the specified set of lines.229*230* @param lines the set of lines for which synchronization support is queried231* @param maintainSync <code>true</code> if the synchronization232* must be precisely maintained (i.e., the synchronization must be sample-accurate)233* at all times during operation of the lines , or <code>false</code>234* if precise synchronization is required only during start and stop operations235*236* @return <code>true</code> if the lines can be synchronized, <code>false</code>237* otherwise238*/239public boolean isSynchronizationSupported(Line[] lines, boolean maintainSync);240241242/**243* The <code>Mixer.Info</code> class represents information about an audio mixer,244* including the product's name, version, and vendor, along with a textual245* description. This information may be retrieved through the246* {@link Mixer#getMixerInfo() getMixerInfo}247* method of the <code>Mixer</code> interface.248*249* @author Kara Kytle250* @since 1.3251*/252public static class Info {253254/**255* Mixer name.256*/257private final String name;258259/**260* Mixer vendor.261*/262private final String vendor;263264/**265* Mixer description.266*/267private final String description;268269/**270* Mixer version.271*/272private final String version;273274/**275* Constructs a mixer's info object, passing it the given276* textual information.277* @param name the name of the mixer278* @param vendor the company who manufactures or creates the hardware279* or software mixer280* @param description descriptive text about the mixer281* @param version version information for the mixer282*/283protected Info(String name, String vendor, String description, String version) {284285this.name = name;286this.vendor = vendor;287this.description = description;288this.version = version;289}290291292/**293* Indicates whether two info objects are equal, returning <code>true</code> if294* they are identical.295* @param obj the reference object with which to compare this info296* object297* @return <code>true</code> if this info object is the same as the298* <code>obj</code> argument; <code>false</code> otherwise299*/300public final boolean equals(Object obj) {301return super.equals(obj);302}303304/**305* Finalizes the hashcode method.306*307* @return the hashcode for this object308*/309public final int hashCode() {310return super.hashCode();311}312313/**314* Obtains the name of the mixer.315* @return a string that names the mixer316*/317public final String getName() {318return name;319}320321/**322* Obtains the vendor of the mixer.323* @return a string that names the mixer's vendor324*/325public final String getVendor() {326return vendor;327}328329/**330* Obtains the description of the mixer.331* @return a textual description of the mixer332*/333public final String getDescription() {334return description;335}336337/**338* Obtains the version of the mixer.339* @return textual version information for the mixer340*/341public final String getVersion() {342return version;343}344345/**346* Provides a string representation of the mixer info.347* @return a string describing the info object348*/349public final String toString() {350return (name + ", version " + version);351}352} // class Info353}354355356