AudioSystem.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:openjdk-jdk10 作者:
/**
 * 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).
 * @throws NullPointerException if {@code sourceFormat} is {@code null}
 */
public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat) {
    Objects.requireNonNull(sourceFormat);

    List<FormatConversionProvider> codecs = getFormatConversionProviders();
    List<AudioFormat.Encoding> encs = new ArrayList<>();

    // gather from all the codecs
    for (final FormatConversionProvider codec : codecs) {
        Collections.addAll(encs, codec.getTargetEncodings(sourceFormat));
    }

    if (!encs.contains(sourceFormat.getEncoding())) {
        encs.add(sourceFormat.getEncoding());
    }

    return encs.toArray(new AudioFormat.Encoding[encs.size()]);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号