public AudioData getData() throws IOException {
int length = getLength();
//limit the memory to 1M, so too large au file won't load
if (length < 1024*1024) {
byte [] buffer = new byte[length];
try {
ais.read(buffer, 0, length);
} catch (IOException ex) {
throw new IOException("Could not create AudioData Object");
}
return new AudioData(format, buffer);
}
/* acis.setData();
if (acis.stream instanceof ByteArrayInputStream) {
Format[] format = acis.getFormat();
byte[] bytes = acis.getBytes();
if (bytes == null)
throw new IOException("could not create AudioData object: no data received");
return new AudioData((AudioFormat)format[0], bytes);
}
*/
throw new IOException("could not create AudioData object");
}
|