Methods Summary |
---|
public int | available()
if (stream != null) { // InputStream
return Math.min(stream.available(),
(int)((frameLength - framePos) * frameSize));
} else { // TargetDataLine
return line.available();
}
|
public void | close()
if (stream != null) { // InputStream
stream.close();
} else { // TargetDataLine
line.close();
}
|
public javax.sound.sampled.AudioFormat | getFormat()
return format;
|
public long | getFrameLength()
return frameLength;
|
public void | mark(int readlimit)
if (stream != null) { //InputStream
stream.mark(readlimit);
marketFramePos = framePos;
} else { // TargetDataLine
// do nothing
}
|
public boolean | markSupported()
if (stream != null) { //InputStream
return stream.markSupported();
} else { // TargetDataLine
return false;
}
|
public int | read()
if (frameSize != 1) {
// sound.0C=Frame size must be one byte
throw new IOException(Messages.getString("sound.0C")); //$NON-NLS-1$
}
int res;
if (stream != null) { // InputStream
if (framePos == frameLength) {
return 0;
}
res = stream.read();
if (res == -1) {
return -1;
}
framePos += 1;
return res;
} else { // TargetDataLine
if (line.read(oneByte, 0, 1) == 0) {
return -1;
}
framePos = line.getLongFramePosition();
return oneByte[0];
}
|
public int | read(byte[] b)
return read(b, 0, b.length);
|
public int | read(byte[] b, int off, int len)
int l = Math.min(len, (int) ((frameLength - framePos) * frameSize));
l = l - (l % frameSize);
if (l == 0) {
return 0;
}
int res;
if (stream != null) { // InputStream
res = stream.read(b, off, l);
if (res == -1) {
return -1;
}
framePos = framePos + res / frameSize;
return res;
} else { // TargetDataLine
res = line.read(b, off, l);
if (res == 0) {
return -1;
}
framePos = line.getLongFramePosition();
return res;
}
|
public void | reset()
if (stream != null) { //InputStream
stream.reset();
framePos = marketFramePos;
} else { // TargetDataLine
// do nothing
}
|
public long | skip(long n)
if (n < frameSize) {
return 0;
}
byte[] skipBuf = new byte[frameSize];
long skipped = 0;
while (skipped < n) {
int read = read(skipBuf, 0, frameSize);
if (read == -1) {
return skipped;
}
skipped += read;
if (n - skipped < frameSize) {
return skipped;
}
}
return skipped;
|