javax.sound.sampled.AudioFormat#matches ( )源码实例Demo

下面列出了javax.sound.sampled.AudioFormat#matches ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u-jdk   文件: FormatConversionProvider.java
/**
 * Indicates whether the format converter supports conversion to one
 * particular format from another.
 * @param targetFormat desired format of outgoing data
 * @param sourceFormat format of the incoming data
 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
 */
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){

    AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

    for(int i=0; i<targetFormats.length; i++) {
        if( targetFormat.matches( targetFormats[i] ) ) {
            return true;
        }
    }
    return false;
}
 
源代码2 项目: jdk8u-jdk   文件: FormatConversionProvider.java
/**
 * Indicates whether the format converter supports conversion to one
 * particular format from another.
 * @param targetFormat desired format of outgoing data
 * @param sourceFormat format of the incoming data
 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
 */
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){

    AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

    for(int i=0; i<targetFormats.length; i++) {
        if( targetFormat.matches( targetFormats[i] ) ) {
            return true;
        }
    }
    return false;
}
 
/**
 * Indicates whether the format converter supports conversion to one
 * particular format from another.
 * @param targetFormat desired format of outgoing data
 * @param sourceFormat format of the incoming data
 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
 */
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){

    AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

    for(int i=0; i<targetFormats.length; i++) {
        if( targetFormat.matches( targetFormats[i] ) ) {
            return true;
        }
    }
    return false;
}
 
源代码4 项目: openjdk-8   文件: FormatConversionProvider.java
/**
 * Indicates whether the format converter supports conversion to one
 * particular format from another.
 * @param targetFormat desired format of outgoing data
 * @param sourceFormat format of the incoming data
 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
 */
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){

    AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

    for(int i=0; i<targetFormats.length; i++) {
        if( targetFormat.matches( targetFormats[i] ) ) {
            return true;
        }
    }
    return false;
}
 
源代码5 项目: TencentKona-8   文件: FormatConversionProvider.java
/**
 * Indicates whether the format converter supports conversion to one
 * particular format from another.
 * @param targetFormat desired format of outgoing data
 * @param sourceFormat format of the incoming data
 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
 */
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){

    AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

    for(int i=0; i<targetFormats.length; i++) {
        if( targetFormat.matches( targetFormats[i] ) ) {
            return true;
        }
    }
    return false;
}
 
源代码6 项目: jdk8u60   文件: FormatConversionProvider.java
/**
 * Indicates whether the format converter supports conversion to one
 * particular format from another.
 * @param targetFormat desired format of outgoing data
 * @param sourceFormat format of the incoming data
 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
 */
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){

    AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

    for(int i=0; i<targetFormats.length; i++) {
        if( targetFormat.matches( targetFormats[i] ) ) {
            return true;
        }
    }
    return false;
}
 
源代码7 项目: Java8CN   文件: FormatConversionProvider.java
/**
 * Indicates whether the format converter supports conversion to one
 * particular format from another.
 * @param targetFormat desired format of outgoing data
 * @param sourceFormat format of the incoming data
 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
 */
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){

    AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

    for(int i=0; i<targetFormats.length; i++) {
        if( targetFormat.matches( targetFormats[i] ) ) {
            return true;
        }
    }
    return false;
}
 
源代码8 项目: tuxguitar   文件: FormatConversionProvider.java
/**
 * Indicates whether the format converter supports conversion to one
 * particular format from another.
 * @param targetFormat desired format of outgoing data
 * @param sourceFormat format of the incoming data
 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
 */
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){

    AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

    for(int i=0; i<targetFormats.length; i++) {
        if( targetFormat.matches( targetFormats[i] ) ) {
            return true;
        }
    }
    return false;
}
 
/**
 * Indicates whether the format converter supports conversion to one
 * particular format from another.
 * @param targetFormat desired format of outgoing data
 * @param sourceFormat format of the incoming data
 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
 */
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){

    AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

    for(int i=0; i<targetFormats.length; i++) {
        if( targetFormat.matches( targetFormats[i] ) ) {
            return true;
        }
    }
    return false;
}
 
源代码10 项目: Bytecoder   文件: AbstractDataLine.java
public final void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
    //$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
    synchronized (mixer) {
        // if the line is not currently open, try to open it with this format and buffer size
        if (!isOpen()) {
            // make sure that the format is specified correctly
            // $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
            Toolkit.isFullySpecifiedAudioFormat(format);
            // reserve mixer resources for this line
            //mixer.open(this, format, bufferSize);
            mixer.open(this);

            try {
                // open the data line.  may throw LineUnavailableException.
                implOpen(format, bufferSize);

                // if we succeeded, set the open state to true and send events
                setOpen(true);

            } catch (LineUnavailableException e) {
                // release mixer resources for this line and then throw the exception
                mixer.close(this);
                throw e;
            }
        } else {
            // if the line is already open and the requested format differs from the
            // current settings, throw an IllegalStateException
            //$$fb 2002-04-02: fix for 4661602: Buffersize is checked when re-opening line
            if (!format.matches(getFormat())) {
                throw new IllegalStateException("Line is already open with format " + getFormat() +
                                                " and bufferSize " + getBufferSize());
            }
            //$$fb 2002-07-26: allow changing the buffersize of already open lines
            if (bufferSize > 0) {
                setBufferSize(bufferSize);
            }
        }
    }
}
 
源代码11 项目: hottub   文件: FormatConversionProvider.java
/**
 * Indicates whether the format converter supports conversion to one
 * particular format from another.
 * @param targetFormat desired format of outgoing data
 * @param sourceFormat format of the incoming data
 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
 */
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){

    AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );

    for(int i=0; i<targetFormats.length; i++) {
        if( targetFormat.matches( targetFormats[i] ) ) {
            return true;
        }
    }
    return false;
}
 
源代码12 项目: openjdk-jdk9   文件: DirectAudioDevice.java
public boolean isFormatSupportedInHardware(AudioFormat format) {
    if (format == null) return false;
    for (int i = 0; i < hardwareFormats.length; i++) {
        if (format.matches(hardwareFormats[i])) {
            return true;
        }
    }
    return false;
}
 
源代码13 项目: Bytecoder   文件: UlawCodec.java
/**
 * Opens the codec with the specified parameters.
 * @param stream stream from which data to be processed should be read
 * @param outputFormat desired data format of the stream after processing
 * @return stream from which processed data may be read
 * @throws IllegalArgumentException if the format combination supplied is
 * not supported.
 */
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {
    AudioInputStream cs = null;

    AudioFormat inputFormat = stream.getFormat();

    if( inputFormat.matches(outputFormat) ) {
        cs = stream;
    } else {
        cs = new UlawCodecStream(stream, outputFormat);
    }
    return cs;
}
 
源代码14 项目: jdk8u-dev-jdk   文件: AbstractDataLine.java
public final void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
    //$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
    synchronized (mixer) {
        if (Printer.trace) Printer.trace("> AbstractDataLine.open(format, bufferSize) (class: "+getClass().getName());

        // if the line is not currently open, try to open it with this format and buffer size
        if (!isOpen()) {
            // make sure that the format is specified correctly
            // $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
            Toolkit.isFullySpecifiedAudioFormat(format);

            if (Printer.debug) Printer.debug("  need to open the mixer...");
            // reserve mixer resources for this line
            //mixer.open(this, format, bufferSize);
            mixer.open(this);

            try {
                // open the data line.  may throw LineUnavailableException.
                implOpen(format, bufferSize);

                // if we succeeded, set the open state to true and send events
                setOpen(true);

            } catch (LineUnavailableException e) {
                // release mixer resources for this line and then throw the exception
                mixer.close(this);
                throw e;
            }
        } else {
            if (Printer.debug) Printer.debug("  dataline already open");

            // if the line is already open and the requested format differs from the
            // current settings, throw an IllegalStateException
            //$$fb 2002-04-02: fix for 4661602: Buffersize is checked when re-opening line
            if (!format.matches(getFormat())) {
                throw new IllegalStateException("Line is already open with format " + getFormat() +
                                                " and bufferSize " + getBufferSize());
            }
            //$$fb 2002-07-26: allow changing the buffersize of already open lines
            if (bufferSize > 0) {
                setBufferSize(bufferSize);
            }
        }

        if (Printer.trace) Printer.trace("< AbstractDataLine.open(format, bufferSize) completed");
    }
}
 
源代码15 项目: openjdk-jdk8u   文件: AbstractDataLine.java
public final void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
    //$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
    synchronized (mixer) {
        if (Printer.trace) Printer.trace("> AbstractDataLine.open(format, bufferSize) (class: "+getClass().getName());

        // if the line is not currently open, try to open it with this format and buffer size
        if (!isOpen()) {
            // make sure that the format is specified correctly
            // $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
            Toolkit.isFullySpecifiedAudioFormat(format);

            if (Printer.debug) Printer.debug("  need to open the mixer...");
            // reserve mixer resources for this line
            //mixer.open(this, format, bufferSize);
            mixer.open(this);

            try {
                // open the data line.  may throw LineUnavailableException.
                implOpen(format, bufferSize);

                // if we succeeded, set the open state to true and send events
                setOpen(true);

            } catch (LineUnavailableException e) {
                // release mixer resources for this line and then throw the exception
                mixer.close(this);
                throw e;
            }
        } else {
            if (Printer.debug) Printer.debug("  dataline already open");

            // if the line is already open and the requested format differs from the
            // current settings, throw an IllegalStateException
            //$$fb 2002-04-02: fix for 4661602: Buffersize is checked when re-opening line
            if (!format.matches(getFormat())) {
                throw new IllegalStateException("Line is already open with format " + getFormat() +
                                                " and bufferSize " + getBufferSize());
            }
            //$$fb 2002-07-26: allow changing the buffersize of already open lines
            if (bufferSize > 0) {
                setBufferSize(bufferSize);
            }
        }

        if (Printer.trace) Printer.trace("< AbstractDataLine.open(format, bufferSize) completed");
    }
}
 
源代码16 项目: jdk8u_jdk   文件: AbstractDataLine.java
public final void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
    //$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
    synchronized (mixer) {
        if (Printer.trace) Printer.trace("> AbstractDataLine.open(format, bufferSize) (class: "+getClass().getName());

        // if the line is not currently open, try to open it with this format and buffer size
        if (!isOpen()) {
            // make sure that the format is specified correctly
            // $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
            Toolkit.isFullySpecifiedAudioFormat(format);

            if (Printer.debug) Printer.debug("  need to open the mixer...");
            // reserve mixer resources for this line
            //mixer.open(this, format, bufferSize);
            mixer.open(this);

            try {
                // open the data line.  may throw LineUnavailableException.
                implOpen(format, bufferSize);

                // if we succeeded, set the open state to true and send events
                setOpen(true);

            } catch (LineUnavailableException e) {
                // release mixer resources for this line and then throw the exception
                mixer.close(this);
                throw e;
            }
        } else {
            if (Printer.debug) Printer.debug("  dataline already open");

            // if the line is already open and the requested format differs from the
            // current settings, throw an IllegalStateException
            //$$fb 2002-04-02: fix for 4661602: Buffersize is checked when re-opening line
            if (!format.matches(getFormat())) {
                throw new IllegalStateException("Line is already open with format " + getFormat() +
                                                " and bufferSize " + getBufferSize());
            }
            //$$fb 2002-07-26: allow changing the buffersize of already open lines
            if (bufferSize > 0) {
                setBufferSize(bufferSize);
            }
        }

        if (Printer.trace) Printer.trace("< AbstractDataLine.open(format, bufferSize) completed");
    }
}
 
源代码17 项目: Bytecoder   文件: PCMtoPCMCodec.java
/**
 * Opens the codec with the specified parameters.
 * @param stream stream from which data to be processed should be read
 * @param outputFormat desired data format of the stream after processing
 * @return stream from which processed data may be read
 * @throws IllegalArgumentException if the format combination supplied is
 * not supported.
 */
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {

    AudioInputStream cs = null;

    AudioFormat inputFormat = stream.getFormat();

    if( inputFormat.matches(outputFormat) ) {

        cs = stream;
    } else {

        cs = new PCMtoPCMCodecStream(stream, outputFormat);
    }
    return cs;
}
 
源代码18 项目: openjdk-jdk9   文件: AbstractDataLine.java
public final void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
    //$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
    synchronized (mixer) {
        if (Printer.trace) Printer.trace("> AbstractDataLine.open(format, bufferSize) (class: "+getClass().getName());

        // if the line is not currently open, try to open it with this format and buffer size
        if (!isOpen()) {
            // make sure that the format is specified correctly
            // $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
            Toolkit.isFullySpecifiedAudioFormat(format);

            if (Printer.debug) Printer.debug("  need to open the mixer...");
            // reserve mixer resources for this line
            //mixer.open(this, format, bufferSize);
            mixer.open(this);

            try {
                // open the data line.  may throw LineUnavailableException.
                implOpen(format, bufferSize);

                // if we succeeded, set the open state to true and send events
                setOpen(true);

            } catch (LineUnavailableException e) {
                // release mixer resources for this line and then throw the exception
                mixer.close(this);
                throw e;
            }
        } else {
            if (Printer.debug) Printer.debug("  dataline already open");

            // if the line is already open and the requested format differs from the
            // current settings, throw an IllegalStateException
            //$$fb 2002-04-02: fix for 4661602: Buffersize is checked when re-opening line
            if (!format.matches(getFormat())) {
                throw new IllegalStateException("Line is already open with format " + getFormat() +
                                                " and bufferSize " + getBufferSize());
            }
            //$$fb 2002-07-26: allow changing the buffersize of already open lines
            if (bufferSize > 0) {
                setBufferSize(bufferSize);
            }
        }

        if (Printer.trace) Printer.trace("< AbstractDataLine.open(format, bufferSize) completed");
    }
}
 
源代码19 项目: openjdk-jdk9   文件: PCMtoPCMCodec.java
/**
 * Opens the codec with the specified parameters.
 * @param stream stream from which data to be processed should be read
 * @param outputFormat desired data format of the stream after processing
 * @return stream from which processed data may be read
 * @throws IllegalArgumentException if the format combination supplied is
 * not supported.
 */
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream) {

    AudioInputStream cs = null;

    AudioFormat inputFormat = stream.getFormat();

    if( inputFormat.matches(outputFormat) ) {

        cs = stream;
    } else {

        cs = new PCMtoPCMCodecStream(stream, outputFormat);
    }
    return cs;
}
 
源代码20 项目: openjdk-8-source   文件: AbstractDataLine.java
public final void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
    //$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
    synchronized (mixer) {
        if (Printer.trace) Printer.trace("> AbstractDataLine.open(format, bufferSize) (class: "+getClass().getName());

        // if the line is not currently open, try to open it with this format and buffer size
        if (!isOpen()) {
            // make sure that the format is specified correctly
            // $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
            Toolkit.isFullySpecifiedAudioFormat(format);

            if (Printer.debug) Printer.debug("  need to open the mixer...");
            // reserve mixer resources for this line
            //mixer.open(this, format, bufferSize);
            mixer.open(this);

            try {
                // open the data line.  may throw LineUnavailableException.
                implOpen(format, bufferSize);

                // if we succeeded, set the open state to true and send events
                setOpen(true);

            } catch (LineUnavailableException e) {
                // release mixer resources for this line and then throw the exception
                mixer.close(this);
                throw e;
            }
        } else {
            if (Printer.debug) Printer.debug("  dataline already open");

            // if the line is already open and the requested format differs from the
            // current settings, throw an IllegalStateException
            //$$fb 2002-04-02: fix for 4661602: Buffersize is checked when re-opening line
            if (!format.matches(getFormat())) {
                throw new IllegalStateException("Line is already open with format " + getFormat() +
                                                " and bufferSize " + getBufferSize());
            }
            //$$fb 2002-07-26: allow changing the buffersize of already open lines
            if (bufferSize > 0) {
                setBufferSize(bufferSize);
            }
        }

        if (Printer.trace) Printer.trace("< AbstractDataLine.open(format, bufferSize) completed");
    }
}