Methods Summary |
---|
private static int | bufferSize(javax.media.format.AudioFormat f)
int bufferSize = 0;
bufferSize = 256*1024;
return ++bufferSize; // make it an odd number
|
public void | flush()
super.flush();
|
public int | getSampleCountHigh()
/*
* We are doing this since the JNI doesn't seem to like getSamplesPlayed().
* which returns a long instead of an int for some reason...
*/
long pos = dataLine.getFramePosition();
// Check for wrap around
if (pos < lastPos) {
totalCount += lastPos - originPos;
originPos = pos;
}
lastPos = pos;
long s = totalCount + pos - originPos - count + JSHackSampleCount;
if (s == JSHackSample) {
if (JSHackCount++ > MAX_TOLERENCE) {
JSHackSampleCount += JSHackIncr;
JSHackCount = 0;
}
} else {
JSHackCount = 0;
JSHackSample = s;
}
sampleCountLow = (int) (s & 0xFFFFFFFFL);
return (int) ((s >> 32) & 0xFFFFFFFFL);
|
public int | getSampleCountLow()
return sampleCountLow;
|
public boolean | initialize(javax.media.format.AudioFormat format)
JSHackIncr = (long)(format.getSampleRate() / 60);
return super.initialize(format, bufferSize(format));
|
public void | pause()
synchronized (pauseSync) {
super.pause();
}
|
public void | resetSamples()
if (dataLine != null) {
count = dataLine.getFramePosition();
lastPos = count;
originPos = count;
totalCount = count;
}
JSHackSampleCount = 0;
|
public void | resume()
synchronized (pauseSync) {
super.resume();
}
|
public int | write(byte[] data, int off, int len)
synchronized (pauseSync) {
if (paused) {
System.err.println("writing when paused: " + len);
return len;
}
return super.write(data, off, len);
}
|