* occured
*/
public boolean setupSound(InputStream in, Mixer mixer) {
if (started == false) {
InputStream audioStream = in;
AudioFormat audioFormat;
if (mixer == null) {
log.error("Playback device is already in use.");
return false;
}
try {
if (audioStream instanceof AudioInputStream) {
audioInputStream = (AudioInputStream) audioStream;
} else {
audioInputStream = AudioSystem
.getAudioInputStream(audioStream);
}
} catch (Exception e) {
log.error("InputStream is not an AudioStream", e);
return false;
}
audioFormat = audioInputStream.getFormat();
DataLine.Info info = new DataLine.Info(SourceDataLine.class,
audioFormat);
// If the audioFormat is not directly supported
if (!AudioSystem.isLineSupported(info)) {
AudioFormat targetFormat = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED, 44100.0F, 16, 1, 2,
44100.0F, false);
audioInputStream = AudioSystem.getAudioInputStream(
targetFormat, audioInputStream);
audioFormat = audioInputStream.getFormat();