--- old/src/share/classes/javax/sound/sampled/AudioSystem.java 2014-06-01 18:59:13.000000000 +0400 +++ new/src/share/classes/javax/sound/sampled/AudioSystem.java 2014-06-01 18:59:12.000000000 +0400 @@ -50,29 +50,24 @@ /** - * The AudioSystem class acts as the entry point to the - * sampled-audio system resources. This class lets you query and - * access the mixers that are installed on the system. - * AudioSystem includes a number of - * methods for converting audio data between different formats, and for - * translating between audio files and streams. It also provides a method - * for obtaining a {@link Line} directly from the - * AudioSystem without dealing explicitly + * The {@code AudioSystem} class acts as the entry point to the sampled-audio + * system resources. This class lets you query and access the mixers that are + * installed on the system. {@code AudioSystem} includes a number of methods for + * converting audio data between different formats, and for translating between + * audio files and streams. It also provides a method for obtaining a + * {@link Line} directly from the {@code AudioSystem} without dealing explicitly * with mixers. - * - *

Properties can be used to specify the default mixer - * for specific line types. - * Both system properties and a properties file are considered. - * The sound.properties properties file is read from - * an implementation-specific location (typically it is the lib - * directory in the Java installation directory). - * If a property exists both as a system property and in the - * properties file, the system property takes precedence. If none is - * specified, a suitable default is chosen among the available devices. - * The syntax of the properties file is specified in - * {@link java.util.Properties#load(InputStream) Properties.load}. The - * following table lists the available property keys and which methods - * consider them: + *

+ * Properties can be used to specify the default mixer for specific line types. + * Both system properties and a properties file are considered. The + * {@code sound.properties} properties file is read from an + * implementation-specific location (typically it is the {@code lib} directory + * in the Java installation directory). If a property exists both as a system + * property and in the properties file, the system property takes precedence. + * If none is specified, a suitable default is chosen among the available + * devices. The syntax of the properties file is specified in + * {@link java.util.Properties#load(InputStream) Properties.load}. The following + * table lists the available property keys and which methods consider them: * * * @@ -82,84 +77,68 @@ * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * * *
Audio System Property Keys
Affected Method(s)
javax.sound.sampled.Clip{@code javax.sound.sampled.Clip}{@link Clip}{@link #getLine}, {@link #getClip}
javax.sound.sampled.Port{@code javax.sound.sampled.Port}{@link Port}{@link #getLine}
javax.sound.sampled.SourceDataLine{@code javax.sound.sampled.SourceDataLine}{@link SourceDataLine}{@link #getLine}, {@link #getSourceDataLine}
javax.sound.sampled.TargetDataLine{@code javax.sound.sampled.TargetDataLine}{@link TargetDataLine}{@link #getLine}, {@link #getTargetDataLine}
* - * The property value consists of the provider class name - * and the mixer name, separated by the hash mark ("#"). - * The provider class name is the fully-qualified - * name of a concrete {@link javax.sound.sampled.spi.MixerProvider - * mixer provider} class. The mixer name is matched against - * the String returned by the getName - * method of Mixer.Info. - * Either the class name, or the mixer name may be omitted. - * If only the class name is specified, the trailing hash mark - * is optional. - * - *

If the provider class is specified, and it can be - * successfully retrieved from the installed providers, the list of - * Mixer.Info objects is retrieved - * from the provider. Otherwise, or when these mixers - * do not provide a subsequent match, the list is retrieved - * from {@link #getMixerInfo} to contain - * all available Mixer.Info objects. - * - *

If a mixer name is specified, the resulting list of - * Mixer.Info objects is searched: - * the first one with a matching name, and whose - * Mixer provides the + * The property value consists of the provider class name and the mixer name, + * separated by the hash mark ("#"). The provider class name is the + * fully-qualified name of a concrete + * {@link javax.sound.sampled.spi.MixerProvider mixer provider} class. The mixer + * name is matched against the {@code String} returned by the {@code getName} + * method of {@code Mixer.Info}. Either the class name, or the mixer name may be + * omitted. If only the class name is specified, the trailing hash mark is + * optional. + *

+ * If the provider class is specified, and it can be successfully retrieved from + * the installed providers, the list of {@code Mixer.Info} objects is retrieved + * from the provider. Otherwise, or when these mixers do not provide a + * subsequent match, the list is retrieved from {@link #getMixerInfo} to contain + * all available {@code Mixer.Info} objects. + *

+ * If a mixer name is specified, the resulting list of {@code Mixer.Info} + * objects is searched: the first one with a matching name, and whose + * {@code Mixer} provides the respective line interface, will be returned. If no + * matching {@code Mixer.Info} object is found, or the mixer name is not + * specified, the first mixer from the resulting list, which provides the * respective line interface, will be returned. - * If no matching Mixer.Info object - * is found, or the mixer name is not specified, - * the first mixer from the resulting - * list, which provides the respective line - * interface, will be returned. * - * For example, the property javax.sound.sampled.Clip - * with a value - * "com.sun.media.sound.MixerProvider#SunClip" - * will have the following consequences when - * getLine is called requesting a Clip - * instance: - * if the class com.sun.media.sound.MixerProvider exists - * in the list of installed mixer providers, - * the first Clip from the first mixer with name - * "SunClip" will be returned. If it cannot - * be found, the first Clip from the first mixer - * of the specified provider will be returned, regardless of name. - * If there is none, the first Clip from the first - * Mixer with name - * "SunClip" in the list of all mixers - * (as returned by getMixerInfo) will be returned, - * or, if not found, the first Clip of the first - * Mixerthat can be found in the list of all - * mixers is returned. - * If that fails, too, an IllegalArgumentException - * is thrown. + * For example, the property {@code javax.sound.sampled.Clip} with a value + * {@code "com.sun.media.sound.MixerProvider#SunClip"} + * will have the following consequences when {@code getLine} is called + * requesting a {@code Clip} instance: if the class + * {@code com.sun.media.sound.MixerProvider} exists in the list of installed + * mixer providers, the first {@code Clip} from the first mixer with name + * {@code "SunClip"} will be returned. If it cannot be found, the + * first {@code Clip} from the first mixer of the specified provider will be + * returned, regardless of name. If there is none, the first {@code Clip} from + * the first {@code Mixer} with name {@code "SunClip"} in the list of + * all mixers (as returned by {@code getMixerInfo}) will be returned, or, if not + * found, the first {@code Clip} of the first {@code Mixer} that can be found in + * the list of all mixers is returned. If that fails, too, an + * {@code IllegalArgumentException} is thrown. * * @author Kara Kytle * @author Florian Bomers * @author Matthias Pfisterer * @author Kevin P. Smith - * * @see AudioFormat * @see AudioInputStream * @see Mixer @@ -170,13 +149,12 @@ public class AudioSystem { /** - * An integer that stands for an unknown numeric value. - * This value is appropriate only for signed quantities that do not - * normally take negative values. Examples include file sizes, frame - * sizes, buffer sizes, and sample rates. - * A number of Java Sound constructors accept - * a value of NOT_SPECIFIED for such parameters. Other - * methods may also accept or return this value, as documented. + * An integer that stands for an unknown numeric value. This value is + * appropriate only for signed quantities that do not normally take negative + * values. Examples include file sizes, frame sizes, buffer sizes, and + * sample rates. A number of Java Sound constructors accept a value of + * {@code NOT_SPECIFIED} for such parameters. Other methods may also accept + * or return this value, as documented. */ public static final int NOT_SPECIFIED = -1; @@ -186,12 +164,13 @@ private AudioSystem() { } - /** - * Obtains an array of mixer info objects that represents - * the set of audio mixers that are currently installed on the system. - * @return an array of info objects for the currently installed mixers. If no mixers - * are available on the system, an array of length 0 is returned. + * Obtains an array of mixer info objects that represents the set of audio + * mixers that are currently installed on the system. + * + * @return an array of info objects for the currently installed mixers. If + * no mixers are available on the system, an array of length 0 is + * returned. * @see #getMixer */ public static Mixer.Info[] getMixerInfo() { @@ -201,16 +180,16 @@ return allInfos; } - /** * Obtains the requested audio mixer. - * @param info a Mixer.Info object representing the desired - * mixer, or null for the system default mixer + * + * @param info a {@code Mixer.Info} object representing the desired mixer, + * or {@code null} for the system default mixer * @return the requested mixer - * @throws SecurityException if the requested mixer - * is unavailable because of security restrictions - * @throws IllegalArgumentException if the info object does not represent - * a mixer installed on the system + * @throws SecurityException if the requested mixer is unavailable because + * of security restrictions + * @throws IllegalArgumentException if the info object does not represent a + * mixer installed on the system * @see #getMixerInfo */ public static Mixer getMixer(Mixer.Info info) { @@ -259,17 +238,17 @@ + (info!=null?info.toString():"null")); } - //$$fb 2002-11-26: fix for 4757930: DOC: AudioSystem.getTarget/SourceLineInfo() is ambiguous + /** - * Obtains information about all source lines of a particular type that are supported - * by the installed mixers. - * @param info a Line.Info object that specifies the kind of - * lines about which information is requested - * @return an array of Line.Info objects describing source lines matching - * the type requested. If no matching source lines are supported, an array of length 0 - * is returned. + * Obtains information about all source lines of a particular type that are + * supported by the installed mixers. * + * @param info a {@code Line.Info} object that specifies the kind of lines + * about which information is requested + * @return an array of {@code Line.Info} objects describing source lines + * matching the type requested. If no matching source lines are + * supported, an array of length 0 is returned. * @see Mixer#getSourceLineInfo(Line.Info) */ public static Line.Info[] getSourceLineInfo(Line.Info info) { @@ -300,16 +279,15 @@ return returnedArray; } - /** - * Obtains information about all target lines of a particular type that are supported - * by the installed mixers. - * @param info a Line.Info object that specifies the kind of - * lines about which information is requested - * @return an array of Line.Info objects describing target lines matching - * the type requested. If no matching target lines are supported, an array of length 0 - * is returned. + * Obtains information about all target lines of a particular type that are + * supported by the installed mixers. * + * @param info a {@code Line.Info} object that specifies the kind of lines + * about which information is requested + * @return an array of {@code Line.Info} objects describing target lines + * matching the type requested. If no matching target lines are + * supported, an array of length 0 is returned. * @see Mixer#getTargetLineInfo(Line.Info) */ public static Line.Info[] getTargetLineInfo(Line.Info info) { @@ -340,15 +318,15 @@ return returnedArray; } - /** - * Indicates whether the system supports any lines that match - * the specified Line.Info object. A line is supported if - * any installed mixer supports it. - * @param info a Line.Info object describing the line for which support is queried - * @return true if at least one matching line is - * supported, otherwise false - * + * Indicates whether the system supports any lines that match the specified + * {@code Line.Info} object. A line is supported if any installed mixer + * supports it. + * + * @param info a {@code Line.Info} object describing the line for which + * support is queried + * @return {@code true} if at least one matching line is supported, + * otherwise {@code false} * @see Mixer#isLineSupported(Line.Info) */ public static boolean isLineSupported(Line.Info info) { @@ -371,40 +349,36 @@ /** * Obtains a line that matches the description in the specified - * Line.Info object. - * - *

If a DataLine is requested, and info - * is an instance of DataLine.Info specifying at least - * one fully qualified audio format, the last one - * will be used as the default format of the returned - * DataLine. - * - *

If system properties - * javax.sound.sampled.Clip, - * javax.sound.sampled.Port, - * javax.sound.sampled.SourceDataLine and - * javax.sound.sampled.TargetDataLine are defined - * or they are defined in the file "sound.properties", - * they are used to retrieve default lines. - * For details, refer to the {@link AudioSystem class description}. - * - * If the respective property is not set, or the mixer - * requested in the property is not installed or does not provide the - * requested line, all installed mixers are queried for the - * requested line type. A Line will be returned from the first mixer - * providing the requested line type. + * {@code Line.Info} object. + *

+ * If a {@code DataLine} is requested, and {@code info} is an instance of + * {@code DataLine.Info} specifying at least one fully qualified audio + * format, the last one will be used as the default format of the returned + * {@code DataLine}. + *

+ * If system properties + * {@code javax.sound.sampled.Clip}, + * {@code javax.sound.sampled.Port}, + * {@code javax.sound.sampled.SourceDataLine} and + * {@code javax.sound.sampled.TargetDataLine} are defined or they are + * defined in the file "sound.properties", they are used to retrieve default + * lines. For details, refer to the {@link AudioSystem class description}. + * + * If the respective property is not set, or the mixer requested in the + * property is not installed or does not provide the requested line, all + * installed mixers are queried for the requested line type. A Line will be + * returned from the first mixer providing the requested line type. * - * @param info a Line.Info object describing the desired kind of line + * @param info a {@code Line.Info} object describing the desired kind of + * line * @return a line of the requested kind - * - * @throws LineUnavailableException if a matching line - * is not available due to resource restrictions - * @throws SecurityException if a matching line - * is not available due to security restrictions - * @throws IllegalArgumentException if the system does not - * support at least one line matching the specified - * Line.Info object - * through any installed mixer + * @throws LineUnavailableException if a matching line is not available due + * to resource restrictions + * @throws SecurityException if a matching line is not available due to + * security restrictions + * @throws IllegalArgumentException if the system does not support at least + * one line matching the specified {@code Line.Info} object through + * any installed mixer */ public static Line getLine(Line.Info info) throws LineUnavailableException { LineUnavailableException lue = null; @@ -479,37 +453,30 @@ info.toString() + " is supported."); } - /** - * Obtains a clip that can be used for playing back - * an audio file or an audio stream. The returned clip - * will be provided by the default system mixer, or, - * if not possible, by any other mixer installed in the - * system that supports a Clip - * object. - * - *

The returned clip must be opened with the - * open(AudioFormat) or - * open(AudioInputStream) method. - * - *

This is a high-level method that uses getMixer - * and getLine internally. - * - *

If the system property - * javax.sound.sampled.Clip - * is defined or it is defined in the file "sound.properties", - * it is used to retrieve the default clip. - * For details, refer to the {@link AudioSystem class description}. + * Obtains a clip that can be used for playing back an audio file or an + * audio stream. The returned clip will be provided by the default system + * mixer, or, if not possible, by any other mixer installed in the system + * that supports a {@code Clip} object. + *

+ * The returned clip must be opened with the {@code open(AudioFormat)} or + * {@code open(AudioInputStream)} method. + *

+ * This is a high-level method that uses {@code getMixer} and + * {@code getLine} internally. + *

+ * If the system property {@code javax.sound.sampled.Clip} is defined or it + * is defined in the file "sound.properties", it is used to retrieve the + * default clip. For details, refer to the + * {@link AudioSystem class description}. * * @return the desired clip object - * - * @throws LineUnavailableException if a clip object - * is not available due to resource restrictions - * @throws SecurityException if a clip object - * is not available due to security restrictions - * @throws IllegalArgumentException if the system does not - * support at least one clip instance through any installed mixer - * + * @throws LineUnavailableException if a clip object is not available due to + * resource restrictions + * @throws SecurityException if a clip object is not available due to + * security restrictions + * @throws IllegalArgumentException if the system does not support at least + * one clip instance through any installed mixer * @see #getClip(Mixer.Info) * @since 1.5 */ @@ -522,29 +489,26 @@ return (Clip) AudioSystem.getLine(info); } - /** - * Obtains a clip from the specified mixer that can be - * used for playing back an audio file or an audio stream. - * - *

The returned clip must be opened with the - * open(AudioFormat) or - * open(AudioInputStream) method. + * Obtains a clip from the specified mixer that can be used for playing back + * an audio file or an audio stream. + *

+ * The returned clip must be opened with the {@code open(AudioFormat)} or + * {@code open(AudioInputStream)} method. + *

+ * This is a high-level method that uses {@code getMixer} and + * {@code getLine} internally. * - *

This is a high-level method that uses getMixer - * and getLine internally. - * - * @param mixerInfo a Mixer.Info object representing the - * desired mixer, or null for the system default mixer + * @param mixerInfo a {@code Mixer.Info} object representing the desired + * mixer, or {@code null} for the system default mixer * @return a clip object from the specified mixer * - * @throws LineUnavailableException if a clip - * is not available from this mixer due to resource restrictions - * @throws SecurityException if a clip - * is not available from this mixer due to security restrictions - * @throws IllegalArgumentException if the system does not - * support at least one clip through the specified mixer - * + * @throws LineUnavailableException if a clip is not available from this + * mixer due to resource restrictions + * @throws SecurityException if a clip is not available from this mixer due + * to security restrictions + * @throws IllegalArgumentException if the system does not support at least + * one clip through the specified mixer * @see #getClip() * @since 1.5 */ @@ -558,45 +522,38 @@ return (Clip) mixer.getLine(info); } - /** - * Obtains a source data line that can be used for playing back - * audio data in the format specified by the - * AudioFormat object. The returned line - * will be provided by the default system mixer, or, - * if not possible, by any other mixer installed in the - * system that supports a matching - * SourceDataLine object. - * - *

The returned line should be opened with the - * open(AudioFormat) or - * open(AudioFormat, int) method. - * - *

This is a high-level method that uses getMixer - * and getLine internally. - * - *

The returned SourceDataLine's default - * audio format will be initialized with format. - * - *

If the system property - * javax.sound.sampled.SourceDataLine - * is defined or it is defined in the file "sound.properties", - * it is used to retrieve the default source data line. - * For details, refer to the {@link AudioSystem class description}. - * - * @param format an AudioFormat object specifying - * the supported audio format of the returned line, - * or null for any audio format - * @return the desired SourceDataLine object - * - * @throws LineUnavailableException if a matching source data line - * is not available due to resource restrictions - * @throws SecurityException if a matching source data line - * is not available due to security restrictions - * @throws IllegalArgumentException if the system does not - * support at least one source data line supporting the - * specified audio format through any installed mixer - * + * Obtains a source data line that can be used for playing back audio data + * in the format specified by the {@code AudioFormat} object. The returned + * line will be provided by the default system mixer, or, if not possible, + * by any other mixer installed in the system that supports a matching + * {@code SourceDataLine} object. + *

+ * The returned line should be opened with the {@code open(AudioFormat)} or + * {@code open(AudioFormat, int)} method. + *

+ * This is a high-level method that uses {@code getMixer} and + * {@code getLine} internally. + *

+ * The returned {@code SourceDataLine}'s default audio format will be + * initialized with {@code format}. + *

+ * If the system property {@code javax.sound.sampled.SourceDataLine} is + * defined or it is defined in the file "sound.properties", it is used to + * retrieve the default source data line. For details, refer to the + * {@link AudioSystem class description}. + * + * @param format an {@code AudioFormat} object specifying the supported + * audio format of the returned line, or {@code null} for any audio + * format + * @return the desired {@code SourceDataLine} object + * @throws LineUnavailableException if a matching source data line is not + * available due to resource restrictions + * @throws SecurityException if a matching source data line is not available + * due to security restrictions + * @throws IllegalArgumentException if the system does not support at least + * one source data line supporting the specified audio format + * through any installed mixer * @see #getSourceDataLine(AudioFormat, Mixer.Info) * @since 1.5 */ @@ -606,41 +563,33 @@ return (SourceDataLine) AudioSystem.getLine(info); } - /** - * Obtains a source data line that can be used for playing back - * audio data in the format specified by the - * AudioFormat object, provided by the mixer - * specified by the Mixer.Info object. - * - *

The returned line should be opened with the - * open(AudioFormat) or - * open(AudioFormat, int) method. - * - *

This is a high-level method that uses getMixer - * and getLine internally. - * - *

The returned SourceDataLine's default - * audio format will be initialized with format. - * - * @param format an AudioFormat object specifying - * the supported audio format of the returned line, - * or null for any audio format - * @param mixerinfo a Mixer.Info object representing - * the desired mixer, or null for the system - * default mixer - * @return the desired SourceDataLine object - * - * @throws LineUnavailableException if a matching source data - * line is not available from the specified mixer due - * to resource restrictions - * @throws SecurityException if a matching source data line - * is not available from the specified mixer due to - * security restrictions - * @throws IllegalArgumentException if the specified mixer does - * not support at least one source data line supporting - * the specified audio format - * + * Obtains a source data line that can be used for playing back audio data + * in the format specified by the {@code AudioFormat} object, provided by + * the mixer specified by the {@code Mixer.Info} object. + *

+ * The returned line should be opened with the {@code open(AudioFormat)} or + * {@code open(AudioFormat, int)} method. + *

+ * This is a high-level method that uses {@code getMixer} and + * {@code getLine} internally. + *

+ * The returned {@code SourceDataLine}'s default audio format will be + * initialized with {@code format}. + * + * @param format an {@code AudioFormat} object specifying the supported + * audio format of the returned line, or {@code null} for any audio + * format + * @param mixerinfo a {@code Mixer.Info} object representing the desired + * mixer, or {@code null} for the system default mixer + * @return the desired {@code SourceDataLine} object + * @throws LineUnavailableException if a matching source data line is not + * available from the specified mixer due to resource restrictions + * @throws SecurityException if a matching source data line is not available + * from the specified mixer due to security restrictions + * @throws IllegalArgumentException if the specified mixer does not support + * at least one source data line supporting the specified audio + * format * @see #getSourceDataLine(AudioFormat) * @since 1.5 */ @@ -650,47 +599,40 @@ DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); Mixer mixer = AudioSystem.getMixer(mixerinfo); return (SourceDataLine) mixer.getLine(info); - } - + } /** - * Obtains a target data line that can be used for recording - * audio data in the format specified by the - * AudioFormat object. The returned line - * will be provided by the default system mixer, or, - * if not possible, by any other mixer installed in the - * system that supports a matching - * TargetDataLine object. - * - *

The returned line should be opened with the - * open(AudioFormat) or - * open(AudioFormat, int) method. - * - *

This is a high-level method that uses getMixer - * and getLine internally. - * - *

The returned TargetDataLine's default - * audio format will be initialized with format. - * - *

If the system property - * {@code javax.sound.sampled.TargetDataLine} - * is defined or it is defined in the file "sound.properties", - * it is used to retrieve the default target data line. - * For details, refer to the {@link AudioSystem class description}. - * - * @param format an AudioFormat object specifying - * the supported audio format of the returned line, - * or null for any audio format - * @return the desired TargetDataLine object - * - * @throws LineUnavailableException if a matching target data line - * is not available due to resource restrictions - * @throws SecurityException if a matching target data line - * is not available due to security restrictions - * @throws IllegalArgumentException if the system does not - * support at least one target data line supporting the - * specified audio format through any installed mixer - * + * Obtains a target data line that can be used for recording audio data in + * the format specified by the {@code AudioFormat} object. The returned line + * will be provided by the default system mixer, or, if not possible, by any + * other mixer installed in the system that supports a matching + * {@code TargetDataLine} object. + *

+ * The returned line should be opened with the {@code open(AudioFormat)} or + * {@code open(AudioFormat, int)} method. + *

+ * This is a high-level method that uses {@code getMixer} and + * {@code getLine} internally. + *

+ * The returned {@code TargetDataLine}'s default audio format will be + * initialized with {@code format}. + *

+ * If the system property {@code javax.sound.sampled.TargetDataLine} is + * defined or it is defined in the file "sound.properties", it is used to + * retrieve the default target data line. For details, refer to the + * {@link AudioSystem class description}. + * + * @param format an {@code AudioFormat} object specifying the supported + * audio format of the returned line, or {@code null} for any audio + * format + * @return the desired {@code TargetDataLine} object + * @throws LineUnavailableException if a matching target data line is not + * available due to resource restrictions + * @throws SecurityException if a matching target data line is not available + * due to security restrictions + * @throws IllegalArgumentException if the system does not support at least + * one target data line supporting the specified audio format + * through any installed mixer * @see #getTargetDataLine(AudioFormat, Mixer.Info) * @see AudioPermission * @since 1.5 @@ -702,41 +644,33 @@ return (TargetDataLine) AudioSystem.getLine(info); } - - /** - * Obtains a target data line that can be used for recording - * audio data in the format specified by the - * AudioFormat object, provided by the mixer - * specified by the Mixer.Info object. - * - *

The returned line should be opened with the - * open(AudioFormat) or - * open(AudioFormat, int) method. - * - *

This is a high-level method that uses getMixer - * and getLine internally. - * - *

The returned TargetDataLine's default - * audio format will be initialized with format. - * - * @param format an AudioFormat object specifying - * the supported audio format of the returned line, - * or null for any audio format - * @param mixerinfo a Mixer.Info object representing the - * desired mixer, or null for the system default mixer - * @return the desired TargetDataLine object - * - * @throws LineUnavailableException if a matching target data - * line is not available from the specified mixer due - * to resource restrictions - * @throws SecurityException if a matching target data line - * is not available from the specified mixer due to - * security restrictions - * @throws IllegalArgumentException if the specified mixer does - * not support at least one target data line supporting - * the specified audio format - * + * Obtains a target data line that can be used for recording audio data in + * the format specified by the {@code AudioFormat} object, provided by the + * mixer specified by the {@code Mixer.Info} object. + *

+ * The returned line should be opened with the {@code open(AudioFormat)} or + * {@code open(AudioFormat, int)} method. + *

+ * This is a high-level method that uses {@code getMixer} and + * {@code getLine} internally. + *

+ * The returned {@code TargetDataLine}'s default audio format will be + * initialized with {@code format}. + * + * @param format an {@code AudioFormat} object specifying the supported + * audio format of the returned line, or {@code null} for any audio + * format + * @param mixerinfo a {@code Mixer.Info} object representing the desired + * mixer, or {@code null} for the system default mixer + * @return the desired {@code TargetDataLine} object + * @throws LineUnavailableException if a matching target data line is not + * available from the specified mixer due to resource restrictions + * @throws SecurityException if a matching target data line is not available + * from the specified mixer due to security restrictions + * @throws IllegalArgumentException if the specified mixer does not support + * at least one target data line supporting the specified audio + * format * @see #getTargetDataLine(AudioFormat) * @see AudioPermission * @since 1.5 @@ -750,17 +684,19 @@ return (TargetDataLine) mixer.getLine(info); } - // $$fb 2002-04-12: fix for 4662082: behavior of AudioSystem.getTargetEncodings() methods doesn't match the spec + /** - * Obtains the encodings that the system can obtain from an - * audio input stream with the specified encoding using the set - * of installed format converters. - * @param sourceEncoding the encoding for which conversion support - * is queried - * @return array of encodings. If sourceEncodingis not supported, - * an array of length 0 is returned. Otherwise, the array will have a length - * of at least 1, representing sourceEncoding (no conversion). + * Obtains the encodings that the system can obtain from an audio input + * stream with the specified encoding using the set of installed format + * converters. + * + * @param sourceEncoding the encoding for which conversion support is + * queried + * @return array of encodings. If {@code sourceEncoding}is not supported, an + * array of length 0 is returned. Otherwise, the array will have a + * length of at least 1, representing {@code sourceEncoding} + * (no conversion). */ public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding sourceEncoding) { @@ -783,18 +719,18 @@ return encs2; } - - // $$fb 2002-04-12: fix for 4662082: behavior of AudioSystem.getTargetEncodings() methods doesn't match the spec + /** - * Obtains the encodings that the system can obtain from an - * audio input stream with the specified format using the set - * of installed format converters. - * @param sourceFormat the audio format for which conversion - * is queried - * @return array of encodings. If sourceFormatis not supported, - * an array of length 0 is returned. Otherwise, the array will have a length - * of at least 1, representing the encoding of sourceFormat (no conversion). + * Obtains the encodings that the system can obtain from an audio input + * stream with the specified format using the set of installed format + * converters. + * + * @param sourceFormat the audio format for which conversion is queried + * @return array of encodings. If {@code sourceFormat}is not supported, an + * array of length 0 is returned. Otherwise, the array will have a + * length of at least 1, representing the encoding of + * {@code sourceFormat} (no conversion). */ public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat) { @@ -826,15 +762,14 @@ return encs2; } - /** - * Indicates whether an audio input stream of the specified encoding - * can be obtained from an audio input stream that has the specified - * format. - * @param targetEncoding the desired encoding after conversion - * @param sourceFormat the audio format before conversion - * @return true if the conversion is supported, - * otherwise false + * Indicates whether an audio input stream of the specified encoding can be + * obtained from an audio input stream that has the specified format. + * + * @param targetEncoding the desired encoding after conversion + * @param sourceFormat the audio format before conversion + * @return {@code true} if the conversion is supported, otherwise + * {@code false} */ public static boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) { @@ -850,12 +785,12 @@ return false; } - /** - * Obtains an audio input stream of the indicated encoding, by converting the - * provided audio input stream. - * @param targetEncoding the desired encoding after conversion - * @param sourceStream the stream to be converted + * Obtains an audio input stream of the indicated encoding, by converting + * the provided audio input stream. + * + * @param targetEncoding the desired encoding after conversion + * @param sourceStream the stream to be converted * @return an audio input stream of the indicated encoding * @throws IllegalArgumentException if the conversion is not supported * @see #getTargetEncodings(AudioFormat.Encoding) @@ -878,15 +813,15 @@ throw new IllegalArgumentException("Unsupported conversion: " + targetEncoding + " from " + sourceStream.getFormat()); } - /** - * Obtains the formats that have a particular encoding and that the system can - * obtain from a stream of the specified format using the set of + * Obtains the formats that have a particular encoding and that the system + * can obtain from a stream of the specified format using the set of * installed format converters. - * @param targetEncoding the desired encoding after conversion - * @param sourceFormat the audio format before conversion - * @return array of formats. If no formats of the specified - * encoding are supported, an array of length 0 is returned. + * + * @param targetEncoding the desired encoding after conversion + * @param sourceFormat the audio format before conversion + * @return array of formats. If no formats of the specified encoding are + * supported, an array of length 0 is returned. */ public static AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) { @@ -918,16 +853,15 @@ return fmts2; } - /** - * Indicates whether an audio input stream of a specified format - * can be obtained from an audio input stream of another specified format. - * @param targetFormat the desired audio format after conversion - * @param sourceFormat the audio format before conversion - * @return true if the conversion is supported, - * otherwise false + * Indicates whether an audio input stream of a specified format can be + * obtained from an audio input stream of another specified format. + * + * @param targetFormat the desired audio format after conversion + * @param sourceFormat the audio format before conversion + * @return {@code true} if the conversion is supported, otherwise + * {@code false} */ - public static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) { List codecs = getFormatConversionProviders(); @@ -941,15 +875,15 @@ return false; } - /** * Obtains an audio input stream of the indicated format, by converting the * provided audio input stream. - * @param targetFormat the desired audio format after conversion - * @param sourceStream the stream to be converted + * + * @param targetFormat the desired audio format after conversion + * @param sourceStream the stream to be converted * @return an audio input stream of the indicated format * @throws IllegalArgumentException if the conversion is not supported - * #see #getTargetEncodings(AudioFormat) + * @see #getTargetEncodings(AudioFormat) * @see #getTargetFormats(AudioFormat.Encoding, AudioFormat) * @see #isConversionSupported(AudioFormat, AudioFormat) * @see #getAudioInputStream(AudioFormat.Encoding, AudioInputStream) @@ -974,20 +908,22 @@ throw new IllegalArgumentException("Unsupported conversion: " + targetFormat + " from " + sourceStream.getFormat()); } - /** - * Obtains the audio file format of the provided input stream. The stream must - * point to valid audio file data. The implementation of this method may require - * multiple parsers to examine the stream to determine whether they support it. - * These parsers must be able to mark the stream, read enough data to determine whether they - * support the stream, and, if not, reset the stream's read pointer to its original - * position. If the input stream does not support these operations, this method may fail - * with an IOException. - * @param stream the input stream from which file format information should be - * extracted - * @return an AudioFileFormat object describing the stream's audio file format - * @throws UnsupportedAudioFileException if the stream does not point to valid audio - * file data recognized by the system + * Obtains the audio file format of the provided input stream. The stream + * must point to valid audio file data. The implementation of this method + * may require multiple parsers to examine the stream to determine whether + * they support it. These parsers must be able to mark the stream, read + * enough data to determine whether they support the stream, and, if not, + * reset the stream's read pointer to its original position. If the input + * stream does not support these operations, this method may fail with an + * {@code IOException}. + * + * @param stream the input stream from which file format information should + * be extracted + * @return an {@code AudioFileFormat} object describing the stream's audio + * file format + * @throws UnsupportedAudioFileException if the stream does not point to + * valid audio file data recognized by the system * @throws IOException if an input/output exception occurs * @see InputStream#markSupported * @see InputStream#mark @@ -1016,13 +952,15 @@ } /** - * Obtains the audio file format of the specified URL. The URL must - * point to valid audio file data. - * @param url the URL from which file format information should be - * extracted - * @return an AudioFileFormat object describing the audio file format - * @throws UnsupportedAudioFileException if the URL does not point to valid audio - * file data recognized by the system + * Obtains the audio file format of the specified URL. The URL must point to + * valid audio file data. + * + * @param url the URL from which file format information should be + * extracted + * @return an {@code AudioFileFormat} object describing the audio file + * format + * @throws UnsupportedAudioFileException if the URL does not point to valid + * audio file data recognized by the system * @throws IOException if an input/output exception occurs */ public static AudioFileFormat getAudioFileFormat(URL url) @@ -1049,13 +987,15 @@ } /** - * Obtains the audio file format of the specified File. The File must - * point to valid audio file data. - * @param file the File from which file format information should be - * extracted - * @return an AudioFileFormat object describing the audio file format - * @throws UnsupportedAudioFileException if the File does not point to valid audio - * file data recognized by the system + * Obtains the audio file format of the specified {@code File}. The + * {@code File} must point to valid audio file data. + * + * @param file the {@code File} from which file format information should + * be extracted + * @return an {@code AudioFileFormat} object describing the audio file + * format + * @throws UnsupportedAudioFileException if the {@code File} does not point + * to valid audio file data recognized by the system * @throws IOException if an I/O exception occurs */ public static AudioFileFormat getAudioFileFormat(File file) @@ -1081,22 +1021,22 @@ } } - /** - * Obtains an audio input stream from the provided input stream. The stream must - * point to valid audio file data. The implementation of this method may - * require multiple parsers to - * examine the stream to determine whether they support it. These parsers must - * be able to mark the stream, read enough data to determine whether they - * support the stream, and, if not, reset the stream's read pointer to its original - * position. If the input stream does not support these operation, this method may fail - * with an IOException. - * @param stream the input stream from which the AudioInputStream should be - * constructed - * @return an AudioInputStream object based on the audio file data contained - * in the input stream. - * @throws UnsupportedAudioFileException if the stream does not point to valid audio - * file data recognized by the system + * Obtains an audio input stream from the provided input stream. The stream + * must point to valid audio file data. The implementation of this method + * may require multiple parsers to examine the stream to determine whether + * they support it. These parsers must be able to mark the stream, read + * enough data to determine whether they support the stream, and, if not, + * reset the stream's read pointer to its original position. If the input + * stream does not support these operation, this method may fail with an + * {@code IOException}. + * + * @param stream the input stream from which the {@code AudioInputStream} + * should be constructed + * @return an {@code AudioInputStream} object based on the audio file data + * contained in the input stream + * @throws UnsupportedAudioFileException if the stream does not point to + * valid audio file data recognized by the system * @throws IOException if an I/O exception occurs * @see InputStream#markSupported * @see InputStream#mark @@ -1125,14 +1065,15 @@ } /** - * Obtains an audio input stream from the URL provided. The URL must - * point to valid audio file data. - * @param url the URL for which the AudioInputStream should be - * constructed - * @return an AudioInputStream object based on the audio file data pointed - * to by the URL - * @throws UnsupportedAudioFileException if the URL does not point to valid audio - * file data recognized by the system + * Obtains an audio input stream from the URL provided. The URL must point + * to valid audio file data. + * + * @param url the URL for which the {@code AudioInputStream} should be + * constructed + * @return an {@code AudioInputStream} object based on the audio file data + * pointed to by the URL + * @throws UnsupportedAudioFileException if the URL does not point to valid + * audio file data recognized by the system * @throws IOException if an I/O exception occurs */ public static AudioInputStream getAudioInputStream(URL url) @@ -1159,14 +1100,15 @@ } /** - * Obtains an audio input stream from the provided File. The File must - * point to valid audio file data. - * @param file the File for which the AudioInputStream should be - * constructed - * @return an AudioInputStream object based on the audio file data pointed - * to by the File - * @throws UnsupportedAudioFileException if the File does not point to valid audio - * file data recognized by the system + * Obtains an audio input stream from the provided {@code File}. The + * {@code File} must point to valid audio file data. + * + * @param file the {@code File} for which the {@code AudioInputStream} + * should be constructed + * @return an {@code AudioInputStream} object based on the audio file data + * pointed to by the {@code File} + * @throws UnsupportedAudioFileException if the {@code File} does not point + * to valid audio file data recognized by the system * @throws IOException if an I/O exception occurs */ public static AudioInputStream getAudioInputStream(File file) @@ -1192,11 +1134,12 @@ } } - /** - * Obtains the file types for which file writing support is provided by the system. - * @return array of unique file types. If no file types are supported, - * an array of length 0 is returned. + * Obtains the file types for which file writing support is provided by the + * system. + * + * @return array of unique file types. If no file types are supported, an + * array of length 0 is returned. */ public static AudioFileFormat.Type[] getAudioFileTypes() { List providers = getAudioFileWriters(); @@ -1214,13 +1157,13 @@ return returnTypes; } - /** - * Indicates whether file writing support for the specified file type is provided - * by the system. - * @param fileType the file type for which write capabilities are queried - * @return true if the file type is supported, - * otherwise false + * Indicates whether file writing support for the specified file type is + * provided by the system. + * + * @param fileType the file type for which write capabilities are queried + * @return {@code true} if the file type is supported, otherwise + * {@code false} */ public static boolean isFileTypeSupported(AudioFileFormat.Type fileType) { @@ -1235,14 +1178,14 @@ return false; } - /** - * Obtains the file types that the system can write from the - * audio input stream specified. - * @param stream the audio input stream for which audio file type support - * is queried - * @return array of file types. If no file types are supported, - * an array of length 0 is returned. + * Obtains the file types that the system can write from the audio input + * stream specified. + * + * @param stream the audio input stream for which audio file type + * support is queried + * @return array of file types. If no file types are supported, an array of + * length 0 is returned. */ public static AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream) { List providers = getAudioFileWriters(); @@ -1260,14 +1203,14 @@ return returnTypes; } - /** * Indicates whether an audio file of the specified file type can be written * from the indicated audio input stream. - * @param fileType the file type for which write capabilities are queried - * @param stream the stream for which file-writing support is queried - * @return true if the file type is supported for this audio input stream, - * otherwise false + * + * @param fileType the file type for which write capabilities are queried + * @param stream the stream for which file-writing support is queried + * @return {@code true} if the file type is supported for this audio input + * stream, otherwise {@code false} */ public static boolean isFileTypeSupported(AudioFileFormat.Type fileType, AudioInputStream stream) { @@ -1283,25 +1226,24 @@ return false; } - /** - * Writes a stream of bytes representing an audio file of the specified file type - * to the output stream provided. Some file types require that - * the length be written into the file header; such files cannot be written from - * start to finish unless the length is known in advance. An attempt - * to write a file of such a type will fail with an IOException if the length in - * the audio file type is AudioSystem.NOT_SPECIFIED. - * - * @param stream the audio input stream containing audio data to be - * written to the file - * @param fileType the kind of audio file to write - * @param out the stream to which the file data should be written + * Writes a stream of bytes representing an audio file of the specified file + * type to the output stream provided. Some file types require that the + * length be written into the file header; such files cannot be written from + * start to finish unless the length is known in advance. An attempt to + * write a file of such a type will fail with an IOException if the length + * in the audio file type is {@code AudioSystem.NOT_SPECIFIED}. + * + * @param stream the audio input stream containing audio data to be written + * to the file + * @param fileType the kind of audio file to write + * @param out the stream to which the file data should be written * @return the number of bytes written to the output stream * @throws IOException if an input/output exception occurs - * @throws IllegalArgumentException if the file type is not supported by - * the system + * @throws IllegalArgumentException if the file type is not supported by the + * system * @see #isFileTypeSupported - * @see #getAudioFileTypes + * @see #getAudioFileTypes */ public static int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException { @@ -1328,20 +1270,20 @@ } } - /** - * Writes a stream of bytes representing an audio file of the specified file type - * to the external file provided. - * @param stream the audio input stream containing audio data to be - * written to the file - * @param fileType the kind of audio file to write - * @param out the external file to which the file data should be written + * Writes a stream of bytes representing an audio file of the specified file + * type to the external file provided. + * + * @param stream the audio input stream containing audio data to be written + * to the file + * @param fileType the kind of audio file to write + * @param out the external file to which the file data should be written * @return the number of bytes written to the file * @throws IOException if an I/O exception occurs - * @throws IllegalArgumentException if the file type is not supported by - * the system + * @throws IllegalArgumentException if the file type is not supported by the + * system * @see #isFileTypeSupported - * @see #getAudioFileTypes + * @see #getAudioFileTypes */ public static int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException { @@ -1368,7 +1310,6 @@ } } - // METHODS FOR INTERNAL IMPLEMENTATION USE /** @@ -1378,55 +1319,54 @@ return getProviders(MixerProvider.class); } - /** - * Obtains the set of format converters (codecs, transcoders, etc.) - * that are currently installed on the system. - * @return an array of - * {@link javax.sound.sampled.spi.FormatConversionProvider - * FormatConversionProvider} - * objects representing the available format converters. If no format - * converters readers are available on the system, an array of length 0 is - * returned. + * Obtains the set of format converters (codecs, transcoders, etc.) that are + * currently installed on the system. + * + * @return an array of {@link javax.sound.sampled.spi.FormatConversionProvider + * FormatConversionProvider} objects representing the available + * format converters. If no format converters readers are available + * on the system, an array of length 0 is returned. */ private static List getFormatConversionProviders() { return getProviders(FormatConversionProvider.class); } - /** - * Obtains the set of audio file readers that are currently installed on the system. - * @return a List of - * {@link javax.sound.sampled.spi.AudioFileReader - * AudioFileReader} - * objects representing the installed audio file readers. If no audio file - * readers are available on the system, an empty List is returned. + * Obtains the set of audio file readers that are currently installed on the + * system. + * + * @return a List of {@link javax.sound.sampled.spi.AudioFileReader + * AudioFileReader} objects representing the installed audio file + * readers. If no audio file readers are available on the system, an + * empty List is returned. */ private static List getAudioFileReaders() { return getProviders(AudioFileReader.class); } - /** - * Obtains the set of audio file writers that are currently installed on the system. - * @return a List of - * {@link javax.sound.samples.spi.AudioFileWriter AudioFileWriter} - * objects representing the available audio file writers. If no audio file - * writers are available on the system, an empty List is returned. + * Obtains the set of audio file writers that are currently installed on the + * system. + * + * @return a List of {@link javax.sound.sampled.spi.AudioFileWriter + * AudioFileWriter} objects representing the available audio file + * writers. If no audio file writers are available on the system, an + * empty List is returned. */ private static List getAudioFileWriters() { return getProviders(AudioFileWriter.class); } - - - /** Attempts to locate and return a default Mixer that provides lines - * of the specified type. + /** + * 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 + * @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(); @@ -1469,16 +1409,13 @@ return null; } - - - /** Return a MixerProvider of a given class from the list of - MixerProviders. - - This method never requires the returned Mixer to do mixing. - @param providerClassName The class name of the provider to be returned. - @param providers The list of MixerProviders that is searched. - @return A MixerProvider of the requested class, or null if none is - found. + /** + * Return a MixerProvider of a given class from the list of MixerProviders. + * This method never requires the returned Mixer to do mixing. + * + * @param providerClassName The class name of the provider to be returned + * @param providers The list of MixerProviders that is searched + * @return A MixerProvider of the requested class, or null if none is found */ private static MixerProvider getNamedProvider(String providerClassName, List providers) { @@ -1491,15 +1428,14 @@ return null; } - - /** Return a Mixer with a given name from a given MixerProvider. - This method never requires the returned Mixer to do mixing. - @param mixerName The name of the Mixer to be returned. - @param provider The MixerProvider to check for Mixers. - @param info The type of line the returned Mixer is required to - support. - - @return A Mixer matching the requirements, or null if none is found. + /** + * Return a Mixer with a given name from a given MixerProvider. This method + * never requires the returned Mixer to do mixing. + * + * @param mixerName The name of the Mixer to be returned + * @param provider The MixerProvider to check for Mixers + * @param info The type of line the returned Mixer is required to support + * @return A Mixer matching the requirements, or null if none is found */ private static Mixer getNamedMixer(String mixerName, MixerProvider provider, @@ -1516,14 +1452,14 @@ return null; } - - /** From a List of MixerProviders, return a Mixer with a given name. - This method never requires the returned Mixer to do mixing. - @param mixerName The name of the Mixer to be returned. - @param providers The List of MixerProviders to check for Mixers. - @param info The type of line the returned Mixer is required to - support. - @return A Mixer matching the requirements, or null if none is found. + /** + * From a List of MixerProviders, return a Mixer with a given name. This + * method never requires the returned Mixer to do mixing. + * + * @param mixerName The name of the Mixer to be returned + * @param providers The List of MixerProviders to check for Mixers + * @param info The type of line the returned Mixer is required to support + * @return A Mixer matching the requirements, or null if none is found */ private static Mixer getNamedMixer(String mixerName, List providers, @@ -1538,16 +1474,14 @@ return null; } - - /** From a given MixerProvider, return the first appropriate Mixer. - @param provider The MixerProvider to check for Mixers. - @param info The type of line the returned Mixer is required to - support. - @param isMixingRequired If true, only Mixers that support mixing are - returned for line types of SourceDataLine and Clip. - - @return A Mixer that is considered appropriate, or null - if none is found. + /** + * From a given MixerProvider, return the first appropriate Mixer. + * + * @param provider The MixerProvider to check for Mixers + * @param info The type of line the returned Mixer is required to support + * @param isMixingRequired If true, only Mixers that support mixing are + * returned for line types of SourceDataLine and Clip + * @return A Mixer that is considered appropriate, or null if none is found */ private static Mixer getFirstMixer(MixerProvider provider, Line.Info info, @@ -1562,15 +1496,14 @@ return null; } - - /** Checks if a Mixer is appropriate. - A Mixer is considered appropriate if it support the given line type. - If isMixingRequired is true and the line type is an output one - (SourceDataLine, Clip), the mixer is appropriate if it supports - at least 2 (concurrent) lines of the given type. - - @return true if the mixer is considered appropriate according to the - rules given above, false otherwise. + /** + * Checks if a Mixer is appropriate. A Mixer is considered appropriate if it + * support the given line type. If isMixingRequired is true and the line + * type is an output one (SourceDataLine, Clip), the mixer is appropriate if + * it supports at least 2 (concurrent) lines of the given type. + * + * @return {@code true} if the mixer is considered appropriate according to + * the rules given above, {@code false} otherwise */ private static boolean isAppropriateMixer(Mixer mixer, Line.Info lineInfo, @@ -1588,19 +1521,16 @@ return true; } - - /** - * Like getMixerInfo, but return List + * Like getMixerInfo, but return List. */ private static List getMixerInfoList() { List providers = getMixerProviders(); return getMixerInfoList(providers); } - /** - * Like getMixerInfo, but return List + * Like getMixerInfo, but return List. */ private static List getMixerInfoList(List providers) { List infos = new ArrayList(); @@ -1619,12 +1549,12 @@ return infos; } - /** - * Obtains the set of services currently installed on the system - * using the SPI mechanism in 1.3. - * @return a List of instances of providers for the requested service. - * If no providers are available, a vector of length 0 will be returned. + * Obtains the set of services currently installed on the system using the + * SPI mechanism in 1.3. + * + * @return a List of instances of providers for the requested service. If no + * providers are available, a vector of length 0 will be returned. */ private static List getProviders(Class providerClass) { return JDK13Services.getProviders(providerClass);