mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
Ishmael bugs
couple of places where PamDatablock.getLastUnit() was being used without synchronization and the unit was being deleted between the line checking there was a unit there and a line attempting to use the unit. Now correctly synched so will get a unit you can use, or null.
This commit is contained in:
parent
35ee1e3dfc
commit
6f6f7407ca
@ -79,8 +79,9 @@ public class EnergySumProcess extends IshDetFnProcess {
|
||||
EnergySumParams p = (EnergySumParams)ishDetControl.ishDetParams;
|
||||
PamDataBlock inputDataBlock = getInputDataBlock(); //might be null
|
||||
|
||||
if (inputDataBlock != null && inputDataBlock.getUnitsCount() > 0) {
|
||||
savedGramHeight = ((FFTDataUnit)inputDataBlock.getLastUnit()).getFftData().length();
|
||||
FFTDataUnit lastFFTUnit = ((FFTDataUnit)inputDataBlock.getLastUnit());
|
||||
if (lastFFTUnit != null) {
|
||||
savedGramHeight = lastFFTUnit.getFftData().length();
|
||||
int len = savedGramHeight;
|
||||
//Should be max(1,...) here, but FFT bin 0 has 0's in it.
|
||||
loBin = Math.max(1, (int) Math.floor(len * p.f0 / (sampleRate/2)));
|
||||
|
@ -83,9 +83,14 @@ public class SgramCorrProcess extends IshDetFnProcess
|
||||
protected void prepareMyParams() {
|
||||
SgramCorrParams p = (SgramCorrParams)ishDetControl.ishDetParams;
|
||||
PamDataBlock inputDataBlock = getInputDataBlock();
|
||||
|
||||
if (inputDataBlock != null && inputDataBlock.getUnitsCount() > 0) {
|
||||
savedGramHeight = ((FFTDataUnit)inputDataBlock.getLastUnit()).getFftData().length();
|
||||
/*
|
||||
* get the unit. first, then check it's null. Due to multithreading it's
|
||||
* possible that checking there are units and then asking for one,without
|
||||
* synchronization will crash if the unit is deleted between those two calls.
|
||||
*/
|
||||
FFTDataUnit lastFFTUnit = ((FFTDataUnit)inputDataBlock.getLastUnit());
|
||||
if (lastFFTUnit != null) {
|
||||
savedGramHeight = lastFFTUnit.getFftData().length();
|
||||
/*
|
||||
* fft information is now stored in an FFTDataBLock, so no need to get
|
||||
* back to the process above it.
|
||||
|
Loading…
Reference in New Issue
Block a user