feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
418
jdkSrc/jdk8/javax/sound/sampled/AudioFileFormat.java
Normal file
418
jdkSrc/jdk8/javax/sound/sampled/AudioFileFormat.java
Normal file
@@ -0,0 +1,418 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* An instance of the <code>AudioFileFormat</code> class describes
|
||||
* an audio file, including the file type, the file's length in bytes,
|
||||
* the length in sample frames of the audio data contained in the file,
|
||||
* and the format of the audio data.
|
||||
* <p>
|
||||
* The <code>{@link AudioSystem}</code> class includes methods for determining the format
|
||||
* of an audio file, obtaining an audio input stream from an audio file, and
|
||||
* writing an audio file from an audio input stream.
|
||||
*
|
||||
* <p>An <code>AudioFileFormat</code> object can
|
||||
* include a set of properties. A property is a pair of key and value:
|
||||
* the key is of type <code>String</code>, the associated property
|
||||
* value is an arbitrary object.
|
||||
* Properties specify additional informational
|
||||
* meta data (like a author, copyright, or file duration).
|
||||
* Properties are optional information, and file reader and file
|
||||
* writer implementations are not required to provide or
|
||||
* recognize properties.
|
||||
*
|
||||
* <p>The following table lists some common properties that should
|
||||
* be used in implementations:
|
||||
*
|
||||
* <table border=1>
|
||||
* <caption>Audio File Format Properties</caption>
|
||||
* <tr>
|
||||
* <th>Property key</th>
|
||||
* <th>Value type</th>
|
||||
* <th>Description</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>"duration"</td>
|
||||
* <td>{@link java.lang.Long Long}</td>
|
||||
* <td>playback duration of the file in microseconds</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>"author"</td>
|
||||
* <td>{@link java.lang.String String}</td>
|
||||
* <td>name of the author of this file</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>"title"</td>
|
||||
* <td>{@link java.lang.String String}</td>
|
||||
* <td>title of this file</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>"copyright"</td>
|
||||
* <td>{@link java.lang.String String}</td>
|
||||
* <td>copyright message</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>"date"</td>
|
||||
* <td>{@link java.util.Date Date}</td>
|
||||
* <td>date of the recording or release</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>"comment"</td>
|
||||
* <td>{@link java.lang.String String}</td>
|
||||
* <td>an arbitrary text</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
*
|
||||
* @author David Rivas
|
||||
* @author Kara Kytle
|
||||
* @author Florian Bomers
|
||||
* @see AudioInputStream
|
||||
* @since 1.3
|
||||
*/
|
||||
public class AudioFileFormat {
|
||||
|
||||
|
||||
// INSTANCE VARIABLES
|
||||
|
||||
|
||||
/**
|
||||
* File type.
|
||||
*/
|
||||
private Type type;
|
||||
|
||||
/**
|
||||
* File length in bytes
|
||||
*/
|
||||
private int byteLength;
|
||||
|
||||
/**
|
||||
* Format of the audio data contained in the file.
|
||||
*/
|
||||
private AudioFormat format;
|
||||
|
||||
/**
|
||||
* Audio data length in sample frames
|
||||
*/
|
||||
private int frameLength;
|
||||
|
||||
|
||||
/** The set of properties */
|
||||
private HashMap<String, Object> properties;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an audio file format object.
|
||||
* This protected constructor is intended for use by providers of file-reading
|
||||
* services when returning information about an audio file or about supported audio file
|
||||
* formats.
|
||||
* @param type the type of the audio file
|
||||
* @param byteLength the length of the file in bytes, or <code>AudioSystem.NOT_SPECIFIED</code>
|
||||
* @param format the format of the audio data contained in the file
|
||||
* @param frameLength the audio data length in sample frames, or <code>AudioSystem.NOT_SPECIFIED</code>
|
||||
*
|
||||
* @see #getType
|
||||
*/
|
||||
protected AudioFileFormat(Type type, int byteLength, AudioFormat format, int frameLength) {
|
||||
|
||||
this.type = type;
|
||||
this.byteLength = byteLength;
|
||||
this.format = format;
|
||||
this.frameLength = frameLength;
|
||||
this.properties = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an audio file format object.
|
||||
* This public constructor may be used by applications to describe the
|
||||
* properties of a requested audio file.
|
||||
* @param type the type of the audio file
|
||||
* @param format the format of the audio data contained in the file
|
||||
* @param frameLength the audio data length in sample frames, or <code>AudioSystem.NOT_SPECIFIED</code>
|
||||
*/
|
||||
public AudioFileFormat(Type type, AudioFormat format, int frameLength) {
|
||||
|
||||
|
||||
this(type,AudioSystem.NOT_SPECIFIED,format,frameLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an audio file format object with a set of
|
||||
* defined properties.
|
||||
* This public constructor may be used by applications to describe the
|
||||
* properties of a requested audio file. The properties map
|
||||
* will be copied to prevent any changes to it.
|
||||
*
|
||||
* @param type the type of the audio file
|
||||
* @param format the format of the audio data contained in the file
|
||||
* @param frameLength the audio data length in sample frames, or
|
||||
* <code>AudioSystem.NOT_SPECIFIED</code>
|
||||
* @param properties a <code>Map<String,Object></code> object
|
||||
* with properties
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public AudioFileFormat(Type type, AudioFormat format,
|
||||
int frameLength, Map<String, Object> properties) {
|
||||
this(type,AudioSystem.NOT_SPECIFIED,format,frameLength);
|
||||
this.properties = new HashMap<String, Object>(properties);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the audio file type, such as <code>WAVE</code> or <code>AU</code>.
|
||||
* @return the audio file type
|
||||
*
|
||||
* @see Type#WAVE
|
||||
* @see Type#AU
|
||||
* @see Type#AIFF
|
||||
* @see Type#AIFC
|
||||
* @see Type#SND
|
||||
*/
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the size in bytes of the entire audio file (not just its audio data).
|
||||
* @return the audio file length in bytes
|
||||
* @see AudioSystem#NOT_SPECIFIED
|
||||
*/
|
||||
public int getByteLength() {
|
||||
return byteLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the format of the audio data contained in the audio file.
|
||||
* @return the audio data format
|
||||
*/
|
||||
public AudioFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the length of the audio data contained in the file, expressed in sample frames.
|
||||
* @return the number of sample frames of audio data in the file
|
||||
* @see AudioSystem#NOT_SPECIFIED
|
||||
*/
|
||||
public int getFrameLength() {
|
||||
return frameLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain an unmodifiable map of properties.
|
||||
* The concept of properties is further explained in
|
||||
* the {@link AudioFileFormat class description}.
|
||||
*
|
||||
* @return a <code>Map<String,Object></code> object containing
|
||||
* all properties. If no properties are recognized, an empty map is
|
||||
* returned.
|
||||
*
|
||||
* @see #getProperty(String)
|
||||
* @since 1.5
|
||||
*/
|
||||
public Map<String,Object> properties() {
|
||||
Map<String,Object> ret;
|
||||
if (properties == null) {
|
||||
ret = new HashMap<String,Object>(0);
|
||||
} else {
|
||||
ret = (Map<String,Object>) (properties.clone());
|
||||
}
|
||||
return (Map<String,Object>) Collections.unmodifiableMap(ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtain the property value specified by the key.
|
||||
* The concept of properties is further explained in
|
||||
* the {@link AudioFileFormat class description}.
|
||||
*
|
||||
* <p>If the specified property is not defined for a
|
||||
* particular file format, this method returns
|
||||
* <code>null</code>.
|
||||
*
|
||||
* @param key the key of the desired property
|
||||
* @return the value of the property with the specified key,
|
||||
* or <code>null</code> if the property does not exist.
|
||||
*
|
||||
* @see #properties()
|
||||
* @since 1.5
|
||||
*/
|
||||
public Object getProperty(String key) {
|
||||
if (properties == null) {
|
||||
return null;
|
||||
}
|
||||
return properties.get(key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides a string representation of the file format.
|
||||
* @return the file format as a string
|
||||
*/
|
||||
public String toString() {
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
//$$fb2002-11-01: fix for 4672864: AudioFileFormat.toString() throws unexpected NullPointerException
|
||||
if (type != null) {
|
||||
buf.append(type.toString() + " (." + type.getExtension() + ") file");
|
||||
} else {
|
||||
buf.append("unknown file format");
|
||||
}
|
||||
|
||||
if (byteLength != AudioSystem.NOT_SPECIFIED) {
|
||||
buf.append(", byte length: " + byteLength);
|
||||
}
|
||||
|
||||
buf.append(", data format: " + format);
|
||||
|
||||
if (frameLength != AudioSystem.NOT_SPECIFIED) {
|
||||
buf.append(", frame length: " + frameLength);
|
||||
}
|
||||
|
||||
return new String(buf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An instance of the <code>Type</code> class represents one of the
|
||||
* standard types of audio file. Static instances are provided for the
|
||||
* common types.
|
||||
*/
|
||||
public static class Type {
|
||||
|
||||
// FILE FORMAT TYPE DEFINES
|
||||
|
||||
/**
|
||||
* Specifies a WAVE file.
|
||||
*/
|
||||
public static final Type WAVE = new Type("WAVE", "wav");
|
||||
|
||||
/**
|
||||
* Specifies an AU file.
|
||||
*/
|
||||
public static final Type AU = new Type("AU", "au");
|
||||
|
||||
/**
|
||||
* Specifies an AIFF file.
|
||||
*/
|
||||
public static final Type AIFF = new Type("AIFF", "aif");
|
||||
|
||||
/**
|
||||
* Specifies an AIFF-C file.
|
||||
*/
|
||||
public static final Type AIFC = new Type("AIFF-C", "aifc");
|
||||
|
||||
/**
|
||||
* Specifies a SND file.
|
||||
*/
|
||||
public static final Type SND = new Type("SND", "snd");
|
||||
|
||||
|
||||
// INSTANCE VARIABLES
|
||||
|
||||
/**
|
||||
* File type name.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* File type extension.
|
||||
*/
|
||||
private final String extension;
|
||||
|
||||
|
||||
// CONSTRUCTOR
|
||||
|
||||
/**
|
||||
* Constructs a file type.
|
||||
* @param name the string that names the file type
|
||||
* @param extension the string that commonly marks the file type
|
||||
* without leading dot.
|
||||
*/
|
||||
public Type(String name, String extension) {
|
||||
|
||||
this.name = name;
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
|
||||
// METHODS
|
||||
|
||||
/**
|
||||
* Finalizes the equals method
|
||||
*/
|
||||
public final boolean equals(Object obj) {
|
||||
if (toString() == null) {
|
||||
return (obj != null) && (obj.toString() == null);
|
||||
}
|
||||
if (obj instanceof Type) {
|
||||
return toString().equals(obj.toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes the hashCode method
|
||||
*/
|
||||
public final int hashCode() {
|
||||
if (toString() == null) {
|
||||
return 0;
|
||||
}
|
||||
return toString().hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the file type's name as the <code>String</code> representation
|
||||
* of the file type.
|
||||
* @return the file type's name
|
||||
*/
|
||||
public final String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the common file name extension for this file type.
|
||||
* @return file type extension
|
||||
*/
|
||||
public String getExtension() {
|
||||
return extension;
|
||||
}
|
||||
|
||||
} // class Type
|
||||
|
||||
} // class AudioFileFormat
|
670
jdkSrc/jdk8/javax/sound/sampled/AudioFormat.java
Normal file
670
jdkSrc/jdk8/javax/sound/sampled/AudioFormat.java
Normal file
@@ -0,0 +1,670 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <code>AudioFormat</code> is the class that specifies a particular arrangement of data in a sound stream.
|
||||
* By examining the information stored in the audio format, you can discover how to interpret the bits in the
|
||||
* binary sound data.
|
||||
* <p>
|
||||
* Every data line has an audio format associated with its data stream. The audio format of a source (playback) data line indicates
|
||||
* what kind of data the data line expects to receive for output. For a target (capture) data line, the audio format specifies the kind
|
||||
* of the data that can be read from the line.
|
||||
* Sound files also have audio formats, of course. The <code>{@link AudioFileFormat}</code>
|
||||
* class encapsulates an <code>AudioFormat</code> in addition to other,
|
||||
* file-specific information. Similarly, an <code>{@link AudioInputStream}</code> has an
|
||||
* <code>AudioFormat</code>.
|
||||
* <p>
|
||||
* The <code>AudioFormat</code> class accommodates a number of common sound-file encoding techniques, including
|
||||
* pulse-code modulation (PCM), mu-law encoding, and a-law encoding. These encoding techniques are predefined,
|
||||
* but service providers can create new encoding types.
|
||||
* The encoding that a specific format uses is named by its <code>encoding</code> field.
|
||||
*<p>
|
||||
* In addition to the encoding, the audio format includes other properties that further specify the exact
|
||||
* arrangement of the data.
|
||||
* These include the number of channels, sample rate, sample size, byte order, frame rate, and frame size.
|
||||
* Sounds may have different numbers of audio channels: one for mono, two for stereo.
|
||||
* The sample rate measures how many "snapshots" (samples) of the sound pressure are taken per second, per channel.
|
||||
* (If the sound is stereo rather than mono, two samples are actually measured at each instant of time: one for the left channel,
|
||||
* and another for the right channel; however, the sample rate still measures the number per channel, so the rate is the same
|
||||
* regardless of the number of channels. This is the standard use of the term.)
|
||||
* The sample size indicates how many bits are used to store each snapshot; 8 and 16 are typical values.
|
||||
* For 16-bit samples (or any other sample size larger than a byte),
|
||||
* byte order is important; the bytes in each sample are arranged in
|
||||
* either the "little-endian" or "big-endian" style.
|
||||
* For encodings like PCM, a frame consists of the set of samples for all channels at a given
|
||||
* point in time, and so the size of a frame (in bytes) is always equal to the size of a sample (in bytes) times
|
||||
* the number of channels. However, with some other sorts of encodings a frame can contain
|
||||
* a bundle of compressed data for a whole series of samples, as well as additional, non-sample
|
||||
* data. For such encodings, the sample rate and sample size refer to the data after it is decoded into PCM,
|
||||
* and so they are completely different from the frame rate and frame size.
|
||||
*
|
||||
* <p>An <code>AudioFormat</code> object can include a set of
|
||||
* properties. A property is a pair of key and value: the key
|
||||
* is of type <code>String</code>, the associated property
|
||||
* value is an arbitrary object. Properties specify
|
||||
* additional format specifications, like the bit rate for
|
||||
* compressed formats. Properties are mainly used as a means
|
||||
* to transport additional information of the audio format
|
||||
* to and from the service providers. Therefore, properties
|
||||
* are ignored in the {@link #matches(AudioFormat)} method.
|
||||
* However, methods which rely on the installed service
|
||||
* providers, like {@link AudioSystem#isConversionSupported
|
||||
* (AudioFormat, AudioFormat) isConversionSupported} may consider
|
||||
* properties, depending on the respective service provider
|
||||
* implementation.
|
||||
*
|
||||
* <p>The following table lists some common properties which
|
||||
* service providers should use, if applicable:
|
||||
*
|
||||
* <table border=0>
|
||||
* <caption>Audio Format Properties</caption>
|
||||
* <tr>
|
||||
* <th>Property key</th>
|
||||
* <th>Value type</th>
|
||||
* <th>Description</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>"bitrate"</td>
|
||||
* <td>{@link java.lang.Integer Integer}</td>
|
||||
* <td>average bit rate in bits per second</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>"vbr"</td>
|
||||
* <td>{@link java.lang.Boolean Boolean}</td>
|
||||
* <td><code>true</code>, if the file is encoded in variable bit
|
||||
* rate (VBR)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>"quality"</td>
|
||||
* <td>{@link java.lang.Integer Integer}</td>
|
||||
* <td>encoding/conversion quality, 1..100</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* <p>Vendors of service providers (plugins) are encouraged
|
||||
* to seek information about other already established
|
||||
* properties in third party plugins, and follow the same
|
||||
* conventions.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @author Florian Bomers
|
||||
* @see DataLine#getFormat
|
||||
* @see AudioInputStream#getFormat
|
||||
* @see AudioFileFormat
|
||||
* @see javax.sound.sampled.spi.FormatConversionProvider
|
||||
* @since 1.3
|
||||
*/
|
||||
public class AudioFormat {
|
||||
|
||||
// INSTANCE VARIABLES
|
||||
|
||||
|
||||
/**
|
||||
* The audio encoding technique used by this format.
|
||||
*/
|
||||
protected Encoding encoding;
|
||||
|
||||
/**
|
||||
* The number of samples played or recorded per second, for sounds that have this format.
|
||||
*/
|
||||
protected float sampleRate;
|
||||
|
||||
/**
|
||||
* The number of bits in each sample of a sound that has this format.
|
||||
*/
|
||||
protected int sampleSizeInBits;
|
||||
|
||||
/**
|
||||
* The number of audio channels in this format (1 for mono, 2 for stereo).
|
||||
*/
|
||||
protected int channels;
|
||||
|
||||
/**
|
||||
* The number of bytes in each frame of a sound that has this format.
|
||||
*/
|
||||
protected int frameSize;
|
||||
|
||||
/**
|
||||
* The number of frames played or recorded per second, for sounds that have this format.
|
||||
*/
|
||||
protected float frameRate;
|
||||
|
||||
/**
|
||||
* Indicates whether the audio data is stored in big-endian or little-endian order.
|
||||
*/
|
||||
protected boolean bigEndian;
|
||||
|
||||
|
||||
/** The set of properties */
|
||||
private HashMap<String, Object> properties;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an <code>AudioFormat</code> with the given parameters.
|
||||
* The encoding specifies the convention used to represent the data.
|
||||
* The other parameters are further explained in the {@link AudioFormat
|
||||
* class description}.
|
||||
* @param encoding the audio encoding technique
|
||||
* @param sampleRate the number of samples per second
|
||||
* @param sampleSizeInBits the number of bits in each sample
|
||||
* @param channels the number of channels (1 for mono, 2 for stereo, and so on)
|
||||
* @param frameSize the number of bytes in each frame
|
||||
* @param frameRate the number of frames per second
|
||||
* @param bigEndian indicates whether the data for a single sample
|
||||
* is stored in big-endian byte order (<code>false</code>
|
||||
* means little-endian)
|
||||
*/
|
||||
public AudioFormat(Encoding encoding, float sampleRate, int sampleSizeInBits,
|
||||
int channels, int frameSize, float frameRate, boolean bigEndian) {
|
||||
|
||||
this.encoding = encoding;
|
||||
this.sampleRate = sampleRate;
|
||||
this.sampleSizeInBits = sampleSizeInBits;
|
||||
this.channels = channels;
|
||||
this.frameSize = frameSize;
|
||||
this.frameRate = frameRate;
|
||||
this.bigEndian = bigEndian;
|
||||
this.properties = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an <code>AudioFormat</code> with the given parameters.
|
||||
* The encoding specifies the convention used to represent the data.
|
||||
* The other parameters are further explained in the {@link AudioFormat
|
||||
* class description}.
|
||||
* @param encoding the audio encoding technique
|
||||
* @param sampleRate the number of samples per second
|
||||
* @param sampleSizeInBits the number of bits in each sample
|
||||
* @param channels the number of channels (1 for mono, 2 for
|
||||
* stereo, and so on)
|
||||
* @param frameSize the number of bytes in each frame
|
||||
* @param frameRate the number of frames per second
|
||||
* @param bigEndian indicates whether the data for a single sample
|
||||
* is stored in big-endian byte order
|
||||
* (<code>false</code> means little-endian)
|
||||
* @param properties a <code>Map<String,Object></code> object
|
||||
* containing format properties
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public AudioFormat(Encoding encoding, float sampleRate,
|
||||
int sampleSizeInBits, int channels,
|
||||
int frameSize, float frameRate,
|
||||
boolean bigEndian, Map<String, Object> properties) {
|
||||
this(encoding, sampleRate, sampleSizeInBits, channels,
|
||||
frameSize, frameRate, bigEndian);
|
||||
this.properties = new HashMap<String, Object>(properties);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an <code>AudioFormat</code> with a linear PCM encoding and
|
||||
* the given parameters. The frame size is set to the number of bytes
|
||||
* required to contain one sample from each channel, and the frame rate
|
||||
* is set to the sample rate.
|
||||
*
|
||||
* @param sampleRate the number of samples per second
|
||||
* @param sampleSizeInBits the number of bits in each sample
|
||||
* @param channels the number of channels (1 for mono, 2 for stereo, and so on)
|
||||
* @param signed indicates whether the data is signed or unsigned
|
||||
* @param bigEndian indicates whether the data for a single sample
|
||||
* is stored in big-endian byte order (<code>false</code>
|
||||
* means little-endian)
|
||||
*/
|
||||
public AudioFormat(float sampleRate, int sampleSizeInBits,
|
||||
int channels, boolean signed, boolean bigEndian) {
|
||||
|
||||
this((signed == true ? Encoding.PCM_SIGNED : Encoding.PCM_UNSIGNED),
|
||||
sampleRate,
|
||||
sampleSizeInBits,
|
||||
channels,
|
||||
(channels == AudioSystem.NOT_SPECIFIED || sampleSizeInBits == AudioSystem.NOT_SPECIFIED)?
|
||||
AudioSystem.NOT_SPECIFIED:
|
||||
((sampleSizeInBits + 7) / 8) * channels,
|
||||
sampleRate,
|
||||
bigEndian);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the type of encoding for sounds in this format.
|
||||
*
|
||||
* @return the encoding type
|
||||
* @see Encoding#PCM_SIGNED
|
||||
* @see Encoding#PCM_UNSIGNED
|
||||
* @see Encoding#ULAW
|
||||
* @see Encoding#ALAW
|
||||
*/
|
||||
public Encoding getEncoding() {
|
||||
|
||||
return encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the sample rate.
|
||||
* For compressed formats, the return value is the sample rate of the uncompressed
|
||||
* audio data.
|
||||
* When this AudioFormat is used for queries (e.g. {@link
|
||||
* AudioSystem#isConversionSupported(AudioFormat, AudioFormat)
|
||||
* AudioSystem.isConversionSupported}) or capabilities (e.g. {@link
|
||||
* DataLine.Info#getFormats() DataLine.Info.getFormats}), a sample rate of
|
||||
* <code>AudioSystem.NOT_SPECIFIED</code> means that any sample rate is
|
||||
* acceptable. <code>AudioSystem.NOT_SPECIFIED</code> is also returned when
|
||||
* the sample rate is not defined for this audio format.
|
||||
* @return the number of samples per second,
|
||||
* or <code>AudioSystem.NOT_SPECIFIED</code>
|
||||
*
|
||||
* @see #getFrameRate()
|
||||
* @see AudioSystem#NOT_SPECIFIED
|
||||
*/
|
||||
public float getSampleRate() {
|
||||
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the size of a sample.
|
||||
* For compressed formats, the return value is the sample size of the
|
||||
* uncompressed audio data.
|
||||
* When this AudioFormat is used for queries (e.g. {@link
|
||||
* AudioSystem#isConversionSupported(AudioFormat, AudioFormat)
|
||||
* AudioSystem.isConversionSupported}) or capabilities (e.g. {@link
|
||||
* DataLine.Info#getFormats() DataLine.Info.getFormats}), a sample size of
|
||||
* <code>AudioSystem.NOT_SPECIFIED</code> means that any sample size is
|
||||
* acceptable. <code>AudioSystem.NOT_SPECIFIED</code> is also returned when
|
||||
* the sample size is not defined for this audio format.
|
||||
* @return the number of bits in each sample,
|
||||
* or <code>AudioSystem.NOT_SPECIFIED</code>
|
||||
*
|
||||
* @see #getFrameSize()
|
||||
* @see AudioSystem#NOT_SPECIFIED
|
||||
*/
|
||||
public int getSampleSizeInBits() {
|
||||
|
||||
return sampleSizeInBits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the number of channels.
|
||||
* When this AudioFormat is used for queries (e.g. {@link
|
||||
* AudioSystem#isConversionSupported(AudioFormat, AudioFormat)
|
||||
* AudioSystem.isConversionSupported}) or capabilities (e.g. {@link
|
||||
* DataLine.Info#getFormats() DataLine.Info.getFormats}), a return value of
|
||||
* <code>AudioSystem.NOT_SPECIFIED</code> means that any (positive) number of channels is
|
||||
* acceptable.
|
||||
* @return The number of channels (1 for mono, 2 for stereo, etc.),
|
||||
* or <code>AudioSystem.NOT_SPECIFIED</code>
|
||||
*
|
||||
* @see AudioSystem#NOT_SPECIFIED
|
||||
*/
|
||||
public int getChannels() {
|
||||
|
||||
return channels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the frame size in bytes.
|
||||
* When this AudioFormat is used for queries (e.g. {@link
|
||||
* AudioSystem#isConversionSupported(AudioFormat, AudioFormat)
|
||||
* AudioSystem.isConversionSupported}) or capabilities (e.g. {@link
|
||||
* DataLine.Info#getFormats() DataLine.Info.getFormats}), a frame size of
|
||||
* <code>AudioSystem.NOT_SPECIFIED</code> means that any frame size is
|
||||
* acceptable. <code>AudioSystem.NOT_SPECIFIED</code> is also returned when
|
||||
* the frame size is not defined for this audio format.
|
||||
* @return the number of bytes per frame,
|
||||
* or <code>AudioSystem.NOT_SPECIFIED</code>
|
||||
*
|
||||
* @see #getSampleSizeInBits()
|
||||
* @see AudioSystem#NOT_SPECIFIED
|
||||
*/
|
||||
public int getFrameSize() {
|
||||
|
||||
return frameSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the frame rate in frames per second.
|
||||
* When this AudioFormat is used for queries (e.g. {@link
|
||||
* AudioSystem#isConversionSupported(AudioFormat, AudioFormat)
|
||||
* AudioSystem.isConversionSupported}) or capabilities (e.g. {@link
|
||||
* DataLine.Info#getFormats() DataLine.Info.getFormats}), a frame rate of
|
||||
* <code>AudioSystem.NOT_SPECIFIED</code> means that any frame rate is
|
||||
* acceptable. <code>AudioSystem.NOT_SPECIFIED</code> is also returned when
|
||||
* the frame rate is not defined for this audio format.
|
||||
* @return the number of frames per second,
|
||||
* or <code>AudioSystem.NOT_SPECIFIED</code>
|
||||
*
|
||||
* @see #getSampleRate()
|
||||
* @see AudioSystem#NOT_SPECIFIED
|
||||
*/
|
||||
public float getFrameRate() {
|
||||
|
||||
return frameRate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether the audio data is stored in big-endian or little-endian
|
||||
* byte order. If the sample size is not more than one byte, the return value is
|
||||
* irrelevant.
|
||||
* @return <code>true</code> if the data is stored in big-endian byte order,
|
||||
* <code>false</code> if little-endian
|
||||
*/
|
||||
public boolean isBigEndian() {
|
||||
|
||||
return bigEndian;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtain an unmodifiable map of properties.
|
||||
* The concept of properties is further explained in
|
||||
* the {@link AudioFileFormat class description}.
|
||||
*
|
||||
* @return a <code>Map<String,Object></code> object containing
|
||||
* all properties. If no properties are recognized, an empty map is
|
||||
* returned.
|
||||
*
|
||||
* @see #getProperty(String)
|
||||
* @since 1.5
|
||||
*/
|
||||
public Map<String,Object> properties() {
|
||||
Map<String,Object> ret;
|
||||
if (properties == null) {
|
||||
ret = new HashMap<String,Object>(0);
|
||||
} else {
|
||||
ret = (Map<String,Object>) (properties.clone());
|
||||
}
|
||||
return (Map<String,Object>) Collections.unmodifiableMap(ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtain the property value specified by the key.
|
||||
* The concept of properties is further explained in
|
||||
* the {@link AudioFileFormat class description}.
|
||||
*
|
||||
* <p>If the specified property is not defined for a
|
||||
* particular file format, this method returns
|
||||
* <code>null</code>.
|
||||
*
|
||||
* @param key the key of the desired property
|
||||
* @return the value of the property with the specified key,
|
||||
* or <code>null</code> if the property does not exist.
|
||||
*
|
||||
* @see #properties()
|
||||
* @since 1.5
|
||||
*/
|
||||
public Object getProperty(String key) {
|
||||
if (properties == null) {
|
||||
return null;
|
||||
}
|
||||
return properties.get(key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether this format matches the one specified.
|
||||
* To match, two formats must have the same encoding,
|
||||
* and consistent values of the number of channels, sample rate, sample size,
|
||||
* frame rate, and frame size.
|
||||
* The values of the property are consistent if they are equal
|
||||
* or the specified format has the property value
|
||||
* {@code AudioSystem.NOT_SPECIFIED}.
|
||||
* The byte order (big-endian or little-endian) must be the same
|
||||
* if the sample size is greater than one byte.
|
||||
*
|
||||
* @param format format to test for match
|
||||
* @return {@code true} if this format matches the one specified,
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
public boolean matches(AudioFormat format) {
|
||||
if (format.getEncoding().equals(getEncoding())
|
||||
&& (format.getChannels() == AudioSystem.NOT_SPECIFIED
|
||||
|| format.getChannels() == getChannels())
|
||||
&& (format.getSampleRate() == (float)AudioSystem.NOT_SPECIFIED
|
||||
|| format.getSampleRate() == getSampleRate())
|
||||
&& (format.getSampleSizeInBits() == AudioSystem.NOT_SPECIFIED
|
||||
|| format.getSampleSizeInBits() == getSampleSizeInBits())
|
||||
&& (format.getFrameRate() == (float)AudioSystem.NOT_SPECIFIED
|
||||
|| format.getFrameRate() == getFrameRate())
|
||||
&& (format.getFrameSize() == AudioSystem.NOT_SPECIFIED
|
||||
|| format.getFrameSize() == getFrameSize())
|
||||
&& (getSampleSizeInBits() <= 8
|
||||
|| format.isBigEndian() == isBigEndian())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string that describes the format, such as:
|
||||
* "PCM SIGNED 22050 Hz 16 bit mono big-endian". The contents of the string
|
||||
* may vary between implementations of Java Sound.
|
||||
*
|
||||
* @return a string that describes the format parameters
|
||||
*/
|
||||
public String toString() {
|
||||
String sEncoding = "";
|
||||
if (getEncoding() != null) {
|
||||
sEncoding = getEncoding().toString() + " ";
|
||||
}
|
||||
|
||||
String sSampleRate;
|
||||
if (getSampleRate() == (float) AudioSystem.NOT_SPECIFIED) {
|
||||
sSampleRate = "unknown sample rate, ";
|
||||
} else {
|
||||
sSampleRate = "" + getSampleRate() + " Hz, ";
|
||||
}
|
||||
|
||||
String sSampleSizeInBits;
|
||||
if (getSampleSizeInBits() == (float) AudioSystem.NOT_SPECIFIED) {
|
||||
sSampleSizeInBits = "unknown bits per sample, ";
|
||||
} else {
|
||||
sSampleSizeInBits = "" + getSampleSizeInBits() + " bit, ";
|
||||
}
|
||||
|
||||
String sChannels;
|
||||
if (getChannels() == 1) {
|
||||
sChannels = "mono, ";
|
||||
} else
|
||||
if (getChannels() == 2) {
|
||||
sChannels = "stereo, ";
|
||||
} else {
|
||||
if (getChannels() == AudioSystem.NOT_SPECIFIED) {
|
||||
sChannels = " unknown number of channels, ";
|
||||
} else {
|
||||
sChannels = ""+getChannels()+" channels, ";
|
||||
}
|
||||
}
|
||||
|
||||
String sFrameSize;
|
||||
if (getFrameSize() == (float) AudioSystem.NOT_SPECIFIED) {
|
||||
sFrameSize = "unknown frame size, ";
|
||||
} else {
|
||||
sFrameSize = "" + getFrameSize()+ " bytes/frame, ";
|
||||
}
|
||||
|
||||
String sFrameRate = "";
|
||||
if (Math.abs(getSampleRate() - getFrameRate()) > 0.00001) {
|
||||
if (getFrameRate() == (float) AudioSystem.NOT_SPECIFIED) {
|
||||
sFrameRate = "unknown frame rate, ";
|
||||
} else {
|
||||
sFrameRate = getFrameRate() + " frames/second, ";
|
||||
}
|
||||
}
|
||||
|
||||
String sEndian = "";
|
||||
if ((getEncoding().equals(Encoding.PCM_SIGNED)
|
||||
|| getEncoding().equals(Encoding.PCM_UNSIGNED))
|
||||
&& ((getSampleSizeInBits() > 8)
|
||||
|| (getSampleSizeInBits() == AudioSystem.NOT_SPECIFIED))) {
|
||||
if (isBigEndian()) {
|
||||
sEndian = "big-endian";
|
||||
} else {
|
||||
sEndian = "little-endian";
|
||||
}
|
||||
}
|
||||
|
||||
return sEncoding
|
||||
+ sSampleRate
|
||||
+ sSampleSizeInBits
|
||||
+ sChannels
|
||||
+ sFrameSize
|
||||
+ sFrameRate
|
||||
+ sEndian;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>Encoding</code> class names the specific type of data representation
|
||||
* used for an audio stream. The encoding includes aspects of the
|
||||
* sound format other than the number of channels, sample rate, sample size,
|
||||
* frame rate, frame size, and byte order.
|
||||
* <p>
|
||||
* One ubiquitous type of audio encoding is pulse-code modulation (PCM),
|
||||
* which is simply a linear (proportional) representation of the sound
|
||||
* waveform. With PCM, the number stored in each sample is proportional
|
||||
* to the instantaneous amplitude of the sound pressure at that point in
|
||||
* time. The numbers may be signed or unsigned integers or floats.
|
||||
* Besides PCM, other encodings include mu-law and a-law, which are nonlinear
|
||||
* mappings of the sound amplitude that are often used for recording speech.
|
||||
* <p>
|
||||
* You can use a predefined encoding by referring to one of the static
|
||||
* objects created by this class, such as PCM_SIGNED or
|
||||
* PCM_UNSIGNED. Service providers can create new encodings, such as
|
||||
* compressed audio formats, and make
|
||||
* these available through the <code>{@link AudioSystem}</code> class.
|
||||
* <p>
|
||||
* The <code>Encoding</code> class is static, so that all
|
||||
* <code>AudioFormat</code> objects that have the same encoding will refer
|
||||
* to the same object (rather than different instances of the same class).
|
||||
* This allows matches to be made by checking that two format's encodings
|
||||
* are equal.
|
||||
*
|
||||
* @see AudioFormat
|
||||
* @see javax.sound.sampled.spi.FormatConversionProvider
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class Encoding {
|
||||
|
||||
|
||||
// ENCODING DEFINES
|
||||
|
||||
/**
|
||||
* Specifies signed, linear PCM data.
|
||||
*/
|
||||
public static final Encoding PCM_SIGNED = new Encoding("PCM_SIGNED");
|
||||
|
||||
/**
|
||||
* Specifies unsigned, linear PCM data.
|
||||
*/
|
||||
public static final Encoding PCM_UNSIGNED = new Encoding("PCM_UNSIGNED");
|
||||
|
||||
/**
|
||||
* Specifies floating-point PCM data.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final Encoding PCM_FLOAT = new Encoding("PCM_FLOAT");
|
||||
|
||||
/**
|
||||
* Specifies u-law encoded data.
|
||||
*/
|
||||
public static final Encoding ULAW = new Encoding("ULAW");
|
||||
|
||||
/**
|
||||
* Specifies a-law encoded data.
|
||||
*/
|
||||
public static final Encoding ALAW = new Encoding("ALAW");
|
||||
|
||||
|
||||
// INSTANCE VARIABLES
|
||||
|
||||
/**
|
||||
* Encoding name.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
|
||||
// CONSTRUCTOR
|
||||
|
||||
/**
|
||||
* Constructs a new encoding.
|
||||
* @param name the name of the new type of encoding
|
||||
*/
|
||||
public Encoding(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
// METHODS
|
||||
|
||||
/**
|
||||
* Finalizes the equals method
|
||||
*/
|
||||
public final boolean equals(Object obj) {
|
||||
if (toString() == null) {
|
||||
return (obj != null) && (obj.toString() == null);
|
||||
}
|
||||
if (obj instanceof Encoding) {
|
||||
return toString().equals(obj.toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes the hashCode method
|
||||
*/
|
||||
public final int hashCode() {
|
||||
if (toString() == null) {
|
||||
return 0;
|
||||
}
|
||||
return toString().hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the <code>String</code> representation of the encoding. This <code>String</code> is
|
||||
* the same name that was passed to the constructor. For the predefined encodings, the name
|
||||
* is similar to the encoding's variable (field) name. For example, <code>PCM_SIGNED.toString()</code> returns
|
||||
* the name "pcm_signed".
|
||||
*
|
||||
* @return the encoding name
|
||||
*/
|
||||
public final String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
} // class Encoding
|
||||
}
|
515
jdkSrc/jdk8/javax/sound/sampled/AudioInputStream.java
Normal file
515
jdkSrc/jdk8/javax/sound/sampled/AudioInputStream.java
Normal file
@@ -0,0 +1,515 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.PushbackInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* An audio input stream is an input stream with a specified audio format and
|
||||
* length. The length is expressed in sample frames, not bytes.
|
||||
* Several methods are provided for reading a certain number of bytes from
|
||||
* the stream, or an unspecified number of bytes.
|
||||
* The audio input stream keeps track of the last byte that was read.
|
||||
* You can skip over an arbitrary number of bytes to get to a later position
|
||||
* for reading. An audio input stream may support marks. When you set a mark,
|
||||
* the current position is remembered so that you can return to it later.
|
||||
* <p>
|
||||
* The <code>AudioSystem</code> class includes many methods that manipulate
|
||||
* <code>AudioInputStream</code> objects.
|
||||
* For example, the methods let you:
|
||||
* <ul>
|
||||
* <li> obtain an
|
||||
* audio input stream from an external audio file, stream, or URL
|
||||
* <li> write an external file from an audio input stream
|
||||
* <li> convert an audio input stream to a different audio format
|
||||
* </ul>
|
||||
*
|
||||
* @author David Rivas
|
||||
* @author Kara Kytle
|
||||
* @author Florian Bomers
|
||||
*
|
||||
* @see AudioSystem
|
||||
* @see Clip#open(AudioInputStream) Clip.open(AudioInputStream)
|
||||
* @since 1.3
|
||||
*/
|
||||
public class AudioInputStream extends InputStream {
|
||||
|
||||
/**
|
||||
* The <code>InputStream</code> from which this <code>AudioInputStream</code>
|
||||
* object was constructed.
|
||||
*/
|
||||
private InputStream stream;
|
||||
|
||||
/**
|
||||
* The format of the audio data contained in the stream.
|
||||
*/
|
||||
protected AudioFormat format;
|
||||
|
||||
/**
|
||||
* This stream's length, in sample frames.
|
||||
*/
|
||||
protected long frameLength;
|
||||
|
||||
/**
|
||||
* The size of each frame, in bytes.
|
||||
*/
|
||||
protected int frameSize;
|
||||
|
||||
/**
|
||||
* The current position in this stream, in sample frames (zero-based).
|
||||
*/
|
||||
protected long framePos;
|
||||
|
||||
/**
|
||||
* The position where a mark was set.
|
||||
*/
|
||||
private long markpos;
|
||||
|
||||
/**
|
||||
* When the underlying stream could only return
|
||||
* a non-integral number of frames, store
|
||||
* the remainder in a temporary buffer
|
||||
*/
|
||||
private byte[] pushBackBuffer = null;
|
||||
|
||||
/**
|
||||
* number of valid bytes in the pushBackBuffer
|
||||
*/
|
||||
private int pushBackLen = 0;
|
||||
|
||||
/**
|
||||
* MarkBuffer at mark position
|
||||
*/
|
||||
private byte[] markPushBackBuffer = null;
|
||||
|
||||
/**
|
||||
* number of valid bytes in the markPushBackBuffer
|
||||
*/
|
||||
private int markPushBackLen = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an audio input stream that has the requested format and length in sample frames,
|
||||
* using audio data from the specified input stream.
|
||||
* @param stream the stream on which this <code>AudioInputStream</code>
|
||||
* object is based
|
||||
* @param format the format of this stream's audio data
|
||||
* @param length the length in sample frames of the data in this stream
|
||||
*/
|
||||
public AudioInputStream(InputStream stream, AudioFormat format, long length) {
|
||||
|
||||
super();
|
||||
|
||||
this.format = format;
|
||||
this.frameLength = length;
|
||||
this.frameSize = format.getFrameSize();
|
||||
|
||||
// any frameSize that is not well-defined will
|
||||
// cause that this stream will be read in bytes
|
||||
if( this.frameSize == AudioSystem.NOT_SPECIFIED || frameSize <= 0) {
|
||||
this.frameSize = 1;
|
||||
}
|
||||
|
||||
this.stream = stream;
|
||||
framePos = 0;
|
||||
markpos = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an audio input stream that reads its data from the target
|
||||
* data line indicated. The format of the stream is the same as that of
|
||||
* the target data line, and the length is AudioSystem#NOT_SPECIFIED.
|
||||
* @param line the target data line from which this stream obtains its data.
|
||||
* @see AudioSystem#NOT_SPECIFIED
|
||||
*/
|
||||
public AudioInputStream(TargetDataLine line) {
|
||||
|
||||
TargetDataLineInputStream tstream = new TargetDataLineInputStream(line);
|
||||
format = line.getFormat();
|
||||
frameLength = AudioSystem.NOT_SPECIFIED;
|
||||
frameSize = format.getFrameSize();
|
||||
|
||||
if( frameSize == AudioSystem.NOT_SPECIFIED || frameSize <= 0) {
|
||||
frameSize = 1;
|
||||
}
|
||||
this.stream = tstream;
|
||||
framePos = 0;
|
||||
markpos = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the audio format of the sound data in this audio input stream.
|
||||
* @return an audio format object describing this stream's format
|
||||
*/
|
||||
public AudioFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the length of the stream, expressed in sample frames rather than bytes.
|
||||
* @return the length in sample frames
|
||||
*/
|
||||
public long getFrameLength() {
|
||||
return frameLength;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next byte of data from the audio input stream. The audio input
|
||||
* stream's frame size must be one byte, or an <code>IOException</code>
|
||||
* will be thrown.
|
||||
*
|
||||
* @return the next byte of data, or -1 if the end of the stream is reached
|
||||
* @throws IOException if an input or output error occurs
|
||||
* @see #read(byte[], int, int)
|
||||
* @see #read(byte[])
|
||||
* @see #available
|
||||
* <p>
|
||||
*/
|
||||
public int read() throws IOException {
|
||||
if( frameSize != 1 ) {
|
||||
throw new IOException("cannot read a single byte if frame size > 1");
|
||||
}
|
||||
|
||||
byte[] data = new byte[1];
|
||||
int temp = read(data);
|
||||
if (temp <= 0) {
|
||||
// we have a weird situation if read(byte[]) returns 0!
|
||||
return -1;
|
||||
}
|
||||
return data[0] & 0xFF;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads some number of bytes from the audio input stream and stores them into
|
||||
* the buffer array <code>b</code>. The number of bytes actually read is
|
||||
* returned as an integer. This method blocks until input data is
|
||||
* available, the end of the stream is detected, or an exception is thrown.
|
||||
* <p>This method will always read an integral number of frames.
|
||||
* If the length of the array is not an integral number
|
||||
* of frames, a maximum of <code>b.length - (b.length % frameSize)
|
||||
* </code> bytes will be read.
|
||||
*
|
||||
* @param b the buffer into which the data is read
|
||||
* @return the total number of bytes read into the buffer, or -1 if there
|
||||
* is no more data because the end of the stream has been reached
|
||||
* @throws IOException if an input or output error occurs
|
||||
* @see #read(byte[], int, int)
|
||||
* @see #read()
|
||||
* @see #available
|
||||
*/
|
||||
public int read(byte[] b) throws IOException {
|
||||
return read(b,0,b.length);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads up to a specified maximum number of bytes of data from the audio
|
||||
* stream, putting them into the given byte array.
|
||||
* <p>This method will always read an integral number of frames.
|
||||
* If <code>len</code> does not specify an integral number
|
||||
* of frames, a maximum of <code>len - (len % frameSize)
|
||||
* </code> bytes will be read.
|
||||
*
|
||||
* @param b the buffer into which the data is read
|
||||
* @param off the offset, from the beginning of array <code>b</code>, at which
|
||||
* the data will be written
|
||||
* @param len the maximum number of bytes to read
|
||||
* @return the total number of bytes read into the buffer, or -1 if there
|
||||
* is no more data because the end of the stream has been reached
|
||||
* @throws IOException if an input or output error occurs
|
||||
* @see #read(byte[])
|
||||
* @see #read()
|
||||
* @see #skip
|
||||
* @see #available
|
||||
*/
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
|
||||
// make sure we don't read fractions of a frame.
|
||||
if( (len%frameSize) != 0 ) {
|
||||
len -= (len%frameSize);
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if( frameLength != AudioSystem.NOT_SPECIFIED ) {
|
||||
if( framePos >= frameLength ) {
|
||||
return -1;
|
||||
} else {
|
||||
|
||||
// don't try to read beyond our own set length in frames
|
||||
if( (len/frameSize) > (frameLength-framePos) ) {
|
||||
len = (int) (frameLength-framePos) * frameSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int bytesRead = 0;
|
||||
int thisOff = off;
|
||||
|
||||
// if we've bytes left from last call to read(),
|
||||
// use them first
|
||||
if (pushBackLen > 0 && len >= pushBackLen) {
|
||||
System.arraycopy(pushBackBuffer, 0,
|
||||
b, off, pushBackLen);
|
||||
thisOff += pushBackLen;
|
||||
len -= pushBackLen;
|
||||
bytesRead += pushBackLen;
|
||||
pushBackLen = 0;
|
||||
}
|
||||
|
||||
int thisBytesRead = stream.read(b, thisOff, len);
|
||||
if (thisBytesRead == -1) {
|
||||
return -1;
|
||||
}
|
||||
if (thisBytesRead > 0) {
|
||||
bytesRead += thisBytesRead;
|
||||
}
|
||||
if (bytesRead > 0) {
|
||||
pushBackLen = bytesRead % frameSize;
|
||||
if (pushBackLen > 0) {
|
||||
// copy everything we got from the beginning of the frame
|
||||
// to our pushback buffer
|
||||
if (pushBackBuffer == null) {
|
||||
pushBackBuffer = new byte[frameSize];
|
||||
}
|
||||
System.arraycopy(b, off + bytesRead - pushBackLen,
|
||||
pushBackBuffer, 0, pushBackLen);
|
||||
bytesRead -= pushBackLen;
|
||||
}
|
||||
// make sure to update our framePos
|
||||
framePos += bytesRead/frameSize;
|
||||
}
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Skips over and discards a specified number of bytes from this
|
||||
* audio input stream.
|
||||
* @param n the requested number of bytes to be skipped
|
||||
* @return the actual number of bytes skipped
|
||||
* @throws IOException if an input or output error occurs
|
||||
* @see #read
|
||||
* @see #available
|
||||
*/
|
||||
public long skip(long n) throws IOException {
|
||||
|
||||
// make sure not to skip fractional frames
|
||||
if( (n%frameSize) != 0 ) {
|
||||
n -= (n%frameSize);
|
||||
}
|
||||
|
||||
if( frameLength != AudioSystem.NOT_SPECIFIED ) {
|
||||
// don't skip more than our set length in frames.
|
||||
if( (n/frameSize) > (frameLength-framePos) ) {
|
||||
n = (frameLength-framePos) * frameSize;
|
||||
}
|
||||
}
|
||||
long temp = stream.skip(n);
|
||||
|
||||
// if no error, update our position.
|
||||
if( temp%frameSize != 0 ) {
|
||||
|
||||
// Throw an IOException if we've skipped a fractional number of frames
|
||||
throw new IOException("Could not skip an integer number of frames.");
|
||||
}
|
||||
if( temp >= 0 ) {
|
||||
framePos += temp/frameSize;
|
||||
}
|
||||
return temp;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the maximum number of bytes that can be read (or skipped over) from this
|
||||
* audio input stream without blocking. This limit applies only to the next invocation of
|
||||
* a <code>read</code> or <code>skip</code> method for this audio input stream; the limit
|
||||
* can vary each time these methods are invoked.
|
||||
* Depending on the underlying stream,an IOException may be thrown if this
|
||||
* stream is closed.
|
||||
* @return the number of bytes that can be read from this audio input stream without blocking
|
||||
* @throws IOException if an input or output error occurs
|
||||
* @see #read(byte[], int, int)
|
||||
* @see #read(byte[])
|
||||
* @see #read()
|
||||
* @see #skip
|
||||
*/
|
||||
public int available() throws IOException {
|
||||
|
||||
int temp = stream.available();
|
||||
|
||||
// don't return greater than our set length in frames
|
||||
if( (frameLength != AudioSystem.NOT_SPECIFIED) && ( (temp/frameSize) > (frameLength-framePos)) ) {
|
||||
return (int) (frameLength-framePos) * frameSize;
|
||||
} else {
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Closes this audio input stream and releases any system resources associated
|
||||
* with the stream.
|
||||
* @throws IOException if an input or output error occurs
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
stream.close();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Marks the current position in this audio input stream.
|
||||
* @param readlimit the maximum number of bytes that can be read before
|
||||
* the mark position becomes invalid.
|
||||
* @see #reset
|
||||
* @see #markSupported
|
||||
*/
|
||||
|
||||
public void mark(int readlimit) {
|
||||
|
||||
stream.mark(readlimit);
|
||||
if (markSupported()) {
|
||||
markpos = framePos;
|
||||
// remember the pushback buffer
|
||||
markPushBackLen = pushBackLen;
|
||||
if (markPushBackLen > 0) {
|
||||
if (markPushBackBuffer == null) {
|
||||
markPushBackBuffer = new byte[frameSize];
|
||||
}
|
||||
System.arraycopy(pushBackBuffer, 0, markPushBackBuffer, 0, markPushBackLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Repositions this audio input stream to the position it had at the time its
|
||||
* <code>mark</code> method was last invoked.
|
||||
* @throws IOException if an input or output error occurs.
|
||||
* @see #mark
|
||||
* @see #markSupported
|
||||
*/
|
||||
public void reset() throws IOException {
|
||||
|
||||
stream.reset();
|
||||
framePos = markpos;
|
||||
// re-create the pushback buffer
|
||||
pushBackLen = markPushBackLen;
|
||||
if (pushBackLen > 0) {
|
||||
if (pushBackBuffer == null) {
|
||||
pushBackBuffer = new byte[frameSize - 1];
|
||||
}
|
||||
System.arraycopy(markPushBackBuffer, 0, pushBackBuffer, 0, pushBackLen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests whether this audio input stream supports the <code>mark</code> and
|
||||
* <code>reset</code> methods.
|
||||
* @return <code>true</code> if this stream supports the <code>mark</code>
|
||||
* and <code>reset</code> methods; <code>false</code> otherwise
|
||||
* @see #mark
|
||||
* @see #reset
|
||||
*/
|
||||
public boolean markSupported() {
|
||||
|
||||
return stream.markSupported();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Private inner class that makes a TargetDataLine look like an InputStream.
|
||||
*/
|
||||
private class TargetDataLineInputStream extends InputStream {
|
||||
|
||||
/**
|
||||
* The TargetDataLine on which this TargetDataLineInputStream is based.
|
||||
*/
|
||||
TargetDataLine line;
|
||||
|
||||
|
||||
TargetDataLineInputStream(TargetDataLine line) {
|
||||
super();
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
|
||||
public int available() throws IOException {
|
||||
return line.available();
|
||||
}
|
||||
|
||||
//$$fb 2001-07-16: added this method to correctly close the underlying TargetDataLine.
|
||||
// fixes bug 4479984
|
||||
public void close() throws IOException {
|
||||
// the line needs to be flushed and stopped to avoid a dead lock...
|
||||
// Probably related to bugs 4417527, 4334868, 4383457
|
||||
if (line.isActive()) {
|
||||
line.flush();
|
||||
line.stop();
|
||||
}
|
||||
line.close();
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
|
||||
byte[] b = new byte[1];
|
||||
|
||||
int value = read(b, 0, 1);
|
||||
|
||||
if (value == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
value = (int)b[0];
|
||||
|
||||
if (line.getFormat().getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)) {
|
||||
value += 128;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
try {
|
||||
return line.read(b, off, len);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
236
jdkSrc/jdk8/javax/sound/sampled/AudioPermission.java
Normal file
236
jdkSrc/jdk8/javax/sound/sampled/AudioPermission.java
Normal file
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
import java.security.BasicPermission;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>AudioPermission</code> class represents access rights to the audio
|
||||
* system resources. An <code>AudioPermission</code> contains a target name
|
||||
* but no actions list; you either have the named permission or you don't.
|
||||
* <p>
|
||||
* The target name is the name of the audio permission (see the table below).
|
||||
* The names follow the hierarchical property-naming convention. Also, an asterisk
|
||||
* can be used to represent all the audio permissions.
|
||||
* <p>
|
||||
* The following table lists the possible <code>AudioPermission</code> target names.
|
||||
* For each name, the table provides a description of exactly what that permission
|
||||
* allows, as well as a discussion of the risks of granting code the permission.
|
||||
* <p>
|
||||
*
|
||||
* <table border=1 cellpadding=5 summary="permission target name, what the permission allows, and associated risks">
|
||||
* <tr>
|
||||
* <th>Permission Target Name</th>
|
||||
* <th>What the Permission Allows</th>
|
||||
* <th>Risks of Allowing this Permission</th>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>play</td>
|
||||
* <td>Audio playback through the audio device or devices on the system.
|
||||
* Allows the application to obtain and manipulate lines and mixers for
|
||||
* audio playback (rendering).</td>
|
||||
* <td>In some cases use of this permission may affect other
|
||||
* applications because the audio from one line may be mixed with other audio
|
||||
* being played on the system, or because manipulation of a mixer affects the
|
||||
* audio for all lines using that mixer.</td>
|
||||
*</tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>record</td>
|
||||
* <td>Audio recording through the audio device or devices on the system.
|
||||
* Allows the application to obtain and manipulate lines and mixers for
|
||||
* audio recording (capture).</td>
|
||||
* <td>In some cases use of this permission may affect other
|
||||
* applications because manipulation of a mixer affects the audio for all lines
|
||||
* using that mixer.
|
||||
* This permission can enable an applet or application to eavesdrop on a user.</td>
|
||||
*</tr>
|
||||
*</table>
|
||||
*<p>
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
/*
|
||||
* (OLD PERMISSIONS TAKEN OUT FOR 1.2 BETA)
|
||||
*
|
||||
* <tr>
|
||||
* <td>playback device access</td>
|
||||
* <td>Direct access to the audio playback device(s), including configuration of the
|
||||
* playback format, volume, and balance, explicit opening and closing of the device,
|
||||
* etc.</td>
|
||||
* <td>Changes the properties of a shared system device and therefore
|
||||
* can affect other applications.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>playback device override</td>
|
||||
* <td>Manipulation of the audio playback device(s) in a way that directly conflicts
|
||||
* with use by other applications. This includes closing the device while it is in
|
||||
* use by another application, changing the device format while another application
|
||||
* is using it, etc. </td>
|
||||
* <td>Changes the properties of a shared system device and therefore
|
||||
* can affect other applications.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>record device access</td>
|
||||
* <td>Direct access to the audio recording device(s), including configuration of the
|
||||
* the record format, volume, and balance, explicit opening and closing of the device,
|
||||
* etc.</td>
|
||||
* <td>Changes the properties of a shared system device and therefore
|
||||
* can affect other applications.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>record device override</td>
|
||||
* <td>Manipulation of the audio recording device(s) in a way that directly conflicts
|
||||
* with use by other applications. This includes closing the device while it is in
|
||||
* use by another application, changing the device format while another application
|
||||
* is using it, etc. </td>
|
||||
* <td>Changes the properties of a shared system device and therefore
|
||||
* can affect other applications.</td>
|
||||
* </tr>
|
||||
*
|
||||
* </table>
|
||||
*<p>
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
|
||||
/*
|
||||
* The <code>AudioPermission</code> class represents access rights to the audio
|
||||
* system resources. An <code>AudioPermission</code> contains a target name
|
||||
* but no actions list; you either have the named permission or you don't.
|
||||
* <p>
|
||||
* The target name is the name of the audio permission (see the table below).
|
||||
* The names follow the hierarchical property-naming convention. Also, an asterisk
|
||||
* can be used to represent all the audio permissions.
|
||||
* <p>
|
||||
* The following table lists all the possible AudioPermission target names.
|
||||
* For each name, the table provides a description of exactly what that permission
|
||||
* allows, as well as a discussion of the risks of granting code the permission.
|
||||
* <p>
|
||||
*
|
||||
* <table border=1 cellpadding=5>
|
||||
* <tr>
|
||||
* <th>Permission Target Name</th>
|
||||
* <th>What the Permission Allows</th>
|
||||
* <th>Risks of Allowing this Permission</th>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>play</td>
|
||||
* <td>Audio playback through the audio device or devices on the system.</td>
|
||||
* <td>Allows the application to use a system device. Can affect other applications,
|
||||
* because the result will be mixed with other audio being played on the system.</td>
|
||||
*</tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>record</td>
|
||||
* <td>Recording audio from the audio device or devices on the system,
|
||||
* commonly through a microphone.</td>
|
||||
* <td>Can enable an applet or application to eavesdrop on a user.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>playback device access</td>
|
||||
* <td>Direct access to the audio playback device(s), including configuration of the
|
||||
* playback format, volume, and balance, explicit opening and closing of the device,
|
||||
* etc.</td>
|
||||
* <td>Changes the properties of a shared system device and therefore
|
||||
* can affect other applications.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>playback device override</td>
|
||||
* <td>Manipulation of the audio playback device(s) in a way that directly conflicts
|
||||
* with use by other applications. This includes closing the device while it is in
|
||||
* use by another application, changing the device format while another application
|
||||
* is using it, etc. </td>
|
||||
* <td>Changes the properties of a shared system device and therefore
|
||||
* can affect other applications.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>record device access</td>
|
||||
* <td>Direct access to the audio recording device(s), including configuration of the
|
||||
* the record format, volume, and balance, explicit opening and closing of the device,
|
||||
* etc.</td>
|
||||
* <td>Changes the properties of a shared system device and therefore
|
||||
* can affect other applications.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>record device override</td>
|
||||
* <td>Manipulation of the audio recording device(s) in a way that directly conflicts
|
||||
* with use by other applications. This includes closing the device while it is in
|
||||
* use by another application, changing the device format while another application
|
||||
* is using it, etc. </td>
|
||||
* <td>Changes the properties of a shared system device and therefore
|
||||
* can affect other applications.</td>
|
||||
* </tr>
|
||||
*
|
||||
* </table>
|
||||
*<p>
|
||||
*
|
||||
* @author Kara Kytle
|
||||
*/
|
||||
|
||||
public class AudioPermission extends BasicPermission {
|
||||
|
||||
/**
|
||||
* Creates a new <code>AudioPermission</code> object that has the specified
|
||||
* symbolic name, such as "play" or "record". An asterisk can be used to indicate
|
||||
* all audio permissions.
|
||||
* @param name the name of the new <code>AudioPermission</code>
|
||||
*
|
||||
* @throws NullPointerException if <code>name</code> is <code>null</code>.
|
||||
* @throws IllegalArgumentException if <code>name</code> is empty.
|
||||
*/
|
||||
public AudioPermission(String name) {
|
||||
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>AudioPermission</code> object that has the specified
|
||||
* symbolic name, such as "play" or "record". The <code>actions</code>
|
||||
* parameter is currently unused and should be <code>null</code>.
|
||||
* @param name the name of the new <code>AudioPermission</code>
|
||||
* @param actions (unused; should be <code>null</code>)
|
||||
*
|
||||
* @throws NullPointerException if <code>name</code> is <code>null</code>.
|
||||
* @throws IllegalArgumentException if <code>name</code> is empty.
|
||||
*/
|
||||
public AudioPermission(String name, String actions) {
|
||||
|
||||
super(name, actions);
|
||||
}
|
||||
}
|
1633
jdkSrc/jdk8/javax/sound/sampled/AudioSystem.java
Normal file
1633
jdkSrc/jdk8/javax/sound/sampled/AudioSystem.java
Normal file
File diff suppressed because it is too large
Load Diff
193
jdkSrc/jdk8/javax/sound/sampled/BooleanControl.java
Normal file
193
jdkSrc/jdk8/javax/sound/sampled/BooleanControl.java
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
/**
|
||||
* A <code>BooleanControl</code> provides the ability to switch between
|
||||
* two possible settings that affect a line's audio. The settings are boolean
|
||||
* values (<code>true</code> and <code>false</code>). A graphical user interface
|
||||
* might represent the control by a two-state button, an on/off switch, two
|
||||
* mutually exclusive buttons, or a checkbox (among other possibilities).
|
||||
* For example, depressing a button might activate a
|
||||
* <code>{@link BooleanControl.Type#MUTE MUTE}</code> control to silence
|
||||
* the line's audio.
|
||||
* <p>
|
||||
* As with other <code>{@link Control}</code> subclasses, a method is
|
||||
* provided that returns string labels for the values, suitable for
|
||||
* display in the user interface.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public abstract class BooleanControl extends Control {
|
||||
|
||||
|
||||
// INSTANCE VARIABLES
|
||||
|
||||
/**
|
||||
* The <code>true</code> state label, such as "true" or "on."
|
||||
*/
|
||||
private final String trueStateLabel;
|
||||
|
||||
/**
|
||||
* The <code>false</code> state label, such as "false" or "off."
|
||||
*/
|
||||
private final String falseStateLabel;
|
||||
|
||||
/**
|
||||
* The current value.
|
||||
*/
|
||||
private boolean value;
|
||||
|
||||
|
||||
// CONSTRUCTORS
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new boolean control object with the given parameters.
|
||||
*
|
||||
* @param type the type of control represented this float control object
|
||||
* @param initialValue the initial control value
|
||||
* @param trueStateLabel the label for the state represented by <code>true</code>,
|
||||
* such as "true" or "on."
|
||||
* @param falseStateLabel the label for the state represented by <code>false</code>,
|
||||
* such as "false" or "off."
|
||||
*/
|
||||
protected BooleanControl(Type type, boolean initialValue, String trueStateLabel, String falseStateLabel) {
|
||||
|
||||
super(type);
|
||||
this.value = initialValue;
|
||||
this.trueStateLabel = trueStateLabel;
|
||||
this.falseStateLabel = falseStateLabel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new boolean control object with the given parameters.
|
||||
* The labels for the <code>true</code> and <code>false</code> states
|
||||
* default to "true" and "false."
|
||||
*
|
||||
* @param type the type of control represented by this float control object
|
||||
* @param initialValue the initial control value
|
||||
*/
|
||||
protected BooleanControl(Type type, boolean initialValue) {
|
||||
this(type, initialValue, "true", "false");
|
||||
}
|
||||
|
||||
|
||||
// METHODS
|
||||
|
||||
|
||||
/**
|
||||
* Sets the current value for the control. The default
|
||||
* implementation simply sets the value as indicated.
|
||||
* Some controls require that their line be open before they can be affected
|
||||
* by setting a value.
|
||||
* @param value desired new value.
|
||||
*/
|
||||
public void setValue(boolean value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Obtains this control's current value.
|
||||
* @return current value.
|
||||
*/
|
||||
public boolean getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the label for the specified state.
|
||||
* @param state the state whose label will be returned
|
||||
* @return the label for the specified state, such as "true" or "on"
|
||||
* for <code>true</code>, or "false" or "off" for <code>false</code>.
|
||||
*/
|
||||
public String getStateLabel(boolean state) {
|
||||
return ((state == true) ? trueStateLabel : falseStateLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ABSTRACT METHOD IMPLEMENTATIONS: CONTROL
|
||||
|
||||
|
||||
/**
|
||||
* Provides a string representation of the control
|
||||
* @return a string description
|
||||
*/
|
||||
public String toString() {
|
||||
return new String(super.toString() + " with current value: " + getStateLabel(getValue()));
|
||||
}
|
||||
|
||||
|
||||
// INNER CLASSES
|
||||
|
||||
|
||||
/**
|
||||
* An instance of the <code>BooleanControl.Type</code> class identifies one kind of
|
||||
* boolean control. Static instances are provided for the
|
||||
* common types.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class Type extends Control.Type {
|
||||
|
||||
|
||||
// TYPE DEFINES
|
||||
|
||||
|
||||
/**
|
||||
* Represents a control for the mute status of a line.
|
||||
* Note that mute status does not affect gain.
|
||||
*/
|
||||
public static final Type MUTE = new Type("Mute");
|
||||
|
||||
/**
|
||||
* Represents a control for whether reverberation is applied
|
||||
* to a line. Note that the status of this control not affect
|
||||
* the reverberation settings for a line, but does affect whether
|
||||
* these settings are used.
|
||||
*/
|
||||
public static final Type APPLY_REVERB = new Type("Apply Reverb");
|
||||
|
||||
|
||||
// CONSTRUCTOR
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new boolean control type.
|
||||
* @param name the name of the new boolean control type
|
||||
*/
|
||||
protected Type(String name) {
|
||||
super(name);
|
||||
}
|
||||
} // class Type
|
||||
}
|
223
jdkSrc/jdk8/javax/sound/sampled/Clip.java
Normal file
223
jdkSrc/jdk8/javax/sound/sampled/Clip.java
Normal file
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* The <code>Clip</code> interface represents a special kind of data line whose
|
||||
* audio data can be loaded prior to playback, instead of being streamed in
|
||||
* real time.
|
||||
* <p>
|
||||
* Because the data is pre-loaded and has a known length, you can set a clip
|
||||
* to start playing at any position in its audio data. You can also create a
|
||||
* loop, so that when the clip is played it will cycle repeatedly. Loops are
|
||||
* specified with a starting and ending sample frame, along with the number of
|
||||
* times that the loop should be played.
|
||||
* <p>
|
||||
* Clips may be obtained from a <code>{@link Mixer}</code> that supports lines
|
||||
* of this type. Data is loaded into a clip when it is opened.
|
||||
* <p>
|
||||
* Playback of an audio clip may be started and stopped using the <code>start</code>
|
||||
* and <code>stop</code> methods. These methods do not reset the media position;
|
||||
* <code>start</code> causes playback to continue from the position where playback
|
||||
* was last stopped. To restart playback from the beginning of the clip's audio
|
||||
* data, simply follow the invocation of <code>{@link DataLine#stop stop}</code>
|
||||
* with setFramePosition(0), which rewinds the media to the beginning
|
||||
* of the clip.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public interface Clip extends DataLine {
|
||||
|
||||
|
||||
/**
|
||||
* A value indicating that looping should continue indefinitely rather than
|
||||
* complete after a specific number of loops.
|
||||
* @see #loop
|
||||
*/
|
||||
public static final int LOOP_CONTINUOUSLY = -1;
|
||||
|
||||
/**
|
||||
* Opens the clip, meaning that it should acquire any required
|
||||
* system resources and become operational. The clip is opened
|
||||
* with the format and audio data indicated.
|
||||
* If this operation succeeds, the line is marked as open and an
|
||||
* <code>{@link LineEvent.Type#OPEN OPEN}</code> event is dispatched
|
||||
* to the line's listeners.
|
||||
* <p>
|
||||
* Invoking this method on a line which is already open is illegal
|
||||
* and may result in an IllegalStateException.
|
||||
* <p>
|
||||
* Note that some lines, once closed, cannot be reopened. Attempts
|
||||
* to reopen such a line will always result in a
|
||||
* <code>{@link LineUnavailableException}</code>.
|
||||
*
|
||||
* @param format the format of the supplied audio data
|
||||
* @param data a byte array containing audio data to load into the clip
|
||||
* @param offset the point at which to start copying, expressed in
|
||||
* <em>bytes</em> from the beginning of the array
|
||||
* @param bufferSize the number of <em>bytes</em>
|
||||
* of data to load into the clip from the array.
|
||||
* @throws LineUnavailableException if the line cannot be
|
||||
* opened due to resource restrictions
|
||||
* @throws IllegalArgumentException if the buffer size does not represent
|
||||
* an integral number of sample frames,
|
||||
* or if <code>format</code> is not fully specified or invalid
|
||||
* @throws IllegalStateException if the line is already open
|
||||
* @throws SecurityException if the line cannot be
|
||||
* opened due to security restrictions
|
||||
*
|
||||
* @see #close
|
||||
* @see #isOpen
|
||||
* @see LineListener
|
||||
*/
|
||||
public void open(AudioFormat format, byte[] data, int offset, int bufferSize) throws LineUnavailableException;
|
||||
|
||||
/**
|
||||
* Opens the clip with the format and audio data present in the provided audio
|
||||
* input stream. Opening a clip means that it should acquire any required
|
||||
* system resources and become operational. If this operation
|
||||
* input stream. If this operation
|
||||
* succeeds, the line is marked open and an
|
||||
* <code>{@link LineEvent.Type#OPEN OPEN}</code> event is dispatched
|
||||
* to the line's listeners.
|
||||
* <p>
|
||||
* Invoking this method on a line which is already open is illegal
|
||||
* and may result in an IllegalStateException.
|
||||
* <p>
|
||||
* Note that some lines, once closed, cannot be reopened. Attempts
|
||||
* to reopen such a line will always result in a
|
||||
* <code>{@link LineUnavailableException}</code>.
|
||||
*
|
||||
* @param stream an audio input stream from which audio data will be read into
|
||||
* the clip
|
||||
* @throws LineUnavailableException if the line cannot be
|
||||
* opened due to resource restrictions
|
||||
* @throws IOException if an I/O exception occurs during reading of
|
||||
* the stream
|
||||
* @throws IllegalArgumentException if the stream's audio format
|
||||
* is not fully specified or invalid
|
||||
* @throws IllegalStateException if the line is already open
|
||||
* @throws SecurityException if the line cannot be
|
||||
* opened due to security restrictions
|
||||
*
|
||||
* @see #close
|
||||
* @see #isOpen
|
||||
* @see LineListener
|
||||
*/
|
||||
public void open(AudioInputStream stream) throws LineUnavailableException, IOException;
|
||||
|
||||
/**
|
||||
* Obtains the media length in sample frames.
|
||||
* @return the media length, expressed in sample frames,
|
||||
* or <code>AudioSystem.NOT_SPECIFIED</code> if the line is not open.
|
||||
* @see AudioSystem#NOT_SPECIFIED
|
||||
*/
|
||||
public int getFrameLength();
|
||||
|
||||
/**
|
||||
* Obtains the media duration in microseconds
|
||||
* @return the media duration, expressed in microseconds,
|
||||
* or <code>AudioSystem.NOT_SPECIFIED</code> if the line is not open.
|
||||
* @see AudioSystem#NOT_SPECIFIED
|
||||
*/
|
||||
public long getMicrosecondLength();
|
||||
|
||||
/**
|
||||
* Sets the media position in sample frames. The position is zero-based;
|
||||
* the first frame is frame number zero. When the clip begins playing the
|
||||
* next time, it will start by playing the frame at this position.
|
||||
* <p>
|
||||
* To obtain the current position in sample frames, use the
|
||||
* <code>{@link DataLine#getFramePosition getFramePosition}</code>
|
||||
* method of <code>DataLine</code>.
|
||||
*
|
||||
* @param frames the desired new media position, expressed in sample frames
|
||||
*/
|
||||
public void setFramePosition(int frames);
|
||||
|
||||
/**
|
||||
* Sets the media position in microseconds. When the clip begins playing the
|
||||
* next time, it will start at this position.
|
||||
* The level of precision is not guaranteed. For example, an implementation
|
||||
* might calculate the microsecond position from the current frame position
|
||||
* and the audio sample frame rate. The precision in microseconds would
|
||||
* then be limited to the number of microseconds per sample frame.
|
||||
* <p>
|
||||
* To obtain the current position in microseconds, use the
|
||||
* <code>{@link DataLine#getMicrosecondPosition getMicrosecondPosition}</code>
|
||||
* method of <code>DataLine</code>.
|
||||
*
|
||||
* @param microseconds the desired new media position, expressed in microseconds
|
||||
*/
|
||||
public void setMicrosecondPosition(long microseconds);
|
||||
|
||||
/**
|
||||
* Sets the first and last sample frames that will be played in
|
||||
* the loop. The ending point must be greater than
|
||||
* or equal to the starting point, and both must fall within the
|
||||
* the size of the loaded media. A value of 0 for the starting
|
||||
* point means the beginning of the loaded media. Similarly, a value of -1
|
||||
* for the ending point indicates the last frame of the media.
|
||||
* @param start the loop's starting position, in sample frames (zero-based)
|
||||
* @param end the loop's ending position, in sample frames (zero-based), or
|
||||
* -1 to indicate the final frame
|
||||
* @throws IllegalArgumentException if the requested
|
||||
* loop points cannot be set, usually because one or both falls outside
|
||||
* the media's duration or because the ending point is
|
||||
* before the starting point
|
||||
*/
|
||||
public void setLoopPoints(int start, int end);
|
||||
|
||||
/**
|
||||
* Starts looping playback from the current position. Playback will
|
||||
* continue to the loop's end point, then loop back to the loop start point
|
||||
* <code>count</code> times, and finally continue playback to the end of
|
||||
* the clip.
|
||||
* <p>
|
||||
* If the current position when this method is invoked is greater than the
|
||||
* loop end point, playback simply continues to the
|
||||
* end of the clip without looping.
|
||||
* <p>
|
||||
* A <code>count</code> value of 0 indicates that any current looping should
|
||||
* cease and playback should continue to the end of the clip. The behavior
|
||||
* is undefined when this method is invoked with any other value during a
|
||||
* loop operation.
|
||||
* <p>
|
||||
* If playback is stopped during looping, the current loop status is
|
||||
* cleared; the behavior of subsequent loop and start requests is not
|
||||
* affected by an interrupted loop operation.
|
||||
*
|
||||
* @param count the number of times playback should loop back from the
|
||||
* loop's end position to the loop's start position, or
|
||||
* <code>{@link #LOOP_CONTINUOUSLY}</code> to indicate that looping should
|
||||
* continue until interrupted
|
||||
*/
|
||||
public void loop(int count);
|
||||
}
|
140
jdkSrc/jdk8/javax/sound/sampled/CompoundControl.java
Normal file
140
jdkSrc/jdk8/javax/sound/sampled/CompoundControl.java
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
/**
|
||||
* A <code>CompoundControl</code>, such as a graphic equalizer, provides control
|
||||
* over two or more related properties, each of which is itself represented as
|
||||
* a <code>Control</code>.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public abstract class CompoundControl extends Control {
|
||||
|
||||
|
||||
// TYPE DEFINES
|
||||
|
||||
|
||||
// INSTANCE VARIABLES
|
||||
|
||||
|
||||
/**
|
||||
* The set of member controls.
|
||||
*/
|
||||
private Control[] controls;
|
||||
|
||||
|
||||
|
||||
// CONSTRUCTORS
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new compound control object with the given parameters.
|
||||
*
|
||||
* @param type the type of control represented this compound control object
|
||||
* @param memberControls the set of member controls
|
||||
*/
|
||||
protected CompoundControl(Type type, Control[] memberControls) {
|
||||
|
||||
super(type);
|
||||
this.controls = memberControls;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// METHODS
|
||||
|
||||
|
||||
/**
|
||||
* Returns the set of member controls that comprise the compound control.
|
||||
* @return the set of member controls.
|
||||
*/
|
||||
public Control[] getMemberControls() {
|
||||
|
||||
Control[] localArray = new Control[controls.length];
|
||||
|
||||
for (int i = 0; i < controls.length; i++) {
|
||||
localArray[i] = controls[i];
|
||||
}
|
||||
|
||||
return localArray;
|
||||
}
|
||||
|
||||
|
||||
// ABSTRACT METHOD IMPLEMENTATIONS: CONTROL
|
||||
|
||||
|
||||
/**
|
||||
* Provides a string representation of the control
|
||||
* @return a string description
|
||||
*/
|
||||
public String toString() {
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (int i = 0; i < controls.length; i++) {
|
||||
if (i != 0) {
|
||||
buf.append(", ");
|
||||
if ((i + 1) == controls.length) {
|
||||
buf.append("and ");
|
||||
}
|
||||
}
|
||||
buf.append(controls[i].getType());
|
||||
}
|
||||
|
||||
return new String(getType() + " Control containing " + buf + " Controls.");
|
||||
}
|
||||
|
||||
|
||||
// INNER CLASSES
|
||||
|
||||
|
||||
/**
|
||||
* An instance of the <code>CompoundControl.Type</code> inner class identifies one kind of
|
||||
* compound control. Static instances are provided for the
|
||||
* common types.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class Type extends Control.Type {
|
||||
|
||||
|
||||
// TYPE DEFINES
|
||||
|
||||
// CONSTRUCTOR
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new compound control type.
|
||||
* @param name the name of the new compound control type
|
||||
*/
|
||||
protected Type(String name) {
|
||||
super(name);
|
||||
}
|
||||
} // class Type
|
||||
|
||||
} // class CompoundControl
|
146
jdkSrc/jdk8/javax/sound/sampled/Control.java
Normal file
146
jdkSrc/jdk8/javax/sound/sampled/Control.java
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
/**
|
||||
* {@link Line Lines} often have a set of controls, such as gain and pan, that affect
|
||||
* the audio signal passing through the line. Java Sound's <code>Line</code> objects
|
||||
* let you obtain a particular control object by passing its class as the
|
||||
* argument to a {@link Line#getControl(Control.Type) getControl} method.
|
||||
* <p>
|
||||
* Because the various types of controls have different purposes and features,
|
||||
* all of their functionality is accessed from the subclasses that define
|
||||
* each kind of control.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
*
|
||||
* @see Line#getControls
|
||||
* @see Line#isControlSupported
|
||||
* @since 1.3
|
||||
*/
|
||||
public abstract class Control {
|
||||
|
||||
|
||||
// INSTANCE VARIABLES
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*/
|
||||
private final Type type;
|
||||
|
||||
|
||||
|
||||
// CONSTRUCTORS
|
||||
|
||||
/**
|
||||
* Constructs a Control with the specified type.
|
||||
* @param type the kind of control desired
|
||||
*/
|
||||
protected Control(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
// METHODS
|
||||
|
||||
/**
|
||||
* Obtains the control's type.
|
||||
* @return the control's type.
|
||||
*/
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
// ABSTRACT METHODS
|
||||
|
||||
/**
|
||||
* Obtains a String describing the control type and its current state.
|
||||
* @return a String representation of the Control.
|
||||
*/
|
||||
public String toString() {
|
||||
return new String(getType() + " Control");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An instance of the <code>Type</code> class represents the type of
|
||||
* the control. Static instances are provided for the
|
||||
* common types.
|
||||
*/
|
||||
public static class Type {
|
||||
|
||||
// CONTROL TYPE DEFINES
|
||||
|
||||
// INSTANCE VARIABLES
|
||||
|
||||
/**
|
||||
* Type name.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
|
||||
// CONSTRUCTOR
|
||||
|
||||
/**
|
||||
* Constructs a new control type with the name specified.
|
||||
* The name should be a descriptive string appropriate for
|
||||
* labelling the control in an application, such as "Gain" or "Balance."
|
||||
* @param name the name of the new control type.
|
||||
*/
|
||||
protected Type(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
// METHODS
|
||||
|
||||
/**
|
||||
* Finalizes the equals method
|
||||
*/
|
||||
public final boolean equals(Object obj) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes the hashCode method
|
||||
*/
|
||||
public final int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the <code>String</code> representation of the control type. This <code>String</code> is
|
||||
* the same name that was passed to the constructor.
|
||||
*
|
||||
* @return the control type name
|
||||
*/
|
||||
public final String toString() {
|
||||
return name;
|
||||
}
|
||||
} // class Type
|
||||
|
||||
} // class Control
|
494
jdkSrc/jdk8/javax/sound/sampled/DataLine.java
Normal file
494
jdkSrc/jdk8/javax/sound/sampled/DataLine.java
Normal file
@@ -0,0 +1,494 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* <code>DataLine</code> adds media-related functionality to its
|
||||
* superinterface, <code>{@link Line}</code>. This functionality includes
|
||||
* transport-control methods that start, stop, drain, and flush
|
||||
* the audio data that passes through the line. A data line can also
|
||||
* report the current position, volume, and audio format of the media.
|
||||
* Data lines are used for output of audio by means of the
|
||||
* subinterfaces <code>{@link SourceDataLine}</code> or
|
||||
* <code>{@link Clip}</code>, which allow an application program to write data. Similarly,
|
||||
* audio input is handled by the subinterface <code>{@link TargetDataLine}</code>,
|
||||
* which allows data to be read.
|
||||
* <p>
|
||||
* A data line has an internal buffer in which
|
||||
* the incoming or outgoing audio data is queued. The
|
||||
* <code>{@link #drain()}</code> method blocks until this internal buffer
|
||||
* becomes empty, usually because all queued data has been processed. The
|
||||
* <code>{@link #flush()}</code> method discards any available queued data
|
||||
* from the internal buffer.
|
||||
* <p>
|
||||
* A data line produces <code>{@link LineEvent.Type#START START}</code> and
|
||||
* <code>{@link LineEvent.Type#STOP STOP}</code> events whenever
|
||||
* it begins or ceases active presentation or capture of data. These events
|
||||
* can be generated in response to specific requests, or as a result of
|
||||
* less direct state changes. For example, if <code>{@link #start()}</code> is called
|
||||
* on an inactive data line, and data is available for capture or playback, a
|
||||
* <code>START</code> event will be generated shortly, when data playback
|
||||
* or capture actually begins. Or, if the flow of data to an active data
|
||||
* line is constricted so that a gap occurs in the presentation of data,
|
||||
* a <code>STOP</code> event is generated.
|
||||
* <p>
|
||||
* Mixers often support synchronized control of multiple data lines.
|
||||
* Synchronization can be established through the Mixer interface's
|
||||
* <code>{@link Mixer#synchronize synchronize}</code> method.
|
||||
* See the description of the <code>{@link Mixer Mixer}</code> interface
|
||||
* for a more complete description.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @see LineEvent
|
||||
* @since 1.3
|
||||
*/
|
||||
public interface DataLine extends Line {
|
||||
|
||||
|
||||
/**
|
||||
* Drains queued data from the line by continuing data I/O until the
|
||||
* data line's internal buffer has been emptied.
|
||||
* This method blocks until the draining is complete. Because this is a
|
||||
* blocking method, it should be used with care. If <code>drain()</code>
|
||||
* is invoked on a stopped line that has data in its queue, the method will
|
||||
* block until the line is running and the data queue becomes empty. If
|
||||
* <code>drain()</code> is invoked by one thread, and another continues to
|
||||
* fill the data queue, the operation will not complete.
|
||||
* This method always returns when the data line is closed.
|
||||
*
|
||||
* @see #flush()
|
||||
*/
|
||||
public void drain();
|
||||
|
||||
/**
|
||||
* Flushes queued data from the line. The flushed data is discarded.
|
||||
* In some cases, not all queued data can be discarded. For example, a
|
||||
* mixer can flush data from the buffer for a specific input line, but any
|
||||
* unplayed data already in the output buffer (the result of the mix) will
|
||||
* still be played. You can invoke this method after pausing a line (the
|
||||
* normal case) if you want to skip the "stale" data when you restart
|
||||
* playback or capture. (It is legal to flush a line that is not stopped,
|
||||
* but doing so on an active line is likely to cause a discontinuity in the
|
||||
* data, resulting in a perceptible click.)
|
||||
*
|
||||
* @see #stop()
|
||||
* @see #drain()
|
||||
*/
|
||||
public void flush();
|
||||
|
||||
/**
|
||||
* Allows a line to engage in data I/O. If invoked on a line
|
||||
* that is already running, this method does nothing. Unless the data in
|
||||
* the buffer has been flushed, the line resumes I/O starting
|
||||
* with the first frame that was unprocessed at the time the line was
|
||||
* stopped. When audio capture or playback starts, a
|
||||
* <code>{@link LineEvent.Type#START START}</code> event is generated.
|
||||
*
|
||||
* @see #stop()
|
||||
* @see #isRunning()
|
||||
* @see LineEvent
|
||||
*/
|
||||
public void start();
|
||||
|
||||
/**
|
||||
* Stops the line. A stopped line should cease I/O activity.
|
||||
* If the line is open and running, however, it should retain the resources required
|
||||
* to resume activity. A stopped line should retain any audio data in its buffer
|
||||
* instead of discarding it, so that upon resumption the I/O can continue where it left off,
|
||||
* if possible. (This doesn't guarantee that there will never be discontinuities beyond the
|
||||
* current buffer, of course; if the stopped condition continues
|
||||
* for too long, input or output samples might be dropped.) If desired, the retained data can be
|
||||
* discarded by invoking the <code>flush</code> method.
|
||||
* When audio capture or playback stops, a <code>{@link LineEvent.Type#STOP STOP}</code> event is generated.
|
||||
*
|
||||
* @see #start()
|
||||
* @see #isRunning()
|
||||
* @see #flush()
|
||||
* @see LineEvent
|
||||
*/
|
||||
public void stop();
|
||||
|
||||
/**
|
||||
* Indicates whether the line is running. The default is <code>false</code>.
|
||||
* An open line begins running when the first data is presented in response to an
|
||||
* invocation of the <code>start</code> method, and continues
|
||||
* until presentation ceases in response to a call to <code>stop</code> or
|
||||
* because playback completes.
|
||||
* @return <code>true</code> if the line is running, otherwise <code>false</code>
|
||||
* @see #start()
|
||||
* @see #stop()
|
||||
*/
|
||||
public boolean isRunning();
|
||||
|
||||
/**
|
||||
* Indicates whether the line is engaging in active I/O (such as playback
|
||||
* or capture). When an inactive line becomes active, it sends a
|
||||
* <code>{@link LineEvent.Type#START START}</code> event to its listeners. Similarly, when
|
||||
* an active line becomes inactive, it sends a
|
||||
* <code>{@link LineEvent.Type#STOP STOP}</code> event.
|
||||
* @return <code>true</code> if the line is actively capturing or rendering
|
||||
* sound, otherwise <code>false</code>
|
||||
* @see #isOpen
|
||||
* @see #addLineListener
|
||||
* @see #removeLineListener
|
||||
* @see LineEvent
|
||||
* @see LineListener
|
||||
*/
|
||||
public boolean isActive();
|
||||
|
||||
/**
|
||||
* Obtains the current format (encoding, sample rate, number of channels,
|
||||
* etc.) of the data line's audio data.
|
||||
*
|
||||
* <p>If the line is not open and has never been opened, it returns
|
||||
* the default format. The default format is an implementation
|
||||
* specific audio format, or, if the <code>DataLine.Info</code>
|
||||
* object, which was used to retrieve this <code>DataLine</code>,
|
||||
* specifies at least one fully qualified audio format, the
|
||||
* last one will be used as the default format. Opening the
|
||||
* line with a specific audio format (e.g.
|
||||
* {@link SourceDataLine#open(AudioFormat)}) will override the
|
||||
* default format.
|
||||
*
|
||||
* @return current audio data format
|
||||
* @see AudioFormat
|
||||
*/
|
||||
public AudioFormat getFormat();
|
||||
|
||||
/**
|
||||
* Obtains the maximum number of bytes of data that will fit in the data line's
|
||||
* internal buffer. For a source data line, this is the size of the buffer to
|
||||
* which data can be written. For a target data line, it is the size of
|
||||
* the buffer from which data can be read. Note that
|
||||
* the units used are bytes, but will always correspond to an integral
|
||||
* number of sample frames of audio data.
|
||||
*
|
||||
* @return the size of the buffer in bytes
|
||||
*/
|
||||
public int getBufferSize();
|
||||
|
||||
/**
|
||||
* Obtains the number of bytes of data currently available to the
|
||||
* application for processing in the data line's internal buffer. For a
|
||||
* source data line, this is the amount of data that can be written to the
|
||||
* buffer without blocking. For a target data line, this is the amount of data
|
||||
* available to be read by the application. For a clip, this value is always
|
||||
* 0 because the audio data is loaded into the buffer when the clip is opened,
|
||||
* and persists without modification until the clip is closed.
|
||||
* <p>
|
||||
* Note that the units used are bytes, but will always
|
||||
* correspond to an integral number of sample frames of audio data.
|
||||
* <p>
|
||||
* An application is guaranteed that a read or
|
||||
* write operation of up to the number of bytes returned from
|
||||
* <code>available()</code> will not block; however, there is no guarantee
|
||||
* that attempts to read or write more data will block.
|
||||
*
|
||||
* @return the amount of data available, in bytes
|
||||
*/
|
||||
public int available();
|
||||
|
||||
/**
|
||||
* Obtains the current position in the audio data, in sample frames.
|
||||
* The frame position measures the number of sample
|
||||
* frames captured by, or rendered from, the line since it was opened.
|
||||
* This return value will wrap around after 2^31 frames. It is recommended
|
||||
* to use <code>getLongFramePosition</code> instead.
|
||||
*
|
||||
* @return the number of frames already processed since the line was opened
|
||||
* @see #getLongFramePosition()
|
||||
*/
|
||||
public int getFramePosition();
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the current position in the audio data, in sample frames.
|
||||
* The frame position measures the number of sample
|
||||
* frames captured by, or rendered from, the line since it was opened.
|
||||
*
|
||||
* @return the number of frames already processed since the line was opened
|
||||
* @since 1.5
|
||||
*/
|
||||
public long getLongFramePosition();
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the current position in the audio data, in microseconds.
|
||||
* The microsecond position measures the time corresponding to the number
|
||||
* of sample frames captured by, or rendered from, the line since it was opened.
|
||||
* The level of precision is not guaranteed. For example, an implementation
|
||||
* might calculate the microsecond position from the current frame position
|
||||
* and the audio sample frame rate. The precision in microseconds would
|
||||
* then be limited to the number of microseconds per sample frame.
|
||||
*
|
||||
* @return the number of microseconds of data processed since the line was opened
|
||||
*/
|
||||
public long getMicrosecondPosition();
|
||||
|
||||
/**
|
||||
* Obtains the current volume level for the line. This level is a measure
|
||||
* of the signal's current amplitude, and should not be confused with the
|
||||
* current setting of a gain control. The range is from 0.0 (silence) to
|
||||
* 1.0 (maximum possible amplitude for the sound waveform). The units
|
||||
* measure linear amplitude, not decibels.
|
||||
*
|
||||
* @return the current amplitude of the signal in this line, or
|
||||
* <code>{@link AudioSystem#NOT_SPECIFIED}</code>
|
||||
*/
|
||||
public float getLevel();
|
||||
|
||||
/**
|
||||
* Besides the class information inherited from its superclass,
|
||||
* <code>DataLine.Info</code> provides additional information specific to data lines.
|
||||
* This information includes:
|
||||
* <ul>
|
||||
* <li> the audio formats supported by the data line
|
||||
* <li> the minimum and maximum sizes of its internal buffer
|
||||
* </ul>
|
||||
* Because a <code>Line.Info</code> knows the class of the line its describes, a
|
||||
* <code>DataLine.Info</code> object can describe <code>DataLine</code>
|
||||
* subinterfaces such as <code>{@link SourceDataLine}</code>,
|
||||
* <code>{@link TargetDataLine}</code>, and <code>{@link Clip}</code>.
|
||||
* You can query a mixer for lines of any of these types, passing an appropriate
|
||||
* instance of <code>DataLine.Info</code> as the argument to a method such as
|
||||
* <code>{@link Mixer#getLine Mixer.getLine(Line.Info)}</code>.
|
||||
*
|
||||
* @see Line.Info
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class Info extends Line.Info {
|
||||
|
||||
private final AudioFormat[] formats;
|
||||
private final int minBufferSize;
|
||||
private final int maxBufferSize;
|
||||
|
||||
/**
|
||||
* Constructs a data line's info object from the specified information,
|
||||
* which includes a set of supported audio formats and a range for the buffer size.
|
||||
* This constructor is typically used by mixer implementations
|
||||
* when returning information about a supported line.
|
||||
*
|
||||
* @param lineClass the class of the data line described by the info object
|
||||
* @param formats set of formats supported
|
||||
* @param minBufferSize minimum buffer size supported by the data line, in bytes
|
||||
* @param maxBufferSize maximum buffer size supported by the data line, in bytes
|
||||
*/
|
||||
public Info(Class<?> lineClass, AudioFormat[] formats, int minBufferSize, int maxBufferSize) {
|
||||
|
||||
super(lineClass);
|
||||
|
||||
if (formats == null) {
|
||||
this.formats = new AudioFormat[0];
|
||||
} else {
|
||||
this.formats = Arrays.copyOf(formats, formats.length);
|
||||
}
|
||||
|
||||
this.minBufferSize = minBufferSize;
|
||||
this.maxBufferSize = maxBufferSize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a data line's info object from the specified information,
|
||||
* which includes a single audio format and a desired buffer size.
|
||||
* This constructor is typically used by an application to
|
||||
* describe a desired line.
|
||||
*
|
||||
* @param lineClass the class of the data line described by the info object
|
||||
* @param format desired format
|
||||
* @param bufferSize desired buffer size in bytes
|
||||
*/
|
||||
public Info(Class<?> lineClass, AudioFormat format, int bufferSize) {
|
||||
|
||||
super(lineClass);
|
||||
|
||||
if (format == null) {
|
||||
this.formats = new AudioFormat[0];
|
||||
} else {
|
||||
this.formats = new AudioFormat[]{format};
|
||||
}
|
||||
|
||||
this.minBufferSize = bufferSize;
|
||||
this.maxBufferSize = bufferSize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a data line's info object from the specified information,
|
||||
* which includes a single audio format.
|
||||
* This constructor is typically used by an application to
|
||||
* describe a desired line.
|
||||
*
|
||||
* @param lineClass the class of the data line described by the info object
|
||||
* @param format desired format
|
||||
*/
|
||||
public Info(Class<?> lineClass, AudioFormat format) {
|
||||
this(lineClass, format, AudioSystem.NOT_SPECIFIED);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains a set of audio formats supported by the data line.
|
||||
* Note that <code>isFormatSupported(AudioFormat)</code> might return
|
||||
* <code>true</code> for certain additional formats that are missing from
|
||||
* the set returned by <code>getFormats()</code>. The reverse is not
|
||||
* the case: <code>isFormatSupported(AudioFormat)</code> is guaranteed to return
|
||||
* <code>true</code> for all formats returned by <code>getFormats()</code>.
|
||||
*
|
||||
* Some fields in the AudioFormat instances can be set to
|
||||
* {@link javax.sound.sampled.AudioSystem#NOT_SPECIFIED NOT_SPECIFIED}
|
||||
* if that field does not apply to the format,
|
||||
* or if the format supports a wide range of values for that field.
|
||||
* For example, a multi-channel device supporting up to
|
||||
* 64 channels, could set the channel field in the
|
||||
* <code>AudioFormat</code> instances returned by this
|
||||
* method to <code>NOT_SPECIFIED</code>.
|
||||
*
|
||||
* @return a set of supported audio formats.
|
||||
* @see #isFormatSupported(AudioFormat)
|
||||
*/
|
||||
public AudioFormat[] getFormats() {
|
||||
return Arrays.copyOf(formats, formats.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this data line supports a particular audio format.
|
||||
* The default implementation of this method simply returns <code>true</code> if
|
||||
* the specified format matches any of the supported formats.
|
||||
*
|
||||
* @param format the audio format for which support is queried.
|
||||
* @return <code>true</code> if the format is supported, otherwise <code>false</code>
|
||||
* @see #getFormats
|
||||
* @see AudioFormat#matches
|
||||
*/
|
||||
public boolean isFormatSupported(AudioFormat format) {
|
||||
|
||||
for (int i = 0; i < formats.length; i++) {
|
||||
if (format.matches(formats[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the minimum buffer size supported by the data line.
|
||||
* @return minimum buffer size in bytes, or <code>AudioSystem.NOT_SPECIFIED</code>
|
||||
*/
|
||||
public int getMinBufferSize() {
|
||||
return minBufferSize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the maximum buffer size supported by the data line.
|
||||
* @return maximum buffer size in bytes, or <code>AudioSystem.NOT_SPECIFIED</code>
|
||||
*/
|
||||
public int getMaxBufferSize() {
|
||||
return maxBufferSize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether the specified info object matches this one.
|
||||
* To match, the superclass match requirements must be met. In
|
||||
* addition, this object's minimum buffer size must be at least as
|
||||
* large as that of the object specified, its maximum buffer size must
|
||||
* be at most as large as that of the object specified, and all of its
|
||||
* formats must match formats supported by the object specified.
|
||||
* @return <code>true</code> if this object matches the one specified,
|
||||
* otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean matches(Line.Info info) {
|
||||
|
||||
if (! (super.matches(info)) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Info dataLineInfo = (Info)info;
|
||||
|
||||
// treat anything < 0 as NOT_SPECIFIED
|
||||
// demo code in old Java Sound Demo used a wrong buffer calculation
|
||||
// that would lead to arbitrary negative values
|
||||
if ((getMaxBufferSize() >= 0) && (dataLineInfo.getMaxBufferSize() >= 0)) {
|
||||
if (getMaxBufferSize() > dataLineInfo.getMaxBufferSize()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((getMinBufferSize() >= 0) && (dataLineInfo.getMinBufferSize() >= 0)) {
|
||||
if (getMinBufferSize() < dataLineInfo.getMinBufferSize()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AudioFormat[] localFormats = getFormats();
|
||||
|
||||
if (localFormats != null) {
|
||||
|
||||
for (int i = 0; i < localFormats.length; i++) {
|
||||
if (! (localFormats[i] == null) ) {
|
||||
if (! (dataLineInfo.isFormatSupported(localFormats[i])) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a textual description of the data line info.
|
||||
* @return a string description
|
||||
*/
|
||||
public String toString() {
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
if ( (formats.length == 1) && (formats[0] != null) ) {
|
||||
buf.append(" supporting format " + formats[0]);
|
||||
} else if (getFormats().length > 1) {
|
||||
buf.append(" supporting " + getFormats().length + " audio formats");
|
||||
}
|
||||
|
||||
if ( (minBufferSize != AudioSystem.NOT_SPECIFIED) && (maxBufferSize != AudioSystem.NOT_SPECIFIED) ) {
|
||||
buf.append(", and buffers of " + minBufferSize + " to " + maxBufferSize + " bytes");
|
||||
} else if ( (minBufferSize != AudioSystem.NOT_SPECIFIED) && (minBufferSize > 0) ) {
|
||||
buf.append(", and buffers of at least " + minBufferSize + " bytes");
|
||||
} else if (maxBufferSize != AudioSystem.NOT_SPECIFIED) {
|
||||
buf.append(", and buffers of up to " + minBufferSize + " bytes");
|
||||
}
|
||||
|
||||
return new String(super.toString() + buf);
|
||||
}
|
||||
} // class Info
|
||||
|
||||
} // interface DataLine
|
214
jdkSrc/jdk8/javax/sound/sampled/EnumControl.java
Normal file
214
jdkSrc/jdk8/javax/sound/sampled/EnumControl.java
Normal file
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
/**
|
||||
* A <code>EnumControl</code> provides control over a set of
|
||||
* discrete possible values, each represented by an object. In a
|
||||
* graphical user interface, such a control might be represented
|
||||
* by a set of buttons, each of which chooses one value or setting. For
|
||||
* example, a reverb control might provide several preset reverberation
|
||||
* settings, instead of providing continuously adjustable parameters
|
||||
* of the sort that would be represented by <code>{@link FloatControl}</code>
|
||||
* objects.
|
||||
* <p>
|
||||
* Controls that provide a choice between only two settings can often be implemented
|
||||
* instead as a <code>{@link BooleanControl}</code>, and controls that provide
|
||||
* a set of values along some quantifiable dimension might be implemented
|
||||
* instead as a <code>FloatControl</code> with a coarse resolution.
|
||||
* However, a key feature of <code>EnumControl</code> is that the returned values
|
||||
* are arbitrary objects, rather than numerical or boolean values. This means that each
|
||||
* returned object can provide further information. As an example, the settings
|
||||
* of a <code>{@link EnumControl.Type#REVERB REVERB}</code> control are instances of
|
||||
* <code>{@link ReverbType}</code> that can be queried for the parameter values
|
||||
* used for each setting.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public abstract class EnumControl extends Control {
|
||||
|
||||
|
||||
// TYPE DEFINES
|
||||
|
||||
|
||||
// INSTANCE VARIABLES
|
||||
|
||||
|
||||
/**
|
||||
* The set of possible values.
|
||||
*/
|
||||
private Object[] values;
|
||||
|
||||
|
||||
/**
|
||||
* The current value.
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
|
||||
|
||||
// CONSTRUCTORS
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new enumerated control object with the given parameters.
|
||||
*
|
||||
* @param type the type of control represented this enumerated control object
|
||||
* @param values the set of possible values for the control
|
||||
* @param value the initial control value
|
||||
*/
|
||||
protected EnumControl(Type type, Object[] values, Object value) {
|
||||
|
||||
super(type);
|
||||
|
||||
this.values = values;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// METHODS
|
||||
|
||||
|
||||
/**
|
||||
* Sets the current value for the control. The default implementation
|
||||
* simply sets the value as indicated. If the value indicated is not
|
||||
* supported, an IllegalArgumentException is thrown.
|
||||
* Some controls require that their line be open before they can be affected
|
||||
* by setting a value.
|
||||
* @param value the desired new value
|
||||
* @throws IllegalArgumentException if the value indicated does not fall
|
||||
* within the allowable range
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
if (!isValueSupported(value)) {
|
||||
throw new IllegalArgumentException("Requested value " + value + " is not supported.");
|
||||
}
|
||||
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains this control's current value.
|
||||
* @return the current value
|
||||
*/
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the set of possible values for this control.
|
||||
* @return the set of possible values
|
||||
*/
|
||||
public Object[] getValues() {
|
||||
|
||||
Object[] localArray = new Object[values.length];
|
||||
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
localArray[i] = values[i];
|
||||
}
|
||||
|
||||
return localArray;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether the value specified is supported.
|
||||
* @param value the value for which support is queried
|
||||
* @return <code>true</code> if the value is supported,
|
||||
* otherwise <code>false</code>
|
||||
*/
|
||||
private boolean isValueSupported(Object value) {
|
||||
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
//$$fb 2001-07-20: Fix for bug 4400392: setValue() in ReverbControl always throws Exception
|
||||
//if (values.equals(values[i])) {
|
||||
if (value.equals(values[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ABSTRACT METHOD IMPLEMENTATIONS: CONTROL
|
||||
|
||||
|
||||
/**
|
||||
* Provides a string representation of the control.
|
||||
* @return a string description
|
||||
*/
|
||||
public String toString() {
|
||||
return new String(getType() + " with current value: " + getValue());
|
||||
}
|
||||
|
||||
|
||||
// INNER CLASSES
|
||||
|
||||
|
||||
/**
|
||||
* An instance of the <code>EnumControl.Type</code> inner class identifies one kind of
|
||||
* enumerated control. Static instances are provided for the
|
||||
* common types.
|
||||
*
|
||||
* @see EnumControl
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class Type extends Control.Type {
|
||||
|
||||
|
||||
// TYPE DEFINES
|
||||
|
||||
/**
|
||||
* Represents a control over a set of possible reverberation settings.
|
||||
* Each reverberation setting is described by an instance of the
|
||||
* {@link ReverbType} class. (To access these settings,
|
||||
* invoke <code>{@link EnumControl#getValues}</code> on an
|
||||
* enumerated control of type <code>REVERB</code>.)
|
||||
*/
|
||||
public static final Type REVERB = new Type("Reverb");
|
||||
|
||||
|
||||
// CONSTRUCTOR
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new enumerated control type.
|
||||
* @param name the name of the new enumerated control type
|
||||
*/
|
||||
protected Type(String name) {
|
||||
super(name);
|
||||
}
|
||||
} // class Type
|
||||
|
||||
} // class EnumControl
|
529
jdkSrc/jdk8/javax/sound/sampled/FloatControl.java
Normal file
529
jdkSrc/jdk8/javax/sound/sampled/FloatControl.java
Normal file
@@ -0,0 +1,529 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
/**
|
||||
* A <code>FloatControl</code> object provides control over a range of
|
||||
* floating-point values. Float controls are often
|
||||
* represented in graphical user interfaces by continuously
|
||||
* adjustable objects such as sliders or rotary knobs. Concrete subclasses
|
||||
* of <code>FloatControl</code> implement controls, such as gain and pan, that
|
||||
* affect a line's audio signal in some way that an application can manipulate.
|
||||
* The <code>{@link FloatControl.Type}</code>
|
||||
* inner class provides static instances of types that are used to
|
||||
* identify some common kinds of float control.
|
||||
* <p>
|
||||
* The <code>FloatControl</code> abstract class provides methods to set and get
|
||||
* the control's current floating-point value. Other methods obtain the possible
|
||||
* range of values and the control's resolution (the smallest increment between
|
||||
* returned values). Some float controls allow ramping to a
|
||||
* new value over a specified period of time. <code>FloatControl</code> also
|
||||
* includes methods that return string labels for the minimum, maximum, and midpoint
|
||||
* positions of the control.
|
||||
*
|
||||
* @see Line#getControls
|
||||
* @see Line#isControlSupported
|
||||
*
|
||||
* @author David Rivas
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public abstract class FloatControl extends Control {
|
||||
|
||||
|
||||
// INSTANCE VARIABLES
|
||||
|
||||
|
||||
// FINAL VARIABLES
|
||||
|
||||
/**
|
||||
* The minimum supported value.
|
||||
*/
|
||||
private float minimum;
|
||||
|
||||
/**
|
||||
* The maximum supported value.
|
||||
*/
|
||||
private float maximum;
|
||||
|
||||
/**
|
||||
* The control's precision.
|
||||
*/
|
||||
private float precision;
|
||||
|
||||
/**
|
||||
* The smallest time increment in which a value change
|
||||
* can be effected during a value shift, in microseconds.
|
||||
*/
|
||||
private int updatePeriod;
|
||||
|
||||
|
||||
/**
|
||||
* A label for the units in which the control values are expressed,
|
||||
* such as "dB" for decibels.
|
||||
*/
|
||||
private final String units;
|
||||
|
||||
/**
|
||||
* A label for the minimum value, such as "Left."
|
||||
*/
|
||||
private final String minLabel;
|
||||
|
||||
/**
|
||||
* A label for the maximum value, such as "Right."
|
||||
*/
|
||||
private final String maxLabel;
|
||||
|
||||
/**
|
||||
* A label for the mid-point value, such as "Center."
|
||||
*/
|
||||
private final String midLabel;
|
||||
|
||||
|
||||
// STATE VARIABLES
|
||||
|
||||
/**
|
||||
* The current value.
|
||||
*/
|
||||
private float value;
|
||||
|
||||
|
||||
|
||||
// CONSTRUCTORS
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new float control object with the given parameters
|
||||
*
|
||||
* @param type the kind of control represented by this float control object
|
||||
* @param minimum the smallest value permitted for the control
|
||||
* @param maximum the largest value permitted for the control
|
||||
* @param precision the resolution or granularity of the control.
|
||||
* This is the size of the increment between discrete valid values.
|
||||
* @param updatePeriod the smallest time interval, in microseconds, over which the control
|
||||
* can change from one discrete value to the next during a {@link #shift(float,float,int) shift}
|
||||
* @param initialValue the value that the control starts with when constructed
|
||||
* @param units the label for the units in which the control's values are expressed,
|
||||
* such as "dB" or "frames per second"
|
||||
* @param minLabel the label for the minimum value, such as "Left" or "Off"
|
||||
* @param midLabel the label for the midpoint value, such as "Center" or "Default"
|
||||
* @param maxLabel the label for the maximum value, such as "Right" or "Full"
|
||||
*
|
||||
* @throws IllegalArgumentException if {@code minimum} is greater
|
||||
* than {@code maximum} or {@code initialValue} does not fall
|
||||
* within the allowable range
|
||||
*/
|
||||
protected FloatControl(Type type, float minimum, float maximum,
|
||||
float precision, int updatePeriod, float initialValue,
|
||||
String units, String minLabel, String midLabel, String maxLabel) {
|
||||
|
||||
super(type);
|
||||
|
||||
if (minimum > maximum) {
|
||||
throw new IllegalArgumentException("Minimum value " + minimum
|
||||
+ " exceeds maximum value " + maximum + ".");
|
||||
}
|
||||
if (initialValue < minimum) {
|
||||
throw new IllegalArgumentException("Initial value " + initialValue
|
||||
+ " smaller than allowable minimum value " + minimum + ".");
|
||||
}
|
||||
if (initialValue > maximum) {
|
||||
throw new IllegalArgumentException("Initial value " + initialValue
|
||||
+ " exceeds allowable maximum value " + maximum + ".");
|
||||
}
|
||||
|
||||
|
||||
this.minimum = minimum;
|
||||
this.maximum = maximum;
|
||||
|
||||
this.precision = precision;
|
||||
this.updatePeriod = updatePeriod;
|
||||
this.value = initialValue;
|
||||
|
||||
this.units = units;
|
||||
this.minLabel = ( (minLabel == null) ? "" : minLabel);
|
||||
this.midLabel = ( (midLabel == null) ? "" : midLabel);
|
||||
this.maxLabel = ( (maxLabel == null) ? "" : maxLabel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new float control object with the given parameters.
|
||||
* The labels for the minimum, maximum, and mid-point values are set
|
||||
* to zero-length strings.
|
||||
*
|
||||
* @param type the kind of control represented by this float control object
|
||||
* @param minimum the smallest value permitted for the control
|
||||
* @param maximum the largest value permitted for the control
|
||||
* @param precision the resolution or granularity of the control.
|
||||
* This is the size of the increment between discrete valid values.
|
||||
* @param updatePeriod the smallest time interval, in microseconds, over which the control
|
||||
* can change from one discrete value to the next during a {@link #shift(float,float,int) shift}
|
||||
* @param initialValue the value that the control starts with when constructed
|
||||
* @param units the label for the units in which the control's values are expressed,
|
||||
* such as "dB" or "frames per second"
|
||||
*
|
||||
* @throws IllegalArgumentException if {@code minimum} is greater
|
||||
* than {@code maximum} or {@code initialValue} does not fall
|
||||
* within the allowable range
|
||||
*/
|
||||
protected FloatControl(Type type, float minimum, float maximum,
|
||||
float precision, int updatePeriod, float initialValue, String units) {
|
||||
this(type, minimum, maximum, precision, updatePeriod,
|
||||
initialValue, units, "", "", "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// METHODS
|
||||
|
||||
|
||||
/**
|
||||
* Sets the current value for the control. The default implementation
|
||||
* simply sets the value as indicated. If the value indicated is greater
|
||||
* than the maximum value, or smaller than the minimum value, an
|
||||
* IllegalArgumentException is thrown.
|
||||
* Some controls require that their line be open before they can be affected
|
||||
* by setting a value.
|
||||
* @param newValue desired new value
|
||||
* @throws IllegalArgumentException if the value indicated does not fall
|
||||
* within the allowable range
|
||||
*/
|
||||
public void setValue(float newValue) {
|
||||
|
||||
if (newValue > maximum) {
|
||||
throw new IllegalArgumentException("Requested value " + newValue + " exceeds allowable maximum value " + maximum + ".");
|
||||
}
|
||||
|
||||
if (newValue < minimum) {
|
||||
throw new IllegalArgumentException("Requested value " + newValue + " smaller than allowable minimum value " + minimum + ".");
|
||||
}
|
||||
|
||||
value = newValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains this control's current value.
|
||||
* @return the current value
|
||||
*/
|
||||
public float getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the maximum value permitted.
|
||||
* @return the maximum allowable value
|
||||
*/
|
||||
public float getMaximum() {
|
||||
return maximum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the minimum value permitted.
|
||||
* @return the minimum allowable value
|
||||
*/
|
||||
public float getMinimum() {
|
||||
return minimum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the label for the units in which the control's values are expressed,
|
||||
* such as "dB" or "frames per second."
|
||||
* @return the units label, or a zero-length string if no label
|
||||
*/
|
||||
public String getUnits() {
|
||||
return units;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the label for the minimum value, such as "Left" or "Off."
|
||||
* @return the minimum value label, or a zero-length string if no label * has been set
|
||||
*/
|
||||
public String getMinLabel() {
|
||||
return minLabel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the label for the mid-point value, such as "Center" or "Default."
|
||||
* @return the mid-point value label, or a zero-length string if no label * has been set
|
||||
*/
|
||||
public String getMidLabel() {
|
||||
return midLabel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the label for the maximum value, such as "Right" or "Full."
|
||||
* @return the maximum value label, or a zero-length string if no label * has been set
|
||||
*/
|
||||
public String getMaxLabel() {
|
||||
return maxLabel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the resolution or granularity of the control, in the units
|
||||
* that the control measures.
|
||||
* The precision is the size of the increment between discrete valid values
|
||||
* for this control, over the set of supported floating-point values.
|
||||
* @return the control's precision
|
||||
*/
|
||||
public float getPrecision() {
|
||||
return precision;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the smallest time interval, in microseconds, over which the control's value can
|
||||
* change during a shift. The update period is the inverse of the frequency with which
|
||||
* the control updates its value during a shift. If the implementation does not support value shifting over
|
||||
* time, it should set the control's value to the final value immediately
|
||||
* and return -1 from this method.
|
||||
*
|
||||
* @return update period in microseconds, or -1 if shifting over time is unsupported
|
||||
* @see #shift
|
||||
*/
|
||||
public int getUpdatePeriod() {
|
||||
return updatePeriod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Changes the control value from the initial value to the final
|
||||
* value linearly over the specified time period, specified in microseconds.
|
||||
* This method returns without blocking; it does not wait for the shift
|
||||
* to complete. An implementation should complete the operation within the time
|
||||
* specified. The default implementation simply changes the value
|
||||
* to the final value immediately.
|
||||
*
|
||||
* @param from initial value at the beginning of the shift
|
||||
* @param to final value after the shift
|
||||
* @param microseconds maximum duration of the shift in microseconds
|
||||
*
|
||||
* @throws IllegalArgumentException if either {@code from} or {@code to}
|
||||
* value does not fall within the allowable range
|
||||
*
|
||||
* @see #getUpdatePeriod
|
||||
*/
|
||||
public void shift(float from, float to, int microseconds) {
|
||||
// test "from" value, "to" value will be tested by setValue()
|
||||
if (from < minimum) {
|
||||
throw new IllegalArgumentException("Requested value " + from
|
||||
+ " smaller than allowable minimum value " + minimum + ".");
|
||||
}
|
||||
if (from > maximum) {
|
||||
throw new IllegalArgumentException("Requested value " + from
|
||||
+ " exceeds allowable maximum value " + maximum + ".");
|
||||
}
|
||||
setValue(to);
|
||||
}
|
||||
|
||||
|
||||
// ABSTRACT METHOD IMPLEMENTATIONS: CONTROL
|
||||
|
||||
|
||||
/**
|
||||
* Provides a string representation of the control
|
||||
* @return a string description
|
||||
*/
|
||||
public String toString() {
|
||||
return new String(getType() + " with current value: " + getValue() + " " + units +
|
||||
" (range: " + minimum + " - " + maximum + ")");
|
||||
}
|
||||
|
||||
|
||||
// INNER CLASSES
|
||||
|
||||
|
||||
/**
|
||||
* An instance of the <code>FloatControl.Type</code> inner class identifies one kind of
|
||||
* float control. Static instances are provided for the
|
||||
* common types.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class Type extends Control.Type {
|
||||
|
||||
|
||||
// TYPE DEFINES
|
||||
|
||||
|
||||
// GAIN TYPES
|
||||
|
||||
/**
|
||||
* Represents a control for the overall gain on a line.
|
||||
* <p>
|
||||
* Gain is a quantity in decibels (dB) that is added to the intrinsic
|
||||
* decibel level of the audio signal--that is, the level of
|
||||
* the signal before it is altered by the gain control. A positive
|
||||
* gain amplifies (boosts) the signal's volume, and a negative gain
|
||||
* attenuates (cuts) it.
|
||||
* The gain setting defaults to a value of 0.0 dB, meaning the signal's
|
||||
* loudness is unaffected. Note that gain measures dB, not amplitude.
|
||||
* The relationship between a gain in decibels and the corresponding
|
||||
* linear amplitude multiplier is:
|
||||
*
|
||||
*<CENTER><CODE> linearScalar = pow(10.0, gainDB/20.0) </CODE></CENTER>
|
||||
* <p>
|
||||
* The <code>FloatControl</code> class has methods to impose a maximum and
|
||||
* minimum allowable value for gain. However, because an audio signal might
|
||||
* already be at a high amplitude, the maximum setting does not guarantee
|
||||
* that the signal will be undistorted when the gain is applied to it (unless
|
||||
* the maximum is zero or negative). To avoid numeric overflow from excessively
|
||||
* large gain settings, a gain control can implement
|
||||
* clipping, meaning that the signal's amplitude will be limited to the maximum
|
||||
* value representable by its audio format, instead of wrapping around.
|
||||
* <p>
|
||||
* These comments apply to gain controls in general, not just master gain controls.
|
||||
* A line can have more than one gain control. For example, a mixer (which is
|
||||
* itself a line) might have a master gain control, an auxiliary return control,
|
||||
* a reverb return control, and, on each of its source lines, an individual aux
|
||||
* send and reverb send.
|
||||
*
|
||||
* @see #AUX_SEND
|
||||
* @see #AUX_RETURN
|
||||
* @see #REVERB_SEND
|
||||
* @see #REVERB_RETURN
|
||||
* @see #VOLUME
|
||||
*/
|
||||
public static final Type MASTER_GAIN = new Type("Master Gain");
|
||||
|
||||
/**
|
||||
* Represents a control for the auxiliary send gain on a line.
|
||||
*
|
||||
* @see #MASTER_GAIN
|
||||
* @see #AUX_RETURN
|
||||
*/
|
||||
public static final Type AUX_SEND = new Type("AUX Send");
|
||||
|
||||
/**
|
||||
* Represents a control for the auxiliary return gain on a line.
|
||||
*
|
||||
* @see #MASTER_GAIN
|
||||
* @see #AUX_SEND
|
||||
*/
|
||||
public static final Type AUX_RETURN = new Type("AUX Return");
|
||||
|
||||
/**
|
||||
* Represents a control for the pre-reverb gain on a line.
|
||||
* This control may be used to affect how much
|
||||
* of a line's signal is directed to a mixer's internal reverberation unit.
|
||||
*
|
||||
* @see #MASTER_GAIN
|
||||
* @see #REVERB_RETURN
|
||||
* @see EnumControl.Type#REVERB
|
||||
*/
|
||||
public static final Type REVERB_SEND = new Type("Reverb Send");
|
||||
|
||||
/**
|
||||
* Represents a control for the post-reverb gain on a line.
|
||||
* This control may be used to control the relative amplitude
|
||||
* of the signal returned from an internal reverberation unit.
|
||||
*
|
||||
* @see #MASTER_GAIN
|
||||
* @see #REVERB_SEND
|
||||
*/
|
||||
public static final Type REVERB_RETURN = new Type("Reverb Return");
|
||||
|
||||
|
||||
// VOLUME
|
||||
|
||||
/**
|
||||
* Represents a control for the volume on a line.
|
||||
*/
|
||||
/*
|
||||
* $$kk: 08.30.99: ISSUE: what units? linear or dB?
|
||||
*/
|
||||
public static final Type VOLUME = new Type("Volume");
|
||||
|
||||
|
||||
// PAN
|
||||
|
||||
/**
|
||||
* Represents a control for the relative pan (left-right positioning)
|
||||
* of the signal. The signal may be mono; the pan setting affects how
|
||||
* it is distributed by the mixer in a stereo mix. The valid range of values is -1.0
|
||||
* (left channel only) to 1.0 (right channel
|
||||
* only). The default is 0.0 (centered).
|
||||
*
|
||||
* @see #BALANCE
|
||||
*/
|
||||
public static final Type PAN = new Type("Pan");
|
||||
|
||||
|
||||
// BALANCE
|
||||
|
||||
/**
|
||||
* Represents a control for the relative balance of a stereo signal
|
||||
* between two stereo speakers. The valid range of values is -1.0 (left channel only) to 1.0 (right channel
|
||||
* only). The default is 0.0 (centered).
|
||||
*
|
||||
* @see #PAN
|
||||
*/
|
||||
public static final Type BALANCE = new Type("Balance");
|
||||
|
||||
|
||||
// SAMPLE RATE
|
||||
|
||||
/**
|
||||
* Represents a control that changes the sample rate of audio playback. The net effect
|
||||
* of changing the sample rate depends on the relationship between
|
||||
* the media's natural rate and the rate that is set via this control.
|
||||
* The natural rate is the sample rate that is specified in the data line's
|
||||
* <code>AudioFormat</code> object. For example, if the natural rate
|
||||
* of the media is 11025 samples per second and the sample rate is set
|
||||
* to 22050 samples per second, the media will play back at twice the
|
||||
* normal speed.
|
||||
* <p>
|
||||
* Changing the sample rate with this control does not affect the data line's
|
||||
* audio format. Also note that whenever you change a sound's sample rate, a
|
||||
* change in the sound's pitch results. For example, doubling the sample
|
||||
* rate has the effect of doubling the frequencies in the sound's spectrum,
|
||||
* which raises the pitch by an octave.
|
||||
*/
|
||||
public static final Type SAMPLE_RATE = new Type("Sample Rate");
|
||||
|
||||
|
||||
// CONSTRUCTOR
|
||||
|
||||
/**
|
||||
* Constructs a new float control type.
|
||||
* @param name the name of the new float control type
|
||||
*/
|
||||
protected Type(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
} // class Type
|
||||
|
||||
} // class FloatControl
|
359
jdkSrc/jdk8/javax/sound/sampled/Line.java
Normal file
359
jdkSrc/jdk8/javax/sound/sampled/Line.java
Normal file
@@ -0,0 +1,359 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
/**
|
||||
* The <code>Line</code> interface represents a mono or multi-channel
|
||||
* audio feed. A line is an element of the digital audio
|
||||
* "pipeline," such as a mixer, an input or output port,
|
||||
* or a data path into or out of a mixer.
|
||||
* <p>
|
||||
* A line can have controls, such as gain, pan, and reverb.
|
||||
* The controls themselves are instances of classes that extend the
|
||||
* base <code>{@link Control}</code> class.
|
||||
* The <code>Line</code> interface provides two accessor methods for
|
||||
* obtaining the line's controls: <code>{@link #getControls getControls}</code> returns the
|
||||
* entire set, and <code>{@link #getControl getControl}</code> returns a single control of
|
||||
* specified type.
|
||||
* <p>
|
||||
* Lines exist in various states at different times. When a line opens, it reserves system
|
||||
* resources for itself, and when it closes, these resources are freed for
|
||||
* other objects or applications. The <code>{@link #isOpen()}</code> method lets
|
||||
* you discover whether a line is open or closed.
|
||||
* An open line need not be processing data, however. Such processing is
|
||||
* typically initiated by subinterface methods such as
|
||||
* <code>{@link SourceDataLine#write SourceDataLine.write}</code> and
|
||||
* <code>{@link TargetDataLine#read TargetDataLine.read}</code>.
|
||||
*<p>
|
||||
* You can register an object to receive notifications whenever the line's
|
||||
* state changes. The object must implement the <code>{@link LineListener}</code>
|
||||
* interface, which consists of the single method
|
||||
* <code>{@link LineListener#update update}</code>.
|
||||
* This method will be invoked when a line opens and closes (and, if it's a
|
||||
* {@link DataLine}, when it starts and stops).
|
||||
*<p>
|
||||
* An object can be registered to listen to multiple lines. The event it
|
||||
* receives in its <code>update</code> method will specify which line created
|
||||
* the event, what type of event it was
|
||||
* (<code>OPEN</code>, <code>CLOSE</code>, <code>START</code>, or <code>STOP</code>),
|
||||
* and how many sample frames the line had processed at the time the event occurred.
|
||||
* <p>
|
||||
* Certain line operations, such as open and close, can generate security
|
||||
* exceptions if invoked by unprivileged code when the line is a shared audio
|
||||
* resource.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
*
|
||||
* @see LineEvent
|
||||
* @since 1.3
|
||||
*/
|
||||
public interface Line extends AutoCloseable {
|
||||
|
||||
/**
|
||||
* Obtains the <code>Line.Info</code> object describing this
|
||||
* line.
|
||||
* @return description of the line
|
||||
*/
|
||||
public Line.Info getLineInfo();
|
||||
|
||||
/**
|
||||
* Opens the line, indicating that it should acquire any required
|
||||
* system resources and become operational.
|
||||
* If this operation
|
||||
* succeeds, the line is marked as open, and an <code>OPEN</code> event is dispatched
|
||||
* to the line's listeners.
|
||||
* <p>
|
||||
* Note that some lines, once closed, cannot be reopened. Attempts
|
||||
* to reopen such a line will always result in an <code>LineUnavailableException</code>.
|
||||
* <p>
|
||||
* Some types of lines have configurable properties that may affect
|
||||
* resource allocation. For example, a <code>DataLine</code> must
|
||||
* be opened with a particular format and buffer size. Such lines
|
||||
* should provide a mechanism for configuring these properties, such
|
||||
* as an additional <code>open</code> method or methods which allow
|
||||
* an application to specify the desired settings.
|
||||
* <p>
|
||||
* This method takes no arguments, and opens the line with the current
|
||||
* settings. For <code>{@link SourceDataLine}</code> and
|
||||
* <code>{@link TargetDataLine}</code> objects, this means that the line is
|
||||
* opened with default settings. For a <code>{@link Clip}</code>, however,
|
||||
* the buffer size is determined when data is loaded. Since this method does not
|
||||
* allow the application to specify any data to load, an IllegalArgumentException
|
||||
* is thrown. Therefore, you should instead use one of the <code>open</code> methods
|
||||
* provided in the <code>Clip</code> interface to load data into the <code>Clip</code>.
|
||||
* <p>
|
||||
* For <code>DataLine</code>'s, if the <code>DataLine.Info</code>
|
||||
* object which was used to retrieve the line, specifies at least
|
||||
* one fully qualified audio format, the last one will be used
|
||||
* as the default format.
|
||||
*
|
||||
* @throws IllegalArgumentException if this method is called on a Clip instance.
|
||||
* @throws LineUnavailableException if the line cannot be
|
||||
* opened due to resource restrictions.
|
||||
* @throws SecurityException if the line cannot be
|
||||
* opened due to security restrictions.
|
||||
*
|
||||
* @see #close
|
||||
* @see #isOpen
|
||||
* @see LineEvent
|
||||
* @see DataLine
|
||||
* @see Clip#open(AudioFormat, byte[], int, int)
|
||||
* @see Clip#open(AudioInputStream)
|
||||
*/
|
||||
public void open() throws LineUnavailableException;
|
||||
|
||||
|
||||
/**
|
||||
* Closes the line, indicating that any system resources
|
||||
* in use by the line can be released. If this operation
|
||||
* succeeds, the line is marked closed and a <code>CLOSE</code> event is dispatched
|
||||
* to the line's listeners.
|
||||
* @throws SecurityException if the line cannot be
|
||||
* closed due to security restrictions.
|
||||
*
|
||||
* @see #open
|
||||
* @see #isOpen
|
||||
* @see LineEvent
|
||||
*/
|
||||
public void close();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether the line is open, meaning that it has reserved
|
||||
* system resources and is operational, although it might not currently be
|
||||
* playing or capturing sound.
|
||||
* @return <code>true</code> if the line is open, otherwise <code>false</code>
|
||||
*
|
||||
* @see #open()
|
||||
* @see #close()
|
||||
*/
|
||||
public boolean isOpen();
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the set of controls associated with this line.
|
||||
* Some controls may only be available when the line is open.
|
||||
* If there are no controls, this method returns an array of length 0.
|
||||
* @return the array of controls
|
||||
* @see #getControl
|
||||
*/
|
||||
public Control[] getControls();
|
||||
|
||||
/**
|
||||
* Indicates whether the line supports a control of the specified type.
|
||||
* Some controls may only be available when the line is open.
|
||||
* @param control the type of the control for which support is queried
|
||||
* @return <code>true</code> if at least one control of the specified type is
|
||||
* supported, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean isControlSupported(Control.Type control);
|
||||
|
||||
|
||||
/**
|
||||
* Obtains a control of the specified type,
|
||||
* if there is any.
|
||||
* Some controls may only be available when the line is open.
|
||||
* @param control the type of the requested control
|
||||
* @return a control of the specified type
|
||||
* @throws IllegalArgumentException if a control of the specified type
|
||||
* is not supported
|
||||
* @see #getControls
|
||||
* @see #isControlSupported(Control.Type control)
|
||||
*/
|
||||
public Control getControl(Control.Type control);
|
||||
|
||||
|
||||
/**
|
||||
* Adds a listener to this line. Whenever the line's status changes, the
|
||||
* listener's <code>update()</code> method is called with a <code>LineEvent</code> object
|
||||
* that describes the change.
|
||||
* @param listener the object to add as a listener to this line
|
||||
* @see #removeLineListener
|
||||
* @see LineListener#update
|
||||
* @see LineEvent
|
||||
*/
|
||||
public void addLineListener(LineListener listener);
|
||||
|
||||
|
||||
/**
|
||||
* Removes the specified listener from this line's list of listeners.
|
||||
* @param listener listener to remove
|
||||
* @see #addLineListener
|
||||
*/
|
||||
public void removeLineListener(LineListener listener);
|
||||
|
||||
|
||||
/**
|
||||
* A <code>Line.Info</code> object contains information about a line.
|
||||
* The only information provided by <code>Line.Info</code> itself
|
||||
* is the Java class of the line.
|
||||
* A subclass of <code>Line.Info</code> adds other kinds of information
|
||||
* about the line. This additional information depends on which <code>Line</code>
|
||||
* subinterface is implemented by the kind of line that the <code>Line.Info</code>
|
||||
* subclass describes.
|
||||
* <p>
|
||||
* A <code>Line.Info</code> can be retrieved using various methods of
|
||||
* the <code>Line</code>, <code>Mixer</code>, and <code>AudioSystem</code>
|
||||
* interfaces. Other such methods let you pass a <code>Line.Info</code> as
|
||||
* an argument, to learn whether lines matching the specified configuration
|
||||
* are available and to obtain them.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
*
|
||||
* @see Line#getLineInfo
|
||||
* @see Mixer#getSourceLineInfo
|
||||
* @see Mixer#getTargetLineInfo
|
||||
* @see Mixer#getLine <code>Mixer.getLine(Line.Info)</code>
|
||||
* @see Mixer#getSourceLineInfo(Line.Info) <code>Mixer.getSourceLineInfo(Line.Info)</code>
|
||||
* @see Mixer#getSourceLineInfo(Line.Info) <code>Mixer.getTargetLineInfo(Line.Info)</code>
|
||||
* @see Mixer#isLineSupported <code>Mixer.isLineSupported(Line.Info)</code>
|
||||
* @see AudioSystem#getLine <code>AudioSystem.getLine(Line.Info)</code>
|
||||
* @see AudioSystem#getSourceLineInfo <code>AudioSystem.getSourceLineInfo(Line.Info)</code>
|
||||
* @see AudioSystem#getTargetLineInfo <code>AudioSystem.getTargetLineInfo(Line.Info)</code>
|
||||
* @see AudioSystem#isLineSupported <code>AudioSystem.isLineSupported(Line.Info)</code>
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class Info {
|
||||
|
||||
/**
|
||||
* The class of the line described by the info object.
|
||||
*/
|
||||
private final Class lineClass;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an info object that describes a line of the specified class.
|
||||
* This constructor is typically used by an application to
|
||||
* describe a desired line.
|
||||
* @param lineClass the class of the line that the new Line.Info object describes
|
||||
*/
|
||||
public Info(Class<?> lineClass) {
|
||||
|
||||
if (lineClass == null) {
|
||||
this.lineClass = Line.class;
|
||||
} else {
|
||||
this.lineClass = lineClass;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the class of the line that this Line.Info object describes.
|
||||
* @return the described line's class
|
||||
*/
|
||||
public Class<?> getLineClass() {
|
||||
return lineClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether the specified info object matches this one.
|
||||
* To match, the specified object must be identical to or
|
||||
* a special case of this one. The specified info object
|
||||
* must be either an instance of the same class as this one,
|
||||
* or an instance of a sub-type of this one. In addition, the
|
||||
* attributes of the specified object must be compatible with the
|
||||
* capabilities of this one. Specifically, the routing configuration
|
||||
* for the specified info object must be compatible with that of this
|
||||
* one.
|
||||
* Subclasses may add other criteria to determine whether the two objects
|
||||
* match.
|
||||
*
|
||||
* @param info the info object which is being compared to this one
|
||||
* @return <code>true</code> if the specified object matches this one,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public boolean matches(Info info) {
|
||||
|
||||
// $$kk: 08.30.99: is this backwards?
|
||||
// dataLine.matches(targetDataLine) == true: targetDataLine is always dataLine
|
||||
// targetDataLine.matches(dataLine) == false
|
||||
// so if i want to make sure i get a targetDataLine, i need:
|
||||
// targetDataLine.matches(prospective_match) == true
|
||||
// => prospective_match may be other things as well, but it is at least a targetDataLine
|
||||
// targetDataLine defines the requirements which prospective_match must meet.
|
||||
|
||||
|
||||
// "if this Class object represents a declared class, this method returns
|
||||
// true if the specified Object argument is an instance of the represented
|
||||
// class (or of any of its subclasses)"
|
||||
// GainControlClass.isInstance(MyGainObj) => true
|
||||
// GainControlClass.isInstance(MySpecialGainInterfaceObj) => true
|
||||
|
||||
// this_class.isInstance(that_object) => that object can by cast to this class
|
||||
// => that_object's class may be a subtype of this_class
|
||||
// => that may be more specific (subtype) of this
|
||||
|
||||
// "If this Class object represents an interface, this method returns true
|
||||
// if the class or any superclass of the specified Object argument implements
|
||||
// this interface"
|
||||
// GainControlClass.isInstance(MyGainObj) => true
|
||||
// GainControlClass.isInstance(GenericControlObj) => may be false
|
||||
// => that may be more specific
|
||||
|
||||
if (! (this.getClass().isInstance(info)) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// this.isAssignableFrom(that) => this is same or super to that
|
||||
// => this is at least as general as that
|
||||
// => that may be subtype of this
|
||||
|
||||
if (! (getLineClass().isAssignableFrom(info.getLineClass())) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains a textual description of the line info.
|
||||
* @return a string description
|
||||
*/
|
||||
public String toString() {
|
||||
|
||||
String fullPackagePath = "javax.sound.sampled.";
|
||||
String initialString = new String(getLineClass().toString());
|
||||
String finalString;
|
||||
|
||||
int index = initialString.indexOf(fullPackagePath);
|
||||
|
||||
if (index != -1) {
|
||||
finalString = initialString.substring(0, index) + initialString.substring( (index + fullPackagePath.length()), initialString.length() );
|
||||
} else {
|
||||
finalString = initialString;
|
||||
}
|
||||
|
||||
return finalString;
|
||||
}
|
||||
|
||||
} // class Info
|
||||
|
||||
} // interface Line
|
281
jdkSrc/jdk8/javax/sound/sampled/LineEvent.java
Normal file
281
jdkSrc/jdk8/javax/sound/sampled/LineEvent.java
Normal file
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
/**
|
||||
* The <code>LineEvent</code> class encapsulates information that a line
|
||||
* sends its listeners whenever the line opens, closes, starts, or stops.
|
||||
* Each of these four state changes is represented by a corresponding
|
||||
* type of event. A listener receives the event as a parameter to its
|
||||
* {@link LineListener#update update} method. By querying the event,
|
||||
* the listener can learn the type of event, the line responsible for
|
||||
* the event, and how much data the line had processed when the event occurred.
|
||||
*
|
||||
* <p>Although this class implements Serializable, attempts to
|
||||
* serialize a <code>LineEvent</code> object will fail.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
*
|
||||
* @see Line
|
||||
* @see LineListener#update
|
||||
* @since 1.3
|
||||
*
|
||||
* @serial exclude
|
||||
*/
|
||||
public class LineEvent extends java.util.EventObject {
|
||||
|
||||
// INSTANCE VARIABLES
|
||||
|
||||
/**
|
||||
* The kind of line event (<code>OPEN</code>, <code>CLOSE</code>,
|
||||
* <code>START</code>, or <code>STOP</code>).
|
||||
* @see #getType
|
||||
* @serial
|
||||
*/
|
||||
private final Type type;
|
||||
|
||||
/**
|
||||
* The media position when the event occurred, expressed in sample frames.
|
||||
* Note that this field is only relevant to certain events generated by
|
||||
* data lines, such as <code>START</code> and <code>STOP</code>. For
|
||||
* events generated by lines that do not count sample frames, and for any
|
||||
* other events for which this value is not known, the position value
|
||||
* should be {@link AudioSystem#NOT_SPECIFIED}.
|
||||
* @serial
|
||||
* @see #getFramePosition
|
||||
*/
|
||||
private final long position;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new event of the specified type, originating from the specified line.
|
||||
* @param line the source of this event
|
||||
* @param type the event type (<code>OPEN</code>, <code>CLOSE</code>, <code>START</code>, or <code>STOP</code>)
|
||||
* @param position the number of sample frames that the line had already processed when the event occurred,
|
||||
* or {@link AudioSystem#NOT_SPECIFIED}
|
||||
*
|
||||
* @throws IllegalArgumentException if <code>line</code> is
|
||||
* <code>null</code>.
|
||||
*/
|
||||
public LineEvent(Line line, Type type, long position) {
|
||||
|
||||
super(line);
|
||||
this.type = type;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the audio line that is the source of this event.
|
||||
* @return the line responsible for this event
|
||||
*/
|
||||
public final Line getLine() {
|
||||
|
||||
return (Line)getSource();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the event's type.
|
||||
* @return this event's type ({@link Type#OPEN}, {@link Type#CLOSE},
|
||||
* {@link Type#START}, or {@link Type#STOP})
|
||||
*/
|
||||
public final Type getType() {
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the position in the line's audio data when the event occurred, expressed in sample frames.
|
||||
* For example, if a source line had already played back 14 sample frames at the time it was
|
||||
* paused, the pause event would report the line's position as 14. The next frame to be processed
|
||||
* would be frame number 14 using zero-based numbering, or 15 using one-based numbering.
|
||||
* <p>
|
||||
* Note that this field is relevant only to certain events generated by
|
||||
* data lines, such as <code>START</code> and <code>STOP</code>. For
|
||||
* events generated by lines that do not count sample frames, and for any
|
||||
* other events for which this value is not known, the position value
|
||||
* should be {@link AudioSystem#NOT_SPECIFIED}.
|
||||
*
|
||||
* @return the line's position as a sample frame number
|
||||
*/
|
||||
/*
|
||||
* $$kk: 04.20.99: note to myself: should make sure our implementation is consistent with this.
|
||||
* which is a reasonable definition....
|
||||
*/
|
||||
public final long getFramePosition() {
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a string representation of the event. The contents of the string may vary
|
||||
* between implementations of Java Sound.
|
||||
* @return a string describing the event.
|
||||
*/
|
||||
public String toString() {
|
||||
String sType = "";
|
||||
if (type != null) sType = type.toString()+" ";
|
||||
String sLine;
|
||||
if (getLine() == null) {
|
||||
sLine = "null";
|
||||
} else {
|
||||
sLine = getLine().toString();
|
||||
}
|
||||
return new String(sType + "event from line " + sLine);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The LineEvent.Type inner class identifies what kind of event occurred on a line.
|
||||
* Static instances are provided for the common types (OPEN, CLOSE, START, and STOP).
|
||||
*
|
||||
* @see LineEvent#getType()
|
||||
*/
|
||||
public static class Type {
|
||||
|
||||
|
||||
/**
|
||||
* Type name.
|
||||
*/
|
||||
// $$kk: 03.25.99: why can't this be final??
|
||||
private /*final*/ String name;
|
||||
|
||||
/**
|
||||
* Constructs a new event type.
|
||||
* @param name name of the type
|
||||
*/
|
||||
protected Type(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
//$$fb 2002-11-26: fix for 4695001: SPEC: description of equals() method contains typo
|
||||
/**
|
||||
* Indicates whether the specified object is equal to this event type,
|
||||
* returning <code>true</code> if the objects are identical.
|
||||
* @param obj the reference object with which to compare
|
||||
* @return <code>true</code> if this event type is the same as
|
||||
* <code>obj</code>; <code>false</code> otherwise
|
||||
*/
|
||||
public final boolean equals(Object obj) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finalizes the hashcode method.
|
||||
*/
|
||||
public final int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the type name as the string representation.
|
||||
*/
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
// LINE EVENT TYPE DEFINES
|
||||
|
||||
/**
|
||||
* A type of event that is sent when a line opens, reserving system
|
||||
* resources for itself.
|
||||
* @see #CLOSE
|
||||
* @see Line#open
|
||||
*/
|
||||
public static final Type OPEN = new Type("Open");
|
||||
|
||||
|
||||
/**
|
||||
* A type of event that is sent when a line closes, freeing the system
|
||||
* resources it had obtained when it was opened.
|
||||
* @see #OPEN
|
||||
* @see Line#close
|
||||
*/
|
||||
public static final Type CLOSE = new Type("Close");
|
||||
|
||||
|
||||
/**
|
||||
* A type of event that is sent when a line begins to engage in active
|
||||
* input or output of audio data in response to a
|
||||
* {@link DataLine#start start} request.
|
||||
* @see #STOP
|
||||
* @see DataLine#start
|
||||
*/
|
||||
public static final Type START = new Type("Start");
|
||||
|
||||
|
||||
/**
|
||||
* A type of event that is sent when a line ceases active input or output
|
||||
* of audio data in response to a {@link DataLine#stop stop} request,
|
||||
* or because the end of media has been reached.
|
||||
* @see #START
|
||||
* @see DataLine#stop
|
||||
*/
|
||||
public static final Type STOP = new Type("Stop");
|
||||
|
||||
|
||||
/**
|
||||
* A type of event that is sent when a line ceases to engage in active
|
||||
* input or output of audio data because the end of media has been reached.
|
||||
*/
|
||||
/*
|
||||
* ISSUE: we may want to get rid of this. Is JavaSound
|
||||
* responsible for reporting this??
|
||||
*
|
||||
* [If it's decided to keep this API, the docs will need to be updated to include mention
|
||||
* of EOM events elsewhere.]
|
||||
*/
|
||||
//public static final Type EOM = new Type("EOM");
|
||||
|
||||
|
||||
/**
|
||||
* A type of event that is sent when a line begins to engage in active
|
||||
* input or output of audio data. Examples of when this happens are
|
||||
* when a source line begins or resumes writing data to its mixer, and
|
||||
* when a target line begins or resumes reading data from its mixer.
|
||||
* @see #STOP
|
||||
* @see SourceDataLine#write
|
||||
* @see TargetDataLine#read
|
||||
* @see DataLine#start
|
||||
*/
|
||||
//public static final Type ACTIVE = new Type("ACTIVE");
|
||||
|
||||
|
||||
/**
|
||||
* A type of event that is sent when a line ceases active input or output
|
||||
* of audio data.
|
||||
* @see #START
|
||||
* @see DataLine#stop
|
||||
*/
|
||||
//public static final Type INACTIVE = new Type("INACTIVE");
|
||||
|
||||
} // class Type
|
||||
|
||||
} // class LineEvent
|
68
jdkSrc/jdk8/javax/sound/sampled/LineListener.java
Normal file
68
jdkSrc/jdk8/javax/sound/sampled/LineListener.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Instances of classes that implement the <code>LineListener</code> interface can register to
|
||||
* receive events when a line's status changes.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
*
|
||||
* @see Line
|
||||
* @see Line#addLineListener
|
||||
* @see Line#removeLineListener
|
||||
* @see LineEvent
|
||||
*
|
||||
* @since 1.3
|
||||
*/
|
||||
/*
|
||||
* Instances of classes that implement the <code>LineListener</code> interface can register to
|
||||
* receive events when a line's status changes.
|
||||
*
|
||||
* @see Line
|
||||
* @see Line#addLineListener
|
||||
* @see Line#removeLineListener
|
||||
* @see LineEvent
|
||||
*
|
||||
* @author Kara Kytle
|
||||
*/
|
||||
public interface LineListener extends java.util.EventListener {
|
||||
|
||||
/**
|
||||
* Informs the listener that a line's state has changed. The listener can then invoke
|
||||
* <code>LineEvent</code> methods to obtain information about the event.
|
||||
* @param event a line event that describes the change
|
||||
*/
|
||||
/*
|
||||
* Informs the listener that a line's state has changed. The listener can then invoke
|
||||
* <code>LineEvent</code> methods to obtain information about the event.
|
||||
* @param event a line event that describes the change
|
||||
*/
|
||||
public void update(LineEvent event);
|
||||
|
||||
} // interface LineListener
|
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
/**
|
||||
* A <code>LineUnavailableException</code> is an exception indicating that a
|
||||
* line cannot be opened because it is unavailable. This situation
|
||||
* arises most commonly when a requested line is already in use
|
||||
* by another application.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
/*
|
||||
* A <code>LinenavailableException</code> is an exception indicating that a
|
||||
* line annot be opened because it is unavailable. This situation
|
||||
* arises most commonly when a line is requested when it is already in use
|
||||
* by another application.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
*/
|
||||
|
||||
public class LineUnavailableException extends Exception {
|
||||
|
||||
/**
|
||||
* Constructs a <code>LineUnavailableException</code> that has
|
||||
* <code>null</code> as its error detail message.
|
||||
*/
|
||||
public LineUnavailableException() {
|
||||
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a <code>LineUnavailableException</code> that has
|
||||
* the specified detail message.
|
||||
*
|
||||
* @param message a string containing the error detail message
|
||||
*/
|
||||
public LineUnavailableException(String message) {
|
||||
|
||||
super(message);
|
||||
}
|
||||
}
|
354
jdkSrc/jdk8/javax/sound/sampled/Mixer.java
Normal file
354
jdkSrc/jdk8/javax/sound/sampled/Mixer.java
Normal file
@@ -0,0 +1,354 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
|
||||
/**
|
||||
* A mixer is an audio device with one or more lines. It need not be
|
||||
* designed for mixing audio signals. A mixer that actually mixes audio
|
||||
* has multiple input (source) lines and at least one output (target) line.
|
||||
* The former are often instances of classes that implement
|
||||
* <code>{@link SourceDataLine}</code>,
|
||||
* and the latter, <code>{@link TargetDataLine}</code>. <code>{@link Port}</code>
|
||||
* objects, too, are either source lines or target lines.
|
||||
* A mixer can accept prerecorded, loopable sound as input, by having
|
||||
* some of its source lines be instances of objects that implement the
|
||||
* <code>{@link Clip}</code> interface.
|
||||
* <p>
|
||||
* Through methods of the <code>Line</code> interface, which <code>Mixer</code> extends,
|
||||
* a mixer might provide a set of controls that are global to the mixer. For example,
|
||||
* the mixer can have a master gain control. These global controls are distinct
|
||||
* from the controls belonging to each of the mixer's individual lines.
|
||||
* <p>
|
||||
* Some mixers, especially
|
||||
* those with internal digital mixing capabilities, may provide
|
||||
* additional capabilities by implementing the <code>DataLine</code> interface.
|
||||
* <p>
|
||||
* A mixer can support synchronization of its lines. When one line in
|
||||
* a synchronized group is started or stopped, the other lines in the group
|
||||
* automatically start or stop simultaneously with the explicitly affected one.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public interface Mixer extends Line {
|
||||
|
||||
/**
|
||||
* Obtains information about this mixer, including the product's name,
|
||||
* version, vendor, etc.
|
||||
* @return a mixer info object that describes this mixer
|
||||
* @see Mixer.Info
|
||||
*/
|
||||
public Info getMixerInfo();
|
||||
|
||||
|
||||
/**
|
||||
* Obtains information about the set of source lines supported
|
||||
* by this mixer.
|
||||
* Some source lines may only be available when this mixer is open.
|
||||
* @return array of <code>Line.Info</code> objects representing source lines
|
||||
* for this mixer. If no source lines are supported,
|
||||
* an array of length 0 is returned.
|
||||
*/
|
||||
public Line.Info[] getSourceLineInfo();
|
||||
|
||||
/**
|
||||
* Obtains information about the set of target lines supported
|
||||
* by this mixer.
|
||||
* Some target lines may only be available when this mixer is open.
|
||||
* @return array of <code>Line.Info</code> objects representing target lines
|
||||
* for this mixer. If no target lines are supported,
|
||||
* an array of length 0 is returned.
|
||||
*/
|
||||
public Line.Info[] getTargetLineInfo();
|
||||
|
||||
|
||||
/**
|
||||
* Obtains information about source lines of a particular type supported
|
||||
* by the mixer.
|
||||
* Some source lines may only be available when this mixer is open.
|
||||
* @param info a <code>Line.Info</code> object describing lines about which information
|
||||
* is queried
|
||||
* @return an array of <code>Line.Info</code> objects describing source lines matching
|
||||
* the type requested. If no matching source lines are supported, an array of length 0
|
||||
* is returned.
|
||||
*/
|
||||
public Line.Info[] getSourceLineInfo(Line.Info info);
|
||||
|
||||
|
||||
/**
|
||||
* Obtains information about target lines of a particular type supported
|
||||
* by the mixer.
|
||||
* Some target lines may only be available when this mixer is open.
|
||||
* @param info a <code>Line.Info</code> object describing lines about which information
|
||||
* is queried
|
||||
* @return an array of <code>Line.Info</code> objects describing target lines matching
|
||||
* the type requested. If no matching target lines are supported, an array of length 0
|
||||
* is returned.
|
||||
*/
|
||||
public Line.Info[] getTargetLineInfo(Line.Info info);
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether the mixer supports a line (or lines) that match
|
||||
* the specified <code>Line.Info</code> object.
|
||||
* Some lines may only be supported when this mixer is open.
|
||||
* @param info describes the line for which support is queried
|
||||
* @return <code>true</code> if at least one matching line is
|
||||
* supported, <code>false</code> otherwise
|
||||
*/
|
||||
public boolean isLineSupported(Line.Info info);
|
||||
|
||||
/**
|
||||
* Obtains a line that is available for use and that matches the description
|
||||
* in the specified <code>Line.Info</code> object.
|
||||
*
|
||||
* <p>If a <code>DataLine</code> is requested, and <code>info</code>
|
||||
* is an instance of <code>DataLine.Info</code> specifying at
|
||||
* least one fully qualified audio format, the last one
|
||||
* will be used as the default format of the returned
|
||||
* <code>DataLine</code>.
|
||||
*
|
||||
* @param info describes the desired line
|
||||
* @return a line that is available for use and that matches the description
|
||||
* in the specified {@code Line.Info} object
|
||||
* @throws LineUnavailableException if a matching line
|
||||
* is not available due to resource restrictions
|
||||
* @throws IllegalArgumentException if this mixer does
|
||||
* not support any lines matching the description
|
||||
* @throws SecurityException if a matching line
|
||||
* is not available due to security restrictions
|
||||
*/
|
||||
public Line getLine(Line.Info info) throws LineUnavailableException;
|
||||
|
||||
//$$fb 2002-04-12: fix for 4667258: behavior of Mixer.getMaxLines(Line.Info) method doesn't match the spec
|
||||
/**
|
||||
* Obtains the approximate maximum number of lines of the requested type that can be open
|
||||
* simultaneously on the mixer.
|
||||
*
|
||||
* Certain types of mixers do not have a hard bound and may allow opening more lines.
|
||||
* Since certain lines are a shared resource, a mixer may not be able to open the maximum
|
||||
* number of lines if another process has opened lines of this mixer.
|
||||
*
|
||||
* The requested type is any line that matches the description in
|
||||
* the provided <code>Line.Info</code> object. For example, if the info
|
||||
* object represents a speaker
|
||||
* port, and the mixer supports exactly one speaker port, this method
|
||||
* should return 1. If the info object represents a source data line
|
||||
* and the mixer supports the use of 32 source data lines simultaneously,
|
||||
* the return value should be 32.
|
||||
* If there is no limit, this function returns <code>AudioSystem.NOT_SPECIFIED</code>.
|
||||
* @param info a <code>Line.Info</code> that describes the line for which
|
||||
* the number of supported instances is queried
|
||||
* @return the maximum number of matching lines supported, or <code>AudioSystem.NOT_SPECIFIED</code>
|
||||
*/
|
||||
public int getMaxLines(Line.Info info);
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the set of all source lines currently open to this mixer.
|
||||
*
|
||||
* @return the source lines currently open to the mixer.
|
||||
* If no source lines are currently open to this mixer, an
|
||||
* array of length 0 is returned.
|
||||
* @throws SecurityException if the matching lines
|
||||
* are not available due to security restrictions
|
||||
*/
|
||||
public Line[] getSourceLines();
|
||||
|
||||
/**
|
||||
* Obtains the set of all target lines currently open from this mixer.
|
||||
*
|
||||
* @return target lines currently open from the mixer.
|
||||
* If no target lines are currently open from this mixer, an
|
||||
* array of length 0 is returned.
|
||||
* @throws SecurityException if the matching lines
|
||||
* are not available due to security restrictions
|
||||
*/
|
||||
public Line[] getTargetLines();
|
||||
|
||||
/**
|
||||
* Synchronizes two or more lines. Any subsequent command that starts or stops
|
||||
* audio playback or capture for one of these lines will exert the
|
||||
* same effect on the other lines in the group, so that they start or stop playing or
|
||||
* capturing data simultaneously.
|
||||
*
|
||||
* @param lines the lines that should be synchronized
|
||||
* @param maintainSync <code>true</code> if the synchronization
|
||||
* must be precisely maintained (i.e., the synchronization must be sample-accurate)
|
||||
* at all times during operation of the lines , or <code>false</code>
|
||||
* if precise synchronization is required only during start and stop operations
|
||||
*
|
||||
* @throws IllegalArgumentException if the lines cannot be synchronized.
|
||||
* This may occur if the lines are of different types or have different
|
||||
* formats for which this mixer does not support synchronization, or if
|
||||
* all lines specified do not belong to this mixer.
|
||||
*/
|
||||
public void synchronize(Line[] lines, boolean maintainSync);
|
||||
|
||||
/**
|
||||
* Releases synchronization for the specified lines. The array must
|
||||
* be identical to one for which synchronization has already been
|
||||
* established; otherwise an exception may be thrown. However, <code>null</code>
|
||||
* may be specified, in which case all currently synchronized lines that belong
|
||||
* to this mixer are unsynchronized.
|
||||
* @param lines the synchronized lines for which synchronization should be
|
||||
* released, or <code>null</code> for all this mixer's synchronized lines
|
||||
*
|
||||
* @throws IllegalArgumentException if the lines cannot be unsynchronized.
|
||||
* This may occur if the argument specified does not exactly match a set
|
||||
* of lines for which synchronization has already been established.
|
||||
*/
|
||||
public void unsynchronize(Line[] lines);
|
||||
|
||||
|
||||
/**
|
||||
* Reports whether this mixer supports synchronization of the specified set of lines.
|
||||
*
|
||||
* @param lines the set of lines for which synchronization support is queried
|
||||
* @param maintainSync <code>true</code> if the synchronization
|
||||
* must be precisely maintained (i.e., the synchronization must be sample-accurate)
|
||||
* at all times during operation of the lines , or <code>false</code>
|
||||
* if precise synchronization is required only during start and stop operations
|
||||
*
|
||||
* @return <code>true</code> if the lines can be synchronized, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
public boolean isSynchronizationSupported(Line[] lines, boolean maintainSync);
|
||||
|
||||
|
||||
/**
|
||||
* The <code>Mixer.Info</code> class represents information about an audio mixer,
|
||||
* including the product's name, version, and vendor, along with a textual
|
||||
* description. This information may be retrieved through the
|
||||
* {@link Mixer#getMixerInfo() getMixerInfo}
|
||||
* method of the <code>Mixer</code> interface.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class Info {
|
||||
|
||||
/**
|
||||
* Mixer name.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Mixer vendor.
|
||||
*/
|
||||
private final String vendor;
|
||||
|
||||
/**
|
||||
* Mixer description.
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
/**
|
||||
* Mixer version.
|
||||
*/
|
||||
private final String version;
|
||||
|
||||
/**
|
||||
* Constructs a mixer's info object, passing it the given
|
||||
* textual information.
|
||||
* @param name the name of the mixer
|
||||
* @param vendor the company who manufactures or creates the hardware
|
||||
* or software mixer
|
||||
* @param description descriptive text about the mixer
|
||||
* @param version version information for the mixer
|
||||
*/
|
||||
protected Info(String name, String vendor, String description, String version) {
|
||||
|
||||
this.name = name;
|
||||
this.vendor = vendor;
|
||||
this.description = description;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether two info objects are equal, returning <code>true</code> if
|
||||
* they are identical.
|
||||
* @param obj the reference object with which to compare this info
|
||||
* object
|
||||
* @return <code>true</code> if this info object is the same as the
|
||||
* <code>obj</code> argument; <code>false</code> otherwise
|
||||
*/
|
||||
public final boolean equals(Object obj) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes the hashcode method.
|
||||
*
|
||||
* @return the hashcode for this object
|
||||
*/
|
||||
public final int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the name of the mixer.
|
||||
* @return a string that names the mixer
|
||||
*/
|
||||
public final String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the vendor of the mixer.
|
||||
* @return a string that names the mixer's vendor
|
||||
*/
|
||||
public final String getVendor() {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the description of the mixer.
|
||||
* @return a textual description of the mixer
|
||||
*/
|
||||
public final String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the version of the mixer.
|
||||
* @return textual version information for the mixer
|
||||
*/
|
||||
public final String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a string representation of the mixer info.
|
||||
* @return a string describing the info object
|
||||
*/
|
||||
public final String toString() {
|
||||
return (name + ", version " + version);
|
||||
}
|
||||
} // class Info
|
||||
}
|
208
jdkSrc/jdk8/javax/sound/sampled/Port.java
Normal file
208
jdkSrc/jdk8/javax/sound/sampled/Port.java
Normal file
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
|
||||
/**
|
||||
* Ports are simple lines for input or output of audio to or from audio devices.
|
||||
* Common examples of ports that act as source lines (mixer inputs) include the microphone,
|
||||
* line input, and CD-ROM drive. Ports that act as target lines (mixer outputs) include the
|
||||
* speaker, headphone, and line output. You can access port using a <code>{@link Port.Info}</code>
|
||||
* object.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public interface Port extends Line {
|
||||
|
||||
|
||||
// INNER CLASSES
|
||||
|
||||
|
||||
/**
|
||||
* The <code>Port.Info</code> class extends <code>{@link Line.Info}</code>
|
||||
* with additional information specific to ports, including the port's name
|
||||
* and whether it is a source or a target for its mixer.
|
||||
* By definition, a port acts as either a source or a target to its mixer,
|
||||
* but not both. (Audio input ports are sources; audio output ports are targets.)
|
||||
* <p>
|
||||
* To learn what ports are available, you can retrieve port info objects through the
|
||||
* <code>{@link Mixer#getSourceLineInfo getSourceLineInfo}</code> and
|
||||
* <code>{@link Mixer#getTargetLineInfo getTargetLineInfo}</code>
|
||||
* methods of the <code>Mixer</code> interface. Instances of the
|
||||
* <code>Port.Info</code> class may also be constructed and used to obtain
|
||||
* lines matching the parameters specified in the <code>Port.Info</code> object.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class Info extends Line.Info {
|
||||
|
||||
|
||||
// AUDIO PORT TYPE DEFINES
|
||||
|
||||
|
||||
// SOURCE PORTS
|
||||
|
||||
/**
|
||||
* A type of port that gets audio from a built-in microphone or a microphone jack.
|
||||
*/
|
||||
public static final Info MICROPHONE = new Info(Port.class,"MICROPHONE", true);
|
||||
|
||||
/**
|
||||
* A type of port that gets audio from a line-level audio input jack.
|
||||
*/
|
||||
public static final Info LINE_IN = new Info(Port.class,"LINE_IN", true);
|
||||
|
||||
/**
|
||||
* A type of port that gets audio from a CD-ROM drive.
|
||||
*/
|
||||
public static final Info COMPACT_DISC = new Info(Port.class,"COMPACT_DISC", true);
|
||||
|
||||
|
||||
// TARGET PORTS
|
||||
|
||||
/**
|
||||
* A type of port that sends audio to a built-in speaker or a speaker jack.
|
||||
*/
|
||||
public static final Info SPEAKER = new Info(Port.class,"SPEAKER", false);
|
||||
|
||||
/**
|
||||
* A type of port that sends audio to a headphone jack.
|
||||
*/
|
||||
public static final Info HEADPHONE = new Info(Port.class,"HEADPHONE", false);
|
||||
|
||||
/**
|
||||
* A type of port that sends audio to a line-level audio output jack.
|
||||
*/
|
||||
public static final Info LINE_OUT = new Info(Port.class,"LINE_OUT", false);
|
||||
|
||||
|
||||
// FUTURE DIRECTIONS...
|
||||
|
||||
// telephone
|
||||
// DAT
|
||||
// DVD
|
||||
|
||||
|
||||
// INSTANCE VARIABLES
|
||||
|
||||
private String name;
|
||||
private boolean isSource;
|
||||
|
||||
|
||||
// CONSTRUCTOR
|
||||
|
||||
/**
|
||||
* Constructs a port's info object from the information given.
|
||||
* This constructor is typically used by an implementation
|
||||
* of Java Sound to describe a supported line.
|
||||
*
|
||||
* @param lineClass the class of the port described by the info object.
|
||||
* @param name the string that names the port
|
||||
* @param isSource <code>true</code> if the port is a source port (such
|
||||
* as a microphone), <code>false</code> if the port is a target port
|
||||
* (such as a speaker).
|
||||
*/
|
||||
public Info(Class<?> lineClass, String name, boolean isSource) {
|
||||
|
||||
super(lineClass);
|
||||
this.name = name;
|
||||
this.isSource = isSource;
|
||||
}
|
||||
|
||||
|
||||
// METHODS
|
||||
|
||||
/**
|
||||
* Obtains the name of the port.
|
||||
* @return the string that names the port
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the port is a source or a target for its mixer.
|
||||
* @return <code>true</code> if the port is a source port (such
|
||||
* as a microphone), <code>false</code> if the port is a target port
|
||||
* (such as a speaker).
|
||||
*/
|
||||
public boolean isSource() {
|
||||
return isSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this info object specified matches this one.
|
||||
* To match, the match requirements of the superclass must be
|
||||
* met and the types must be equal.
|
||||
* @param info the info object for which the match is queried
|
||||
*/
|
||||
public boolean matches(Line.Info info) {
|
||||
|
||||
if (! (super.matches(info)) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(name.equals(((Info)info).getName())) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! (isSource == ((Info)info).isSource()) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finalizes the equals method
|
||||
*/
|
||||
public final boolean equals(Object obj) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalizes the hashCode method
|
||||
*/
|
||||
public final int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Provides a <code>String</code> representation
|
||||
* of the port.
|
||||
* @return a string that describes the port
|
||||
*/
|
||||
public final String toString() {
|
||||
return (name + ((isSource == true) ? " source" : " target") + " port");
|
||||
}
|
||||
|
||||
} // class Info
|
||||
}
|
299
jdkSrc/jdk8/javax/sound/sampled/ReverbType.java
Normal file
299
jdkSrc/jdk8/javax/sound/sampled/ReverbType.java
Normal file
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>ReverbType</code> class provides methods for
|
||||
* accessing various reverberation settings to be applied to
|
||||
* an audio signal.
|
||||
* <p>
|
||||
* Reverberation simulates the reflection of sound off of
|
||||
* the walls, ceiling, and floor of a room. Depending on
|
||||
* the size of the room, and how absorbent or reflective the materials in the
|
||||
* room's surfaces are, the sound might bounce around for a
|
||||
* long time before dying away.
|
||||
* <p>
|
||||
* The reverberation parameters provided by <code>ReverbType</code> consist
|
||||
* of the delay time and intensity of early reflections, the delay time and
|
||||
* intensity of late reflections, and an overall decay time.
|
||||
* Early reflections are the initial individual low-order reflections of the
|
||||
* direct signal off the surfaces in the room.
|
||||
* The late Reflections are the dense, high-order reflections that characterize
|
||||
* the room's reverberation.
|
||||
* The delay times for the start of these two reflection types give the listener
|
||||
* a sense of the overall size and complexity of the room's shape and contents.
|
||||
* The larger the room, the longer the reflection delay times.
|
||||
* The early and late reflections' intensities define the gain (in decibels) of the reflected
|
||||
* signals as compared to the direct signal. These intensities give the
|
||||
* listener an impression of the absorptive nature of the surfaces and objects
|
||||
* in the room.
|
||||
* The decay time defines how long the reverberation takes to exponentially
|
||||
* decay until it is no longer perceptible ("effective zero").
|
||||
* The larger and less absorbent the surfaces, the longer the decay time.
|
||||
* <p>
|
||||
* The set of parameters defined here may not include all aspects of reverberation
|
||||
* as specified by some systems. For example, the Midi Manufacturer's Association
|
||||
* (MMA) has an Interactive Audio Special Interest Group (IASIG), which has a
|
||||
* 3-D Working Group that has defined a Level 2 Spec (I3DL2). I3DL2
|
||||
* supports filtering of reverberation and
|
||||
* control of reverb density. These properties are not included in the JavaSound 1.0
|
||||
* definition of a reverb control. In such a case, the implementing system
|
||||
* should either extend the defined reverb control to include additional
|
||||
* parameters, or else interpret the system's additional capabilities in a way that fits
|
||||
* the model described here.
|
||||
* <p>
|
||||
* If implementing JavaSound on a I3DL2-compliant device:
|
||||
* <ul>
|
||||
* <li>Filtering is disabled (high-frequency attenuations are set to 0.0 dB)
|
||||
* <li>Density parameters are set to midway between minimum and maximum
|
||||
* </ul>
|
||||
* <p>
|
||||
* The following table shows what parameter values an implementation might use for a
|
||||
* representative set of reverberation settings.
|
||||
* <p>
|
||||
*
|
||||
* <b>Reverberation Types and Parameters</b>
|
||||
* <p>
|
||||
* <table border=1 cellpadding=5 summary="reverb types and params: decay time, late intensity, late delay, early intensity, and early delay">
|
||||
*
|
||||
* <tr>
|
||||
* <th>Type</th>
|
||||
* <th>Decay Time (ms)</th>
|
||||
* <th>Late Intensity (dB)</th>
|
||||
* <th>Late Delay (ms)</th>
|
||||
* <th>Early Intensity (dB)</th>
|
||||
* <th>Early Delay(ms)</th>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>Cavern</td>
|
||||
* <td>2250</td>
|
||||
* <td>-2.0</td>
|
||||
* <td>41.3</td>
|
||||
* <td>-1.4</td>
|
||||
* <td>10.3</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>Dungeon</td>
|
||||
* <td>1600</td>
|
||||
* <td>-1.0</td>
|
||||
* <td>10.3</td>
|
||||
* <td>-0.7</td>
|
||||
* <td>2.6</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>Garage</td>
|
||||
* <td>900</td>
|
||||
* <td>-6.0</td>
|
||||
* <td>14.7</td>
|
||||
* <td>-4.0</td>
|
||||
* <td>3.9</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>Acoustic Lab</td>
|
||||
* <td>280</td>
|
||||
* <td>-3.0</td>
|
||||
* <td>8.0</td>
|
||||
* <td>-2.0</td>
|
||||
* <td>2.0</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>Closet</td>
|
||||
* <td>150</td>
|
||||
* <td>-10.0</td>
|
||||
* <td>2.5</td>
|
||||
* <td>-7.0</td>
|
||||
* <td>0.6</td>
|
||||
* </tr>
|
||||
*
|
||||
* </table>
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public class ReverbType {
|
||||
|
||||
/**
|
||||
* Descriptive name of the reverb type..
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Early reflection delay in microseconds.
|
||||
*/
|
||||
private int earlyReflectionDelay;
|
||||
|
||||
/**
|
||||
* Early reflection intensity.
|
||||
*/
|
||||
private float earlyReflectionIntensity;
|
||||
|
||||
/**
|
||||
* Late reflection delay in microseconds.
|
||||
*/
|
||||
private int lateReflectionDelay;
|
||||
|
||||
/**
|
||||
* Late reflection intensity.
|
||||
*/
|
||||
private float lateReflectionIntensity;
|
||||
|
||||
/**
|
||||
* Total decay time
|
||||
*/
|
||||
private int decayTime;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new reverb type that has the specified reverberation
|
||||
* parameter values.
|
||||
* @param name the name of the new reverb type, or a zero-length <code>String</code>
|
||||
* @param earlyReflectionDelay the new type's early reflection delay time in microseconds
|
||||
* @param earlyReflectionIntensity the new type's early reflection intensity in dB
|
||||
* @param lateReflectionDelay the new type's late reflection delay time in microseconds
|
||||
* @param lateReflectionIntensity the new type's late reflection intensity in dB
|
||||
* @param decayTime the new type's decay time in microseconds
|
||||
*/
|
||||
protected ReverbType(String name, int earlyReflectionDelay, float earlyReflectionIntensity, int lateReflectionDelay, float lateReflectionIntensity, int decayTime) {
|
||||
|
||||
this.name = name;
|
||||
this.earlyReflectionDelay = earlyReflectionDelay;
|
||||
this.earlyReflectionIntensity = earlyReflectionIntensity;
|
||||
this.lateReflectionDelay = lateReflectionDelay;
|
||||
this.lateReflectionIntensity = lateReflectionIntensity;
|
||||
this.decayTime = decayTime;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the name of this reverb type.
|
||||
* @return the name of this reverb type
|
||||
* @since 1.5
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the early reflection delay time in microseconds.
|
||||
* This is the amount of time between when the direct signal is
|
||||
* heard and when the first early reflections are heard.
|
||||
* @return early reflection delay time for this reverb type, in microseconds
|
||||
*/
|
||||
public final int getEarlyReflectionDelay() {
|
||||
return earlyReflectionDelay;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the early reflection intensity in decibels.
|
||||
* This is the amplitude attenuation of the first early reflections
|
||||
* relative to the direct signal.
|
||||
* @return early reflection intensity for this reverb type, in dB
|
||||
*/
|
||||
public final float getEarlyReflectionIntensity() {
|
||||
return earlyReflectionIntensity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the late reflection delay time in microseconds.
|
||||
* This is the amount of time between when the first early reflections
|
||||
* are heard and when the first late reflections are heard.
|
||||
* @return late reflection delay time for this reverb type, in microseconds
|
||||
*/
|
||||
public final int getLateReflectionDelay() {
|
||||
return lateReflectionDelay;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the late reflection intensity in decibels.
|
||||
* This is the amplitude attenuation of the first late reflections
|
||||
* relative to the direct signal.
|
||||
* @return late reflection intensity for this reverb type, in dB
|
||||
*/
|
||||
public final float getLateReflectionIntensity() {
|
||||
return lateReflectionIntensity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the decay time, which is the amount of time over which the
|
||||
* late reflections attenuate to effective zero. The effective zero
|
||||
* value is implementation-dependent.
|
||||
* @return the decay time of the late reflections, in microseconds
|
||||
*/
|
||||
public final int getDecayTime() {
|
||||
return decayTime;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether the specified object is equal to this reverb type,
|
||||
* returning <code>true</code> if the objects are identical.
|
||||
* @param obj the reference object with which to compare
|
||||
* @return <code>true</code> if this reverb type is the same as
|
||||
* <code>obj</code>; <code>false</code> otherwise
|
||||
*/
|
||||
public final boolean equals(Object obj) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finalizes the hashcode method.
|
||||
*/
|
||||
public final int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides a <code>String</code> representation of the reverb type,
|
||||
* including its name and its parameter settings.
|
||||
* The exact contents of the string may vary between implementations of
|
||||
* Java Sound.
|
||||
* @return reverberation type name and description
|
||||
*/
|
||||
public final String toString() {
|
||||
|
||||
//$$fb2001-07-20: fix for bug 4385060: The "name" attribute of class "ReverbType" is not accessible.
|
||||
//return (super.toString() + ", early reflection delay " + earlyReflectionDelay +
|
||||
return (name + ", early reflection delay " + earlyReflectionDelay +
|
||||
" ns, early reflection intensity " + earlyReflectionIntensity +
|
||||
" dB, late deflection delay " + lateReflectionDelay +
|
||||
" ns, late reflection intensity " + lateReflectionIntensity +
|
||||
" dB, decay time " + decayTime);
|
||||
}
|
||||
|
||||
} // class ReverbType
|
203
jdkSrc/jdk8/javax/sound/sampled/SourceDataLine.java
Normal file
203
jdkSrc/jdk8/javax/sound/sampled/SourceDataLine.java
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
|
||||
/**
|
||||
* A source data line is a data line to which data may be written. It acts as
|
||||
* a source to its mixer. An application writes audio bytes to a source data line,
|
||||
* which handles the buffering of the bytes and delivers them to the mixer.
|
||||
* The mixer may mix the samples with those from other sources and then deliver
|
||||
* the mix to a target such as an output port (which may represent an audio output
|
||||
* device on a sound card).
|
||||
* <p>
|
||||
* Note that the naming convention for this interface reflects the relationship
|
||||
* between the line and its mixer. From the perspective of an application,
|
||||
* a source data line may act as a target for audio data.
|
||||
* <p>
|
||||
* A source data line can be obtained from a mixer by invoking the
|
||||
* <code>{@link Mixer#getLine getLine}</code> method of <code>Mixer</code> with
|
||||
* an appropriate <code>{@link DataLine.Info}</code> object.
|
||||
* <p>
|
||||
* The <code>SourceDataLine</code> interface provides a method for writing
|
||||
* audio data to the data line's buffer. Applications that play or mix
|
||||
* audio should write data to the source data line quickly enough to keep the
|
||||
* buffer from underflowing (emptying), which could cause discontinuities in
|
||||
* the audio that are perceived as clicks. Applications can use the
|
||||
* <code>{@link DataLine#available available}</code> method defined in the
|
||||
* <code>DataLine</code> interface to determine the amount of data currently
|
||||
* queued in the data line's buffer. The amount of data which can be written
|
||||
* to the buffer without blocking is the difference between the buffer size
|
||||
* and the amount of queued data. If the delivery of audio output
|
||||
* stops due to underflow, a <code>{@link LineEvent.Type#STOP STOP}</code> event is
|
||||
* generated. A <code>{@link LineEvent.Type#START START}</code> event is generated
|
||||
* when the audio output resumes.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @see Mixer
|
||||
* @see DataLine
|
||||
* @see TargetDataLine
|
||||
* @since 1.3
|
||||
*/
|
||||
public interface SourceDataLine extends DataLine {
|
||||
|
||||
|
||||
/**
|
||||
* Opens the line with the specified format and suggested buffer size,
|
||||
* causing the line to acquire any required
|
||||
* system resources and become operational.
|
||||
* <p>
|
||||
* The buffer size is specified in bytes, but must represent an integral
|
||||
* number of sample frames. Invoking this method with a requested buffer
|
||||
* size that does not meet this requirement may result in an
|
||||
* IllegalArgumentException. The actual buffer size for the open line may
|
||||
* differ from the requested buffer size. The value actually set may be
|
||||
* queried by subsequently calling <code>{@link DataLine#getBufferSize}</code>.
|
||||
* <p>
|
||||
* If this operation succeeds, the line is marked as open, and an
|
||||
* <code>{@link LineEvent.Type#OPEN OPEN}</code> event is dispatched to the
|
||||
* line's listeners.
|
||||
* <p>
|
||||
* Invoking this method on a line which is already open is illegal
|
||||
* and may result in an <code>IllegalStateException</code>.
|
||||
* <p>
|
||||
* Note that some lines, once closed, cannot be reopened. Attempts
|
||||
* to reopen such a line will always result in a
|
||||
* <code>LineUnavailableException</code>.
|
||||
*
|
||||
* @param format the desired audio format
|
||||
* @param bufferSize the desired buffer size
|
||||
* @throws LineUnavailableException if the line cannot be
|
||||
* opened due to resource restrictions
|
||||
* @throws IllegalArgumentException if the buffer size does not represent
|
||||
* an integral number of sample frames,
|
||||
* or if <code>format</code> is not fully specified or invalid
|
||||
* @throws IllegalStateException if the line is already open
|
||||
* @throws SecurityException if the line cannot be
|
||||
* opened due to security restrictions
|
||||
*
|
||||
* @see #open(AudioFormat)
|
||||
* @see Line#open
|
||||
* @see Line#close
|
||||
* @see Line#isOpen
|
||||
* @see LineEvent
|
||||
*/
|
||||
public void open(AudioFormat format, int bufferSize) throws LineUnavailableException;
|
||||
|
||||
|
||||
/**
|
||||
* Opens the line with the specified format, causing the line to acquire any
|
||||
* required system resources and become operational.
|
||||
*
|
||||
* <p>
|
||||
* The implementation chooses a buffer size, which is measured in bytes but
|
||||
* which encompasses an integral number of sample frames. The buffer size
|
||||
* that the system has chosen may be queried by subsequently calling
|
||||
* <code>{@link DataLine#getBufferSize}</code>.
|
||||
* <p>
|
||||
* If this operation succeeds, the line is marked as open, and an
|
||||
* <code>{@link LineEvent.Type#OPEN OPEN}</code> event is dispatched to the
|
||||
* line's listeners.
|
||||
* <p>
|
||||
* Invoking this method on a line which is already open is illegal
|
||||
* and may result in an <code>IllegalStateException</code>.
|
||||
* <p>
|
||||
* Note that some lines, once closed, cannot be reopened. Attempts
|
||||
* to reopen such a line will always result in a
|
||||
* <code>LineUnavailableException</code>.
|
||||
*
|
||||
* @param format the desired audio format
|
||||
* @throws LineUnavailableException if the line cannot be
|
||||
* opened due to resource restrictions
|
||||
* @throws IllegalArgumentException if <code>format</code>
|
||||
* is not fully specified or invalid
|
||||
* @throws IllegalStateException if the line is already open
|
||||
* @throws SecurityException if the line cannot be
|
||||
* opened due to security restrictions
|
||||
*
|
||||
* @see #open(AudioFormat, int)
|
||||
* @see Line#open
|
||||
* @see Line#close
|
||||
* @see Line#isOpen
|
||||
* @see LineEvent
|
||||
*/
|
||||
public void open(AudioFormat format) throws LineUnavailableException;
|
||||
|
||||
|
||||
/**
|
||||
* Writes audio data to the mixer via this source data line. The requested
|
||||
* number of bytes of data are read from the specified array,
|
||||
* starting at the given offset into the array, and written to the data
|
||||
* line's buffer. If the caller attempts to write more data than can
|
||||
* currently be written (see <code>{@link DataLine#available available}</code>),
|
||||
* this method blocks until the requested amount of data has been written.
|
||||
* This applies even if the requested amount of data to write is greater
|
||||
* than the data line's buffer size. However, if the data line is closed,
|
||||
* stopped, or flushed before the requested amount has been written,
|
||||
* the method no longer blocks, but returns the number of bytes
|
||||
* written thus far.
|
||||
* <p>
|
||||
* The number of bytes that can be written without blocking can be ascertained
|
||||
* using the <code>{@link DataLine#available available}</code> method of the
|
||||
* <code>DataLine</code> interface. (While it is guaranteed that
|
||||
* this number of bytes can be written without blocking, there is no guarantee
|
||||
* that attempts to write additional data will block.)
|
||||
* <p>
|
||||
* The number of bytes to write must represent an integral number of
|
||||
* sample frames, such that:
|
||||
* <br>
|
||||
* <center><code>[ bytes written ] % [frame size in bytes ] == 0</code></center>
|
||||
* <br>
|
||||
* The return value will always meet this requirement. A request to write a
|
||||
* number of bytes representing a non-integral number of sample frames cannot
|
||||
* be fulfilled and may result in an <code>IllegalArgumentException</code>.
|
||||
*
|
||||
* @param b a byte array containing data to be written to the data line
|
||||
* @param len the length, in bytes, of the valid data in the array
|
||||
* (in other words, the requested amount of data to write, in bytes)
|
||||
* @param off the offset from the beginning of the array, in bytes
|
||||
* @return the number of bytes actually written
|
||||
* @throws IllegalArgumentException if the requested number of bytes does
|
||||
* not represent an integral number of sample frames,
|
||||
* or if <code>len</code> is negative
|
||||
* @throws ArrayIndexOutOfBoundsException if <code>off</code> is negative,
|
||||
* or <code>off+len</code> is greater than the length of the array
|
||||
* <code>b</code>.
|
||||
*
|
||||
* @see TargetDataLine#read
|
||||
* @see DataLine#available
|
||||
*/
|
||||
public int write(byte[] b, int off, int len);
|
||||
|
||||
/**
|
||||
* Obtains the number of sample frames of audio data that can be written to
|
||||
* the mixer, via this data line, without blocking. Note that the return
|
||||
* value measures sample frames, not bytes.
|
||||
* @return the number of sample frames currently available for writing
|
||||
* @see TargetDataLine#availableRead
|
||||
*/
|
||||
//public int availableWrite();
|
||||
}
|
192
jdkSrc/jdk8/javax/sound/sampled/TargetDataLine.java
Normal file
192
jdkSrc/jdk8/javax/sound/sampled/TargetDataLine.java
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
/**
|
||||
* A target data line is a type of <code>{@link DataLine}</code> from which
|
||||
* audio data can be read. The most common example is a data line that gets
|
||||
* its data from an audio capture device. (The device is implemented as a
|
||||
* mixer that writes to the target data line.)
|
||||
* <p>
|
||||
* Note that the naming convention for this interface reflects the relationship
|
||||
* between the line and its mixer. From the perspective of an application,
|
||||
* a target data line may act as a source for audio data.
|
||||
* <p>
|
||||
* The target data line can be obtained from a mixer by invoking the
|
||||
* <code>{@link Mixer#getLine getLine}</code>
|
||||
* method of <code>Mixer</code> with an appropriate
|
||||
* <code>{@link DataLine.Info}</code> object.
|
||||
* <p>
|
||||
* The <code>TargetDataLine</code> interface provides a method for reading the
|
||||
* captured data from the target data line's buffer.Applications
|
||||
* that record audio should read data from the target data line quickly enough
|
||||
* to keep the buffer from overflowing, which could cause discontinuities in
|
||||
* the captured data that are perceived as clicks. Applications can use the
|
||||
* <code>{@link DataLine#available available}</code> method defined in the
|
||||
* <code>DataLine</code> interface to determine the amount of data currently
|
||||
* queued in the data line's buffer. If the buffer does overflow,
|
||||
* the oldest queued data is discarded and replaced by new data.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @see Mixer
|
||||
* @see DataLine
|
||||
* @see SourceDataLine
|
||||
* @since 1.3
|
||||
*/
|
||||
public interface TargetDataLine extends DataLine {
|
||||
|
||||
|
||||
/**
|
||||
* Opens the line with the specified format and requested buffer size,
|
||||
* causing the line to acquire any required system resources and become
|
||||
* operational.
|
||||
* <p>
|
||||
* The buffer size is specified in bytes, but must represent an integral
|
||||
* number of sample frames. Invoking this method with a requested buffer
|
||||
* size that does not meet this requirement may result in an
|
||||
* IllegalArgumentException. The actual buffer size for the open line may
|
||||
* differ from the requested buffer size. The value actually set may be
|
||||
* queried by subsequently calling <code>{@link DataLine#getBufferSize}</code>
|
||||
* <p>
|
||||
* If this operation succeeds, the line is marked as open, and an
|
||||
* <code>{@link LineEvent.Type#OPEN OPEN}</code> event is dispatched to the
|
||||
* line's listeners.
|
||||
* <p>
|
||||
* Invoking this method on a line that is already open is illegal
|
||||
* and may result in an <code>IllegalStateException</code>.
|
||||
* <p>
|
||||
* Some lines, once closed, cannot be reopened. Attempts
|
||||
* to reopen such a line will always result in a
|
||||
* <code>LineUnavailableException</code>.
|
||||
*
|
||||
* @param format the desired audio format
|
||||
* @param bufferSize the desired buffer size, in bytes.
|
||||
* @throws LineUnavailableException if the line cannot be
|
||||
* opened due to resource restrictions
|
||||
* @throws IllegalArgumentException if the buffer size does not represent
|
||||
* an integral number of sample frames,
|
||||
* or if <code>format</code> is not fully specified or invalid
|
||||
* @throws IllegalStateException if the line is already open
|
||||
* @throws SecurityException if the line cannot be
|
||||
* opened due to security restrictions
|
||||
*
|
||||
* @see #open(AudioFormat)
|
||||
* @see Line#open
|
||||
* @see Line#close
|
||||
* @see Line#isOpen
|
||||
* @see LineEvent
|
||||
*/
|
||||
public void open(AudioFormat format, int bufferSize) throws LineUnavailableException;
|
||||
|
||||
|
||||
/**
|
||||
* Opens the line with the specified format, causing the line to acquire any
|
||||
* required system resources and become operational.
|
||||
*
|
||||
* <p>
|
||||
* The implementation chooses a buffer size, which is measured in bytes but
|
||||
* which encompasses an integral number of sample frames. The buffer size
|
||||
* that the system has chosen may be queried by subsequently calling <code>{@link DataLine#getBufferSize}</code>
|
||||
* <p>
|
||||
* If this operation succeeds, the line is marked as open, and an
|
||||
* <code>{@link LineEvent.Type#OPEN OPEN}</code> event is dispatched to the
|
||||
* line's listeners.
|
||||
* <p>
|
||||
* Invoking this method on a line that is already open is illegal
|
||||
* and may result in an <code>IllegalStateException</code>.
|
||||
* <p>
|
||||
* Some lines, once closed, cannot be reopened. Attempts
|
||||
* to reopen such a line will always result in a
|
||||
* <code>LineUnavailableException</code>.
|
||||
*
|
||||
* @param format the desired audio format
|
||||
* @throws LineUnavailableException if the line cannot be
|
||||
* opened due to resource restrictions
|
||||
* @throws IllegalArgumentException if <code>format</code>
|
||||
* is not fully specified or invalid
|
||||
* @throws IllegalStateException if the line is already open
|
||||
* @throws SecurityException if the line cannot be
|
||||
* opened due to security restrictions
|
||||
*
|
||||
* @see #open(AudioFormat, int)
|
||||
* @see Line#open
|
||||
* @see Line#close
|
||||
* @see Line#isOpen
|
||||
* @see LineEvent
|
||||
*/
|
||||
public void open(AudioFormat format) throws LineUnavailableException;
|
||||
|
||||
|
||||
/**
|
||||
* Reads audio data from the data line's input buffer. The requested
|
||||
* number of bytes is read into the specified array, starting at
|
||||
* the specified offset into the array in bytes. This method blocks until
|
||||
* the requested amount of data has been read. However, if the data line
|
||||
* is closed, stopped, drained, or flushed before the requested amount has
|
||||
* been read, the method no longer blocks, but returns the number of bytes
|
||||
* read thus far.
|
||||
* <p>
|
||||
* The number of bytes that can be read without blocking can be ascertained
|
||||
* using the <code>{@link DataLine#available available}</code> method of the
|
||||
* <code>DataLine</code> interface. (While it is guaranteed that
|
||||
* this number of bytes can be read without blocking, there is no guarantee
|
||||
* that attempts to read additional data will block.)
|
||||
* <p>
|
||||
* The number of bytes to be read must represent an integral number of
|
||||
* sample frames, such that:
|
||||
* <br>
|
||||
* <center><code>[ bytes read ] % [frame size in bytes ] == 0</code></center>
|
||||
* <br>
|
||||
* The return value will always meet this requirement. A request to read a
|
||||
* number of bytes representing a non-integral number of sample frames cannot
|
||||
* be fulfilled and may result in an IllegalArgumentException.
|
||||
*
|
||||
* @param b a byte array that will contain the requested input data when
|
||||
* this method returns
|
||||
* @param off the offset from the beginning of the array, in bytes
|
||||
* @param len the requested number of bytes to read
|
||||
* @return the number of bytes actually read
|
||||
* @throws IllegalArgumentException if the requested number of bytes does
|
||||
* not represent an integral number of sample frames.
|
||||
* or if <code>len</code> is negative.
|
||||
* @throws ArrayIndexOutOfBoundsException if <code>off</code> is negative,
|
||||
* or <code>off+len</code> is greater than the length of the array
|
||||
* <code>b</code>.
|
||||
*
|
||||
* @see SourceDataLine#write
|
||||
* @see DataLine#available
|
||||
*/
|
||||
public int read(byte[] b, int off, int len);
|
||||
|
||||
/**
|
||||
* Obtains the number of sample frames of audio data that can be read from
|
||||
* the target data line without blocking. Note that the return value
|
||||
* measures sample frames, not bytes.
|
||||
* @return the number of sample frames currently available for reading
|
||||
* @see SourceDataLine#availableWrite
|
||||
*/
|
||||
//public int availableRead();
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled;
|
||||
|
||||
/**
|
||||
* An <code>UnsupportedAudioFileException</code> is an exception indicating that an
|
||||
* operation failed because a file did not contain valid data of a recognized file
|
||||
* type and format.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
/*
|
||||
* An <code>UnsupportedAudioFileException</code> is an exception indicating that an
|
||||
* operation failed because a file did not contain valid data of a recognized file
|
||||
* type and format.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
*/
|
||||
|
||||
public class UnsupportedAudioFileException extends Exception {
|
||||
|
||||
/**
|
||||
* Constructs a <code>UnsupportedAudioFileException</code> that has
|
||||
* <code>null</code> as its error detail message.
|
||||
*/
|
||||
public UnsupportedAudioFileException() {
|
||||
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a <code>UnsupportedAudioFileException</code> that has
|
||||
* the specified detail message.
|
||||
*
|
||||
* @param message a string containing the error detail message
|
||||
*/
|
||||
public UnsupportedAudioFileException(String message) {
|
||||
|
||||
super(message);
|
||||
}
|
||||
}
|
137
jdkSrc/jdk8/javax/sound/sampled/spi/AudioFileReader.java
Normal file
137
jdkSrc/jdk8/javax/sound/sampled/spi/AudioFileReader.java
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled.spi;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.sound.sampled.AudioFileFormat;
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||
|
||||
/**
|
||||
* Provider for audio file reading services. Classes providing concrete
|
||||
* implementations can parse the format information from one or more types of
|
||||
* audio file, and can produce audio input streams from files of these types.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public abstract class AudioFileReader {
|
||||
|
||||
/**
|
||||
* Obtains the audio file format of the input stream provided. The stream must
|
||||
* point to valid audio file data. In general, audio file readers may
|
||||
* need to read some data from the stream before determining 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 this, this method may fail
|
||||
* with an <code>IOException</code>.
|
||||
* @param stream the input stream from which file format information should be
|
||||
* extracted
|
||||
* @return an <code>AudioFileFormat</code> object describing the audio file format
|
||||
* @throws UnsupportedAudioFileException if the stream does not point to valid audio
|
||||
* file data recognized by the system
|
||||
* @throws IOException if an I/O exception occurs
|
||||
* @see InputStream#markSupported
|
||||
* @see InputStream#mark
|
||||
*/
|
||||
public abstract AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException;
|
||||
|
||||
/**
|
||||
* Obtains the audio file format of the URL provided. The URL must
|
||||
* point to valid audio file data.
|
||||
* @param url the URL from which file format information should be
|
||||
* extracted
|
||||
* @return an <code>AudioFileFormat</code> object describing the audio file format
|
||||
* @throws UnsupportedAudioFileException if the URL does not point to valid audio
|
||||
* file data recognized by the system
|
||||
* @throws IOException if an I/O exception occurs
|
||||
*/
|
||||
public abstract AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException;
|
||||
|
||||
/**
|
||||
* Obtains the audio file format of the <code>File</code> provided. The <code>File</code> must
|
||||
* point to valid audio file data.
|
||||
* @param file the <code>File</code> from which file format information should be
|
||||
* extracted
|
||||
* @return an <code>AudioFileFormat</code> object describing the audio file format
|
||||
* @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
|
||||
* file data recognized by the system
|
||||
* @throws IOException if an I/O exception occurs
|
||||
*/
|
||||
public abstract AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException;
|
||||
|
||||
/**
|
||||
* Obtains an audio input stream from the input stream provided. The stream must
|
||||
* point to valid audio file data. In general, audio file readers may
|
||||
* need to read some data from the stream before determining 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 this, 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
|
||||
* file data recognized by the system
|
||||
* @throws IOException if an I/O exception occurs
|
||||
* @see InputStream#markSupported
|
||||
* @see InputStream#mark
|
||||
*/
|
||||
public abstract AudioInputStream getAudioInputStream(InputStream stream) throws UnsupportedAudioFileException, IOException;
|
||||
|
||||
/**
|
||||
* Obtains an audio input stream from the URL provided. The URL must
|
||||
* point to valid audio file data.
|
||||
* @param url the URL for which the <code>AudioInputStream</code> should be
|
||||
* constructed
|
||||
* @return an <code>AudioInputStream</code> object based on the audio file data pointed
|
||||
* to by the URL
|
||||
* @throws UnsupportedAudioFileException if the URL does not point to valid audio
|
||||
* file data recognized by the system
|
||||
* @throws IOException if an I/O exception occurs
|
||||
*/
|
||||
public abstract AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException;
|
||||
|
||||
/**
|
||||
* Obtains an audio input stream from the <code>File</code> provided. The <code>File</code> must
|
||||
* point to valid audio file data.
|
||||
* @param file the <code>File</code> for which the <code>AudioInputStream</code> should be
|
||||
* constructed
|
||||
* @return an <code>AudioInputStream</code> object based on the audio file data pointed
|
||||
* to by the File
|
||||
* @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
|
||||
* file data recognized by the system
|
||||
* @throws IOException if an I/O exception occurs
|
||||
*/
|
||||
public abstract AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException;
|
||||
}
|
147
jdkSrc/jdk8/javax/sound/sampled/spi/AudioFileWriter.java
Normal file
147
jdkSrc/jdk8/javax/sound/sampled/spi/AudioFileWriter.java
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled.spi;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.sound.sampled.AudioFileFormat;
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
|
||||
|
||||
/**
|
||||
* Provider for audio file writing services. Classes providing concrete
|
||||
* implementations can write one or more types of audio file from an audio
|
||||
* stream.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public abstract class AudioFileWriter {
|
||||
|
||||
/**
|
||||
* Obtains the file types for which file writing support is provided by this
|
||||
* audio file writer.
|
||||
* @return array of file types. If no file types are supported,
|
||||
* an array of length 0 is returned.
|
||||
*/
|
||||
public abstract AudioFileFormat.Type[] getAudioFileTypes();
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether file writing support for the specified file type is provided
|
||||
* by this audio file writer.
|
||||
* @param fileType the file type for which write capabilities are queried
|
||||
* @return <code>true</code> if the file type is supported,
|
||||
* otherwise <code>false</code>
|
||||
*/
|
||||
public boolean isFileTypeSupported(AudioFileFormat.Type fileType) {
|
||||
|
||||
AudioFileFormat.Type types[] = getAudioFileTypes();
|
||||
|
||||
for(int i=0; i<types.length; i++) {
|
||||
if( fileType.equals( types[i] ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the file types that this audio file writer can write from the
|
||||
* audio input stream specified.
|
||||
* @param stream the audio input stream for which audio file type support
|
||||
* is queried
|
||||
* @return array of file types. If no file types are supported,
|
||||
* an array of length 0 is returned.
|
||||
*/
|
||||
public abstract AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream);
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether an audio file of the type specified can be written
|
||||
* from the audio input stream indicated.
|
||||
* @param fileType file type for which write capabilities are queried
|
||||
* @param stream for which file writing support is queried
|
||||
* @return <code>true</code> if the file type is supported for this audio input stream,
|
||||
* otherwise <code>false</code>
|
||||
*/
|
||||
public boolean isFileTypeSupported(AudioFileFormat.Type fileType, AudioInputStream stream) {
|
||||
|
||||
AudioFileFormat.Type types[] = getAudioFileTypes( stream );
|
||||
|
||||
for(int i=0; i<types.length; i++) {
|
||||
if( fileType.equals( types[i] ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes a stream of bytes representing an audio file of the file type
|
||||
* indicated to the output stream provided. Some file types require that
|
||||
* the length be written into the file header, and cannot be written from
|
||||
* start to finish unless the length is known in advance. An attempt
|
||||
* to write such a file type will fail with an IOException if the length in
|
||||
* the audio file format is
|
||||
* {@link javax.sound.sampled.AudioSystem#NOT_SPECIFIED AudioSystem.NOT_SPECIFIED}.
|
||||
* @param stream the audio input stream containing audio data to be
|
||||
* written to the output stream
|
||||
* @param fileType file type to be written to the output stream
|
||||
* @param out stream to which the file data should be written
|
||||
* @return the number of bytes written to the output stream
|
||||
* @throws IOException if an I/O exception occurs
|
||||
* @throws IllegalArgumentException if the file type is not supported by
|
||||
* the system
|
||||
* @see #isFileTypeSupported(AudioFileFormat.Type, AudioInputStream)
|
||||
* @see #getAudioFileTypes
|
||||
*/
|
||||
public abstract int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Writes a stream of bytes representing an audio file of the file format
|
||||
* indicated to the external file provided.
|
||||
* @param stream the audio input stream containing audio data to be
|
||||
* written to the file
|
||||
* @param fileType file type to be written to the file
|
||||
* @param out external file to which the file data should be written
|
||||
* @return the number of bytes written to the file
|
||||
* @throws IOException if an I/O exception occurs
|
||||
* @throws IllegalArgumentException if the file format is not supported by
|
||||
* the system
|
||||
* @see #isFileTypeSupported
|
||||
* @see #getAudioFileTypes
|
||||
*/
|
||||
public abstract int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled.spi;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
|
||||
/**
|
||||
* A format conversion provider provides format conversion services
|
||||
* from one or more input formats to one or more output formats.
|
||||
* Converters include codecs, which encode and/or decode audio data,
|
||||
* as well as transcoders, etc. Format converters provide methods for
|
||||
* determining what conversions are supported and for obtaining an audio
|
||||
* stream from which converted data can be read.
|
||||
* <p>
|
||||
* The source format represents the format of the incoming
|
||||
* audio data, which will be converted.
|
||||
* <p>
|
||||
* The target format represents the format of the processed, converted
|
||||
* audio data. This is the format of the data that can be read from
|
||||
* the stream returned by one of the <code>getAudioInputStream</code> methods.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public abstract class FormatConversionProvider {
|
||||
|
||||
|
||||
// NEW METHODS
|
||||
|
||||
/**
|
||||
* Obtains the set of source format encodings from which format
|
||||
* conversion services are provided by this provider.
|
||||
* @return array of source format encodings. If for some reason provider
|
||||
* does not provide any conversion services, an array of length 0 is
|
||||
* returned.
|
||||
*/
|
||||
public abstract AudioFormat.Encoding[] getSourceEncodings();
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the set of target format encodings to which format
|
||||
* conversion services are provided by this provider.
|
||||
* @return array of target format encodings. If for some reason provider
|
||||
* does not provide any conversion services, an array of length 0 is
|
||||
* returned.
|
||||
*/
|
||||
public abstract AudioFormat.Encoding[] getTargetEncodings();
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether the format converter supports conversion from the
|
||||
* specified source format encoding.
|
||||
* @param sourceEncoding the source format encoding for which support is queried
|
||||
* @return <code>true</code> if the encoding is supported, otherwise <code>false</code>
|
||||
*/
|
||||
public boolean isSourceEncodingSupported(AudioFormat.Encoding sourceEncoding){
|
||||
|
||||
AudioFormat.Encoding sourceEncodings[] = getSourceEncodings();
|
||||
|
||||
for(int i=0; i<sourceEncodings.length; i++) {
|
||||
if( sourceEncoding.equals( sourceEncodings[i]) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether the format converter supports conversion to the
|
||||
* specified target format encoding.
|
||||
* @param targetEncoding the target format encoding for which support is queried
|
||||
* @return <code>true</code> if the encoding is supported, otherwise <code>false</code>
|
||||
*/
|
||||
public boolean isTargetEncodingSupported(AudioFormat.Encoding targetEncoding){
|
||||
|
||||
AudioFormat.Encoding targetEncodings[] = getTargetEncodings();
|
||||
|
||||
for(int i=0; i<targetEncodings.length; i++) {
|
||||
if( targetEncoding.equals( targetEncodings[i]) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the set of target format encodings supported by the format converter
|
||||
* given a particular source format.
|
||||
* If no target format encodings are supported for this source format,
|
||||
* an array of length 0 is returned.
|
||||
* @param sourceFormat format of the incoming data
|
||||
* @return array of supported target format encodings.
|
||||
*/
|
||||
public abstract AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat);
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether the format converter supports conversion to a particular encoding
|
||||
* from a particular format.
|
||||
* @param targetEncoding desired encoding of the 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.Encoding targetEncoding, AudioFormat sourceFormat){
|
||||
|
||||
AudioFormat.Encoding targetEncodings[] = getTargetEncodings(sourceFormat);
|
||||
|
||||
for(int i=0; i<targetEncodings.length; i++) {
|
||||
if( targetEncoding.equals( targetEncodings[i]) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the set of target formats with the encoding specified
|
||||
* supported by the format converter
|
||||
* If no target formats with the specified encoding are supported
|
||||
* for this source format, an array of length 0 is returned.
|
||||
* @param targetEncoding desired encoding of the stream after processing
|
||||
* @param sourceFormat format of the incoming data
|
||||
* @return array of supported target formats.
|
||||
*/
|
||||
public abstract AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat);
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains an audio input stream with the specified encoding from the given audio
|
||||
* input stream.
|
||||
* @param targetEncoding desired encoding of the stream after processing
|
||||
* @param sourceStream stream from which data to be processed should be read
|
||||
* @return stream from which processed data with the specified target encoding may be read
|
||||
* @throws IllegalArgumentException if the format combination supplied is
|
||||
* not supported.
|
||||
*/
|
||||
public abstract AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream);
|
||||
|
||||
|
||||
/**
|
||||
* Obtains an audio input stream with the specified format from the given audio
|
||||
* input stream.
|
||||
* @param targetFormat desired data format of the stream after processing
|
||||
* @param sourceStream stream from which data to be processed should be read
|
||||
* @return stream from which processed data with the specified format may be read
|
||||
* @throws IllegalArgumentException if the format combination supplied is
|
||||
* not supported.
|
||||
*/
|
||||
public abstract AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream);
|
||||
|
||||
}
|
101
jdkSrc/jdk8/javax/sound/sampled/spi/MixerProvider.java
Normal file
101
jdkSrc/jdk8/javax/sound/sampled/spi/MixerProvider.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.sound.sampled.spi;
|
||||
|
||||
import javax.sound.sampled.Mixer;
|
||||
|
||||
/**
|
||||
* A provider or factory for a particular mixer type.
|
||||
* This mechanism allows the implementation to determine
|
||||
* how resources are managed in creation / management of
|
||||
* a mixer.
|
||||
*
|
||||
* @author Kara Kytle
|
||||
* @since 1.3
|
||||
*/
|
||||
public abstract class MixerProvider {
|
||||
|
||||
|
||||
/**
|
||||
* Indicates whether the mixer provider supports the mixer represented by
|
||||
* the specified mixer info object.
|
||||
* <p>
|
||||
* The full set of mixer info objects that represent the mixers supported
|
||||
* by this {@code MixerProvider} may be obtained
|
||||
* through the {@code getMixerInfo} method.
|
||||
*
|
||||
* @param info an info object that describes the mixer for which support is queried
|
||||
* @return {@code true} if the specified mixer is supported,
|
||||
* otherwise {@code false}
|
||||
* @see #getMixerInfo()
|
||||
*/
|
||||
public boolean isMixerSupported(Mixer.Info info) {
|
||||
|
||||
Mixer.Info infos[] = getMixerInfo();
|
||||
|
||||
for(int i=0; i<infos.length; i++){
|
||||
if( info.equals( infos[i] ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the set of info objects representing the mixer
|
||||
* or mixers provided by this MixerProvider.
|
||||
* <p>
|
||||
* The {@code isMixerSupported} method returns {@code true}
|
||||
* for all the info objects returned by this method.
|
||||
* The corresponding mixer instances for the info objects
|
||||
* are returned by the {@code getMixer} method.
|
||||
*
|
||||
* @return a set of mixer info objects
|
||||
* @see #getMixer(javax.sound.sampled.Mixer.Info) getMixer(Mixer.Info)
|
||||
* @see #isMixerSupported(javax.sound.sampled.Mixer.Info) isMixerSupported(Mixer.Info)
|
||||
*/
|
||||
public abstract Mixer.Info[] getMixerInfo();
|
||||
|
||||
|
||||
/**
|
||||
* Obtains an instance of the mixer represented by the info object.
|
||||
* <p>
|
||||
* The full set of the mixer info objects that represent the mixers
|
||||
* supported by this {@code MixerProvider} may be obtained
|
||||
* through the {@code getMixerInfo} method.
|
||||
* Use the {@code isMixerSupported} method to test whether
|
||||
* this {@code MixerProvider} supports a particular mixer.
|
||||
*
|
||||
* @param info an info object that describes the desired mixer
|
||||
* @return mixer instance
|
||||
* @throws IllegalArgumentException if the info object specified does not
|
||||
* match the info object for a mixer supported by this MixerProvider.
|
||||
* @see #getMixerInfo()
|
||||
* @see #isMixerSupported(javax.sound.sampled.Mixer.Info) isMixerSupported(Mixer.Info)
|
||||
*/
|
||||
public abstract Mixer getMixer(Mixer.Info info);
|
||||
}
|
Reference in New Issue
Block a user