*/
protected boolean decodeFrame() throws JavaLayerException
{
try
{
AudioDevice out = audio;
if (out == null) return false;
Header h = bitstream.readFrame();
if (h == null) return false;
// sample buffer set when decoder constructed
SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, bitstream);
short amplitude = 0;
for(int i = 1; i < output.getBuffer().length; i++) {
output.getBuffer()[i] = (short) (output.getBuffer()[i] * volume);
if(output.getBuffer()[i] > amplitude) {
amplitude = output.getBuffer()[i];
}
}
if(amplitudeListener != null) {
amplitudeListener.getAmplitude(amplitude);
}
synchronized (this)
{
out = audio;
if(out != null)
{
out.write(output.getBuffer(), 0, output.getBufferLength());
}
}
bitstream.closeFrame();
}