Java Code Examples for javax.sound.sampled.AudioFormat#matches()
The following examples show how to use
javax.sound.sampled.AudioFormat#matches() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FormatConversionProvider.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 2
Source File: UlawCodec.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * 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; }
Example 3
Source File: DirectAudioDevice.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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; }
Example 4
Source File: FormatConversionProvider.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 5
Source File: AbstractDataLine.java From Bytecoder with Apache License 2.0 | 5 votes |
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); } } } }
Example 6
Source File: FormatConversionProvider.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 7
Source File: FormatConversionProvider.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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; }
Example 8
Source File: FormatConversionProvider.java From Java8CN with Apache License 2.0 | 5 votes |
/** * 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; }
Example 9
Source File: FormatConversionProvider.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 10
Source File: FormatConversionProvider.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 11
Source File: FormatConversionProvider.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 12
Source File: FormatConversionProvider.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 13
Source File: FormatConversionProvider.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 14
Source File: AbstractDataLine.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
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"); } }
Example 15
Source File: AbstractDataLine.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
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"); } }
Example 16
Source File: AbstractDataLine.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
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"); } }
Example 17
Source File: PCMtoPCMCodec.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * 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; }
Example 18
Source File: AbstractDataLine.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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"); } }
Example 19
Source File: PCMtoPCMCodec.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * 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; }
Example 20
Source File: AbstractDataLine.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
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"); } }