Files
sdrtrunk/src/source/tuner/fcd/FCDTuner.java
denny dd22397f75 Resolves issue with application memory growth and thread pool
saturation.

Each tunerchannelsource was sharing a thread pool and as the processing
load increased, the thread pool was not expanding and the processing
tasks were backing up, causing the buffers to grow with unprocessed
data.

Changed so that each tuner channel source is handed a thread pool to use
for processing incoming sample data.  Processing chain maintains the
thread pool and starts the channel source.  This allows traffic channels
to reuse the thread pool across multiple iterations.
2016-02-15 09:46:33 -05:00

139 lines
3.6 KiB
Java

/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
******************************************************************************/
package source.tuner.fcd;
import java.util.concurrent.RejectedExecutionException;
import javax.swing.JPanel;
import sample.Listener;
import sample.adapter.ShortAdapter;
import sample.complex.ComplexBuffer;
import source.SourceException;
import source.tuner.MixerTuner;
import source.tuner.MixerTunerDataLine;
import source.tuner.TunerChannel;
import source.tuner.TunerChannelSource;
import source.tuner.TunerClass;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.frequency.FrequencyChangeListener;
import controller.ResourceManager;
import controller.ThreadPoolManager;
public class FCDTuner extends MixerTuner
{
private FCDTunerController mController;
public FCDTuner( MixerTunerDataLine mixerTDL,
FCDTunerController controller )
{
super( controller.getConfiguration().toString(),
mixerTDL,
new ShortAdapter() );
mController = controller;
mController.addListener( (FrequencyChangeListener)this );
}
public void dispose()
{
//TODO: release the mixer tuner data line as well
mController.dispose();
}
public FCDTunerController getController()
{
return mController;
}
@Override
public TunerClass getTunerClass()
{
return mController.getTunerClass();
}
@Override
public TunerType getTunerType()
{
return mController.getTunerType();
}
@Override
public String getUniqueID()
{
return mController.getUSBAddress();
}
@Override
public JPanel getEditor( ResourceManager resourceManager )
{
return mController.getEditor( this, resourceManager );
}
@Override
public void apply( TunerConfiguration config )throws SourceException
{
mController.apply( config );
}
@Override
public int getSampleRate()
{
return (int)mMixerTunerType.getAudioFormat().getSampleRate();
}
@Override
public double getSampleSize()
{
return 16.0;
}
@Override
public long getFrequency() throws SourceException
{
return mController.getFrequency();
}
@Override
public TunerChannelSource getChannel( TunerChannel tunerChannel )
throws RejectedExecutionException, SourceException
{
return mController.getChannel( this, tunerChannel );
}
/**
* Releases the tuned channel so that the tuner controller can tune to
* other frequencies as needed.
*/
@Override
public void releaseChannel( TunerChannelSource source )
{
if( source != null )
{
/* Unregister for receiving samples */
removeListener( (Listener<ComplexBuffer>)source );
/* Tell the controller to release the channel and cleanup */
/* This will release the channel as a frequency change listener */
mController.releaseChannel( source );
}
}
}