mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
Merges changes from master branch to resolve issue with CPU and memory
and constraints on scheduled thread pool saturation. Adds a new scheduled thread pool for each processing chain that the components in the chain can share, versus the single shared pool exposed by the threadpoolmanager class.
This commit is contained in:
@@ -19,6 +19,7 @@ package source.mixer;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
@@ -29,12 +30,12 @@ import javax.sound.sampled.TargetDataLine;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import dsp.gain.AutomaticGainControl;
|
||||
import sample.Listener;
|
||||
import sample.adapter.ISampleAdapter;
|
||||
import sample.real.RealBuffer;
|
||||
import source.RealSource;
|
||||
import source.SourceException;
|
||||
import dsp.gain.AutomaticGainControl;
|
||||
|
||||
public class RealMixerSource extends RealSource
|
||||
{
|
||||
@@ -86,7 +87,7 @@ public class RealMixerSource extends RealSource
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
public void start( ScheduledExecutorService executor )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package source.tuner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedTransferQueue;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -39,8 +38,6 @@ import source.SourceException;
|
||||
import source.tuner.frequency.FrequencyChangeEvent;
|
||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
||||
import controller.NamingThreadFactory;
|
||||
import controller.ThreadPoolManager.ThreadType;
|
||||
import dsp.filter.FilterFactory;
|
||||
import dsp.filter.Window.WindowType;
|
||||
import dsp.filter.cic.ComplexPrimeCICDecimate;
|
||||
@@ -63,7 +60,6 @@ public class TunerChannelSource extends ComplexSource
|
||||
private ComplexPrimeCICDecimate mDecimationFilter;
|
||||
private Listener<ComplexBuffer> mListener;
|
||||
private IFrequencyChangeProcessor mFrequencyChangeProcessor;
|
||||
private ScheduledExecutorService mScheduledExecutorService;
|
||||
private ScheduledFuture<?> mTaskHandle;
|
||||
|
||||
private long mTunerFrequency = 0;
|
||||
@@ -114,14 +110,7 @@ public class TunerChannelSource extends ComplexSource
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
public void start( ScheduledExecutorService executor )
|
||||
{
|
||||
if( mExpended )
|
||||
{
|
||||
@@ -132,12 +121,9 @@ public class TunerChannelSource extends ComplexSource
|
||||
|
||||
if( mRunning.compareAndSet( false, true ))
|
||||
{
|
||||
mScheduledExecutorService = Executors.newScheduledThreadPool( 1,
|
||||
new NamingThreadFactory( "tuner channel source" ) );
|
||||
|
||||
/* Schedule the decimation task to run every 10 ms (100 iterations/second) */
|
||||
mTaskHandle = mScheduledExecutorService.scheduleAtFixedRate(
|
||||
mDecimationProcessor, 0, 10, TimeUnit.MILLISECONDS );
|
||||
mTaskHandle = executor.scheduleAtFixedRate( mDecimationProcessor,
|
||||
0, 10, TimeUnit.MILLISECONDS );
|
||||
|
||||
/* Finally, register to receive samples from the tuner */
|
||||
mTuner.addListener( (Listener<ComplexBuffer>)this );
|
||||
@@ -149,6 +135,10 @@ public class TunerChannelSource extends ComplexSource
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop()
|
||||
@@ -158,15 +148,10 @@ public class TunerChannelSource extends ComplexSource
|
||||
mTuner.releaseChannel( this );
|
||||
mDecimationProcessor.shutdown();
|
||||
|
||||
if( mScheduledExecutorService != null && mTaskHandle != null )
|
||||
if( mTaskHandle != null )
|
||||
{
|
||||
if( mTaskHandle != null )
|
||||
{
|
||||
mTaskHandle.cancel( true );
|
||||
mTaskHandle = null;
|
||||
}
|
||||
|
||||
mScheduledExecutorService.shutdownNow();
|
||||
mTaskHandle.cancel( true );
|
||||
mTaskHandle = null;
|
||||
}
|
||||
|
||||
mBuffer.clear();
|
||||
@@ -349,7 +334,7 @@ public class TunerChannelSource extends ComplexSource
|
||||
{
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
mBuffer.drainTo( mSampleBuffers );
|
||||
mBuffer.drainTo( mSampleBuffers, 8 );
|
||||
|
||||
for( Buffer buffer: mSampleBuffers )
|
||||
{
|
||||
|
||||
@@ -18,6 +18,8 @@ package source.tuner.frequency;
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import module.Module;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -118,7 +120,7 @@ public class DCTrackingFrequencyControl extends Module
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
public void start( ScheduledExecutorService executor )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ package source.wave;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
@@ -58,11 +59,11 @@ public class ComplexWaveSource extends ComplexSource implements IControllableFil
|
||||
public void reset()
|
||||
{
|
||||
stop();
|
||||
start();
|
||||
start( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
public void start( ScheduledExecutorService executor )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ package source.wave;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
@@ -60,12 +61,12 @@ public class RealWaveSource extends RealSource
|
||||
public void reset()
|
||||
{
|
||||
stop();
|
||||
start();
|
||||
start( null );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
public void start( ScheduledExecutorService executor )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user