src/share/classes/javax/sound/sampled/AudioSystem.java

Print this page

        

*** 194,205 **** * are available on the system, an array of length 0 is returned. * @see #getMixer */ public static Mixer.Info[] getMixerInfo() { ! List infos = getMixerInfoList(); ! Mixer.Info[] allInfos = (Mixer.Info[]) infos.toArray(new Mixer.Info[infos.size()]); return allInfos; } /** --- 194,205 ---- * are available on the system, an array of length 0 is returned. * @see #getMixer */ public static Mixer.Info[] getMixerInfo() { ! List<Mixer.Info> infos = getMixerInfoList(); ! Mixer.Info[] allInfos = infos.toArray(new Mixer.Info[infos.size()]); return allInfos; } /**
*** 214,229 **** * @see #getMixerInfo */ public static Mixer getMixer(Mixer.Info info) { Mixer mixer = null; ! List providers = getMixerProviders(); for(int i = 0; i < providers.size(); i++ ) { try { ! return ((MixerProvider)providers.get(i)).getMixer(info); } catch (IllegalArgumentException e) { } catch (NullPointerException e) { // $$jb 08.20.99: If the strings in the info object aren't // set, then Netscape (using jdk1.1.5) tends to throw --- 214,229 ---- * @see #getMixerInfo */ public static Mixer getMixer(Mixer.Info info) { Mixer mixer = null; ! List<MixerProvider> providers = getMixerProviders(); for(int i = 0; i < providers.size(); i++ ) { try { ! return providers.get(i).getMixer(info); } catch (IllegalArgumentException e) { } catch (NullPointerException e) { // $$jb 08.20.99: If the strings in the info object aren't // set, then Netscape (using jdk1.1.5) tends to throw
*** 236,246 **** //$$fb if looking for default mixer, and not found yet, add a round of looking if (info == null) { for(int i = 0; i < providers.size(); i++ ) { try { ! MixerProvider provider = (MixerProvider) providers.get(i); Mixer.Info[] infos = provider.getMixerInfo(); // start from 0 to last device (do not reverse this order) for (int ii = 0; ii < infos.length; ii++) { try { return provider.getMixer(infos[ii]); --- 236,246 ---- //$$fb if looking for default mixer, and not found yet, add a round of looking if (info == null) { for(int i = 0; i < providers.size(); i++ ) { try { ! MixerProvider provider = providers.get(i); Mixer.Info[] infos = provider.getMixerInfo(); // start from 0 to last device (do not reverse this order) for (int ii = 0; ii < infos.length; ii++) { try { return provider.getMixer(infos[ii]);
*** 272,282 **** * * @see Mixer#getSourceLineInfo(Line.Info) */ public static Line.Info[] getSourceLineInfo(Line.Info info) { ! Vector vector = new Vector(); Line.Info[] currentInfoArray; Mixer mixer; Line.Info fullInfo = null; Mixer.Info[] infoArray = getMixerInfo(); --- 272,282 ---- * * @see Mixer#getSourceLineInfo(Line.Info) */ public static Line.Info[] getSourceLineInfo(Line.Info info) { ! Vector<Line.Info> vector = new Vector<>(); Line.Info[] currentInfoArray; Mixer mixer; Line.Info fullInfo = null; Mixer.Info[] infoArray = getMixerInfo();
*** 292,302 **** } Line.Info[] returnedArray = new Line.Info[vector.size()]; for (int i = 0; i < returnedArray.length; i++) { ! returnedArray[i] = (Line.Info)vector.get(i); } return returnedArray; } --- 292,302 ---- } Line.Info[] returnedArray = new Line.Info[vector.size()]; for (int i = 0; i < returnedArray.length; i++) { ! returnedArray[i] = vector.get(i); } return returnedArray; }
*** 312,322 **** * * @see Mixer#getTargetLineInfo(Line.Info) */ public static Line.Info[] getTargetLineInfo(Line.Info info) { ! Vector vector = new Vector(); Line.Info[] currentInfoArray; Mixer mixer; Line.Info fullInfo = null; Mixer.Info[] infoArray = getMixerInfo(); --- 312,322 ---- * * @see Mixer#getTargetLineInfo(Line.Info) */ public static Line.Info[] getTargetLineInfo(Line.Info info) { ! Vector<Line.Info> vector = new Vector<>(); Line.Info[] currentInfoArray; Mixer mixer; Line.Info fullInfo = null; Mixer.Info[] infoArray = getMixerInfo();
*** 332,342 **** } Line.Info[] returnedArray = new Line.Info[vector.size()]; for (int i = 0; i < returnedArray.length; i++) { ! returnedArray[i] = (Line.Info)vector.get(i); } return returnedArray; } --- 332,342 ---- } Line.Info[] returnedArray = new Line.Info[vector.size()]; for (int i = 0; i < returnedArray.length; i++) { ! returnedArray[i] = vector.get(i); } return returnedArray; }
*** 406,416 **** * <code>Line.Info</code> object * through any installed mixer */ public static Line getLine(Line.Info info) throws LineUnavailableException { LineUnavailableException lue = null; ! List providers = getMixerProviders(); // 1: try from default mixer for this line class try { Mixer mixer = getDefaultMixer(providers, info); --- 406,416 ---- * <code>Line.Info</code> object * through any installed mixer */ public static Line getLine(Line.Info info) throws LineUnavailableException { LineUnavailableException lue = null; ! List<MixerProvider> providers = getMixerProviders(); // 1: try from default mixer for this line class try { Mixer mixer = getDefaultMixer(providers, info);
*** 425,435 **** } // 2: if that doesn't work, try to find any mixing mixer for(int i = 0; i < providers.size(); i++) { ! MixerProvider provider = (MixerProvider) providers.get(i); Mixer.Info[] infos = provider.getMixerInfo(); for (int j = 0; j < infos.length; j++) { try { Mixer mixer = provider.getMixer(infos[j]); --- 425,435 ---- } // 2: if that doesn't work, try to find any mixing mixer for(int i = 0; i < providers.size(); i++) { ! MixerProvider provider = providers.get(i); Mixer.Info[] infos = provider.getMixerInfo(); for (int j = 0; j < infos.length; j++) { try { Mixer mixer = provider.getMixer(infos[j]);
*** 447,457 **** } // 3: if that didn't work, try to find any non-mixing mixer for(int i = 0; i < providers.size(); i++) { ! MixerProvider provider = (MixerProvider) providers.get(i); Mixer.Info[] infos = provider.getMixerInfo(); for (int j = 0; j < infos.length; j++) { try { Mixer mixer = provider.getMixer(infos[j]); // see if this is an appropriate mixer which can mix --- 447,457 ---- } // 3: if that didn't work, try to find any non-mixing mixer for(int i = 0; i < providers.size(); i++) { ! MixerProvider provider = providers.get(i); Mixer.Info[] infos = provider.getMixerInfo(); for (int j = 0; j < infos.length; j++) { try { Mixer mixer = provider.getMixer(infos[j]); // see if this is an appropriate mixer which can mix
*** 762,787 **** * an array of length 0 is returned. Otherwise, the array will have a length * of at least 1, representing <code>sourceEncoding</code> (no conversion). */ public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding sourceEncoding) { ! List codecs = getFormatConversionProviders(); ! Vector encodings = new Vector(); AudioFormat.Encoding encs[] = null; // gather from all the codecs for(int i=0; i<codecs.size(); i++ ) { ! FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); if( codec.isSourceEncodingSupported( sourceEncoding ) ) { encs = codec.getTargetEncodings(); for (int j = 0; j < encs.length; j++) { encodings.addElement( encs[j] ); } } } ! AudioFormat.Encoding encs2[] = (AudioFormat.Encoding[]) encodings.toArray(new AudioFormat.Encoding[0]); return encs2; } --- 762,787 ---- * an array of length 0 is returned. Otherwise, the array will have a length * of at least 1, representing <code>sourceEncoding</code> (no conversion). */ public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding sourceEncoding) { ! List<FormatConversionProvider> codecs = getFormatConversionProviders(); ! Vector<AudioFormat.Encoding> encodings = new Vector<>(); AudioFormat.Encoding encs[] = null; // gather from all the codecs for(int i=0; i<codecs.size(); i++ ) { ! FormatConversionProvider codec = codecs.get(i); if( codec.isSourceEncodingSupported( sourceEncoding ) ) { encs = codec.getTargetEncodings(); for (int j = 0; j < encs.length; j++) { encodings.addElement( encs[j] ); } } } ! AudioFormat.Encoding encs2[] = encodings.toArray(new AudioFormat.Encoding[0]); return encs2; }
*** 797,826 **** * of at least 1, representing the encoding of <code>sourceFormat</code> (no conversion). */ public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat) { ! List codecs = getFormatConversionProviders(); ! Vector encodings = new Vector(); int size = 0; int index = 0; AudioFormat.Encoding encs[] = null; // gather from all the codecs for(int i=0; i<codecs.size(); i++ ) { ! encs = ((FormatConversionProvider) codecs.get(i)).getTargetEncodings(sourceFormat); size += encs.length; encodings.addElement( encs ); } // now build a new array AudioFormat.Encoding encs2[] = new AudioFormat.Encoding[size]; for(int i=0; i<encodings.size(); i++ ) { ! encs = (AudioFormat.Encoding [])(encodings.get(i)); for(int j=0; j<encs.length; j++ ) { encs2[index++] = encs[j]; } } return encs2; --- 797,826 ---- * of at least 1, representing the encoding of <code>sourceFormat</code> (no conversion). */ public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat) { ! List<FormatConversionProvider> codecs = getFormatConversionProviders(); ! Vector<AudioFormat.Encoding[]> encodings = new Vector<>(); int size = 0; int index = 0; AudioFormat.Encoding encs[] = null; // gather from all the codecs for(int i=0; i<codecs.size(); i++ ) { ! encs = codecs.get(i).getTargetEncodings(sourceFormat); size += encs.length; encodings.addElement( encs ); } // now build a new array AudioFormat.Encoding encs2[] = new AudioFormat.Encoding[size]; for(int i=0; i<encodings.size(); i++ ) { ! encs = encodings.get(i); for(int j=0; j<encs.length; j++ ) { encs2[index++] = encs[j]; } } return encs2;
*** 837,850 **** * otherwise <code>false</code> */ public static boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) { ! List codecs = getFormatConversionProviders(); for(int i=0; i<codecs.size(); i++ ) { ! FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); if(codec.isConversionSupported(targetEncoding,sourceFormat) ) { return true; } } return false; --- 837,850 ---- * otherwise <code>false</code> */ public static boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat) { ! List<FormatConversionProvider> codecs = getFormatConversionProviders(); for(int i=0; i<codecs.size(); i++ ) { ! FormatConversionProvider codec = codecs.get(i); if(codec.isConversionSupported(targetEncoding,sourceFormat) ) { return true; } } return false;
*** 864,877 **** * @see #getAudioInputStream(AudioFormat, AudioInputStream) */ public static AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream) { ! List codecs = getFormatConversionProviders(); for(int i = 0; i < codecs.size(); i++) { ! FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); if( codec.isConversionSupported( targetEncoding, sourceStream.getFormat() ) ) { return codec.getAudioInputStream( targetEncoding, sourceStream ); } } // we ran out of options, throw an exception --- 864,877 ---- * @see #getAudioInputStream(AudioFormat, AudioInputStream) */ public static AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream) { ! List<FormatConversionProvider> codecs = getFormatConversionProviders(); for(int i = 0; i < codecs.size(); i++) { ! FormatConversionProvider codec = codecs.get(i); if( codec.isConversionSupported( targetEncoding, sourceStream.getFormat() ) ) { return codec.getAudioInputStream( targetEncoding, sourceStream ); } } // we ran out of options, throw an exception
*** 888,918 **** * @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) { ! List codecs = getFormatConversionProviders(); ! Vector formats = new Vector(); int size = 0; int index = 0; AudioFormat fmts[] = null; // gather from all the codecs for(int i=0; i<codecs.size(); i++ ) { ! FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); fmts = codec.getTargetFormats(targetEncoding, sourceFormat); size += fmts.length; formats.addElement( fmts ); } // now build a new array AudioFormat fmts2[] = new AudioFormat[size]; for(int i=0; i<formats.size(); i++ ) { ! fmts = (AudioFormat [])(formats.get(i)); for(int j=0; j<fmts.length; j++ ) { fmts2[index++] = fmts[j]; } } return fmts2; --- 888,918 ---- * @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) { ! List<FormatConversionProvider> codecs = getFormatConversionProviders(); ! Vector<AudioFormat[]> formats = new Vector<>(); int size = 0; int index = 0; AudioFormat fmts[] = null; // gather from all the codecs for(int i=0; i<codecs.size(); i++ ) { ! FormatConversionProvider codec = codecs.get(i); fmts = codec.getTargetFormats(targetEncoding, sourceFormat); size += fmts.length; formats.addElement( fmts ); } // now build a new array AudioFormat fmts2[] = new AudioFormat[size]; for(int i=0; i<formats.size(); i++ ) { ! fmts = formats.get(i); for(int j=0; j<fmts.length; j++ ) { fmts2[index++] = fmts[j]; } } return fmts2;
*** 928,941 **** * otherwise <code>false</code> */ public static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) { ! List codecs = getFormatConversionProviders(); for(int i=0; i<codecs.size(); i++ ) { ! FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); if(codec.isConversionSupported(targetFormat, sourceFormat) ) { return true; } } return false; --- 928,941 ---- * otherwise <code>false</code> */ public static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) { ! List<FormatConversionProvider> codecs = getFormatConversionProviders(); for(int i=0; i<codecs.size(); i++ ) { ! FormatConversionProvider codec = codecs.get(i); if(codec.isConversionSupported(targetFormat, sourceFormat) ) { return true; } } return false;
*** 959,972 **** if (sourceStream.getFormat().matches(targetFormat)) { return sourceStream; } ! List codecs = getFormatConversionProviders(); for(int i = 0; i < codecs.size(); i++) { ! FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i); if(codec.isConversionSupported(targetFormat,sourceStream.getFormat()) ) { return codec.getAudioInputStream(targetFormat,sourceStream); } } --- 959,972 ---- if (sourceStream.getFormat().matches(targetFormat)) { return sourceStream; } ! List<FormatConversionProvider> codecs = getFormatConversionProviders(); for(int i = 0; i < codecs.size(); i++) { ! FormatConversionProvider codec = codecs.get(i); if(codec.isConversionSupported(targetFormat,sourceStream.getFormat()) ) { return codec.getAudioInputStream(targetFormat,sourceStream); } }
*** 993,1007 **** * @see InputStream#mark */ public static AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException { ! List providers = getAudioFileReaders(); AudioFileFormat format = null; for(int i = 0; i < providers.size(); i++ ) { ! AudioFileReader reader = (AudioFileReader) providers.get(i); try { format = reader.getAudioFileFormat( stream ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue; --- 993,1007 ---- * @see InputStream#mark */ public static AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException { ! List<AudioFileReader> providers = getAudioFileReaders(); AudioFileFormat format = null; for(int i = 0; i < providers.size(); i++ ) { ! AudioFileReader reader = providers.get(i); try { format = reader.getAudioFileFormat( stream ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue;
*** 1026,1040 **** * @throws IOException if an input/output exception occurs */ public static AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException { ! List providers = getAudioFileReaders(); AudioFileFormat format = null; for(int i = 0; i < providers.size(); i++ ) { ! AudioFileReader reader = (AudioFileReader) providers.get(i); try { format = reader.getAudioFileFormat( url ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue; --- 1026,1040 ---- * @throws IOException if an input/output exception occurs */ public static AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException { ! List<AudioFileReader> providers = getAudioFileReaders(); AudioFileFormat format = null; for(int i = 0; i < providers.size(); i++ ) { ! AudioFileReader reader = providers.get(i); try { format = reader.getAudioFileFormat( url ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue;
*** 1059,1073 **** * @throws IOException if an I/O exception occurs */ public static AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException { ! List providers = getAudioFileReaders(); AudioFileFormat format = null; for(int i = 0; i < providers.size(); i++ ) { ! AudioFileReader reader = (AudioFileReader) providers.get(i); try { format = reader.getAudioFileFormat( file ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue; --- 1059,1073 ---- * @throws IOException if an I/O exception occurs */ public static AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException { ! List<AudioFileReader> providers = getAudioFileReaders(); AudioFileFormat format = null; for(int i = 0; i < providers.size(); i++ ) { ! AudioFileReader reader = providers.get(i); try { format = reader.getAudioFileFormat( file ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue;
*** 1088,1098 **** * 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</code>. * @param stream the input stream from which the <code>AudioInputStream</code> should be * constructed * @return an <code>AudioInputStream</code> object based on the audio file data contained * in the input stream. * @throws UnsupportedAudioFileException if the stream does not point to valid audio --- 1088,1098 ---- * 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</code>. * @param stream the input stream from which the <code>AudioInputStream</code> should be * constructed * @return an <code>AudioInputStream</code> object based on the audio file data contained * in the input stream. * @throws UnsupportedAudioFileException if the stream does not point to valid audio
*** 1102,1116 **** * @see InputStream#mark */ public static AudioInputStream getAudioInputStream(InputStream stream) throws UnsupportedAudioFileException, IOException { ! List providers = getAudioFileReaders(); AudioInputStream audioStream = null; for(int i = 0; i < providers.size(); i++ ) { ! AudioFileReader reader = (AudioFileReader) providers.get(i); try { audioStream = reader.getAudioInputStream( stream ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue; --- 1102,1116 ---- * @see InputStream#mark */ public static AudioInputStream getAudioInputStream(InputStream stream) throws UnsupportedAudioFileException, IOException { ! List<AudioFileReader> providers = getAudioFileReaders(); AudioInputStream audioStream = null; for(int i = 0; i < providers.size(); i++ ) { ! AudioFileReader reader = providers.get(i); try { audioStream = reader.getAudioInputStream( stream ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue;
*** 1136,1150 **** * @throws IOException if an I/O exception occurs */ public static AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException { ! List providers = getAudioFileReaders(); AudioInputStream audioStream = null; for(int i = 0; i < providers.size(); i++ ) { ! AudioFileReader reader = (AudioFileReader) providers.get(i); try { audioStream = reader.getAudioInputStream( url ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue; --- 1136,1150 ---- * @throws IOException if an I/O exception occurs */ public static AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException { ! List<AudioFileReader> providers = getAudioFileReaders(); AudioInputStream audioStream = null; for(int i = 0; i < providers.size(); i++ ) { ! AudioFileReader reader = providers.get(i); try { audioStream = reader.getAudioInputStream( url ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue;
*** 1170,1184 **** * @throws IOException if an I/O exception occurs */ public static AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException { ! List providers = getAudioFileReaders(); AudioInputStream audioStream = null; for(int i = 0; i < providers.size(); i++ ) { ! AudioFileReader reader = (AudioFileReader) providers.get(i); try { audioStream = reader.getAudioInputStream( file ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue; --- 1170,1184 ---- * @throws IOException if an I/O exception occurs */ public static AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException { ! List<AudioFileReader> providers = getAudioFileReaders(); AudioInputStream audioStream = null; for(int i = 0; i < providers.size(); i++ ) { ! AudioFileReader reader = providers.get(i); try { audioStream = reader.getAudioInputStream( file ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue;
*** 1197,1217 **** * 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(); ! Set returnTypesSet = new HashSet(); for(int i=0; i < providers.size(); i++) { ! AudioFileWriter writer = (AudioFileWriter) providers.get(i); AudioFileFormat.Type[] fileTypes = writer.getAudioFileTypes(); for(int j=0; j < fileTypes.length; j++) { returnTypesSet.add(fileTypes[j]); } } ! AudioFileFormat.Type returnTypes[] = (AudioFileFormat.Type[]) returnTypesSet.toArray(new AudioFileFormat.Type[0]); return returnTypes; } --- 1197,1217 ---- * 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<AudioFileWriter> providers = getAudioFileWriters(); ! Set<AudioFileFormat.Type> returnTypesSet = new HashSet<>(); for(int i=0; i < providers.size(); i++) { ! AudioFileWriter writer = providers.get(i); AudioFileFormat.Type[] fileTypes = writer.getAudioFileTypes(); for(int j=0; j < fileTypes.length; j++) { returnTypesSet.add(fileTypes[j]); } } ! AudioFileFormat.Type returnTypes[] = returnTypesSet.toArray(new AudioFileFormat.Type[0]); return returnTypes; }
*** 1222,1235 **** * @return <code>true</code> if the file type is supported, * otherwise <code>false</code> */ public static boolean isFileTypeSupported(AudioFileFormat.Type fileType) { ! List providers = getAudioFileWriters(); for(int i=0; i < providers.size(); i++) { ! AudioFileWriter writer = (AudioFileWriter) providers.get(i); if (writer.isFileTypeSupported(fileType)) { return true; } } return false; --- 1222,1235 ---- * @return <code>true</code> if the file type is supported, * otherwise <code>false</code> */ public static boolean isFileTypeSupported(AudioFileFormat.Type fileType) { ! List<AudioFileWriter> providers = getAudioFileWriters(); for(int i=0; i < providers.size(); i++) { ! AudioFileWriter writer = providers.get(i); if (writer.isFileTypeSupported(fileType)) { return true; } } return false;
*** 1243,1263 **** * 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(); ! Set returnTypesSet = new HashSet(); for(int i=0; i < providers.size(); i++) { ! AudioFileWriter writer = (AudioFileWriter) providers.get(i); AudioFileFormat.Type[] fileTypes = writer.getAudioFileTypes(stream); for(int j=0; j < fileTypes.length; j++) { returnTypesSet.add(fileTypes[j]); } } ! AudioFileFormat.Type returnTypes[] = (AudioFileFormat.Type[]) returnTypesSet.toArray(new AudioFileFormat.Type[0]); return returnTypes; } --- 1243,1263 ---- * 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<AudioFileWriter> providers = getAudioFileWriters(); ! Set<AudioFileFormat.Type> returnTypesSet = new HashSet<>(); for(int i=0; i < providers.size(); i++) { ! AudioFileWriter writer = providers.get(i); AudioFileFormat.Type[] fileTypes = writer.getAudioFileTypes(stream); for(int j=0; j < fileTypes.length; j++) { returnTypesSet.add(fileTypes[j]); } } ! AudioFileFormat.Type returnTypes[] = returnTypesSet.toArray(new AudioFileFormat.Type[0]); return returnTypes; }
*** 1270,1283 **** * otherwise <code>false</code> */ public static boolean isFileTypeSupported(AudioFileFormat.Type fileType, AudioInputStream stream) { ! List providers = getAudioFileWriters(); for(int i=0; i < providers.size(); i++) { ! AudioFileWriter writer = (AudioFileWriter) providers.get(i); if(writer.isFileTypeSupported(fileType, stream)) { return true; } } return false; --- 1270,1283 ---- * otherwise <code>false</code> */ public static boolean isFileTypeSupported(AudioFileFormat.Type fileType, AudioInputStream stream) { ! List<AudioFileWriter> providers = getAudioFileWriters(); for(int i=0; i < providers.size(); i++) { ! AudioFileWriter writer = providers.get(i); if(writer.isFileTypeSupported(fileType, stream)) { return true; } } return false;
*** 1304,1319 **** * @see #getAudioFileTypes */ public static int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException { ! List providers = getAudioFileWriters(); int bytesWritten = 0; boolean flag = false; for(int i=0; i < providers.size(); i++) { ! AudioFileWriter writer = (AudioFileWriter) providers.get(i); try { bytesWritten = writer.write( stream, fileType, out ); // throws IOException flag = true; break; } catch (IllegalArgumentException e) { --- 1304,1319 ---- * @see #getAudioFileTypes */ public static int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException { ! List<AudioFileWriter> providers = getAudioFileWriters(); int bytesWritten = 0; boolean flag = false; for(int i=0; i < providers.size(); i++) { ! AudioFileWriter writer = providers.get(i); try { bytesWritten = writer.write( stream, fileType, out ); // throws IOException flag = true; break; } catch (IllegalArgumentException e) {
*** 1344,1359 **** * @see #getAudioFileTypes */ public static int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException { ! List providers = getAudioFileWriters(); int bytesWritten = 0; boolean flag = false; for(int i=0; i < providers.size(); i++) { ! AudioFileWriter writer = (AudioFileWriter) providers.get(i); try { bytesWritten = writer.write( stream, fileType, out ); // throws IOException flag = true; break; } catch (IllegalArgumentException e) { --- 1344,1359 ---- * @see #getAudioFileTypes */ public static int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException { ! List<AudioFileWriter> providers = getAudioFileWriters(); int bytesWritten = 0; boolean flag = false; for(int i=0; i < providers.size(); i++) { ! AudioFileWriter writer = providers.get(i); try { bytesWritten = writer.write( stream, fileType, out ); // throws IOException flag = true; break; } catch (IllegalArgumentException e) {
*** 1372,1383 **** // METHODS FOR INTERNAL IMPLEMENTATION USE /** * Obtains the set of MixerProviders on the system. */ ! private static List getMixerProviders() { ! return getProviders(MixerProvider.class); } /** * Obtains the set of format converters (codecs, transcoders, etc.) --- 1372,1384 ---- // METHODS FOR INTERNAL IMPLEMENTATION USE /** * Obtains the set of MixerProviders on the system. */ ! @SuppressWarnings("unchecked") ! private static List<MixerProvider> getMixerProviders() { ! return (List<MixerProvider>) getProviders(MixerProvider.class); } /** * Obtains the set of format converters (codecs, transcoders, etc.)
*** 1387,1398 **** * 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. --- 1388,1400 ---- * FormatConversionProvider} * objects representing the available format converters. If no format * converters readers are available on the system, an array of length 0 is * returned. */ ! @SuppressWarnings("unchecked") ! private static List<FormatConversionProvider> getFormatConversionProviders() { ! return (List<FormatConversionProvider>) getProviders(FormatConversionProvider.class); } /** * Obtains the set of audio file readers that are currently installed on the system.
*** 1400,1423 **** * {@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. */ ! private static List getAudioFileWriters() { ! return getProviders(AudioFileWriter.class); } /** Attempts to locate and return a default Mixer that provides lines --- 1402,1427 ---- * {@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. */ ! @SuppressWarnings("unchecked") ! private static List<AudioFileReader> getAudioFileReaders() { ! return (List<AudioFileReader>)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. */ ! @SuppressWarnings("unchecked") ! private static List<AudioFileWriter> getAudioFileWriters() { ! return (List<AudioFileWriter>)getProviders(AudioFileWriter.class); } /** Attempts to locate and return a default Mixer that provides lines
*** 1426,1437 **** * @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) { --- 1430,1441 ---- * @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) {
*** 1479,1491 **** @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) { for(int i = 0; i < providers.size(); i++) { ! MixerProvider provider = (MixerProvider) providers.get(i); if (provider.getClass().getName().equals(providerClassName)) { return provider; } } return null; --- 1483,1495 ---- @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<MixerProvider> providers) { for(int i = 0; i < providers.size(); i++) { ! MixerProvider provider = providers.get(i); if (provider.getClass().getName().equals(providerClassName)) { return provider; } } return null;
*** 1524,1537 **** @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, Line.Info info) { for(int i = 0; i < providers.size(); i++) { ! MixerProvider provider = (MixerProvider) providers.get(i); Mixer mixer = getNamedMixer(mixerName, provider, info); if (mixer != null) { return mixer; } } --- 1528,1541 ---- @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<MixerProvider> providers, Line.Info info) { for(int i = 0; i < providers.size(); i++) { ! MixerProvider provider = providers.get(i); Mixer mixer = getNamedMixer(mixerName, provider, info); if (mixer != null) { return mixer; } }
*** 1576,1586 **** Line.Info lineInfo, boolean isMixingRequired) { if (! mixer.isLineSupported(lineInfo)) { return false; } ! Class lineClass = lineInfo.getLineClass(); if (isMixingRequired && (SourceDataLine.class.isAssignableFrom(lineClass) || Clip.class.isAssignableFrom(lineClass))) { int maxLines = mixer.getMaxLines(lineInfo); return ((maxLines == NOT_SPECIFIED) || (maxLines > 1)); --- 1580,1590 ---- Line.Info lineInfo, boolean isMixingRequired) { if (! mixer.isLineSupported(lineInfo)) { return false; } ! Class<?> lineClass = lineInfo.getLineClass(); if (isMixingRequired && (SourceDataLine.class.isAssignableFrom(lineClass) || Clip.class.isAssignableFrom(lineClass))) { int maxLines = mixer.getMaxLines(lineInfo); return ((maxLines == NOT_SPECIFIED) || (maxLines > 1));
*** 1591,1617 **** /** * Like getMixerInfo, but return List */ ! private static List getMixerInfoList() { ! List providers = getMixerProviders(); return getMixerInfoList(providers); } /** * Like getMixerInfo, but return List */ ! private static List getMixerInfoList(List providers) { ! List infos = new ArrayList(); Mixer.Info[] someInfos; // per-mixer Mixer.Info[] allInfos; // for all mixers for(int i = 0; i < providers.size(); i++ ) { ! someInfos = ((MixerProvider)providers.get(i)).getMixerInfo(); for (int j = 0; j < someInfos.length; j++) { infos.add(someInfos[j]); } } --- 1595,1621 ---- /** * Like getMixerInfo, but return List */ ! private static List<Mixer.Info> getMixerInfoList() { ! List<MixerProvider> providers = getMixerProviders(); return getMixerInfoList(providers); } /** * Like getMixerInfo, but return List */ ! private static List<Mixer.Info> getMixerInfoList(List<MixerProvider> providers) { ! List<Mixer.Info> infos = new ArrayList<>(); Mixer.Info[] someInfos; // per-mixer Mixer.Info[] allInfos; // for all mixers for(int i = 0; i < providers.size(); i++ ) { ! someInfos = providers.get(i).getMixerInfo(); for (int j = 0; j < someInfos.length; j++) { infos.add(someInfos[j]); } }
*** 1624,1632 **** * 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); } } --- 1628,1636 ---- * 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); } }