// process selected files
for (int i = 0; i < flacFiles.size(); i++) {
File file = (File) flacFiles.get(i);
try {
FileInputStream is = new FileInputStream(file);
FLACDecoder decoder = new FLACDecoder(is);
decoder.readMetadata();
StreamInfo info = decoder.getStreamInfo();
if (masterStreamInfo == null) {
masterStreamInfo = info;
masterStreamInfo.setTotalSamples(0);
}
if (!info.compatiable(masterStreamInfo)) {
appendMsg("Bad StreamInfo " + file + ": " + info);
continue;
}
masterStreamInfo.addTotalSamples(info.getTotalSamples());
SeekPoint seekPoint = new SeekPoint(lastSampleNumber, lastStreamOffset, 0);
//decoder.processMetadata();
long frameStartOffs = decoder.getTotalBytesRead();
PackerFile aFile = new PackerFile(file, seekPoint, frameStartOffs);
albumFiles.add(aFile);
//System.out.println("Do decode " +i);
try {
decoder.decodeFrames();
}
catch (EOFException e) {
//appendMsg("File " + file + ": " + e);
}
//System.out.println("Done decode");
long frameEndOffs = decoder.getTotalBytesRead();
//appendMsg(frameStartOffs + " " + frameEndOffs + " " + decoder.getSamplesDecoded());
lastSampleNumber += decoder.getSamplesDecoded();
lastStreamOffset += frameEndOffs - frameStartOffs;
}
catch (FileNotFoundException e) {
appendMsg("File " + file + ": " + e);
}