Methods Summary |
---|
protected com.sun.media.renderer.audio.device.AudioOutput | createDevice(javax.media.format.AudioFormat format)
return new JavaSoundOutput();
|
public java.lang.Object[] | getControls()
Control c[] = new Control[] {
gainControl,
bufferControl,
peakVolumeMeter
};
return c;
|
public java.lang.String | getName()
return NAME;
|
protected boolean | initDevice(javax.media.format.AudioFormat in)
javax.media.Format newInput = in;
// Free the old ulaw decoder if there's one.
if (ulawDecoder != null) {
ulawDecoder.close();
ulawDecoder = null;
}
// Initialize a ulaw decoder if the input format is ulaw.
Format outs[] = new Format[1];
if (ulawFormat.matches(in)) {
ulawDecoder = SimpleGraphBuilder.findCodec(in, linearFormat, null, outs);
if (ulawDecoder != null) {
ulawOutputFormat = newInput = outs[0];
} else
return false;
}
devFormat = in;
return super.initDevice((javax.media.format.AudioFormat)newInput);
|
public boolean | isExclusive()
// JavaSound can mix audio
return false;
|
public void | open()
if (device == null && inputFormat != null) {
if (!initDevice(inputFormat))
throw new ResourceUnavailableException("Cannot intialize audio device for playback");
device.pause();
}
|
public int | processData(javax.media.Buffer buffer)
if (!checkInput(buffer))
return BUFFER_PROCESSED_FAILED;
// Processing linear data
if (ulawDecoder == null) {
try {
((PeakVolumeMeter)peakVolumeMeter).processData(buffer);
} catch (Throwable t) {
t.printStackTrace();
}
return super.doProcessData(buffer);
}
// Pre-processing ulaw data, then feed it into JavaSound.
if (decodeBuffer == null) {
decodeBuffer = new Buffer();
decodeBuffer.setFormat(ulawOutputFormat);
}
decodeBuffer.setLength(0);
decodeBuffer.setOffset(0);
decodeBuffer.setFlags(buffer.getFlags());
decodeBuffer.setTimeStamp(buffer.getTimeStamp());
decodeBuffer.setSequenceNumber(buffer.getSequenceNumber());
int rc = ulawDecoder.process(buffer, decodeBuffer);
if (rc == BUFFER_PROCESSED_OK) {
try {
((PeakVolumeMeter)peakVolumeMeter).processData(decodeBuffer);
} catch (Throwable t) {
System.err.println(t);
}
return super.doProcessData(decodeBuffer);
}
return BUFFER_PROCESSED_FAILED;
|