summaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/sound/sampled
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/sound/sampled')
-rw-r--r--libjava/classpath/javax/sound/sampled/AudioFileFormat.java242
-rw-r--r--libjava/classpath/javax/sound/sampled/AudioFormat.java366
-rw-r--r--libjava/classpath/javax/sound/sampled/AudioInputStream.java258
-rw-r--r--libjava/classpath/javax/sound/sampled/AudioPermission.java70
-rw-r--r--libjava/classpath/javax/sound/sampled/AudioSystem.java751
-rw-r--r--libjava/classpath/javax/sound/sampled/BooleanControl.java144
-rw-r--r--libjava/classpath/javax/sound/sampled/Clip.java115
-rw-r--r--libjava/classpath/javax/sound/sampled/CompoundControl.java104
-rw-r--r--libjava/classpath/javax/sound/sampled/Control.java111
-rw-r--r--libjava/classpath/javax/sound/sampled/DataLine.java271
-rw-r--r--libjava/classpath/javax/sound/sampled/EnumControl.java126
-rw-r--r--libjava/classpath/javax/sound/sampled/FloatControl.java267
-rw-r--r--libjava/classpath/javax/sound/sampled/Line.java150
-rw-r--r--libjava/classpath/javax/sound/sampled/LineEvent.java170
-rw-r--r--libjava/classpath/javax/sound/sampled/LineListener.java55
-rw-r--r--libjava/classpath/javax/sound/sampled/LineUnavailableException.java61
-rw-r--r--libjava/classpath/javax/sound/sampled/Mixer.java206
-rw-r--r--libjava/classpath/javax/sound/sampled/Port.java135
-rw-r--r--libjava/classpath/javax/sound/sampled/ReverbType.java144
-rw-r--r--libjava/classpath/javax/sound/sampled/SourceDataLine.java77
-rw-r--r--libjava/classpath/javax/sound/sampled/TargetDataLine.java79
-rw-r--r--libjava/classpath/javax/sound/sampled/UnsupportedAudioFileException.java65
-rw-r--r--libjava/classpath/javax/sound/sampled/spi/AudioFileReader.java146
-rw-r--r--libjava/classpath/javax/sound/sampled/spi/AudioFileWriter.java131
-rw-r--r--libjava/classpath/javax/sound/sampled/spi/FormatConversionProvider.java179
-rw-r--r--libjava/classpath/javax/sound/sampled/spi/MixerProvider.java86
26 files changed, 4509 insertions, 0 deletions
diff --git a/libjava/classpath/javax/sound/sampled/AudioFileFormat.java b/libjava/classpath/javax/sound/sampled/AudioFileFormat.java
new file mode 100644
index 000000000..2eeb78cf3
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/AudioFileFormat.java
@@ -0,0 +1,242 @@
+/* Audio file format
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This describes an audio file, including information about its length,
+ * the format of the audio data, and other things.
+ * @since 1.3
+ */
+public class AudioFileFormat
+{
+ /**
+ * An instance of this type describes a standard audio file format.
+ * @since 1.3
+ */
+ public static class Type
+ {
+ // This is kind of goofy since there are multiple extensions for
+ // some of these.
+
+ /** The AIFC format. */
+ public static final Type AIFC = new Type("AIFC", "aifc");
+
+ /** The AIFF format. */
+ public static final Type AIFF = new Type("AIFF", "aiff");
+
+ /** The AU format. */
+ public static final Type AU = new Type("AU", "au");
+
+ /** The SND format. */
+ public static final Type SND = new Type("SND", "snd");
+
+ /** The WAVE format. */
+ public static final Type WAVE = new Type ("WAVE", "wav");
+
+ private String name;
+ private String extension;
+
+ /**
+ * Create a new Type given its name and file extension.
+ * The file extension does not include the ".".
+ * @param name the type's name
+ * @param extension the file extension
+ */
+ public Type(String name, String extension)
+ {
+ this.name = name;
+ this.extension = extension;
+ }
+
+ public final boolean equals(Object o)
+ {
+ if (! (o instanceof Type))
+ return false;
+ Type other = (Type) o;
+ return name.equals(other.name) && extension.equals(other.extension);
+ }
+
+ public final int hashCode()
+ {
+ return name.hashCode() + extension.hashCode();
+ }
+
+ /**
+ * Return the extension associated with this Type.
+ */
+ public String getExtension()
+ {
+ return extension;
+ }
+
+ /**
+ * Return the name of this Type.
+ */
+ public final String toString()
+ {
+ return name;
+ }
+ }
+
+ private int byteLength;
+ private AudioFormat format;
+ private Type type;
+ private int frameLength;
+ private Map<String, Object> properties;
+
+ /**
+ * Create a new AudioFileFormat given the type, the format, and the
+ * frame length. The new object will have an unspecified byte length,
+ * and an empty properties map.
+ * @param type the type
+ * @param fmt the format
+ * @param frameLen the frame length
+ */
+ public AudioFileFormat(Type type, AudioFormat fmt, int frameLen)
+ {
+ this.byteLength = AudioSystem.NOT_SPECIFIED;
+ this.format = fmt;
+ this.type = type;
+ this.frameLength = frameLen;
+ this.properties = Collections.<String, Object> emptyMap();
+ }
+
+ /**
+ * Create a new AudioFileFormat given the type, the format, the
+ * frame length, and some properties. The new object will have an
+ * unspecified byte length. A copy of the properties argument will
+ * be made, so changes to the map passed in will not affect the
+ * new AudioFileFormat.
+ * @param type the type
+ * @param fmt the format
+ * @param frameLen the frame length
+ * @param properties the properties
+ */
+ public AudioFileFormat(Type type, AudioFormat fmt, int frameLen,
+ Map<String, Object> properties)
+ {
+ this.byteLength = AudioSystem.NOT_SPECIFIED;
+ this.format = fmt;
+ this.type = type;
+ this.frameLength = frameLen;
+ this.properties = Collections.unmodifiableMap(new HashMap<String, Object>(properties));
+ }
+
+ /**
+ * Create a new AudioFileFormat given the type, the byte length, the format,
+ * and the frame length. The new object will have an empty properties map.
+ * @param type the type
+ * @param byteLen the byte length
+ * @param fmt the format
+ * @param frameLen the frame length
+ */
+ protected AudioFileFormat(Type type, int byteLen, AudioFormat fmt,
+ int frameLen)
+ {
+ this.byteLength = byteLen;
+ this.format = fmt;
+ this.type = type;
+ this.frameLength = frameLen;
+ this.properties = Collections.<String, Object> emptyMap();
+ }
+
+ /**
+ * Return the byte length of this file format.
+ */
+ public int getByteLength()
+ {
+ return byteLength;
+ }
+
+ /**
+ * Return the AudioFormat associated with this file format.
+ */
+ public AudioFormat getFormat()
+ {
+ return format;
+ }
+
+ /**
+ * Return the frame length of this file format.
+ */
+ public int getFrameLength()
+ {
+ return frameLength;
+ }
+
+ /**
+ * Return the value of a property defined in this format.
+ * @param key the property name
+ * @return the value of the property, or null if the property is not defined
+ */
+ public Object getProperty(String key)
+ {
+ return properties.get(key);
+ }
+
+ /**
+ * Return the Type associated with this file format.
+ */
+ public Type getType()
+ {
+ return type;
+ }
+
+ /**
+ * Return the properties associated with this format, as a Map.
+ * The returned Map is unmodifiable.
+ */
+ public Map<String, Object> properties()
+ {
+ return properties;
+ }
+
+ /**
+ * Return a description of this AudioFileFormat.
+ */
+ public String toString()
+ {
+ return ("byteLength=" + byteLength + "; format=" + format
+ + "; type=" + type + "; frameLength=" + frameLength);
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/AudioFormat.java b/libjava/classpath/javax/sound/sampled/AudioFormat.java
new file mode 100644
index 000000000..b4fc601f2
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/AudioFormat.java
@@ -0,0 +1,366 @@
+/* An audio format
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+import gnu.java.lang.CPStringBuilder;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class describes an audio format, including its encoding,
+ * the number of channels, its frame rate, etc.
+ * @since 1.3
+ */
+public class AudioFormat
+{
+ /**
+ * This describes a given audio format encoding.
+ * @since 1.3
+ */
+ public static class Encoding
+ {
+ /** The ALAW encoding. */
+ public static final Encoding ALAW = new Encoding("alaw");
+
+ /** The signed PCM encoding. */
+ public static final Encoding PCM_SIGNED = new Encoding("pcm_signed");
+
+ /** The unsigned PCM encoding. */
+ public static final Encoding PCM_UNSIGNED = new Encoding("pcm_unsigned");
+
+ /** The ULAW encoding. */
+ public static final Encoding ULAW = new Encoding("ulaw");
+
+ private String name;
+
+ /**
+ * Create a new encoding descriptor, given its name.
+ * @param name the name
+ */
+ public Encoding(String name)
+ {
+ this.name = name;
+ }
+
+ public final boolean equals(Object o)
+ {
+ return super.equals(o);
+ }
+
+ public final int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ /**
+ * Return the name of this encoding.
+ */
+ public final String toString()
+ {
+ return name;
+ }
+ }
+
+ /**
+ * True if the audio data is stored big-endian.
+ */
+ protected boolean bigEndian;
+
+ /**
+ * The number of channels of data in this format.
+ */
+ protected int channels;
+
+ /**
+ * The encoding of this format.
+ */
+ protected Encoding encoding;
+
+ /**
+ * The frame rate of this format. This is the number of frames
+ * per second.
+ */
+ protected float frameRate;
+
+ /**
+ * The number of bytes per frame in this format.
+ */
+ protected int frameSize;
+
+ /**
+ * The number of samples per second.
+ */
+ protected float sampleRate;
+
+ /**
+ * The number of bits in each sample.
+ */
+ protected int sampleSizeInBits;
+
+ private Map<String, Object> properties;
+
+ /**
+ * Create a new audio format, given various attributes of it.
+ * The properties map for this format will be empty.
+ *
+ * @param encoding the encoding for this format
+ * @param sampleRate the sample rate
+ * @param sampleSizeInBits the sample size, in bits
+ * @param channels the number of channels
+ * @param frameSize the frame size, in bytes
+ * @param frameRate the frame rate, in frames per second
+ * @param bigEndian true if the data is stored big-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 = Collections.<String, Object> emptyMap();
+ }
+
+ /**
+ * Create a new audio format, given various attributes of it.
+ * The properties map is copied by this constructor, so changes
+ * to the argument Map will not affect the new object.
+ *
+ * @param encoding the encoding for this format
+ * @param sampleRate the sample rate
+ * @param sampleSizeInBits the sample size, in bits
+ * @param channels the number of channels
+ * @param frameSize the frame size, in bytes
+ * @param frameRate the frame rate, in frames per second
+ * @param bigEndian true if the data is stored big-endian
+ * @param properties a map describing properties of this format
+ */
+ public AudioFormat(Encoding encoding, float sampleRate, int sampleSizeInBits,
+ int channels, int frameSize, float frameRate,
+ boolean bigEndian, Map<String, Object> properties)
+ {
+ this.encoding = encoding;
+ this.sampleRate = sampleRate;
+ this.sampleSizeInBits = sampleSizeInBits;
+ this.channels = channels;
+ this.frameSize = frameSize;
+ this.frameRate = frameRate;
+ this.bigEndian = bigEndian;
+ this.properties = Collections.unmodifiableMap(new HashMap<String, Object>(properties));
+ }
+
+ /**
+ * Create a new PCM-based audio format, given various attributes of it.
+ * The encoding will either be Encoding#PCM_SIGNED or Encoding#PCM_UNSIGNED.
+ * The frame size for this format will be derived from the sample size in
+ * bits and the number of channels, unless one of those is
+ * AudioSystem#NOT_SPECIFIED. The frame rate will be the same as the sample
+ * rate, and the properties map will be empty.
+ *
+ * @param sampleRate the sample rate
+ * @param sampleSizeInBits the sample size, in bits
+ * @param channels the number of channels
+ * @param signed true if this is a signed encoding
+ * @param bigEndian true if the data is stored big-endian
+ */
+ public AudioFormat(float sampleRate, int sampleSizeInBits,
+ int channels, boolean signed, boolean bigEndian)
+ {
+ this.encoding = signed ? Encoding.PCM_SIGNED : Encoding.PCM_UNSIGNED;
+ this.sampleRate = sampleRate;
+ this.sampleSizeInBits = sampleSizeInBits;
+ this.channels = channels;
+ // It isn't clear whether channels can be NOT_SPECIFIED.
+ if (sampleSizeInBits == AudioSystem.NOT_SPECIFIED
+ || channels == AudioSystem.NOT_SPECIFIED)
+ this.frameSize = AudioSystem.NOT_SPECIFIED;
+ else
+ this.frameSize = (sampleSizeInBits + 7) / 8 * channels;
+ this.frameRate = sampleRate;
+ this.bigEndian = bigEndian;
+ this.properties = Collections.<String, Object> emptyMap();
+ }
+
+ /**
+ * Return the number of channels in this format.
+ */
+ public int getChannels()
+ {
+ return channels;
+ }
+
+ /**
+ * Return the encoding of this format.
+ */
+ public Encoding getEncoding()
+ {
+ return encoding;
+ }
+
+ /**
+ * Return the frame rate of this format.
+ */
+ public float getFrameRate()
+ {
+ return frameRate;
+ }
+
+ /**
+ * Return the frame size of this format.
+ */
+ public int getFrameSize()
+ {
+ return frameSize;
+ }
+
+ /**
+ * Given a key, return a property associated with this format;
+ * or null if this property is not set.
+ * @param key the name of the property
+ * @return the value of the property, or null if the property is not set
+ */
+ public Object getProperty(String key)
+ {
+ return properties.get(key);
+ }
+
+ /**
+ * Return the sample rate of this format.
+ */
+ public float getSampleRate()
+ {
+ return sampleRate;
+ }
+
+ /**
+ * Return the sample size of this format, in bits.
+ */
+ public int getSampleSizeInBits()
+ {
+ return sampleSizeInBits;
+ }
+
+ /**
+ * Return true if this format is big endian, false otherwise.
+ * This only matters for formats whose sample size is greater than
+ * one byte.
+ */
+ public boolean isBigEndian()
+ {
+ return bigEndian;
+ }
+
+ /**
+ * Return true if this audio format matches another.
+ * @param fmt the format to match against
+ * @return true if they match, false otherwise
+ */
+ public boolean matches(AudioFormat fmt)
+ {
+ if (! encoding.equals(fmt.encoding)
+ || channels != fmt.channels
+ || sampleSizeInBits != fmt.sampleSizeInBits
+ || frameSize != fmt.frameSize)
+ return false;
+ if (sampleRate != AudioSystem.NOT_SPECIFIED
+ && fmt.sampleRate != AudioSystem.NOT_SPECIFIED
+ && sampleRate != fmt.sampleRate)
+ return false;
+ if (frameRate != AudioSystem.NOT_SPECIFIED
+ && fmt.frameRate != AudioSystem.NOT_SPECIFIED
+ && frameRate != fmt.frameRate)
+ return false;
+ if (sampleSizeInBits > 8)
+ return bigEndian == fmt.bigEndian;
+ return true;
+ }
+
+ /**
+ * Return a read-only Map holding the properties associated with
+ * this format.
+ */
+ public Map<String, Object> properties()
+ {
+ return properties;
+ }
+
+ /**
+ * Return a description of this format.
+ */
+ public String toString()
+ {
+ CPStringBuilder result = new CPStringBuilder();
+
+ // usually at least encoding should be somewhat specified
+ result.append(encoding);
+
+ if (sampleRate != AudioSystem.NOT_SPECIFIED)
+ {
+ result.append(" ");
+ result.append(sampleRate);
+ result.append(" Hz");
+ }
+
+ if (sampleSizeInBits != AudioSystem.NOT_SPECIFIED)
+ {
+ result.append(" ");
+ result.append(sampleSizeInBits);
+ result.append(" bits");
+ }
+
+ if (channels != AudioSystem.NOT_SPECIFIED)
+ {
+ result.append(" ");
+ result.append(channels);
+ result.append(" channel");
+ if (channels > 1) result.append("s");
+ }
+
+ if (sampleSizeInBits > 8)
+ result.append(bigEndian ? " big endian" : " little endian");
+
+ return result.toString();
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/AudioInputStream.java b/libjava/classpath/javax/sound/sampled/AudioInputStream.java
new file mode 100644
index 000000000..526e7e192
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/AudioInputStream.java
@@ -0,0 +1,258 @@
+/*
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * This is an InputStream which is specialized for reading audio files.
+ * In particular it only allows operations to act on a multiple of
+ * the audio stream's frame size.
+ * @since 1.3
+ */
+public class AudioInputStream extends InputStream
+{
+ /** The format of the audio stream. */
+ protected AudioFormat format;
+
+ /** The length of the audio stream in frames. */
+ protected long frameLength;
+
+ /** The current frame position, starting from frame zero. */
+ protected long framePos;
+
+ /** The size of a frame in bytes. */
+ protected int frameSize;
+
+ // I wonder why this class doesn't inherit from FilterInputStream.
+ private InputStream input;
+
+ // The saved frame position, used for mark/reset.
+ private long markedFramePos;
+
+ /**
+ * Create a new AudioInputStream given an underlying InputStream,
+ * the audio format, and the length of the data in frames. The
+ * frame size is taken from the format.
+ * @param is the underlying input stream
+ * @param fmt the format of the data
+ * @param length the length of the data in frames
+ */
+ public AudioInputStream(InputStream is, AudioFormat fmt, long length)
+ {
+ this.format = fmt;
+ this.frameLength = length;
+ this.framePos = 0;
+ this.frameSize = fmt.getFrameSize();
+ this.input = is;
+ }
+
+ /**
+ * Create a new AudioInputStream given a TargetDataLine. The audio
+ * format and the frame size are taken from the line.
+ * @param line the TargetDataLine
+ */
+ public AudioInputStream(TargetDataLine line)
+ {
+ this(new TargetInputStream(line), line.getFormat(),
+ AudioSystem.NOT_SPECIFIED);
+ }
+
+ /**
+ * Return the number of bytes available to be read from the
+ * underlying stream. This wrapper method ensures that the result
+ * is always a multiple of the frame size.
+ */
+ public int available() throws IOException
+ {
+ int result = input.available();
+ // Ensure result is a multiple of the frame size.
+ if (frameSize != AudioSystem.NOT_SPECIFIED)
+ result -= result % frameSize;
+ return result;
+ }
+
+ /**
+ * Close the stream.
+ */
+ public void close() throws IOException
+ {
+ input.close();
+ }
+
+ /**
+ * Get the format associated with this stream.
+ * @return the AudioFormat
+ */
+ public AudioFormat getFormat()
+ {
+ return format;
+ }
+
+ /**
+ * Get the length of this stream in frames. Note that this
+ * may be AudioSystem#NOT_SPECIFIED.
+ * @return the length of the stream in frames
+ */
+ public long getFrameLength()
+ {
+ return frameLength;
+ }
+
+ public void mark(int limit)
+ {
+ input.mark(limit);
+ markedFramePos = framePos;
+ }
+
+ /**
+ * Return true if the underlying stream supports mark and reset,
+ * false otherwise.
+ */
+ public boolean markSupported()
+ {
+ return input.markSupported();
+ }
+
+ /**
+ * Read a single byte from the underlying stream. If the frame
+ * size is set, and is not one byte, an IOException will be thrown.
+ */
+ public int read() throws IOException
+ {
+ if (frameSize != 1)
+ throw new IOException("frame size must be 1 for read()");
+ int result;
+ if (framePos == frameLength)
+ result = -1;
+ else
+ result = input.read();
+ if (result != -1)
+ ++framePos;
+ return result;
+ }
+
+ public int read(byte[] buf) throws IOException
+ {
+ return read(buf, 0, buf.length);
+ }
+
+ public int read(byte[] buf, int offset, int length) throws IOException
+ {
+ int result;
+ if (framePos == frameLength)
+ result = -1;
+ else
+ {
+ int myFrameSize = (frameSize == AudioSystem.NOT_SPECIFIED
+ ? 1 : frameSize);
+ // Ensure length is a multiple of frame size.
+ length -= length % myFrameSize;
+
+ result = 0;
+ while (result == 0 || result % myFrameSize != 0)
+ {
+ int val = input.read(buf, offset, length);
+ if (val < 0)
+ {
+ // This is a weird situation as we might have read a
+ // frame already. It isn't clear at all what to do if
+ // we only found a partial frame. For now we just
+ // return whatever we did find.
+ if (result == 0)
+ return -1;
+ result -= result % myFrameSize;
+ break;
+ }
+ result += val;
+ }
+ // assert result % myFrameSize == 0;
+ framePos += result / myFrameSize;
+ }
+ return result;
+ }
+
+ public void reset() throws IOException
+ {
+ input.reset();
+ framePos = markedFramePos;
+ }
+
+ public long skip(long n) throws IOException
+ {
+ if (frameSize != AudioSystem.NOT_SPECIFIED)
+ n -= n % frameSize;
+ long actual = input.skip(n);
+ if (frameSize != AudioSystem.NOT_SPECIFIED)
+ framePos += actual / frameSize;
+ return actual;
+ }
+
+ private static class TargetInputStream extends InputStream
+ {
+ private TargetDataLine line;
+ private byte[] buf;
+
+ /**
+ * Create a new TargetInputStream.
+ * @param line the line to wrap
+ */
+ public TargetInputStream(TargetDataLine line)
+ {
+ this.line = line;
+ // FIXME: do we have to call line.open()?
+ }
+
+ public synchronized int read() throws IOException
+ {
+ if (buf == null)
+ buf = new byte[1];
+ int count = read(buf, 0, 1);
+ if (count < 0)
+ return -1;
+ return buf[0];
+ }
+
+ public int read(byte[] buf, int offset, int length) throws IOException
+ {
+ return line.read(buf, offset, length);
+ }
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/AudioPermission.java b/libjava/classpath/javax/sound/sampled/AudioPermission.java
new file mode 100644
index 000000000..a5325c910
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/AudioPermission.java
@@ -0,0 +1,70 @@
+/*
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+import java.security.BasicPermission;
+
+/**
+ * This represents the permission to use an audio device.
+ * The only predefined permission names are "play" and "record".
+ * @since 1.3
+ */
+public class AudioPermission extends BasicPermission
+{
+ private static final long serialVersionUID = -5518053473477801126L;
+
+ /**
+ * Construct an AudioPermission with the given name.
+ * @param name the name of the permission, like "play" or "record"
+ */
+ public AudioPermission(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Construct an AudioPermission with the given name.
+ * @param name the name of the permission, like "play" or "record"
+ * @param actions the actions; should be null
+ */
+ public AudioPermission(String name, String actions)
+ {
+ super(name, actions);
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/AudioSystem.java b/libjava/classpath/javax/sound/sampled/AudioSystem.java
new file mode 100644
index 000000000..01133c91d
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/AudioSystem.java
@@ -0,0 +1,751 @@
+/* Main interface to audio system
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+import gnu.classpath.ServiceFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import javax.sound.sampled.spi.AudioFileReader;
+import javax.sound.sampled.spi.AudioFileWriter;
+import javax.sound.sampled.spi.FormatConversionProvider;
+import javax.sound.sampled.spi.MixerProvider;
+
+/**
+ * This clas is the primary interface to the audio system. It contains
+ * a number of static methods which can be used to access this package's
+ * functionality.
+ *
+ * @since 1.3
+ */
+public class AudioSystem
+{
+ /**
+ * A constant which can be passed to a number of methods in this package,
+ * to indicate an unspecified value.
+ */
+ public static final int NOT_SPECIFIED = -1;
+
+ // This class is not instantiable.
+ private AudioSystem()
+ {
+ }
+
+ /**
+ * Return the file format of a given File.
+ * @param f the file to check
+ * @return the format of the file
+ * @throws UnsupportedAudioFileException if the file's format is not
+ * recognized
+ * @throws IOException if there is an I/O error reading the file
+ */
+ public static AudioFileFormat getAudioFileFormat(File f)
+ throws UnsupportedAudioFileException, IOException
+ {
+ Iterator i = ServiceFactory.lookupProviders(AudioFileReader.class);
+ while (i.hasNext())
+ {
+ AudioFileReader reader = (AudioFileReader) i.next();
+ try
+ {
+ return reader.getAudioFileFormat(f);
+ }
+ catch (UnsupportedAudioFileException _)
+ {
+ // Try the next provider.
+ }
+ }
+ throw new UnsupportedAudioFileException("file type not recognized");
+ }
+
+ /**
+ * Return the file format of a given input stream.
+ * @param is the input stream to check
+ * @return the format of the stream
+ * @throws UnsupportedAudioFileException if the stream's format is not
+ * recognized
+ * @throws IOException if there is an I/O error reading the stream
+ */
+ public static AudioFileFormat getAudioFileFormat(InputStream is)
+ throws UnsupportedAudioFileException, IOException
+ {
+ Iterator i = ServiceFactory.lookupProviders(AudioFileReader.class);
+ while (i.hasNext())
+ {
+ AudioFileReader reader = (AudioFileReader) i.next();
+ try
+ {
+ return reader.getAudioFileFormat(is);
+ }
+ catch (UnsupportedAudioFileException _)
+ {
+ // Try the next provider.
+ }
+ }
+ throw new UnsupportedAudioFileException("input stream type not recognized");
+ }
+
+ /**
+ * Return the file format of a given URL.
+ * @param url the URL to check
+ * @return the format of the URL
+ * @throws UnsupportedAudioFileException if the URL's format is not
+ * recognized
+ * @throws IOException if there is an I/O error reading the URL
+ */
+ public static AudioFileFormat getAudioFileFormat(URL url)
+ throws UnsupportedAudioFileException, IOException
+ {
+ Iterator i = ServiceFactory.lookupProviders(AudioFileReader.class);
+ while (i.hasNext())
+ {
+ AudioFileReader reader = (AudioFileReader) i.next();
+ try
+ {
+ return reader.getAudioFileFormat(url);
+ }
+ catch (UnsupportedAudioFileException _)
+ {
+ // Try the next provider.
+ }
+ }
+ throw new UnsupportedAudioFileException("URL type not recognized");
+ }
+
+ /**
+ * Return an array of all the supported AudioFileFormat types.
+ * @return an array of unique types
+ */
+ public static AudioFileFormat.Type[] getAudioFileTypes()
+ {
+ HashSet<AudioFileFormat.Type> result
+ = new HashSet<AudioFileFormat.Type>();
+ Iterator i = ServiceFactory.lookupProviders(AudioFileWriter.class);
+ while (i.hasNext())
+ {
+ AudioFileWriter writer = (AudioFileWriter) i.next();
+ AudioFileFormat.Type[] types = writer.getAudioFileTypes();
+ for (int j = 0; j < types.length; ++j)
+ result.add(types[j]);
+ }
+ return result.toArray(new AudioFileFormat.Type[result.size()]);
+ }
+
+ /**
+ * Return an array of all the supported AudioFileFormat types which match the
+ * given audio input stream
+ * @param ais the audio input stream
+ * @return an array of unique types
+ */
+ public static AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream ais)
+ {
+ HashSet<AudioFileFormat.Type> result
+ = new HashSet<AudioFileFormat.Type>();
+ Iterator i = ServiceFactory.lookupProviders(AudioFileWriter.class);
+ while (i.hasNext())
+ {
+ AudioFileWriter writer = (AudioFileWriter) i.next();
+ AudioFileFormat.Type[] types = writer.getAudioFileTypes(ais);
+ for (int j = 0; j < types.length; ++j)
+ result.add(types[j]);
+ }
+ return result.toArray(new AudioFileFormat.Type[result.size()]);
+ }
+
+ /**
+ * Given an audio input stream, this will try to create a new audio input
+ * stream whose encoding matches the given target encoding. If no provider
+ * offers this conversion, an exception is thrown.
+ * @param targ the target encoding
+ * @param ais the original audio stream
+ * @return a new audio stream
+ * @throws IllegalArgumentException if the conversion cannot be made
+ */
+ public static AudioInputStream getAudioInputStream(AudioFormat.Encoding targ,
+ AudioInputStream ais)
+ {
+ Iterator i = ServiceFactory.lookupProviders(FormatConversionProvider.class);
+ while (i.hasNext())
+ {
+ FormatConversionProvider prov = (FormatConversionProvider) i.next();
+ if (! prov.isConversionSupported(targ, ais.getFormat()))
+ continue;
+ return prov.getAudioInputStream(targ, ais);
+ }
+ throw new IllegalArgumentException("encoding not supported for stream");
+ }
+
+ /**
+ * Given an audio input stream, this will try to create a new audio input
+ * stream whose format matches the given target format. If no provider
+ * offers this conversion, an exception is thrown.
+ * @param targ the target format
+ * @param ais the original audio stream
+ * @return a new audio stream
+ * @throws IllegalArgumentException if the conversion cannot be made
+ */
+ public static AudioInputStream getAudioInputStream(AudioFormat targ,
+ AudioInputStream ais)
+ {
+ Iterator i = ServiceFactory.lookupProviders(FormatConversionProvider.class);
+ while (i.hasNext())
+ {
+ FormatConversionProvider prov = (FormatConversionProvider) i.next();
+ if (! prov.isConversionSupported(targ, ais.getFormat()))
+ continue;
+ return prov.getAudioInputStream(targ, ais);
+ }
+ throw new IllegalArgumentException("format not supported for stream");
+ }
+
+ /**
+ * Return an audio input stream for the file.
+ * @param f the file to read
+ * @return an audio input stream for the file
+ * @throws UnsupportedAudioFileException if the file's audio format is not
+ * recognized
+ * @throws IOException if there is an error while reading the file
+ */
+ public static AudioInputStream getAudioInputStream(File f)
+ throws UnsupportedAudioFileException, IOException
+ {
+ Iterator i = ServiceFactory.lookupProviders(AudioFileReader.class);
+ while (i.hasNext())
+ {
+ AudioFileReader reader = (AudioFileReader) i.next();
+ try
+ {
+ return reader.getAudioInputStream(f);
+ }
+ catch (UnsupportedAudioFileException _)
+ {
+ // Try the next provider.
+ }
+ }
+ throw new UnsupportedAudioFileException("file type not recognized");
+ }
+
+ /**
+ * Return an audio input stream given an input stream.
+ * @param is the input stream
+ * @return an audio input stream
+ * @throws UnsupportedAudioFileException if the input stream's audio format
+ * is not supported by any of the installed providers
+ * @throws IOException if there is an error while reading the input stream
+ */
+ public static AudioInputStream getAudioInputStream(InputStream is)
+ throws UnsupportedAudioFileException, IOException
+ {
+ Iterator i = ServiceFactory.lookupProviders(AudioFileReader.class);
+ while (i.hasNext())
+ {
+ AudioFileReader reader = (AudioFileReader) i.next();
+ try
+ {
+ return reader.getAudioInputStream(is);
+ }
+ catch (UnsupportedAudioFileException _)
+ {
+ // Try the next provider.
+ }
+ }
+ throw new UnsupportedAudioFileException("input stream type not recognized");
+ }
+
+ /**
+ * Return an audio input stream for the given URL.
+ * @param url the URL
+ * @return an audio input stream
+ * @throws UnsupportedAudioFileException if the URL's audio format is not
+ * supported by any of the installed providers
+ * @throws IOException if there is an error while reading the URL
+ */
+ public static AudioInputStream getAudioInputStream(URL url)
+ throws UnsupportedAudioFileException, IOException
+ {
+ Iterator i = ServiceFactory.lookupProviders(AudioFileReader.class);
+ while (i.hasNext())
+ {
+ AudioFileReader reader = (AudioFileReader) i.next();
+ try
+ {
+ return reader.getAudioInputStream(url);
+ }
+ catch (UnsupportedAudioFileException _)
+ {
+ // Try the next provider.
+ }
+ }
+ throw new UnsupportedAudioFileException("URL type not recognized");
+ }
+
+ /**
+ * Return a new clip which can be used for playing back an audio stream.
+ * @throws LineUnavailableException if a clip is not available for some
+ * reason
+ * @throws SecurityException if a clip cannot be made for security reasons
+ * @since 1.5
+ */
+ public static Clip getClip()
+ throws LineUnavailableException
+ {
+ Mixer.Info[] infos = getMixerInfo();
+ for (int i = 0; i < infos.length; ++i)
+ {
+ Mixer mix = getMixer(infos[i]);
+ Line[] lines = mix.getSourceLines();
+ for (int j = 0; j < lines.length; ++j)
+ {
+ if (lines[j] instanceof Clip)
+ return (Clip) lines[j];
+ }
+ }
+ throw new LineUnavailableException("no Clip available");
+ }
+
+ /**
+ * Return a new clip which can be used for playing back an audio stream.
+ * The clip is obtained from the indicated mixer.
+ * @param info the mixer to use
+ * @throws LineUnavailableException if a clip is not available for some
+ * reason
+ * @throws SecurityException if a clip cannot be made for security reasons
+ * @since 1.5
+ */
+ public static Clip getClip(Mixer.Info info)
+ throws LineUnavailableException
+ {
+ Mixer mix = getMixer(info);
+ Line[] lines = mix.getSourceLines();
+ for (int j = 0; j < lines.length; ++j)
+ {
+ if (lines[j] instanceof Clip)
+ return (Clip) lines[j];
+ }
+ throw new LineUnavailableException("no Clip available");
+ }
+
+ /**
+ * Return a line matching the provided description. All the providers
+ * on the system are searched for a matching line.
+ * @param info description of the line
+ * @return the matching line
+ * @throws LineUnavailableException if no provider supplies a matching line
+ */
+ public static Line getLine(Line.Info info) throws LineUnavailableException
+ {
+ Mixer.Info[] infos = getMixerInfo();
+ for (int i = 0; i < infos.length; ++i)
+ {
+ Mixer mix = getMixer(infos[i]);
+ try
+ {
+ return mix.getLine(info);
+ }
+ catch (LineUnavailableException _)
+ {
+ // Try the next provider.
+ }
+ }
+ throw new LineUnavailableException("no Clip available");
+ }
+
+ /**
+ * Return a mixer matching the provided description. All the providers
+ * on the system are searched for a matching mixer.
+ * @param info description of the mixer
+ * @return the matching mixer
+ * @throws IllegalArgumentException if no provider supplies a matching mixer
+ */
+ public static Mixer getMixer(Mixer.Info info)
+ {
+ Iterator i = ServiceFactory.lookupProviders(MixerProvider.class);
+ while (i.hasNext())
+ {
+ MixerProvider prov = (MixerProvider) i.next();
+ if (prov.isMixerSupported(info))
+ return prov.getMixer(info);
+ }
+ throw new IllegalArgumentException("mixer not found");
+ }
+
+ /**
+ * Return an array of descriptions of all the mixers provided on the system.
+ */
+ public static Mixer.Info[] getMixerInfo()
+ {
+ HashSet<Mixer.Info> result = new HashSet<Mixer.Info>();
+ Iterator i = ServiceFactory.lookupProviders(MixerProvider.class);
+ while (i.hasNext())
+ {
+ MixerProvider prov = (MixerProvider) i.next();
+ Mixer.Info[] is = prov.getMixerInfo();
+ for (int j = 0; j < is.length; ++j)
+ result.add(is[j]);
+ }
+ return result.toArray(new Mixer.Info[result.size()]);
+ }
+
+ /**
+ * Return a source data line matching the given audio format.
+ * @param fmt the audio format
+ * @throws LineUnavailableException if no source data line matching
+ * this format is available
+ * @since 1.5
+ */
+ public static SourceDataLine getSourceDataLine(AudioFormat fmt)
+ throws LineUnavailableException
+ {
+ DataLine.Info info = new DataLine.Info(SourceDataLine.class, fmt);
+ Mixer.Info[] mixers = getMixerInfo();
+ for (int i = 0; i < mixers.length; ++i)
+ {
+ Mixer mix = getMixer(mixers[i]);
+ if (mix.isLineSupported(info))
+ return (SourceDataLine) mix.getLine(info);
+ }
+ throw new LineUnavailableException("source data line not found");
+ }
+
+ /**
+ * Return a target data line matching the given audio format.
+ * @param fmt the audio format
+ * @throws LineUnavailableException if no target data line matching
+ * this format is available
+ * @since 1.5
+ */
+ public static SourceDataLine getSourceDataLine(AudioFormat fmt,
+ Mixer.Info mixer)
+ throws LineUnavailableException
+ {
+ DataLine.Info info = new DataLine.Info(SourceDataLine.class, fmt);
+ Mixer mix = getMixer(mixer);
+ if (mix.isLineSupported(info))
+ return (SourceDataLine) mix.getLine(info);
+ throw new LineUnavailableException("source data line not found");
+ }
+
+ /**
+ * Return an array of descriptions of all the source lines matching
+ * the given line description.
+ * @param info description of the lines to match
+ */
+ public static Line.Info[] getSourceLineInfo(Line.Info info)
+ {
+ HashSet<Line.Info> result = new HashSet<Line.Info>();
+ Mixer.Info[] infos = getMixerInfo();
+ for (int i = 0; i < infos.length; ++i)
+ {
+ Mixer mix = getMixer(infos[i]);
+ Line.Info[] srcs = mix.getSourceLineInfo(info);
+ for (int j = 0; j < srcs.length; ++j)
+ result.add(srcs[j]);
+ }
+ return result.toArray(new Line.Info[result.size()]);
+ }
+
+ /**
+ * Find and return a target data line matching the given audio format.
+ * @param fmt the format to match
+ * @throws LineUnavailableException if no matching line was found
+ * @since 1.5
+ */
+ public static TargetDataLine getTargetDataLine(AudioFormat fmt)
+ throws LineUnavailableException
+ {
+ DataLine.Info info = new DataLine.Info(TargetDataLine.class, fmt);
+ Mixer.Info[] mixers = getMixerInfo();
+ for (int i = 0; i < mixers.length; ++i)
+ {
+ Mixer mix = getMixer(mixers[i]);
+ if (mix.isLineSupported(info))
+ return (TargetDataLine) mix.getLine(info);
+ }
+ throw new LineUnavailableException("target data line not found");
+ }
+
+ /**
+ * Return a target data line matching the given audio format and
+ * mixer.
+ * @param fmt the audio format
+ * @param mixer the mixer description
+ * @return a target data line
+ * @throws LineUnavailableException if no matching target data line was
+ * found
+ * @since 1.5
+ */
+ public static TargetDataLine getTargetDataLine(AudioFormat fmt,
+ Mixer.Info mixer)
+ throws LineUnavailableException
+ {
+ DataLine.Info info = new DataLine.Info(TargetDataLine.class, fmt);
+ Mixer mix = getMixer(mixer);
+ if (mix.isLineSupported(info))
+ return (TargetDataLine) mix.getLine(info);
+ throw new LineUnavailableException("target data line not found");
+ }
+
+ /**
+ * Given a source encoding, return an array of all target encodings to which
+ * data in this form can be converted.
+ * @param source the source encoding
+ */
+ public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat.Encoding source)
+ {
+ HashSet<AudioFormat.Encoding> result
+ = new HashSet<AudioFormat.Encoding>();
+ Iterator i = ServiceFactory.lookupProviders(FormatConversionProvider.class);
+ while (i.hasNext())
+ {
+ FormatConversionProvider prov = (FormatConversionProvider) i.next();
+ if (! prov.isSourceEncodingSupported(source))
+ continue;
+ AudioFormat.Encoding[] es = prov.getTargetEncodings();
+ for (int j = 0; j < es.length; ++j)
+ result.add(es[j]);
+ }
+ return result.toArray(new AudioFormat.Encoding[result.size()]);
+ }
+
+ /**
+ * Given a source format, return an array of all the target encodings to
+ * which data in this format can be converted.
+ * @param source the source format
+ */
+ public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat source)
+ {
+ HashSet<AudioFormat.Encoding> result
+ = new HashSet<AudioFormat.Encoding>();
+ Iterator i = ServiceFactory.lookupProviders(FormatConversionProvider.class);
+ while (i.hasNext())
+ {
+ FormatConversionProvider prov = (FormatConversionProvider) i.next();
+ AudioFormat.Encoding[] es = prov.getTargetEncodings(source);
+ for (int j = 0; j < es.length; ++j)
+ result.add(es[j]);
+ }
+ return result.toArray(new AudioFormat.Encoding[result.size()]);
+ }
+
+ /**
+ * Given a target encoding and a source audio format, return an array of all
+ * matching audio formats to which data in this source format can be converted.
+ * @param encoding the target encoding
+ * @param sourceFmt the source format
+ */
+ public static AudioFormat[] getTargetFormats(AudioFormat.Encoding encoding,
+ AudioFormat sourceFmt)
+ {
+ HashSet<AudioFormat> result = new HashSet<AudioFormat>();
+ Iterator i = ServiceFactory.lookupProviders(FormatConversionProvider.class);
+ while (i.hasNext())
+ {
+ FormatConversionProvider prov = (FormatConversionProvider) i.next();
+ AudioFormat[] es = prov.getTargetFormats(encoding, sourceFmt);
+ for (int j = 0; j < es.length; ++j)
+ result.add(es[j]);
+ }
+ return result.toArray(new AudioFormat[result.size()]);
+ }
+
+ /**
+ * Given a line description, return an array of descriptions of all
+ * the matching target lines.
+ * @param info the line description
+ */
+ public static Line.Info[] getTargetLineInfo(Line.Info info)
+ {
+ HashSet<Line.Info> result = new HashSet<Line.Info>();
+ Mixer.Info[] infos = getMixerInfo();
+ for (int i = 0; i < infos.length; ++i)
+ {
+ Mixer mix = getMixer(infos[i]);
+ Line.Info[] targs = mix.getTargetLineInfo(info);
+ for (int j = 0; j < targs.length; ++j)
+ result.add(targs[j]);
+ }
+ return result.toArray(new Line.Info[result.size()]);
+ }
+
+ /**
+ * Return true if the currently installed providers are able to
+ * convert data from the given source format to the given target encoding.
+ * @param targ the target encoding
+ * @param source the source format
+ */
+ public static boolean isConversionSupported(AudioFormat.Encoding targ,
+ AudioFormat source)
+ {
+ Iterator i
+ = ServiceFactory.lookupProviders(FormatConversionProvider.class);
+ while (i.hasNext())
+ {
+ FormatConversionProvider prov = (FormatConversionProvider) i.next();
+ if (prov.isConversionSupported(targ, source))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return true if the currently installed providers are able to convert
+ * the given source format to the given target format.
+ * @param targ the target format
+ * @param source the source format
+ */
+ public static boolean isConversionSupported(AudioFormat targ,
+ AudioFormat source)
+ {
+ Iterator i
+ = ServiceFactory.lookupProviders(FormatConversionProvider.class);
+ while (i.hasNext())
+ {
+ FormatConversionProvider prov = (FormatConversionProvider) i.next();
+ if (prov.isConversionSupported(targ, source))
+ return true;
+ }
+ return false;
+ }
+
+ private static boolean isFileTypeSupported(AudioFileFormat.Type[] types,
+ AudioFileFormat.Type type)
+ {
+ for (int i = 0; i < types.length; ++i)
+ {
+ if (types[i].equals(type))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return true if the given audio file format is supported by one of
+ * the providers installed on the system.
+ * @param type the audio file format type
+ */
+ public static boolean isFileTypeSupported(AudioFileFormat.Type type)
+ {
+ return isFileTypeSupported(getAudioFileTypes(), type);
+ }
+
+ /**
+ * Return true if the given audio file format is supported for the
+ * given audio input stream by one of the providers installed on the
+ * system.
+ * @param type the audio file format type
+ * @param ais the audio input stream
+ */
+ public static boolean isFileTypeSupported(AudioFileFormat.Type type,
+ AudioInputStream ais)
+ {
+ return isFileTypeSupported(getAudioFileTypes(ais), type);
+ }
+
+ /**
+ * Return true if some provider on the system supplies a line
+ * matching the argument.
+ * @param info the line to match
+ */
+ public static boolean isLineSupported(Line.Info info)
+ {
+ Mixer.Info[] infos = getMixerInfo();
+ for (int i = 0; i < infos.length; ++i)
+ {
+ if (getMixer(infos[i]).isLineSupported(info))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Write an audio input stream to the given file, using the specified
+ * audio file format. All the providers installed on the system will
+ * be searched to find one that supports this operation.
+ * @param ais the audio input stream to write
+ * @param type the desired audio file format type
+ * @param out the file to write to
+ * @return the number of bytes written
+ * @throws IOException if an I/O error occurs while writing
+ * @throws IllegalArgumentException if the file type is not supported
+ */
+ public static int write(AudioInputStream ais, AudioFileFormat.Type type,
+ File out)
+ throws IOException
+ {
+ Iterator i = ServiceFactory.lookupProviders(AudioFileWriter.class);
+ while (i.hasNext())
+ {
+ AudioFileWriter w = (AudioFileWriter) i.next();
+ if (w.isFileTypeSupported(type, ais))
+ return w.write(ais, type, out);
+ }
+ throw new IllegalArgumentException("file type not supported by system");
+ }
+
+ /**
+ * Write an audio input stream to the given output stream, using the
+ * specified audio file format. All the providers installed on the
+ * system will be searched to find one that supports this operation.
+ * @param ais the audio input stream to write
+ * @param type the desired audio file format type
+ * @param os the output stream to write to
+ * @return the number of bytes written
+ * @throws IOException if an I/O error occurs while writing
+ * @throws IllegalArgumentException if the file type is not supported
+ */
+ public static int write(AudioInputStream ais, AudioFileFormat.Type type,
+ OutputStream os)
+ throws IOException
+ {
+ Iterator i = ServiceFactory.lookupProviders(AudioFileWriter.class);
+ while (i.hasNext())
+ {
+ AudioFileWriter w = (AudioFileWriter) i.next();
+ if (w.isFileTypeSupported(type, ais))
+ return w.write(ais, type, os);
+ }
+ throw new IllegalArgumentException("file type not supported by system");
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/BooleanControl.java b/libjava/classpath/javax/sound/sampled/BooleanControl.java
new file mode 100644
index 000000000..37e372e7b
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/BooleanControl.java
@@ -0,0 +1,144 @@
+/*
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+/**
+ * A BooleanControl is a Control which has two states.
+ * @since 1.3
+ */
+public abstract class BooleanControl extends Control
+{
+ /**
+ * A Type specialized to represent a boolean control.
+ * @since 1.3
+ */
+ public static class Type extends Control.Type
+ {
+ // FIXME: correct constructions?
+
+ /**
+ * A control for applying reverb.
+ */
+ public final static Type APPLY_REVERB = new Type("Apply reverb");
+
+ /**
+ * A control for muting.
+ */
+ public final static Type MUTE = new Type("Mute");
+
+ /**
+ * Create a new Type given its name.
+ * @param name the name of the type
+ */
+ protected Type(String name)
+ {
+ super(name);
+ }
+ }
+
+ private boolean value;
+ private String trueLabel;
+ private String falseLabel;
+
+ /**
+ * Create a new boolean control, with the indicated Type and initial
+ * value. The description strings will default to "true" and "false".
+ * @param type the type
+ * @param init the initial value
+ */
+ protected BooleanControl(Type type, boolean init)
+ {
+ super(type);
+ this.value = init;
+ this.trueLabel = "true";
+ this.falseLabel = "false";
+ }
+
+ /**
+ * Create a new boolean control, with the indicated Type, initial
+ * value, and labels.
+ * @param type the type
+ * @param init the initial value
+ * @param trueLabel the label for the true state
+ * @param falseLabel the label for the false state
+ */
+ protected BooleanControl(Type type, boolean init, String trueLabel,
+ String falseLabel)
+ {
+ super(type);
+ this.value = init;
+ this.trueLabel = trueLabel;
+ this.falseLabel = falseLabel;
+ }
+
+ /**
+ * Return the label corresponding to the indicated state.
+ * @param state the state
+ * @return the true label or the false label, as appropriate
+ */
+ public String getStateLabel(boolean state)
+ {
+ return state ? trueLabel : falseLabel;
+ }
+
+ /**
+ * Return the current value of thhe control.
+ */
+ public boolean getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the value of the control as indicated.
+ * @param value the new value
+ */
+ public void setValue(boolean value)
+ {
+ this.value = value;
+ }
+
+ /**
+ * Return a string describing this control.
+ */
+ public String toString()
+ {
+ return super.toString() + ": " + getStateLabel(value);
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/Clip.java b/libjava/classpath/javax/sound/sampled/Clip.java
new file mode 100644
index 000000000..28b49796f
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/Clip.java
@@ -0,0 +1,115 @@
+/*
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+import java.io.IOException;
+
+/**
+ * A Clip represents some pre-loaded audio data.
+ * @since 1.3
+ */
+public interface Clip extends DataLine
+{
+ /**
+ * This can be passed to {@link #loop(int)} to indicate that looping
+ * should be done continuously.
+ */
+ int LOOP_CONTINUOUSLY = -1;
+
+ /**
+ * Return the frame length of this clip.
+ */
+ int getFrameLength();
+
+ /**
+ * Return the length of the clip in microseconds.
+ */
+ long getMicrosecondLength();
+
+ /**
+ * Start looping the clip. Looping will occur count times, or, if count
+ * is LOOP_CONTINUOUSLY, will be done continuously. A count of 0 indicates
+ * that any current looping should stop.
+ * @param count the number of times to loop
+ */
+ void loop(int count);
+
+ /**
+ * Open a clip, given an audio format and some data.
+ * @param fmt the format of the data
+ * @param data a byte array containing the audio data
+ * @param offset the offset of the first byte of data in the array
+ * @param len the length of the audio data in the array, in bytes
+ * @throws LineUnavailableException if the line cannot be opened
+ * @throws SecurityException if the line cannot be opened for security
+ * reasons
+ */
+ void open(AudioFormat fmt, byte[] data, int offset, int len)
+ throws LineUnavailableException;
+
+ /**
+ * Open a clip, given an audio input stream.
+ * @param ais the input stream
+ * @throws LineUnavailableException if the line cannot be opened
+ * @throws SecurityException if the line cannot be opened for security
+ * reasons
+ * @throws IOException if there is an I/O error while reading the stream
+ */
+ void open(AudioInputStream ais)
+ throws LineUnavailableException, IOException;
+
+ /**
+ * Set the position to the indicated frame.
+ * @param where new frame position
+ */
+ void setFramePosition(int where);
+
+ /**
+ * Set the loop begin and end points. These are used by loop(int).
+ * @param begin the starting point
+ * @param end the ending point
+ */
+ void setLoopPoints(int begin, int end);
+
+ /**
+ * Set the position to the indicated microsecond.
+ * @param ms the new position in microseconds
+ */
+ void setMicrosecondPosition(long ms);
+}
diff --git a/libjava/classpath/javax/sound/sampled/CompoundControl.java b/libjava/classpath/javax/sound/sampled/CompoundControl.java
new file mode 100644
index 000000000..2b8941cf3
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/CompoundControl.java
@@ -0,0 +1,104 @@
+/* Control consisting of several other controls
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+import gnu.java.lang.CPStringBuilder;
+
+/**
+ * A compound control provides control over several other controls.
+ * @since 1.3
+ */
+public abstract class CompoundControl extends Control
+{
+ /**
+ * This describes a single compound control.
+ * @since 1.3
+ */
+ public static class Type extends Control.Type
+ {
+ /**
+ * Create a new Type given its name.
+ * @param name the name of the type
+ */
+ protected Type(String name)
+ {
+ super(name);
+ }
+ }
+
+ private Control[] memberControls;
+
+ /**
+ * Create a new compound control given its type and members.
+ * @param type the type of the compound control
+ * @param members the members of the compound control
+ */
+ protected CompoundControl(Type type, Control[] members)
+ {
+ super(type);
+ // FIXME: clone?
+ this.memberControls = members;
+ }
+
+ /**
+ * Return the members of this compound control.
+ */
+ public Control[] getMemberControls()
+ {
+ // FIXME: clone?
+ return memberControls;
+ }
+
+ /**
+ * Return a string description of this compound control.
+ */
+ public String toString()
+ {
+ CPStringBuilder result = new CPStringBuilder();
+ result.append(super.toString());
+ result.append(": ");
+ for (int i = 0; i < memberControls.length; ++i)
+ {
+ if (i > 0)
+ result.append(", ");
+ result.append(memberControls[i].toString());
+ }
+ return result.toString();
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/Control.java b/libjava/classpath/javax/sound/sampled/Control.java
new file mode 100644
index 000000000..4759a3353
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/Control.java
@@ -0,0 +1,111 @@
+/* Control over an attribute of a line
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+/**
+ * A control provides the ability to affect some attribute of a line,
+ * for instance its volume.
+ * @since 1.3
+ */
+public abstract class Control
+{
+ /**
+ * This describes a single control.
+ * @since 1.3
+ */
+ public static class Type
+ {
+ private String name;
+
+ /**
+ * Create a new Type given its name.
+ * @param name the name of the type
+ */
+ protected Type(String name)
+ {
+ this.name = name;
+ }
+
+ public final boolean equals(Object o)
+ {
+ return super.equals(o);
+ }
+
+ public final int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ /**
+ * Return the name of this Type.
+ */
+ public final String toString()
+ {
+ return name;
+ }
+ }
+
+ private Type type;
+
+ /**
+ * Create a new Control given its Type.
+ * @param type the type
+ */
+ protected Control(Type type)
+ {
+ this.type = type;
+ }
+
+ /**
+ * Return the Type of this Control.
+ */
+ public Type getType()
+ {
+ return type;
+ }
+
+ /**
+ * Return a String descrsibing this control. In particular the
+ * value will include the name of the associated Type.
+ */
+ public String toString()
+ {
+ return type.toString();
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/DataLine.java b/libjava/classpath/javax/sound/sampled/DataLine.java
new file mode 100644
index 000000000..5d88c6ace
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/DataLine.java
@@ -0,0 +1,271 @@
+/*
+ Copyright (C) 2005-2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.sound.sampled;
+
+import gnu.java.lang.CPStringBuilder;
+
+/**
+ * The DataLine interface adds data-related functionality to the Line
+ * interface. For example, it adds methods to start and stop the data
+ * on the line.
+ * @since 1.3
+ */
+public interface DataLine extends Line
+{
+ /**
+ * This class extends Line.Info with information specific to DataLine.
+ * In particular it adds information about buffer sizes, and about supported
+ * audio formats.
+ * @since 1.3
+ */
+ class Info extends Line.Info
+ {
+ private int minBufferSize;
+ private int maxBufferSize;
+ private AudioFormat[] formats;
+
+ /**
+ * Create a new Info given the line's class and a supported
+ * audio format. The buffer sizes default to AudioSystem.NOT_SPECIFIED.
+ * @param klass the class of the line
+ * @param fmt the supported format
+ */
+ public Info(Class<?> klass, AudioFormat fmt)
+ {
+ super(klass);
+ this.minBufferSize = AudioSystem.NOT_SPECIFIED;
+ this.maxBufferSize = AudioSystem.NOT_SPECIFIED;
+ this.formats = new AudioFormat[] { fmt };
+ }
+
+ /**
+ * Create a new Info given the line's class, the supported audio formats,
+ * the minimum buffer size, and the maximum buffer size.
+ * @param klass the class of the linee
+ * @param fmts the supported audio formats
+ * @param minSize the minimum buffer size
+ * @param maxSize the maximum buffer size
+ */
+ public Info(Class<?> klass, AudioFormat[] fmts, int minSize, int maxSize)
+ {
+ super(klass);
+ this.minBufferSize = minSize;
+ this.maxBufferSize = maxSize;
+ this.formats = fmts;
+ }
+
+ /**
+ * Create a new Info given the line's class, a supported
+ * audio format, and a buffer size. Both the minimum and maximum
+ * sizes are set from this size.
+ * @param klass the class of the line
+ * @param fmt the supported format
+ * @param size the buffer size
+ */
+ public Info(Class<?> klass, AudioFormat fmt, int size)
+ {
+ super(klass);
+ this.minBufferSize = size;
+ this.maxBufferSize = size;
+ this.formats = new AudioFormat[] { fmt };
+ }
+
+ /**
+ * Return the supported audio formats.
+ */
+ public AudioFormat[] getFormats()
+ {
+ // FIXME: clone?
+ return formats;
+ }
+
+ /**
+ * Return the maximum buffer size.
+ */
+ public int getMaxBufferSize()
+ {
+ return maxBufferSize;
+ }
+
+ /**
+ * Return the minimum buffer size.
+ */
+ public int getMinBufferSize()
+ {
+ return minBufferSize;
+ }
+
+ /**
+ * Return true if the indicated audio format is supported by this
+ * Info, false otherwise.
+ * @param fmt the audio format
+ * @return true if the format is supported
+ */
+ public boolean isFormatSupported(AudioFormat fmt)
+ {
+ for (int i = 0; i < formats.length; ++i)
+ {
+ if (fmt.matches(formats[i]))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return true if this Info matches another Info object.
+ */
+ public boolean matches(Line.Info o)
+ {
+ if (! super.matches(o) || ! (o instanceof Info))
+ return false;
+
+ Info other = (Info) o;
+ if (minBufferSize < other.minBufferSize ||
+ maxBufferSize > other.maxBufferSize)
+ return false;
+
+ for (int i = 0; i < formats.length; ++i)
+ {
+ boolean ok = false;
+ for (int j = 0; j < other.formats.length; ++j)
+ {
+ if (formats[i].matches(other.formats[j]))
+ {
+ ok = true;
+ break;
+ }
+ }
+ if (! ok)
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Return a description of this Info object.
+ */
+ public String toString()
+ {
+ CPStringBuilder result = new CPStringBuilder();
+ result.append("formats: [");
+ for (int i = 0; i < formats.length; ++i)
+ {
+ if (i > 0)
+ result.append(", ");
+ result.append(formats[i].toString());
+ }
+
+ result.append("]; minBufferSize: ");
+ result.append(minBufferSize);
+ result.append("; maxBufferSize: ");
+ result.append(maxBufferSize);
+ return result.toString();
+ }
+
+ } // end class: Info
+
+ /**
+ * Return the number of bytes currently available on this DataLine.
+ */
+ int available();
+
+ /**
+ * This method blocks until whatever data is buffered in the
+ * DataLine's internal buffer has been drained.
+ */
+ void drain();
+
+ /**
+ * This flushes the DataLine by discarding any buffered data.
+ */
+ void flush();
+
+ /**
+ * Returns the size of the DataLine's internal buffer, in bytes.
+ */
+ int getBufferSize();
+
+ /**
+ * Return the current format of the data associated with this DataLine.
+ */
+ AudioFormat getFormat();
+
+ /**
+ * Return the current frame position.
+ */
+ int getFramePosition();
+
+ /**
+ * Return the volume level for this DataLine.
+ */
+ float getLevel();
+
+ /**
+ * Return the current frame position.
+ * @since 1.5
+ */
+ long getLongFramePosition();
+
+ /**
+ * Return the number of microseconds this DataLine has been playing.
+ */
+ long getMicrosecondPosition();
+
+ /**
+ * Return true if this line is active, meaning that it is actively
+ * performing audio I/O.
+ */
+ boolean isActive();
+
+ /**
+ * Return true if this line is running, meaning that it has been
+ * started. When the line is stopped, this method will return false.
+ */
+ boolean isRunning();
+
+ /**
+ * Start processing data. This will emit a START event.
+ */
+ void start();
+
+ /**
+ * Stop processing data. This will emit a STOP event.
+ */
+ void stop();
+}
diff --git a/libjava/classpath/javax/sound/sampled/EnumControl.java b/libjava/classpath/javax/sound/sampled/EnumControl.java
new file mode 100644
index 000000000..7a032420d
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/EnumControl.java
@@ -0,0 +1,126 @@
+/*
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+/**
+ * An EnumControl is a Control which can take one of a specified set of
+ * values.
+ * @since 1.3
+ */
+public abstract class EnumControl extends Control
+{
+ /**
+ * This Type describes an EnumControl.
+ * @since 1.3
+ */
+ public static class Type extends Control.Type
+ {
+ /** This describes an enum control used for reverb. */
+ public static final Type REVERB = new Type("Reverb");
+
+ /**
+ * Create a new Type given its name.
+ * @param name the name of the type
+ */
+ protected Type(String name)
+ {
+ super(name);
+ }
+ }
+
+ private Object[] values;
+ private Object value;
+
+ /**
+ * Create a new enumerated control given its Type, the range of valid
+ * values, and its initial value.
+ * @param type the type
+ * @param values the valid values
+ * @param val the initial value
+ */
+ protected EnumControl(Type type, Object[] values, Object val)
+ {
+ super(type);
+ // FIXME: error checking: values.length>0, val in values... ?
+ // FIXME: clone here?
+ this.values = values;
+ this.value = val;
+ }
+
+ /**
+ * Return the current value of this control.
+ */
+ public Object getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Return the valid values for this control.
+ */
+ public Object[] getValues()
+ {
+ // FIXME: clone here?
+ return values;
+ }
+
+ /**
+ * Set the value of this control. If the indicated value is not among
+ * the valid values, this method will throw an IllegalArgumentException.
+ * @param value the new value
+ * @throws IllegalArgumentException if the new value is invalid
+ */
+ public void setValue(Object value)
+ {
+ for (int i = 0; i < values.length; ++i)
+ {
+ if (! values[i].equals(value))
+ throw new IllegalArgumentException("value not supported");
+ }
+ this.value = value;
+ }
+
+ /**
+ * Return a string describing this control.
+ */
+ public String toString()
+ {
+ return super.toString() + ": " + value;
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/FloatControl.java b/libjava/classpath/javax/sound/sampled/FloatControl.java
new file mode 100644
index 000000000..6ae917829
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/FloatControl.java
@@ -0,0 +1,267 @@
+/* Floating point control
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+/** @since 1.3 */
+public abstract class FloatControl extends Control
+{
+ /**
+ * An instance of this class describes a particular floating point control.
+ * @since 1.3
+ */
+ public static class Type extends Control.Type
+ {
+ /** Auxiliary return gain. */
+ public static final Type AUX_RETURN = new Type("AUX return");
+
+ /** Auxiliary send gain. */
+ public static final Type AUX_SEND = new Type("AUX send");
+
+ /** Balance. */
+ public static final Type BALANCE = new Type("Balance");
+
+ /** Master gain control. */
+ public static final Type MASTER_GAIN = new Type("Master gain");
+
+ /** Control for panning. */
+ public static final Type PAN = new Type("Pan");
+
+ /** Post-reverb gain. */
+ public static final Type REVERB_RETURN = new Type("Reverb return");
+
+ /** Pre-reverb gain. */
+ public static final Type REVERB_SEND = new Type("Reverb send");
+
+ /** Control the sample rate. */
+ public static final Type SAMPLE_RATE = new Type("Sample rate");
+
+ /** Volume control. */
+ public static final Type VOLUME = new Type("Volume");
+
+ /**
+ * Create a new type given its name.
+ * @param name the name of the type
+ */
+ protected Type(String name)
+ {
+ super(name);
+ }
+ }
+
+ private float minimum;
+ private float maximum;
+ private float precision;
+ private int updatePeriod;
+ private float value;
+ private String units;
+ private String minLabel;
+ private String maxLabel;
+ private String midLabel;
+
+ /**
+ * Create a new FloatControl given its type and various parameters.
+ * The minimum, maximum, and midpoint labels will all be the empty string.
+ *
+ * @param type the type
+ * @param min the minimum valuee
+ * @param max the maximum value
+ * @param prec the precision
+ * @param update the update period
+ * @param init the initial value
+ * @param units the description of the units
+ */
+ protected FloatControl(Type type, float min, float max, float prec,
+ int update, float init, String units)
+ {
+ super(type);
+ this.minimum = min;
+ this.maximum = max;
+ this.precision = prec;
+ this.updatePeriod = update;
+ this.value = init;
+ this.units = units;
+ this.minLabel = "";
+ this.maxLabel = "";
+ this.midLabel = "";
+ }
+
+ /**
+ * Create a new FloatControl given its type and various parameters.
+ *
+ * @param type the type
+ * @param min the minimum valuee
+ * @param max the maximum value
+ * @param prec the precision
+ * @param update the update period
+ * @param init the initial value
+ * @param units the description of the units
+ * @param minLabel the label for the minimum value
+ * @param midLabel the label for the midpoint
+ * @param maxLabel the label for the maximum value
+ */
+ protected FloatControl(Type type, float min, float max, float prec,
+ int update, float init, String units,
+ String minLabel, String midLabel, String maxLabel)
+ {
+ super(type);
+ this.minimum = min;
+ this.maximum = max;
+ this.precision = prec;
+ this.updatePeriod = update;
+ this.value = init;
+ this.units = units;
+ this.minLabel = minLabel;
+ this.maxLabel = maxLabel;
+ this.midLabel = midLabel;
+ }
+
+ /**
+ * Return the maximum value of this control.
+ */
+ public float getMaximum()
+ {
+ return maximum;
+ }
+
+ /**
+ * Return the label for the minimum value of this control.
+ */
+ public String getMaxLabel()
+ {
+ return maxLabel;
+ }
+
+ /**
+ * Return the label for the midpoint of this control.
+ */
+ public String getMidLabel()
+ {
+ return midLabel;
+ }
+
+ /**
+ * Return the minimum value of this control.
+ */
+ public float getMinimum()
+ {
+ return minimum;
+ }
+
+ /**
+ * Return the label for the minimum value of this control.
+ */
+ public String getMinLabel()
+ {
+ return minLabel;
+ }
+
+ /**
+ * Return the precision of this control.
+ */
+ public float getPrecision()
+ {
+ return precision;
+ }
+
+ /**
+ * Return the name of the units for this control.
+ */
+ public String getUnits()
+ {
+ return units;
+ }
+
+ /**
+ * Return the update period of this control.
+ */
+ public int getUpdatePeriod()
+ {
+ return updatePeriod;
+ }
+
+ /**
+ * Return the current value of this control.
+ */
+ public float getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the new value of this control.
+ * @param value the new value
+ * @throws IllegalArgumentException if the new value is greater than the
+ * maximum or less than the minimum.
+ */
+ public void setValue(float value)
+ {
+ if (value < minimum || value > maximum)
+ throw new IllegalArgumentException("value out of range");
+ this.value = value;
+ }
+
+ /**
+ * This tells the control to start at the starting value
+ * and to shift its value incrementally to the final value
+ * over the given time interval, specified in microseconds.
+ * The default implementation does not do this, but instead
+ * simply sets the value to the final value immediately.
+ *
+ * @param from the starting value
+ * @param to the final value
+ * @param ms the number of microseconds
+ */
+ public void shift(float from, float to, int ms)
+ {
+ if (from < minimum || from > maximum
+ || to < minimum || to > maximum
+ || ms < 0)
+ throw new IllegalArgumentException("argument out of range");
+ // The default just sets the value to TO.
+ this.value = to;
+ }
+
+ /**
+ * Return a string describing this control.
+ */
+ public String toString()
+ {
+ return super.toString() + ": " + value;
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/Line.java b/libjava/classpath/javax/sound/sampled/Line.java
new file mode 100644
index 000000000..62d284bd8
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/Line.java
@@ -0,0 +1,150 @@
+/* An input or output line
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+/**
+ * A Line represents a single input or output audio line.
+ * @since 1.3
+ */
+public interface Line
+{
+ /**
+ * An object of this type holds information about a Line.
+ * @since 1.3
+ */
+ class Info
+ {
+ private Class klass;
+
+ /**
+ * Create a new Info object. The argument is the class of the line,
+ * for instance TargetDataLine.class.
+ * @param klass the class of the line
+ */
+ public Info(Class<?> klass)
+ {
+ this.klass = klass;
+ }
+
+ /**
+ * Return the line's class.
+ */
+ public Class<?> getLineClass()
+ {
+ return klass;
+ }
+
+ /**
+ * Return true if this Info object matches the given object.
+ * @param other the object to match
+ * @return true if they match, false otherwise
+ */
+ public boolean matches(Info other)
+ {
+ return klass.equals(other.klass);
+ }
+
+ /**
+ * Return a description of this Info object.
+ */
+ public String toString()
+ {
+ return klass.toString();
+ }
+ }
+
+ /**
+ * Add a listener which will be notified whenever this Line changes state.
+ * @param listener the listener to notify
+ */
+ void addLineListener(LineListener listener);
+
+ /**
+ * Close this line.
+ */
+ void close();
+
+ /**
+ * Return the control associated with this Line that matches the
+ * argument.
+ * @param what the type of the control to match
+ * @return the associated control
+ * @throws IllegalArgumentException if a control of this type is not
+ * available for this line
+ */
+ Control getControl(Control.Type what);
+
+ /**
+ * Return an array of controls associated with this Line. Note that
+ * this method will not return null -- if there are no controls, it
+ * will return a zero-length array.
+ */
+ Control[] getControls();
+
+ /**
+ * Return the Info object associated with this Line.
+ */
+ Info getLineInfo();
+
+ /**
+ * Return true if a Control matching the argument is available for this
+ * Line, false otherwise.
+ * @param what the type of the control to match
+ */
+ boolean isControlSupported(Control.Type what);
+
+ /**
+ * Return true if this line is open, false otherwise.
+ */
+ boolean isOpen();
+
+ /**
+ * Open this line.
+ * @throws LineUnavailableException if the line is unavailable for some
+ * reason
+ */
+ void open() throws LineUnavailableException;
+
+ /**
+ * Remove the listener from this Line; after this call the listener will
+ * no longer be notified when this Line changes state.
+ * @param listener the listener to remove
+ */
+ void removeLineListener(LineListener listener);
+}
diff --git a/libjava/classpath/javax/sound/sampled/LineEvent.java b/libjava/classpath/javax/sound/sampled/LineEvent.java
new file mode 100644
index 000000000..43a184cae
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/LineEvent.java
@@ -0,0 +1,170 @@
+/*
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.EventObject;
+
+/**
+ * This class holds information about a state change of a Line.
+ * @specnote This class is not really serializable, and attempts to
+ * serialize it will throw {@link NotSerializableException}.
+ * @since 1.3
+ */
+public class LineEvent extends EventObject
+{
+ // We define this even though this class can't be serialized, in
+ // order to placate the compiler.
+ private static final long serialVersionUID = -1274246333383880410L;
+
+ /**
+ * This class represents the kinds of state changes that can occur
+ * to a Line. The standard states are availabe as static instances.
+ * @since 1.3
+ */
+ public static class Type
+ {
+ /** An event of this type is posted when a Line closes. */
+ public static final Type CLOSE = new Type("close");
+
+ /** An event of this type is posted when a Line opens. */
+ public static final Type OPEN = new Type("open");
+
+ /** An event of this type is posted when a Line starts. */
+ public static final Type START = new Type("start");
+
+ /** An event of this type is posted when a Line stops. */
+ public static final Type STOP = new Type("stop");
+
+ private String name;
+
+ /**
+ * Create a new type with the indicated name.
+ * @param name the name
+ */
+ protected Type(String name)
+ {
+ this.name = name;
+ }
+
+ public final boolean equals(Object o)
+ {
+ return super.equals(o);
+ }
+
+ public final int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ /**
+ * Return the name of this Type.
+ */
+ public String toString()
+ {
+ return name;
+ }
+ }
+
+ private Type type;
+ private long framePosition;
+ private Line line;
+
+ /**
+ * Create a new LineEvent with the indicated line, type, and frame position.
+ * @param line the line
+ * @param type the type of the event
+ * @param pos the frame position
+ */
+ public LineEvent(Line line, Type type, long pos)
+ {
+ super(line);
+ this.line = line;
+ this.type = type;
+ this.framePosition = pos;
+ }
+
+ /**
+ * Return the frame position associated with this event.
+ */
+ public final long getFramePosition()
+ {
+ return framePosition;
+ }
+
+ /**
+ * Return the Line associated with this event.
+ */
+ public final Line getLine()
+ {
+ return line;
+ }
+
+ /**
+ * Return the Type associated with this event.
+ */
+ public final Type getType()
+ {
+ return type;
+ }
+
+ /**
+ * Return a description of this event.
+ */
+ public String toString()
+ {
+ return ("type=" + type + "; framePosition=" + framePosition
+ + "line=" + line);
+ }
+
+ private void readObject(ObjectInputStream ois)
+ throws IOException
+ {
+ throw new NotSerializableException("LineEvent is not serializable");
+ }
+
+ private void writeObject(ObjectOutputStream oos)
+ throws IOException
+ {
+ throw new NotSerializableException("LineEvent is not serializable");
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/LineListener.java b/libjava/classpath/javax/sound/sampled/LineListener.java
new file mode 100644
index 000000000..1b87c0279
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/LineListener.java
@@ -0,0 +1,55 @@
+/* Listener for Lines
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+import java.util.EventListener;
+
+/**
+ * This interface is used by classes which wish to be notified
+ * when the state of a Line changes.
+ * @since 1.3
+ */
+public interface LineListener extends EventListener
+{
+ /**
+ * This is called when the line's status changes.
+ * @param ev the event describing the change
+ */
+ void update(LineEvent ev);
+}
diff --git a/libjava/classpath/javax/sound/sampled/LineUnavailableException.java b/libjava/classpath/javax/sound/sampled/LineUnavailableException.java
new file mode 100644
index 000000000..a4655fffd
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/LineUnavailableException.java
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+/** @since 1.3 */
+public class LineUnavailableException extends Exception
+{
+ private static final long serialVersionUID = -2046718279487432130L;
+
+ /**
+ * Create a new LineUnavailableException.
+ */
+ public LineUnavailableException()
+ {
+ }
+
+ /**
+ * Create a new LineUnavailableException with the given message.
+ * @param msg the message
+ */
+ public LineUnavailableException(String msg)
+ {
+ super(msg);
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/Mixer.java b/libjava/classpath/javax/sound/sampled/Mixer.java
new file mode 100644
index 000000000..dd400f94d
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/Mixer.java
@@ -0,0 +1,206 @@
+/* Mixers
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+/**
+ * A Mixer is a Line which itself holds multiple lines.
+ * @since 1.3
+ */
+public interface Mixer extends Line
+{
+ /**
+ * An Info object describes a mixer.
+ * @since 1.3
+ */
+ class Info
+ {
+ private String name;
+ private String description;
+ private String vendor;
+ private String version;
+
+ /**
+ * Create a new mixer description.
+ * @param name the name of the mixer
+ * @param vendor the vendor
+ * @param desc a descriptive string
+ * @param vers the mixer's version
+ */
+ protected Info(String name, String vendor, String desc, String vers)
+ {
+ this.name = name;
+ this.description = desc;
+ this.vendor = vendor;
+ this.version = vers;
+ }
+
+ public final boolean equals(Object o)
+ {
+ return super.equals(o);
+ }
+
+ public final int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ /**
+ * Return the name of the mixer.
+ */
+ public final String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Return the mixer's description.
+ */
+ public final String getDescription()
+ {
+ return description;
+ }
+
+ /**
+ * Return the mixer's vendor.
+ */
+ public final String getVendor()
+ {
+ return vendor;
+ }
+
+ /**
+ * Return the mixer's version.
+ */
+ public final String getVersion()
+ {
+ return version;
+ }
+
+ public final String toString()
+ {
+ return ("name=" + name + "; description=" + description
+ + "; vendor=" + vendor + "; version=" + version);
+ }
+ }
+
+ /**
+ * Return a Line associated with this Mixer, given its description.
+ * @param info the description of the line to find
+ * @return the corresponding Line
+ * @throws LineUnavailableException if no Line matching the description
+ * exists in this Mixer
+ */
+ Line getLine(Line.Info info) throws LineUnavailableException;
+
+ /**
+ * Return the number of lines matching this description.
+ * @param info the description of the lines to find.
+ */
+ int getMaxLines(Line.Info info);
+
+ /**
+ * Return an Info object describing this Mixer.
+ */
+ Info getMixerInfo();
+
+ /**
+ * Return an array of Info objects describing all the source lines
+ * available in this Mixer.
+ */
+ Line.Info[] getSourceLineInfo();
+
+ /**
+ * Return an array of Info objects describing all the source lines
+ * available in this Mixer, which match the provided decsription.
+ * @param info the description of the source lines to find
+ */
+ Line.Info[] getSourceLineInfo(Line.Info info);
+
+ /**
+ * Return an array of all the source lines available in this Mixer.
+ */
+ Line[] getSourceLines();
+
+ /**
+ * Return an array of Info objects describing all the target lines
+ * available in this Mixer.
+ */
+ Line.Info[] getTargetLineInfo();
+
+ /**
+ * Return an array of Info objects describing all the target lines
+ * available in this Mixer, which match the provided decsription.
+ * @param info the description of the target lines to find
+ */
+ Line.Info[] getTargetLineInfo(Line.Info info);
+
+ /**
+ * Return an array of all the target lines available in this Mixer.
+ */
+ Line[] getTargetLines();
+
+ /**
+ * Return true if a Line matching the given description is supported
+ * by this Mixer, false otherwise.
+ * @param info the description of the line to find
+ */
+ boolean isLineSupported(Line.Info info);
+
+ /**
+ * Return true if this Mixer supports synchronization of the given set
+ * of lines.
+ * @param lines the lines to check
+ * @param sync true if the synchronization must be accurate at all times
+ */
+ boolean isSynchronizationSupported(Line[] lines, boolean sync);
+
+ /**
+ * Start synchronization on the given set of lines.
+ * @param lines the lines to synchronize, or null for all the lines
+ * @param sync true if the synchronization must be accurate at all times
+ * @throws IllegalArgumentException if the lines cannot be synchronized
+ */
+ void synchronize(Line[] lines, boolean sync);
+
+ /**
+ * Stop synchronization for the given set of lines.
+ * @param lines the lines to unsynchronize, or null for all the lines
+ */
+ void unsynchronize(Line[] lines);
+}
diff --git a/libjava/classpath/javax/sound/sampled/Port.java b/libjava/classpath/javax/sound/sampled/Port.java
new file mode 100644
index 000000000..292e1f151
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/Port.java
@@ -0,0 +1,135 @@
+/*
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+/**
+ * A Port is a Line which represents an audio device, for instance
+ * a microphone.
+ *
+ * @since 1.3
+ */
+public interface Port extends Line
+{
+ /**
+ * This describes a single port.
+ * @since 1.3
+ */
+ class Info extends Line.Info
+ {
+ // FIXME names?
+
+ /** A CD player. */
+ public static final Info COMPACT_DISC = new Info(Port.class,
+ "Compact Disc",
+ true);
+
+ /** Headphones. */
+ public static final Info HEADPHONE = new Info(Port.class, "Headphone",
+ false);
+
+ /** Generic input line. */
+ public static final Info LINE_IN = new Info(Port.class, "Line in",
+ true);
+
+ /** Generic output line. */
+ public static final Info LINE_OUT = new Info(Port.class, "Line out",
+ false);
+
+ /** A microphone. */
+ public static final Info MICROPHONE = new Info(Port.class, "Microphone",
+ true);
+
+ /** A speaker. */
+ public static final Info SPEAKER = new Info(Port.class, "Speaker",
+ false);
+
+ private String name;
+ private boolean isSource;
+
+ /**
+ * Create a new Info object, given the line's class, the name,
+ * and an argument indicating whether this is an input or an output.
+ * @param klass the class of the line
+ * @param name the name of the line
+ * @param isSource true if this is an input source
+ */
+ public Info(Class<?> klass, String name, boolean isSource)
+ {
+ super(klass);
+ this.name = name;
+ this.isSource = isSource;
+ }
+
+ public final boolean equals(Object o)
+ {
+ return super.equals(o);
+ }
+
+ public final int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ /**
+ * Return the name of this object.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Return true if this describes an input line.
+ */
+ public boolean isSource()
+ {
+ return isSource;
+ }
+
+ public boolean matches(Line.Info other)
+ {
+ return super.matches(other) && equals(other);
+ }
+
+ public final String toString()
+ {
+ return super.toString() + "; name=" + name + "; isSource=" + isSource;
+ }
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/ReverbType.java b/libjava/classpath/javax/sound/sampled/ReverbType.java
new file mode 100644
index 000000000..79a4b4945
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/ReverbType.java
@@ -0,0 +1,144 @@
+/* Reverb attributes
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+/**
+ * This represents a reverb effect which can be applied to an audio signal.
+ * @since 1.3
+ */
+public class ReverbType
+{
+ private String name;
+ private int earlyReflectionDelay;
+ private float earlyReflectionIntensity;
+ private int lateReflectionDelay;
+ private float lateReflectionIntensity;
+ private int decayTime;
+
+ /**
+ * Create a new ReverbType given its attributes.
+ * @param name the name of this type
+ * @param earlyDelay the early delay time in microseconds
+ * @param earlyInten the early intensity in decibels
+ * @param lateDelay the late delay time in microseconds
+ * @param lateInten the late intensity in decibels
+ * @param decay the decay time in microseconds
+ */
+ protected ReverbType(String name, int earlyDelay, float earlyInten,
+ int lateDelay, float lateInten, int decay)
+ {
+ this.name = name;
+ this.earlyReflectionDelay = earlyDelay;
+ this.earlyReflectionIntensity = earlyInten;
+ this.lateReflectionDelay = lateDelay;
+ this.lateReflectionIntensity = lateInten;
+ this.decayTime = decay;
+ }
+
+ public final boolean equals(Object o)
+ {
+ return super.equals(o);
+ }
+
+ public final int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ /**
+ * Return the decay time.
+ */
+ public final int getDecayTime()
+ {
+ return decayTime;
+ }
+
+ /**
+ * Return the early reflection delay.
+ */
+ public final int getEarlyReflectionDelay()
+ {
+ return earlyReflectionDelay;
+ }
+
+ /**
+ * Return the early reflection intensity.
+ */
+ public final float getEarlyReflectionIntensity()
+ {
+ return earlyReflectionIntensity;
+ }
+
+ /**
+ * Return the late reflection delay.
+ */
+ public final int getLateReflectionDelay()
+ {
+ return lateReflectionDelay;
+ }
+
+ /**
+ * Return the late reflection intensity.
+ */
+ public final float getLateReflectionIntensity()
+ {
+ return lateReflectionIntensity;
+ }
+
+ /**
+ * Return the name of this ReverbType.
+ * @since 1.5
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Return a description of this ReverbType.
+ */
+ public final String toString()
+ {
+ return ("name=" + name + "; earlyReflectionDelay=" + earlyReflectionDelay
+ + "; earlyReflectionIntensity=" + earlyReflectionIntensity
+ + "; lateReflectionDelay=" + lateReflectionDelay
+ + "; lateReflectionIntensity=" + lateReflectionIntensity
+ + "; decayTime=" + decayTime);
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/SourceDataLine.java b/libjava/classpath/javax/sound/sampled/SourceDataLine.java
new file mode 100644
index 000000000..6e73d6d9c
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/SourceDataLine.java
@@ -0,0 +1,77 @@
+/* Output data line.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+/**
+ * This is a DataLine to which data may be written.
+ * @since 1.3
+ */
+public interface SourceDataLine extends DataLine
+{
+ /**
+ * Open the line, given the desired audio format.
+ * @param fmt the format to use
+ * @throws LineUnavailableException if the line is not available for
+ * some reason
+ * @throws SecurityException if this is prevented by the security manager
+ */
+ void open(AudioFormat fmt)
+ throws LineUnavailableException;
+
+ /**
+ * Open the line, given the desired audio format and the buffer size.
+ * @param fmt the format to use
+ * @param size the buffer size
+ * @throws LineUnavailableException if the line is not available for
+ * some reason
+ * @throws SecurityException if this is prevented by the security manager
+ */
+ void open(AudioFormat fmt, int size)
+ throws LineUnavailableException;
+
+ /**
+ * Write audio data to this line. The data must be an integral number
+ * of frames, as determined by the audio format.
+ * @param buf a byte array of audio data
+ * @param offset index of the first byte in the array to use
+ * @param length the number of bytes to write
+ * @return the number of bytes written
+ */
+ int write(byte[] buf, int offset, int length);
+}
diff --git a/libjava/classpath/javax/sound/sampled/TargetDataLine.java b/libjava/classpath/javax/sound/sampled/TargetDataLine.java
new file mode 100644
index 000000000..61ad344ef
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/TargetDataLine.java
@@ -0,0 +1,79 @@
+/* Input data line.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+/**
+ * This is a DataLine from which data may be read.
+ * @since 1.3
+ */
+public interface TargetDataLine extends DataLine
+{
+ /**
+ * Open the line using the indicated audio format.
+ * @param fmt the format to use
+ * @throws LineUnavailableException if the line is not available for
+ * some reason
+ * @throws SecurityException if this operation is prevented by the
+ * security manager
+ */
+ void open(AudioFormat fmt)
+ throws LineUnavailableException;
+
+ /**
+ * Open the line using the indicated audio format and buffer size.
+ * @param fmt the format to use
+ * @throws LineUnavailableException if the line is not available for
+ * some reason
+ * @throws SecurityException if this operation is prevented by the
+ * security manager
+ */
+ void open(AudioFormat fmt, int size)
+ throws LineUnavailableException;
+
+ /**
+ * Read data from the line into the given buffer. The requested data
+ * should be an integral number of framaes, as determined by the audio
+ * format.
+ * @param buf the buffer into which the data is put
+ * @param offset the initial offset at which to write
+ * @param length the maximum number of bytes to read
+ * @return the actual number of bytes read
+ */
+ int read(byte[] buf, int offset, int length);
+}
diff --git a/libjava/classpath/javax/sound/sampled/UnsupportedAudioFileException.java b/libjava/classpath/javax/sound/sampled/UnsupportedAudioFileException.java
new file mode 100644
index 000000000..1399b61a8
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/UnsupportedAudioFileException.java
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled;
+
+/**
+ * An exception of this type is thrown when an operation is attempted
+ * on a file whose format is unrecognized.
+ * @since 1.3
+ */
+public class UnsupportedAudioFileException extends Exception
+{
+ private static final long serialVersionUID = -139127412623160368L;
+
+ /**
+ * Create a new UnsupportedAudioFileException.
+ */
+ public UnsupportedAudioFileException()
+ {
+ }
+
+ /**
+ * Create a new UnsupportedAudioFileException with the indicated message.
+ * @param msg the message
+ */
+ public UnsupportedAudioFileException(String msg)
+ {
+ super(msg);
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/spi/AudioFileReader.java b/libjava/classpath/javax/sound/sampled/spi/AudioFileReader.java
new file mode 100644
index 000000000..098190f0f
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/spi/AudioFileReader.java
@@ -0,0 +1,146 @@
+/* Audio file reader API
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled.spi;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.UnsupportedAudioFileException;
+
+/**
+ * This abstract class defines the interface to audio file readers.
+ * A concrete provider subclass will implement the methods declared
+ * here. These methods can be used to determine the format of
+ * files, and to retrieve an AudioInputStream for a file.
+ * @since 1.3
+ */
+public abstract class AudioFileReader
+{
+ /**
+ * The default constructor. Note that this class is abstract and
+ * thus not directly instantiable.
+ */
+ public AudioFileReader()
+ {
+ }
+
+ /**
+ * Return the format of the given file as deduced by this provider.
+ * If the format of the file is not recognized, throws an exception.
+ * This will also throw an exception if there is an I/O error when
+ * reading the file.
+ * @param file the file to examine
+ * @return the audio file format
+ * @throws UnsupportedAudioFileException if the file's format is not
+ * recognized
+ * @throws IOException if there is an I/O error while reading the file
+ */
+ public abstract AudioFileFormat getAudioFileFormat(File file)
+ throws UnsupportedAudioFileException, IOException;
+
+ /**
+ * Return the format of the given input stream as deduced by this provider.
+ * If the format of the stream is not recognized, throws an exception.
+ * This will also throw an exception if there is an I/O error when
+ * reading the stream. Note that providers typically use mark and reset
+ * on the stream when examining the data, and as a result an IOException
+ * may be thrown if the stream does not support these.
+ * @param is the stream to examine
+ * @return the audio file format
+ * @throws UnsupportedAudioFileException if the stream's format is not
+ * recognized
+ * @throws IOException if there is an I/O error while reading the stream
+ */
+ public abstract AudioFileFormat getAudioFileFormat(InputStream is)
+ throws UnsupportedAudioFileException, IOException;
+
+ /**
+ * Return the format of the given URL as deduced by this provider.
+ * If the format of the URL is not recognized, throws an exception.
+ * This will also throw an exception if there is an I/O error when
+ * reading the URL.
+ * @param url the URL to examine
+ * @return the audio file format
+ * @throws UnsupportedAudioFileException if the URL's format is not
+ * recognized
+ * @throws IOException if there is an I/O error while reading the URL
+ */
+ public abstract AudioFileFormat getAudioFileFormat(URL url)
+ throws UnsupportedAudioFileException, IOException;
+
+ /**
+ * Return an AudioInputStream for the given file. The file is assumed
+ * to hold valid audio data.
+ * @param file the file to read
+ * @return an AudioInputStream for the file
+ * @throws UnsupportedAudioFileException if the file's type is not
+ * recognized
+ * @throws IOException if there is an error while reading the file
+ */
+ public abstract AudioInputStream getAudioInputStream(File file)
+ throws UnsupportedAudioFileException, IOException;
+
+ /**
+ * Return an AudioInputStream wrapping the given input stream. The stream
+ * is assumed to hold valid audio data.
+ * @param is the input stream to wrap
+ * @return an AudioInputStream for the stream
+ * @throws UnsupportedAudioFileException if the stream's type is not
+ * recognized
+ * @throws IOException if there is an error while reading the stream
+ */
+ public abstract AudioInputStream getAudioInputStream(InputStream is)
+ throws UnsupportedAudioFileException, IOException;
+
+ /**
+ * Return an AudioInputStream for the given URL. The URL is assumed
+ * to hold valid audio data.
+ * @param url the URL to read
+ * @return an AudioInputStream for the URL
+ * @throws UnsupportedAudioFileException if the URL's type is not
+ * recognized
+ * @throws IOException if there is an error while reading the URL
+ */
+ public abstract AudioInputStream getAudioInputStream(URL url)
+ throws UnsupportedAudioFileException, IOException;
+}
diff --git a/libjava/classpath/javax/sound/sampled/spi/AudioFileWriter.java b/libjava/classpath/javax/sound/sampled/spi/AudioFileWriter.java
new file mode 100644
index 000000000..82f9b31b8
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/spi/AudioFileWriter.java
@@ -0,0 +1,131 @@
+/* Audio file writer API
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled.spi;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioInputStream;
+
+/**
+ * This abstract class provides an API for writing audio files. Concrete
+ * subclasses implement the methods declared here.
+ * @since 1.3
+ */
+public abstract class AudioFileWriter
+{
+ /**
+ * Creat a new audio file writer.
+ */
+ public AudioFileWriter()
+ {
+ }
+
+ /**
+ * Return an array of all audio file format types supported by this
+ * provider.
+ */
+ public abstract AudioFileFormat.Type[] getAudioFileTypes();
+
+ /**
+ * Return an array of all the audio file format types supported by this
+ * provider, which can be written given the input stream.
+ * @param ais the audio input stream
+ */
+ public abstract AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream ais);
+
+ /**
+ * Return true if the indicated type is supported by this provider.
+ * @param type the audio file format type
+ */
+ public boolean isFileTypeSupported(AudioFileFormat.Type type)
+ {
+ AudioFileFormat.Type[] types = getAudioFileTypes();
+ for (int i = 0; i < types.length; ++i)
+ {
+ if (type.equals(types[i]))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return true if the indicated type is supported by this provider,
+ * and can be written from the given audio input stream.
+ * @param type the audio file format type
+ * @param ais the audio input stream to write
+ */
+ public boolean isFileTypeSupported(AudioFileFormat.Type type,
+ AudioInputStream ais)
+ {
+ AudioFileFormat.Type[] types = getAudioFileTypes(ais);
+ for (int i = 0; i < types.length; ++i)
+ {
+ if (type.equals(types[i]))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Write audio data to a file.
+ * @param ais the audio input stream to write
+ * @param type the desired audio file format type
+ * @param out the file to write to
+ * @return the number of bytes written
+ * @throws IOException if an I/O error occurs when writing
+ */
+ public abstract int write(AudioInputStream ais, AudioFileFormat.Type type,
+ File out)
+ throws IOException;
+
+ /**
+ * Write audio data to an output stream.
+ * @param ais the audio input stream to write
+ * @param type the desired audio file format type
+ * @param os the output stream
+ * @return the number of bytes written
+ * @throws IOException if an I/O error occurs when writing
+ */
+ public abstract int write(AudioInputStream ais, AudioFileFormat.Type type,
+ OutputStream os)
+ throws IOException;
+}
diff --git a/libjava/classpath/javax/sound/sampled/spi/FormatConversionProvider.java b/libjava/classpath/javax/sound/sampled/spi/FormatConversionProvider.java
new file mode 100644
index 000000000..b9d3e9d10
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/spi/FormatConversionProvider.java
@@ -0,0 +1,179 @@
+/* Format conversion API
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled.spi;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
+
+/**
+ * A format conversion provider supplies methods for converting between
+ * different audio formats. This abstract class defines the interface
+ * to this functionality; concrete subclasses will implement the methods
+ * declared here.
+ * @since 1.3
+ */
+public abstract class FormatConversionProvider
+{
+ /**
+ * Create a new format conversion provider.
+ */
+ public FormatConversionProvider()
+ {
+ }
+
+ /**
+ * Return an audio input stream given the desired target encoding and
+ * another audio input stream. The data in the given stream will be
+ * converted to the desired encoding.
+ * @param encoding the encoding
+ * @param source the source audio input stream
+ * @return a new audio input stream
+ * @throws IllegalArgumentException if the conversion is not supported
+ */
+ public abstract AudioInputStream getAudioInputStream(AudioFormat.Encoding encoding,
+ AudioInputStream source);
+
+ /**
+ * Return an audio input stream given the desired target format and
+ * another audio input stream. The data in the given stream will be
+ * converted to the desired format.
+ * @param format the format
+ * @param source the source audio input stream
+ * @return a new audio input stream
+ * @throws IllegalArgumentException if the conversion is not supported
+ */
+ public abstract AudioInputStream getAudioInputStream(AudioFormat format,
+ AudioInputStream source);
+
+ /**
+ * Return an array of all the source encodings supported by this conversion
+ * provider.
+ */
+ public abstract AudioFormat.Encoding[] getSourceEncodings();
+
+ /**
+ * Return an array of all the target encodings supported by this conversion
+ * provider.
+ */
+ public abstract AudioFormat.Encoding[] getTargetEncodings();
+
+ /**
+ * Return an array of all the target encodings that are available for a given
+ * source format.
+ * @param fmt the source format
+ * @return an array of supported target encodings
+ */
+ public abstract AudioFormat.Encoding[] getTargetEncodings(AudioFormat fmt);
+
+ /**
+ * Return a array of all the target formats that match given target encoding,
+ * and to which this provider can convert the source format.
+ * @param targ the target encoding to match
+ * @param src the source format
+ * @return an array of supported target formats
+ */
+ public abstract AudioFormat[] getTargetFormats(AudioFormat.Encoding targ,
+ AudioFormat src);
+
+ /**
+ * Return true if this provider supports conversion from the given
+ * source format to the given target encoding.
+ * @param targ the target encoding
+ * @param src the source format
+ * @return true if the conversion is supported
+ */
+ public boolean isConversionSupported(AudioFormat.Encoding targ,
+ AudioFormat src)
+ {
+ AudioFormat.Encoding[] encodings = getTargetEncodings(src);
+ for (int i = 0; i < encodings.length; ++i)
+ {
+ if (targ.equals(encodings[i]))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return true if this provider supports conversions from the given
+ * source format to the given target format.
+ * @param targ the source format
+ * @param src the target format
+ * @return true if the conversion is supported
+ */
+ public boolean isConversionSupported(AudioFormat targ, AudioFormat src)
+ {
+ AudioFormat[] encodings = getTargetFormats(targ.getEncoding(), src);
+ return encodings.length > 0;
+ }
+
+ /**
+ * Return true if an encoding matching the argument is supported as a
+ * source encoding by this provider.
+ * @param src the source encoding
+ * @return true if it is supported
+ */
+ public boolean isSourceEncodingSupported(AudioFormat.Encoding src)
+ {
+ AudioFormat.Encoding[] srcs = getSourceEncodings();
+ for (int i = 0; i < srcs.length; ++i)
+ {
+ if (src.equals(srcs[i]))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return true if an encoding matching the argument is supported as a
+ * target encoding by this provider.
+ * @param targ the target encoding
+ * @return true if it is supported
+ */
+ public boolean isTargetEncodingSupported(AudioFormat.Encoding targ)
+ {
+ AudioFormat.Encoding[] encodings = getTargetEncodings();
+ for (int i = 0; i < encodings.length; ++i)
+ {
+ if (targ.equals(encodings[i]))
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/libjava/classpath/javax/sound/sampled/spi/MixerProvider.java b/libjava/classpath/javax/sound/sampled/spi/MixerProvider.java
new file mode 100644
index 000000000..72b972497
--- /dev/null
+++ b/libjava/classpath/javax/sound/sampled/spi/MixerProvider.java
@@ -0,0 +1,86 @@
+/* Mixer API
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.sampled.spi;
+
+import javax.sound.sampled.Mixer;
+
+/**
+ * This abstract class defines an interface to mixer providers.
+ * Concrete subclasses will implement the methods in this class.
+ * @since 1.3
+ */
+public abstract class MixerProvider
+{
+ /**
+ * Create a new mixer provider.
+ */
+ public MixerProvider()
+ {
+ }
+
+ /**
+ * Return a mixer that matches the given info object.
+ * @param info description of the mixer to match
+ * @return the mixer
+ * @throws IllegalArgumentException if no mixer matches the description
+ */
+ public abstract Mixer getMixer(Mixer.Info info);
+
+ /**
+ * Return an array of info objects describing all the mixers provided by
+ * this provider.
+ */
+ public abstract Mixer.Info[] getMixerInfo();
+
+ /**
+ * Return true if a mixer matching the provided description is supported.
+ * @param info description of the mixer to match
+ * @return true if it is supported by this provider
+ */
+ 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;
+ }
+}