From 97a1b18071291625dc832bd32a193c1fae17ff7f Mon Sep 17 00:00:00 2001 From: denny Date: Thu, 31 Dec 2015 10:05:26 -0500 Subject: [PATCH] Adds error handling for module startup to processing chain and adds file existance checking for recording files before attempting to create them. --- src/module/ProcessingChain.java | 9 ++++++++- src/record/wave/WaveWriter.java | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/module/ProcessingChain.java b/src/module/ProcessingChain.java index 8d65b537..5f2ff6cf 100644 --- a/src/module/ProcessingChain.java +++ b/src/module/ProcessingChain.java @@ -417,7 +417,14 @@ public class ProcessingChain implements IChannelEventListener /* Start each of the modules */ for( Module module: mModules ) { - module.start(); + try + { + module.start(); + } + catch( Exception e ) + { + mLog.error( "Error starting module", e ); + } } /* Register with the source to receive sample data. Setup a diff --git a/src/record/wave/WaveWriter.java b/src/record/wave/WaveWriter.java index 1f275099..c5e37b24 100644 --- a/src/record/wave/WaveWriter.java +++ b/src/record/wave/WaveWriter.java @@ -96,6 +96,16 @@ public class WaveWriter implements AutoCloseable */ private void open() throws IOException { + int version = 2; + + while( Files.exists( mFile ) ) + { + mFile = Paths.get( mFile.toFile().getAbsolutePath() + .replace( ".wav", "_" + version + ".wav" ) ); + + version++; + } + Files.createFile( mFile ); mFileChannel = (FileChannel.open( mFile, StandardOpenOption.WRITE ) );