/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Common conversions etc.
*
* @author Kara Kytle
* @author Florian Bomers
*/
public final class Toolkit {
/**
* Suppresses default constructor, ensuring non-instantiability.
*/
private Toolkit() {
}
/**
* Converts bytes from signed to unsigned.
*/
b[i] += 128;
}
}
/**
* Swaps bytes.
* @throws ArrayOutOfBoundsException if len is not a multiple of 2.
*/
byte tempByte;
tempByte = b[i];
b[i] = b[i+1];
b[i+1] = tempByte;
}
}
/**
* Linear to DB scale conversion.
*/
return dB;
}
/**
* DB to linear scale conversion.
*/
return linear;
}
/*
* returns bytes aligned to a multiple of blocksize
* the return value will be in the range of (bytes-blocksize+1) ... bytes
*/
// prevent null pointers
if (blockSize <= 1) {
return bytes;
}
}
// prevent null pointers
if (blockSize <= 1) {
return bytes;
}
}
/*
* gets the number of bytes needed to play the specified number of milliseconds
*/
}
/*
* gets the time in milliseconds for the given number of bytes
*/
}
/*
* gets the number of bytes needed to play the specified number of microseconds
*/
}
/*
* gets the time in microseconds for the given number of bytes
*/
}
/*
* gets the number of frames needed to play the specified number of microseconds
*/
}
/*
* gets the time in microseconds for the given number of frames
*/
}
// we don't know how to verify possibly non-linear encodings
return;
}
throw new IllegalArgumentException("invalid frame rate: "
}
throw new IllegalArgumentException("invalid sample rate: "
}
throw new IllegalArgumentException("invalid sample size in bits: "
}
throw new IllegalArgumentException("invalid frame size: "
}
throw new IllegalArgumentException("invalid number of channels: "
}
}
return false;
}
return false;
}
return true;
}
// we can't open the device for non-PCM playback, so we have
// convert any other encodings to PCM here (at least we try!)
try {
af.getSampleRate(),
16,
af.getChannels(),
af.getSampleRate(),
Platform.isBigEndian());
} catch (Exception e) {
}
}
return ais;
}
}