mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 16:42:27 +00:00
Handle corrupt sud files
Better handling of corrupt sud files which will not return a valid audioinputstream. These will be gracelessly skipped during analysis.
This commit is contained in:
parent
62148351c6
commit
d207325b2d
@ -104,9 +104,13 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
|||||||
boolean ans = super.prepareInputFile();
|
boolean ans = super.prepareInputFile();
|
||||||
if (ans == false && ++currentFile < allFiles.size()) {
|
if (ans == false && ++currentFile < allFiles.size()) {
|
||||||
System.out.println("Failed to open sound file. Try again with file " + allFiles.get(currentFile).getName());
|
System.out.println("Failed to open sound file. Try again with file " + allFiles.get(currentFile).getName());
|
||||||
|
/*
|
||||||
|
* jumping striaght to the next file messes it up if it thinks the files
|
||||||
|
* are continuous, so we HAVE to stop and restart.
|
||||||
|
*/
|
||||||
|
// return prepareInputFile();
|
||||||
PamController.getInstance().pamStop();
|
PamController.getInstance().pamStop();
|
||||||
PamController.getInstance().startLater();
|
PamController.getInstance().startLater(false);
|
||||||
}
|
}
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
@ -648,7 +652,17 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
|
|||||||
}
|
}
|
||||||
setFolderProgress();
|
setFolderProgress();
|
||||||
// sayEta();
|
// sayEta();
|
||||||
ans = prepareInputFile();
|
/*
|
||||||
|
* I think that here, we just need a check of the file. the prepareInputFile in
|
||||||
|
* this class will (on failure) move straight to the next file and also issue a
|
||||||
|
* stop/start, which is not good if it's trying a continuous file, where this is
|
||||||
|
* being called, if false is returned it should manage moving onto the next file by
|
||||||
|
* itself if we use the super.prep ....
|
||||||
|
*/
|
||||||
|
ans = super.prepareInputFile();
|
||||||
|
if (ans == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
currentFileStart = System.currentTimeMillis();
|
currentFileStart = System.currentTimeMillis();
|
||||||
// if (ans && audioFormat.getSampleRate() != currentSampleRate && currentFile > 0) {
|
// if (ans && audioFormat.getSampleRate() != currentSampleRate && currentFile > 0) {
|
||||||
// acquisitionControl.getDaqProcess().setSampleRate(currentSampleRate = audioFormat.getSampleRate(), true);
|
// acquisitionControl.getDaqProcess().setSampleRate(currentSampleRate = audioFormat.getSampleRate(), true);
|
||||||
|
@ -48,9 +48,9 @@ public class SudAudioFile extends WavAudioFile {
|
|||||||
}
|
}
|
||||||
// don't do anything and it will try the built in Audiosystem
|
// don't do anything and it will try the built in Audiosystem
|
||||||
catch (UnsupportedAudioFileException e) {
|
catch (UnsupportedAudioFileException e) {
|
||||||
System.err.println("Could not open sud file: not a supported file " + soundFile.getName());
|
System.err.println("UnsupportedAudioFileException: Could not open sud file: not a supported file " + soundFile.getName());
|
||||||
|
System.err.println(e.getMessage());
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("Could not open sud file: IO Exception: " + soundFile.getName());
|
System.err.println("Could not open sud file: IO Exception: " + soundFile.getName());
|
||||||
|
|
||||||
|
@ -46,7 +46,8 @@ public class SudAudioFileReader {
|
|||||||
try {
|
try {
|
||||||
sudAudioInputStream = SudAudioInputStream.openInputStream(file, sudParams, false);
|
sudAudioInputStream = SudAudioInputStream.openInputStream(file, sudParams, false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
String msg = String.format("Corrupt sud file %s: %s", file.getName(), e.getMessage());
|
||||||
|
throw new UnsupportedAudioFileException(msg);
|
||||||
}
|
}
|
||||||
return sudAudioInputStream;
|
return sudAudioInputStream;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user