Skip to content

Commit bac38a5

Browse files
DSheirerDennis Sheirer
andauthored
#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 <[email protected]>
1 parent e5f5df7 commit bac38a5

File tree

8 files changed

+122
-81
lines changed

8 files changed

+122
-81
lines changed

src/main/java/io/github/dsheirer/dsp/psk/PSKDemodulator.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* *****************************************************************************
3-
* Copyright (C) 2014-2022 Dennis Sheirer
3+
* Copyright (C) 2014-2023 Dennis Sheirer
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -30,6 +30,7 @@ public abstract class PSKDemodulator<T> implements ComplexSampleListener
3030
private IPhaseLockedLoop mPLL;
3131
private Complex mReceivedSample = new Complex(0, 0);
3232
private Listener<T> mSymbolListener;
33+
private boolean mRunning;
3334

3435
/**
3536
* Abstract Phase Shift Keyed (PSK) demodulator
@@ -42,6 +43,31 @@ public PSKDemodulator(InterpolatingSampleBuffer interpolatingSampleBuffer, IPhas
4243
mPLL = phaseLockedLoop;
4344
}
4445

46+
/**
47+
* Starts this decoder and sets the running flag to true
48+
*/
49+
public void start()
50+
{
51+
mRunning = true;
52+
}
53+
54+
/**
55+
* Stops this decoder and sets the running flag to false.
56+
*/
57+
public void stop()
58+
{
59+
mRunning = false;
60+
}
61+
62+
/**
63+
* Indicates if this demodulator is running and capable of processing samples
64+
* @return true if running
65+
*/
66+
public boolean isRunning()
67+
{
68+
return mRunning;
69+
}
70+
4571
/**
4672
* Registers the listener to receive symbol decisions from this demodulator
4773
*/
@@ -90,7 +116,10 @@ public void receive(ComplexSamples samples)
90116

91117
for(int x = 0; x < i.length; x++)
92118
{
93-
receive(i[x], q[x]);
119+
if(isRunning())
120+
{
121+
receive(i[x], q[x]);
122+
}
94123
}
95124
}
96125

src/main/java/io/github/dsheirer/module/decode/Decoder.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* *****************************************************************************
3-
* Copyright (C) 2014-2022 Dennis Sheirer
3+
* Copyright (C) 2014-2023 Dennis Sheirer
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -23,11 +23,14 @@
2323
import io.github.dsheirer.module.Module;
2424
import io.github.dsheirer.sample.Listener;
2525

26+
/**
27+
* Base decoder class.
28+
*/
2629
public abstract class Decoder extends Module implements IMessageProvider
2730
{
28-
/* This has to be a broadcaster in order for references to persist */
2931
private Listener<IMessage> mMessageDistributor = new MessageDistributor();
3032
protected Listener<IMessage> mMessageListener;
33+
private boolean mRunning;
3134

3235
/**
3336
* Decoder - parent class for all decoders, demodulators and components.
@@ -36,14 +39,29 @@ public Decoder()
3639
{
3740
}
3841

42+
/**
43+
* Starts this decoder and sets the running flag to true.
44+
*/
3945
public void start()
4046
{
41-
//no-op
47+
mRunning = true;
4248
}
4349

50+
/**
51+
* Stops this decoder and sets the running flag to false.
52+
*/
4453
public void stop()
4554
{
46-
//no-op
55+
mRunning = false;
56+
}
57+
58+
/**
59+
* Indicates if this decoder is currently started and in a running state.
60+
* @return true if running or false if not.
61+
*/
62+
public boolean isRunning()
63+
{
64+
return mRunning;
4765
}
4866

4967
public void reset()

src/main/java/io/github/dsheirer/module/decode/dmr/DMRDecoder.java

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* *****************************************************************************
3-
* Copyright (C) 2014-2022 Dennis Sheirer
3+
* Copyright (C) 2014-2023 Dennis Sheirer
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -84,6 +84,20 @@ public DMRDecoder(DecodeConfigDMR config)
8484
setSampleRate(25000.0);
8585
}
8686

87+
@Override
88+
public void start()
89+
{
90+
super.start();
91+
mQPSKDemodulator.start();
92+
}
93+
94+
@Override
95+
public void stop()
96+
{
97+
super.stop();
98+
mQPSKDemodulator.stop();
99+
}
100+
87101
/**
88102
* DMR decoder type.
89103
*/
@@ -318,22 +332,4 @@ public Listener<ComplexSamples> getComplexSamplesListener()
318332
{
319333
return DMRDecoder.this;
320334
}
321-
322-
/**
323-
* Starts the decoder
324-
*/
325-
@Override
326-
public void start()
327-
{
328-
//No-op
329-
}
330-
331-
/**
332-
* Stops the decoder
333-
*/
334-
@Override
335-
public void stop()
336-
{
337-
//No-op
338-
}
339335
}

src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1Decoder.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* *****************************************************************************
3-
* Copyright (C) 2014-2022 Dennis Sheirer
3+
* Copyright (C) 2014-2023 Dennis Sheirer
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -31,7 +31,6 @@
3131
import io.github.dsheirer.source.ISourceEventListener;
3232
import io.github.dsheirer.source.ISourceEventProvider;
3333
import io.github.dsheirer.source.SourceEvent;
34-
3534
import java.nio.ByteBuffer;
3635

3736
public abstract class P25P1Decoder extends FeedbackDecoder implements ISourceEventListener, ISourceEventProvider,
@@ -166,24 +165,6 @@ public Listener<ComplexSamples> getComplexSamplesListener()
166165
return P25P1Decoder.this;
167166
}
168167

169-
/**
170-
* Starts the decoder
171-
*/
172-
@Override
173-
public void start()
174-
{
175-
//No-op
176-
}
177-
178-
/**
179-
* Stops the decoder
180-
*/
181-
@Override
182-
public void stop()
183-
{
184-
//No-op
185-
}
186-
187168
@Override
188169
public DecoderType getDecoderType()
189170
{

src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1DecoderC4FM.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* *****************************************************************************
3-
* Copyright (C) 2014-2022 Dennis Sheirer
3+
* Copyright (C) 2014-2023 Dennis Sheirer
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -62,6 +62,20 @@ public P25P1DecoderC4FM()
6262
setSampleRate(25000.0);
6363
}
6464

65+
@Override
66+
public void start()
67+
{
68+
super.start();
69+
mQPSKDemodulator.start();
70+
}
71+
72+
@Override
73+
public void stop()
74+
{
75+
super.stop();
76+
mQPSKDemodulator.stop();
77+
}
78+
6579
public void setSampleRate(double sampleRate)
6680
{
6781
super.setSampleRate(sampleRate);

src/main/java/io/github/dsheirer/module/decode/p25/phase1/P25P1DecoderLSM.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* *****************************************************************************
3-
* Copyright (C) 2014-2022 Dennis Sheirer
3+
* Copyright (C) 2014-2023 Dennis Sheirer
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -62,6 +62,20 @@ public P25P1DecoderLSM()
6262
setSampleRate(25000.0);
6363
}
6464

65+
@Override
66+
public void start()
67+
{
68+
super.start();
69+
mQPSKDemodulator.start();
70+
}
71+
72+
@Override
73+
public void stop()
74+
{
75+
super.stop();
76+
mQPSKDemodulator.stop();
77+
}
78+
6579
/**
6680
* Sets or changes the channel sample rate
6781
*

src/main/java/io/github/dsheirer/module/decode/p25/phase2/P25P2Decoder.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* *****************************************************************************
3-
* Copyright (C) 2014-2022 Dennis Sheirer
3+
* Copyright (C) 2014-2023 Dennis Sheirer
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -31,7 +31,6 @@
3131
import io.github.dsheirer.source.ISourceEventListener;
3232
import io.github.dsheirer.source.ISourceEventProvider;
3333
import io.github.dsheirer.source.SourceEvent;
34-
3534
import java.nio.ByteBuffer;
3635

3736
/**
@@ -169,24 +168,6 @@ public Listener<ComplexSamples> getComplexSamplesListener()
169168
return P25P2Decoder.this;
170169
}
171170

172-
/**
173-
* Starts the decoder
174-
*/
175-
@Override
176-
public void start()
177-
{
178-
//No-op
179-
}
180-
181-
/**
182-
* Stops the decoder
183-
*/
184-
@Override
185-
public void stop()
186-
{
187-
//No-op
188-
}
189-
190171
@Override
191172
public DecoderType getDecoderType()
192173
{

src/main/java/io/github/dsheirer/module/decode/p25/phase2/P25P2DecoderHDQPSK.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* *****************************************************************************
3-
* Copyright (C) 2014-2022 Dennis Sheirer
3+
* Copyright (C) 2014-2023 Dennis Sheirer
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -67,6 +67,27 @@ public P25P2DecoderHDQPSK(DecodeConfigP25Phase2 decodeConfigP25Phase2)
6767
mDecodeConfigP25Phase2 = decodeConfigP25Phase2;
6868
}
6969

70+
@Override
71+
public void start()
72+
{
73+
super.start();
74+
mQPSKDemodulator.start();
75+
76+
//Refresh the scramble parameters each time we start in case they change
77+
if(mDecodeConfigP25Phase2 != null && mDecodeConfigP25Phase2.getScrambleParameters() != null &&
78+
!mDecodeConfigP25Phase2.isAutoDetectScrambleParameters())
79+
{
80+
mMessageFramer.setScrambleParameters(mDecodeConfigP25Phase2.getScrambleParameters());
81+
}
82+
}
83+
84+
@Override
85+
public void stop()
86+
{
87+
super.stop();
88+
mQPSKDemodulator.stop();
89+
}
90+
7091
public void setSampleRate(double sampleRate)
7192
{
7293
super.setSampleRate(sampleRate);
@@ -188,19 +209,6 @@ public void reset()
188209
mCostasLoop.reset();
189210
}
190211

191-
@Override
192-
public void start()
193-
{
194-
super.start();
195-
196-
//Refresh the scramble parameters each time we start in case they change
197-
if(mDecodeConfigP25Phase2 != null && mDecodeConfigP25Phase2.getScrambleParameters() != null &&
198-
!mDecodeConfigP25Phase2.isAutoDetectScrambleParameters())
199-
{
200-
mMessageFramer.setScrambleParameters(mDecodeConfigP25Phase2.getScrambleParameters());
201-
}
202-
}
203-
204212
@Override
205213
public Listener<IdentifierUpdateNotification> getIdentifierUpdateListener()
206214
{

0 commit comments

Comments
 (0)