mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-11 08:07:24 -05:00
#1397 Resolves issue where decoding channels go IDLE after period of time. Isolated the cause to a multi-threading issue where the polyphase channel manager receives notification that the tuner center frequency has changed and sets a flag to update each of the channels. This happens concurrent with a previous tuner center frequency change where the flag gets set and the second thread is updating the output processors with the previous frequency change and then unsets the frequency change flag, completely missing the second/latest frequency change update and causing the channels to all tune-out their desired signals as the tuner center frequency changes and the output channels continue mixing to the previous frequency. (#1407)
Identified and resolved issue where a 2-stream polyphase synthesizer was being updated with an incorrectly designed synthesis filter which was causing massive droop on the second half of the reconstructed channel. Oddly enough, this didn't seem to impact the P25 decoders, but it may have impacted other decoding. Identified and resolved issue with concurrent modification of the modules list in the processing chain associated with recent addition of the channel FFT view in the channel power tab. Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
@@ -74,9 +74,11 @@ import io.github.dsheirer.source.heartbeat.IHeartbeatListener;
|
||||
import io.github.dsheirer.source.heartbeat.IHeartbeatProvider;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -115,12 +117,15 @@ public class ProcessingChain implements Listener<ChannelEvent>
|
||||
private Broadcaster<IMessage> mMessageBroadcaster = new Broadcaster<>();
|
||||
private Broadcaster<SquelchStateEvent> mSquelchStateEventBroadcaster = new Broadcaster<>();
|
||||
private AtomicBoolean mRunning = new AtomicBoolean();
|
||||
private List<Module> mModules = new ArrayList<>();
|
||||
private DecodeEventHistory mDecodeEventHistory = new DecodeEventHistory(500);
|
||||
private MessageHistory mMessageHistory = new MessageHistory(500);
|
||||
private AbstractChannelState mChannelState;
|
||||
private EventBus mEventBus;
|
||||
protected Source mSource;
|
||||
//Lock to protect access to the modules list.
|
||||
private ReentrantLock mModuleLock = new ReentrantLock();
|
||||
private List<Module> mModules = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a processing chain for managing a set of modules
|
||||
@@ -195,30 +200,46 @@ public class ProcessingChain implements Listener<ChannelEvent>
|
||||
*/
|
||||
public void removeTrafficChannelManager()
|
||||
{
|
||||
Iterator<Module> it = mModules.iterator();
|
||||
mModuleLock.lock();
|
||||
|
||||
while(it.hasNext())
|
||||
try
|
||||
{
|
||||
if(it.next() instanceof TrafficChannelManager)
|
||||
Iterator<Module> it = mModules.iterator();
|
||||
|
||||
while(it.hasNext())
|
||||
{
|
||||
it.remove();
|
||||
if(it.next() instanceof TrafficChannelManager)
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
mModuleLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
stop();
|
||||
|
||||
List<Module> modules = new ArrayList<>(mModules);
|
||||
mModuleLock.lock();
|
||||
|
||||
for(Module module : modules)
|
||||
try
|
||||
{
|
||||
removeModule(module);
|
||||
module.dispose();
|
||||
}
|
||||
List<Module> modulesToRemove = new ArrayList<>(mModules);
|
||||
|
||||
mModules.clear();
|
||||
for(Module module : modulesToRemove)
|
||||
{
|
||||
removeModule(module);
|
||||
module.dispose();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
mModuleLock.unlock();
|
||||
}
|
||||
|
||||
mAudioSegmentBroadcaster.dispose();
|
||||
mDecodeEventBroadcaster.dispose();
|
||||
@@ -282,7 +303,7 @@ public class ProcessingChain implements Listener<ChannelEvent>
|
||||
*/
|
||||
public List<Module> getModules()
|
||||
{
|
||||
return mModules;
|
||||
return Collections.unmodifiableList(mModules);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -292,13 +313,22 @@ public class ProcessingChain implements Listener<ChannelEvent>
|
||||
{
|
||||
List<DecoderState> decoderStates = new ArrayList<>();
|
||||
|
||||
for(Module module : mModules)
|
||||
mModuleLock.lock();
|
||||
|
||||
try
|
||||
{
|
||||
if(module instanceof DecoderState)
|
||||
for(Module module : mModules)
|
||||
{
|
||||
decoderStates.add((DecoderState)module);
|
||||
if(module instanceof DecoderState)
|
||||
{
|
||||
decoderStates.add((DecoderState)module);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
mModuleLock.unlock();
|
||||
}
|
||||
|
||||
return decoderStates;
|
||||
}
|
||||
@@ -330,7 +360,17 @@ public class ProcessingChain implements Listener<ChannelEvent>
|
||||
*/
|
||||
public void addModule(Module module)
|
||||
{
|
||||
mModules.add(module);
|
||||
mModuleLock.lock();
|
||||
|
||||
try
|
||||
{
|
||||
mModules.add(module);
|
||||
}
|
||||
finally
|
||||
{
|
||||
mModuleLock.unlock();
|
||||
}
|
||||
|
||||
module.setInterModuleEventBus(getEventBus());
|
||||
registerListeners(module);
|
||||
registerProviders(module);
|
||||
@@ -345,7 +385,17 @@ public class ProcessingChain implements Listener<ChannelEvent>
|
||||
unregisterListeners(module);
|
||||
unregisterProviders(module);
|
||||
module.setInterModuleEventBus(null);
|
||||
mModules.remove(module);
|
||||
|
||||
mModuleLock.lock();
|
||||
|
||||
try
|
||||
{
|
||||
mModules.remove(module);
|
||||
}
|
||||
finally
|
||||
{
|
||||
mModuleLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -664,18 +714,27 @@ public class ProcessingChain implements Listener<ChannelEvent>
|
||||
+ "sample type - cannot start processing chain");
|
||||
}
|
||||
|
||||
/* Start each of the modules */
|
||||
for(Module module : mModules)
|
||||
mModuleLock.lock();
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
/* Start each of the modules */
|
||||
for(Module module : mModules)
|
||||
{
|
||||
module.start();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("Error starting module", e);
|
||||
try
|
||||
{
|
||||
module.start();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("Error starting module", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
mModuleLock.unlock();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -716,15 +775,28 @@ public class ProcessingChain implements Listener<ChannelEvent>
|
||||
}
|
||||
|
||||
/* Stop each of the remaining modules */
|
||||
for(Module module : mModules)
|
||||
{
|
||||
module.stop();
|
||||
}
|
||||
mModuleLock.lock();
|
||||
|
||||
//Reset each of the modules
|
||||
for(Module module : mModules)
|
||||
try
|
||||
{
|
||||
module.reset();
|
||||
for(Module module : mModules)
|
||||
{
|
||||
module.stop();
|
||||
}
|
||||
|
||||
//Reset each of the modules
|
||||
for(Module module : mModules)
|
||||
{
|
||||
module.reset();
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("Error stopping or resetting modules", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
mModuleLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -736,13 +808,22 @@ public class ProcessingChain implements Listener<ChannelEvent>
|
||||
{
|
||||
List<Module> eventLoggingModules = new ArrayList<>();
|
||||
|
||||
for(Module module : mModules)
|
||||
mModuleLock.lock();
|
||||
|
||||
try
|
||||
{
|
||||
if(module instanceof EventLogger)
|
||||
for(Module module : mModules)
|
||||
{
|
||||
eventLoggingModules.add(module);
|
||||
if(module instanceof EventLogger)
|
||||
{
|
||||
eventLoggingModules.add(module);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
mModuleLock.unlock();
|
||||
}
|
||||
|
||||
for(Module eventLoggingModule : eventLoggingModules)
|
||||
{
|
||||
@@ -757,21 +838,30 @@ public class ProcessingChain implements Listener<ChannelEvent>
|
||||
{
|
||||
List<Module> recordingModules = new ArrayList<>();
|
||||
|
||||
for(Module module : mModules)
|
||||
mModuleLock.lock();
|
||||
|
||||
try
|
||||
{
|
||||
if(module instanceof ComplexSamplesWaveRecorder)
|
||||
for(Module module : mModules)
|
||||
{
|
||||
recordingModules.add(module);
|
||||
}
|
||||
else if(module instanceof MBECallSequenceRecorder)
|
||||
{
|
||||
recordingModules.add(module);
|
||||
}
|
||||
else if(module instanceof BinaryRecorder)
|
||||
{
|
||||
recordingModules.add(module);
|
||||
if(module instanceof ComplexSamplesWaveRecorder)
|
||||
{
|
||||
recordingModules.add(module);
|
||||
}
|
||||
else if(module instanceof MBECallSequenceRecorder)
|
||||
{
|
||||
recordingModules.add(module);
|
||||
}
|
||||
else if(module instanceof BinaryRecorder)
|
||||
{
|
||||
recordingModules.add(module);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
mModuleLock.unlock();
|
||||
}
|
||||
|
||||
for(Module recordingModule : recordingModules)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user