From bac38a5bd8527baae2cb128c8f1ffcfb603e3cdf Mon Sep 17 00:00:00 2001 From: Denny Sheirer Date: Sun, 25 Jun 2023 03:56:08 -0400 Subject: [PATCH] #1584 Updates DMR & P25 decoders to stop processing residual samples from the current buffer after a traffic channel shutdown has been signalled. (#1585) Co-authored-by: Dennis Sheirer --- .../dsheirer/dsp/psk/PSKDemodulator.java | 33 +++++++++++++++-- .../dsheirer/module/decode/Decoder.java | 26 +++++++++++--- .../module/decode/dmr/DMRDecoder.java | 34 ++++++++---------- .../decode/p25/phase1/P25P1Decoder.java | 21 +---------- .../decode/p25/phase1/P25P1DecoderC4FM.java | 16 ++++++++- .../decode/p25/phase1/P25P1DecoderLSM.java | 16 ++++++++- .../decode/p25/phase2/P25P2Decoder.java | 21 +---------- .../decode/p25/phase2/P25P2DecoderHDQPSK.java | 36 +++++++++++-------- 8 files changed, 122 insertions(+), 81 deletions(-) diff --git a/src/main/java/io/github/dsheirer/dsp/psk/PSKDemodulator.java b/src/main/java/io/github/dsheirer/dsp/psk/PSKDemodulator.java index 3acf1662..824e118c 100644 --- a/src/main/java/io/github/dsheirer/dsp/psk/PSKDemodulator.java +++ b/src/main/java/io/github/dsheirer/dsp/psk/PSKDemodulator.java @@ -1,6 +1,6 @@ /* * ***************************************************************************** - * Copyright (C) 2014-2022 Dennis Sheirer + * Copyright (C) 2014-2023 Dennis Sheirer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ public abstract class PSKDemodulator implements ComplexSampleListener private IPhaseLockedLoop mPLL; private Complex mReceivedSample = new Complex(0, 0); private Listener mSymbolListener; + private boolean mRunning; /** * Abstract Phase Shift Keyed (PSK) demodulator @@ -42,6 +43,31 @@ public abstract class PSKDemodulator implements ComplexSampleListener mPLL = phaseLockedLoop; } + /** + * Starts this decoder and sets the running flag to true + */ + public void start() + { + mRunning = true; + } + + /** + * Stops this decoder and sets the running flag to false. + */ + public void stop() + { + mRunning = false; + } + + /** + * Indicates if this demodulator is running and capable of processing samples + * @return true if running + */ + public boolean isRunning() + { + return mRunning; + } + /** * Registers the listener to receive symbol decisions from this demodulator */ @@ -90,7 +116,10 @@ public abstract class PSKDemodulator implements ComplexSampleListener for(int x = 0; x < i.length; x++) { - receive(i[x], q[x]); + if(isRunning()) + { + receive(i[x], q[x]); + } } } diff --git a/src/main/java/io/github/dsheirer/module/decode/Decoder.java b/src/main/java/io/github/dsheirer/module/decode/Decoder.java index 0364e3f0..db8d9457 100644 --- a/src/main/java/io/github/dsheirer/module/decode/Decoder.java +++ b/src/main/java/io/github/dsheirer/module/decode/Decoder.java @@ -1,6 +1,6 @@ /* * ***************************************************************************** - * Copyright (C) 2014-2022 Dennis Sheirer + * Copyright (C) 2014-2023 Dennis Sheirer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,11 +23,14 @@ import io.github.dsheirer.message.IMessageProvider; import io.github.dsheirer.module.Module; import io.github.dsheirer.sample.Listener; +/** + * Base decoder class. + */ public abstract class Decoder extends Module implements IMessageProvider { - /* This has to be a broadcaster in order for references to persist */ private Listener mMessageDistributor = new MessageDistributor(); protected Listener mMessageListener; + private boolean mRunning; /** * Decoder - parent class for all decoders, demodulators and components. @@ -36,14 +39,29 @@ public abstract class Decoder extends Module implements IMessageProvider { } + /** + * Starts this decoder and sets the running flag to true. + */ public void start() { - //no-op + mRunning = true; } + /** + * Stops this decoder and sets the running flag to false. + */ public void stop() { - //no-op + mRunning = false; + } + + /** + * Indicates if this decoder is currently started and in a running state. + * @return true if running or false if not. + */ + public boolean isRunning() + { + return mRunning; } public void reset() diff --git a/src/main/java/io/github/dsheirer/module/decode/dmr/DMRDecoder.java b/src/main/java/io/github/dsheirer/module/decode/dmr/DMRDecoder.java index 5b6f19b2..2dea9513 100644 --- a/src/main/java/io/github/dsheirer/module/decode/dmr/DMRDecoder.java +++ b/src/main/java/io/github/dsheirer/module/decode/dmr/DMRDecoder.java @@ -1,6 +1,6 @@ /* * ***************************************************************************** - * Copyright (C) 2014-2022 Dennis Sheirer + * Copyright (C) 2014-2023 Dennis Sheirer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -84,6 +84,20 @@ public class DMRDecoder extends FeedbackDecoder implements ISourceEventListener, setSampleRate(25000.0); } + @Override + public void start() + { + super.start(); + mQPSKDemodulator.start(); + } + + @Override + public void stop() + { + super.stop(); + mQPSKDemodulator.stop(); + } + /** * DMR decoder type. */ @@ -318,22 +332,4 @@ public class DMRDecoder extends FeedbackDecoder implements ISourceEventListener, { return DMRDecoder.this; } - - /** - * Starts the decoder - */ - @Override - public void start() - { - //No-op - } - - /** - * Stops the decoder - */ - @Override - public void stop() - { - //No-op - } } diff --git a/src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1Decoder.java b/src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1Decoder.java index 24885908..a27ac798 100644 --- a/src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1Decoder.java +++ b/src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1Decoder.java @@ -1,6 +1,6 @@ /* * ***************************************************************************** - * Copyright (C) 2014-2022 Dennis Sheirer + * Copyright (C) 2014-2023 Dennis Sheirer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,6 @@ import io.github.dsheirer.sample.complex.IComplexSamplesListener; import io.github.dsheirer.source.ISourceEventListener; import io.github.dsheirer.source.ISourceEventProvider; import io.github.dsheirer.source.SourceEvent; - import java.nio.ByteBuffer; public abstract class P25P1Decoder extends FeedbackDecoder implements ISourceEventListener, ISourceEventProvider, @@ -166,24 +165,6 @@ public abstract class P25P1Decoder extends FeedbackDecoder implements ISourceEve return P25P1Decoder.this; } - /** - * Starts the decoder - */ - @Override - public void start() - { - //No-op - } - - /** - * Stops the decoder - */ - @Override - public void stop() - { - //No-op - } - @Override public DecoderType getDecoderType() { diff --git a/src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1DecoderC4FM.java b/src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1DecoderC4FM.java index f29d4fad..11518709 100644 --- a/src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1DecoderC4FM.java +++ b/src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1DecoderC4FM.java @@ -1,6 +1,6 @@ /* * ***************************************************************************** - * Copyright (C) 2014-2022 Dennis Sheirer + * Copyright (C) 2014-2023 Dennis Sheirer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -62,6 +62,20 @@ public class P25P1DecoderC4FM extends P25P1Decoder setSampleRate(25000.0); } + @Override + public void start() + { + super.start(); + mQPSKDemodulator.start(); + } + + @Override + public void stop() + { + super.stop(); + mQPSKDemodulator.stop(); + } + public void setSampleRate(double sampleRate) { super.setSampleRate(sampleRate); diff --git a/src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1DecoderLSM.java b/src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1DecoderLSM.java index 5f86ddfc..9edd6651 100644 --- a/src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1DecoderLSM.java +++ b/src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1DecoderLSM.java @@ -1,6 +1,6 @@ /* * ***************************************************************************** - * Copyright (C) 2014-2022 Dennis Sheirer + * Copyright (C) 2014-2023 Dennis Sheirer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -62,6 +62,20 @@ public class P25P1DecoderLSM extends P25P1Decoder setSampleRate(25000.0); } + @Override + public void start() + { + super.start(); + mQPSKDemodulator.start(); + } + + @Override + public void stop() + { + super.stop(); + mQPSKDemodulator.stop(); + } + /** * Sets or changes the channel sample rate * diff --git a/src/main/java/io/github/dsheirer/module/decode/p25/phase2/P25P2Decoder.java b/src/main/java/io/github/dsheirer/module/decode/p25/phase2/P25P2Decoder.java index 7ee604f8..2d272e69 100644 --- a/src/main/java/io/github/dsheirer/module/decode/p25/phase2/P25P2Decoder.java +++ b/src/main/java/io/github/dsheirer/module/decode/p25/phase2/P25P2Decoder.java @@ -1,6 +1,6 @@ /* * ***************************************************************************** - * Copyright (C) 2014-2022 Dennis Sheirer + * Copyright (C) 2014-2023 Dennis Sheirer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,6 @@ import io.github.dsheirer.sample.complex.IComplexSamplesListener; import io.github.dsheirer.source.ISourceEventListener; import io.github.dsheirer.source.ISourceEventProvider; import io.github.dsheirer.source.SourceEvent; - import java.nio.ByteBuffer; /** @@ -169,24 +168,6 @@ public abstract class P25P2Decoder extends FeedbackDecoder implements ISourceEve return P25P2Decoder.this; } - /** - * Starts the decoder - */ - @Override - public void start() - { - //No-op - } - - /** - * Stops the decoder - */ - @Override - public void stop() - { - //No-op - } - @Override public DecoderType getDecoderType() { diff --git a/src/main/java/io/github/dsheirer/module/decode/p25/phase2/P25P2DecoderHDQPSK.java b/src/main/java/io/github/dsheirer/module/decode/p25/phase2/P25P2DecoderHDQPSK.java index 9667cc15..1c2d949d 100644 --- a/src/main/java/io/github/dsheirer/module/decode/p25/phase2/P25P2DecoderHDQPSK.java +++ b/src/main/java/io/github/dsheirer/module/decode/p25/phase2/P25P2DecoderHDQPSK.java @@ -1,6 +1,6 @@ /* * ***************************************************************************** - * Copyright (C) 2014-2022 Dennis Sheirer + * Copyright (C) 2014-2023 Dennis Sheirer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -67,6 +67,27 @@ public class P25P2DecoderHDQPSK extends P25P2Decoder implements IdentifierUpdate mDecodeConfigP25Phase2 = decodeConfigP25Phase2; } + @Override + public void start() + { + super.start(); + mQPSKDemodulator.start(); + + //Refresh the scramble parameters each time we start in case they change + if(mDecodeConfigP25Phase2 != null && mDecodeConfigP25Phase2.getScrambleParameters() != null && + !mDecodeConfigP25Phase2.isAutoDetectScrambleParameters()) + { + mMessageFramer.setScrambleParameters(mDecodeConfigP25Phase2.getScrambleParameters()); + } + } + + @Override + public void stop() + { + super.stop(); + mQPSKDemodulator.stop(); + } + public void setSampleRate(double sampleRate) { super.setSampleRate(sampleRate); @@ -188,19 +209,6 @@ public class P25P2DecoderHDQPSK extends P25P2Decoder implements IdentifierUpdate mCostasLoop.reset(); } - @Override - public void start() - { - super.start(); - - //Refresh the scramble parameters each time we start in case they change - if(mDecodeConfigP25Phase2 != null && mDecodeConfigP25Phase2.getScrambleParameters() != null && - !mDecodeConfigP25Phase2.isAutoDetectScrambleParameters()) - { - mMessageFramer.setScrambleParameters(mDecodeConfigP25Phase2.getScrambleParameters()); - } - } - @Override public Listener getIdentifierUpdateListener() {