24 */ |
24 */ |
25 |
25 |
26 package javax.sound.sampled; |
26 package javax.sound.sampled; |
27 |
27 |
28 import java.io.File; |
28 import java.io.File; |
|
29 import java.io.IOException; |
29 import java.io.InputStream; |
30 import java.io.InputStream; |
30 import java.io.IOException; |
|
31 import java.io.OutputStream; |
31 import java.io.OutputStream; |
32 import java.net.URL; |
32 import java.net.URL; |
33 |
33 import java.util.ArrayList; |
34 import java.util.HashSet; |
34 import java.util.HashSet; |
35 import java.util.List; |
35 import java.util.List; |
|
36 import java.util.Properties; |
36 import java.util.Set; |
37 import java.util.Set; |
37 import java.util.Vector; |
38 import java.util.Vector; |
38 import java.util.ArrayList; |
39 |
39 |
40 import javax.sound.sampled.spi.AudioFileReader; |
40 import javax.sound.sampled.spi.AudioFileWriter; |
41 import javax.sound.sampled.spi.AudioFileWriter; |
41 import javax.sound.sampled.spi.AudioFileReader; |
|
42 import javax.sound.sampled.spi.FormatConversionProvider; |
42 import javax.sound.sampled.spi.FormatConversionProvider; |
43 import javax.sound.sampled.spi.MixerProvider; |
43 import javax.sound.sampled.spi.MixerProvider; |
44 |
44 |
45 import com.sun.media.sound.JDK13Services; |
45 import com.sun.media.sound.JDK13Services; |
46 |
46 |
58 * {@link Line} directly from the {@code AudioSystem} without dealing explicitly |
58 * {@link Line} directly from the {@code AudioSystem} without dealing explicitly |
59 * with mixers. |
59 * with mixers. |
60 * <p> |
60 * <p> |
61 * Properties can be used to specify the default mixer for specific line types. |
61 * Properties can be used to specify the default mixer for specific line types. |
62 * Both system properties and a properties file are considered. The |
62 * Both system properties and a properties file are considered. The |
63 * {@code sound.properties} properties file is read from an |
63 * "sound.properties" properties file is read from an implementation-specific |
64 * implementation-specific location (typically it is the {@code lib} directory |
64 * location (typically it is the {@code lib} directory in the Java installation |
65 * in the Java installation directory). If a property exists both as a system |
65 * directory). If a property exists both as a system property and in the |
66 * property and in the properties file, the system property takes precedence. |
66 * properties file, the system property takes precedence. If none is specified, |
67 * If none is specified, a suitable default is chosen among the available |
67 * a suitable default is chosen among the available devices. The syntax of the |
68 * devices. The syntax of the properties file is specified in |
68 * properties file is specified in |
69 * {@link java.util.Properties#load(InputStream) Properties.load}. The following |
69 * {@link Properties#load(InputStream) Properties.load}. The following table |
70 * table lists the available property keys and which methods consider them: |
70 * lists the available property keys and which methods consider them: |
71 * |
71 * |
72 * <table border=0> |
72 * <table border=0> |
73 * <caption>Audio System Property Keys</caption> |
73 * <caption>Audio System Property Keys</caption> |
74 * <tr> |
74 * <tr> |
75 * <th>Property Key</th> |
75 * <th>Property Key</th> |
98 * </tr> |
98 * </tr> |
99 * </table> |
99 * </table> |
100 * |
100 * |
101 * The property value consists of the provider class name and the mixer name, |
101 * The property value consists of the provider class name and the mixer name, |
102 * separated by the hash mark ("#"). The provider class name is the |
102 * separated by the hash mark ("#"). The provider class name is the |
103 * fully-qualified name of a concrete |
103 * fully-qualified name of a concrete {@link MixerProvider mixer provider} |
104 * {@link javax.sound.sampled.spi.MixerProvider mixer provider} class. The mixer |
104 * class. The mixer name is matched against the {@code String} returned by the |
105 * name is matched against the {@code String} returned by the {@code getName} |
105 * {@code getName} method of {@code Mixer.Info}. Either the class name, or the |
106 * method of {@code Mixer.Info}. Either the class name, or the mixer name may be |
106 * mixer name may be omitted. If only the class name is specified, the trailing |
107 * omitted. If only the class name is specified, the trailing hash mark is |
107 * hash mark is optional. |
108 * optional. |
|
109 * <p> |
108 * <p> |
110 * If the provider class is specified, and it can be successfully retrieved from |
109 * If the provider class is specified, and it can be successfully retrieved from |
111 * the installed providers, the list of {@code Mixer.Info} objects is retrieved |
110 * the installed providers, the list of {@code Mixer.Info} objects is retrieved |
112 * from the provider. Otherwise, or when these mixers do not provide a |
111 * from the provider. Otherwise, or when these mixers do not provide a |
113 * subsequent match, the list is retrieved from {@link #getMixerInfo} to contain |
112 * subsequent match, the list is retrieved from {@link #getMixerInfo} to contain |
1322 |
1321 |
1323 /** |
1322 /** |
1324 * Obtains the set of format converters (codecs, transcoders, etc.) that are |
1323 * Obtains the set of format converters (codecs, transcoders, etc.) that are |
1325 * currently installed on the system. |
1324 * currently installed on the system. |
1326 * |
1325 * |
1327 * @return an array of {@link javax.sound.sampled.spi.FormatConversionProvider |
1326 * @return an array of {@link FormatConversionProvider} objects representing |
1328 * FormatConversionProvider} objects representing the available |
1327 * the available format converters. If no format converters readers |
1329 * format converters. If no format converters readers are available |
1328 * are available on the system, an array of length 0 is returned. |
1330 * on the system, an array of length 0 is returned. |
|
1331 */ |
1329 */ |
1332 @SuppressWarnings("unchecked") |
1330 @SuppressWarnings("unchecked") |
1333 private static List<FormatConversionProvider> getFormatConversionProviders() { |
1331 private static List<FormatConversionProvider> getFormatConversionProviders() { |
1334 return (List<FormatConversionProvider>) getProviders(FormatConversionProvider.class); |
1332 return (List<FormatConversionProvider>) getProviders(FormatConversionProvider.class); |
1335 } |
1333 } |
1336 |
1334 |
1337 /** |
1335 /** |
1338 * Obtains the set of audio file readers that are currently installed on the |
1336 * Obtains the set of audio file readers that are currently installed on the |
1339 * system. |
1337 * system. |
1340 * |
1338 * |
1341 * @return a List of {@link javax.sound.sampled.spi.AudioFileReader |
1339 * @return a List of {@link AudioFileReader} objects representing the |
1342 * AudioFileReader} objects representing the installed audio file |
1340 * installed audio file readers. If no audio file readers are |
1343 * readers. If no audio file readers are available on the system, an |
1341 * available on the system, an empty List is returned. |
1344 * empty List is returned. |
|
1345 */ |
1342 */ |
1346 @SuppressWarnings("unchecked") |
1343 @SuppressWarnings("unchecked") |
1347 private static List<AudioFileReader> getAudioFileReaders() { |
1344 private static List<AudioFileReader> getAudioFileReaders() { |
1348 return (List<AudioFileReader>)getProviders(AudioFileReader.class); |
1345 return (List<AudioFileReader>)getProviders(AudioFileReader.class); |
1349 } |
1346 } |
1350 |
1347 |
1351 /** |
1348 /** |
1352 * Obtains the set of audio file writers that are currently installed on the |
1349 * Obtains the set of audio file writers that are currently installed on the |
1353 * system. |
1350 * system. |
1354 * |
1351 * |
1355 * @return a List of {@link javax.sound.sampled.spi.AudioFileWriter |
1352 * @return a List of {@link AudioFileWriter} objects representing the |
1356 * AudioFileWriter} objects representing the available audio file |
1353 * available audio file writers. If no audio file writers are |
1357 * writers. If no audio file writers are available on the system, an |
1354 * available on the system, an empty List is returned. |
1358 * empty List is returned. |
|
1359 */ |
1355 */ |
1360 @SuppressWarnings("unchecked") |
1356 @SuppressWarnings("unchecked") |
1361 private static List<AudioFileWriter> getAudioFileWriters() { |
1357 private static List<AudioFileWriter> getAudioFileWriters() { |
1362 return (List<AudioFileWriter>)getProviders(AudioFileWriter.class); |
1358 return (List<AudioFileWriter>)getProviders(AudioFileWriter.class); |
1363 } |
1359 } |