mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
#39 WIP - rolls back embedding source events in buffers. The channel
calculator must be updated immediately any time the tuner's center frequency changes so that a channel can be allocated immediately. So, I changed source event handling to two parts where the channel calculator is immediately updated and the channelizer configuration is deferred so that it can happen on the buffer processor execution thread and we can avoid any sync() locking on the channelizer or polyphase channel sources.
This commit is contained in:
@@ -46,6 +46,7 @@ public class TunerSourceManager extends AbstractSourceManager
|
||||
mPolyphaseChannelManager = new PolyphaseChannelManager(tunerController);
|
||||
//Register to receive channel count change notifications for rebroadcasting
|
||||
mPolyphaseChannelManager.addSourceEventListener(this::process);
|
||||
mTunerController.addListener(mPolyphaseChannelManager);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -427,7 +428,7 @@ public class TunerSourceManager extends AbstractSourceManager
|
||||
broadcast(sourceEvent);
|
||||
break;
|
||||
default:
|
||||
mLog.info("Received an unrecognized source event: " + sourceEvent);
|
||||
mLog.info("Unrecognized source event: " + sourceEvent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,13 +22,10 @@ import io.github.dsheirer.dsp.mixer.LowPhaseNoiseOscillator;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.complex.ComplexBuffer;
|
||||
import io.github.dsheirer.sample.complex.TimestampedComplexBuffer;
|
||||
import io.github.dsheirer.source.SourceEvent;
|
||||
import io.github.dsheirer.util.ThreadPool;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -42,7 +39,6 @@ public class SampleGenerator
|
||||
private long mInterval;
|
||||
private int mSamplesPerInterval;
|
||||
private ScheduledFuture<?> mScheduledFuture;
|
||||
private Queue<SourceEvent> mSourceEventQueue = new ConcurrentLinkedQueue();
|
||||
|
||||
/**
|
||||
* Generates complex sample buffers at the specified sample rate with a unity gain tone at the specified
|
||||
@@ -84,16 +80,6 @@ public class SampleGenerator
|
||||
this(sampleRate, frequency, interval, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Queues the source event for inclusion in the complex buffers generated by this sample generator. Source events
|
||||
* are queued FIFO and embedded one at a time in the subsequent buffers produced by this generator.
|
||||
* @param sourceEvent to queue
|
||||
*/
|
||||
public void queue(SourceEvent sourceEvent)
|
||||
{
|
||||
mSourceEventQueue.offer(sourceEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the number of complex samples generated per interval
|
||||
*/
|
||||
@@ -185,7 +171,7 @@ public class SampleGenerator
|
||||
if(mListener != null)
|
||||
{
|
||||
float[] samples = mOscillator.generate(mSamplesPerInterval);
|
||||
mListener.receive(new TimestampedComplexBuffer(samples, mSourceEventQueue.poll()));
|
||||
mListener.receive(new TimestampedComplexBuffer(samples));
|
||||
|
||||
if(mSweepUpdateInterval != 0)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ package io.github.dsheirer.source.tuner.test;
|
||||
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.complex.ComplexBuffer;
|
||||
import io.github.dsheirer.source.SourceEvent;
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
import io.github.dsheirer.source.tuner.TunerController;
|
||||
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
|
||||
@@ -56,7 +55,7 @@ public class TestTunerController extends TunerController
|
||||
|
||||
try
|
||||
{
|
||||
mLog.debug("Setting frequency ...");
|
||||
mLog.debug("Setting frequency to:" + DEFAULT_CENTER_FREQUENCY);
|
||||
mFrequencyController.setFrequency(DEFAULT_CENTER_FREQUENCY);
|
||||
mLog.debug("Setting sample rate of freq controller to: " + DEFAULT_SAMPLE_RATE);
|
||||
mFrequencyController.setSampleRate(DEFAULT_SAMPLE_RATE);
|
||||
@@ -130,7 +129,6 @@ public class TestTunerController extends TunerController
|
||||
{
|
||||
long frequency = toneFrequency - mReferenceFrequency;
|
||||
mSampleGenerator.setFrequency(frequency);
|
||||
mSampleGenerator.queue(SourceEvent.frequencyChange(frequency));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,6 +155,5 @@ public class TestTunerController extends TunerController
|
||||
public void setSampleRate(int sampleRate) throws SourceException
|
||||
{
|
||||
mFrequencyController.setSampleRate(sampleRate);
|
||||
mSampleGenerator.queue(SourceEvent.sampleRateChange(sampleRate));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user