Airspy controller - changes method for adjusting center tuned frequency

when tuner channels are allocated by the airspy.  New method determines
the min/max requested frequency range and sets tuner center to the
center of that range, while limiting the total usable bandwidth to 90%
of the bandwidth, to account for rolloff of 5% at the upper/lower edges.

When a new channel is requested, if the channel fits within the current
center frequency and usable bandwidth, the center tune frequency is not
adjusted, to minimize the number of retunes on a busy system.
This commit is contained in:
denny
2015-11-29 07:11:47 -05:00
parent f04a6727b0
commit ae10b5fc1c
3 changed files with 39 additions and 9 deletions

View File

@@ -714,7 +714,7 @@ public class Channel extends Configuration
} }
catch( SourceException se ) catch( SourceException se )
{ {
mLog.info( "Couldn't obtain source for channel [" + mName + "]" ); //Do nothing, we couldn't get a source for the channel
} }
} }
} }

View File

@@ -114,7 +114,7 @@ public abstract class TunerController implements Tunable
public long getMinTunedFrequency() public long getMinTunedFrequency()
{ {
return mFrequencyController.getFrequency() - return mFrequencyController.getFrequency() -
( mFrequencyController.getBandwidth() / 2 ); ( mFrequencyController.getBandwidth() / 2 );
} }

View File

@@ -832,7 +832,7 @@ public class AirspyTunerController extends TunerController
} }
/** /**
* Indicates if the tuner can accomodate this new channel frequency and * Indicates if the tuner can accommodate this new channel frequency and
* bandwidth, along with all of the existing tuned channels currently in * bandwidth, along with all of the existing tuned channels currently in
* place. * place.
*/ */
@@ -857,20 +857,49 @@ public class AirspyTunerController extends TunerController
{ {
return true; return true;
} }
int usable = getUsableBandwidth();
if( channel.getMinFrequency() < minLockedFrequency ) if( channel.getMinFrequency() < minLockedFrequency )
{ {
return ( maxLockedFrequency - channel.getMinFrequency() ) < getBandwidth() - 1E5; return ( maxLockedFrequency - channel.getMinFrequency() ) <= usable;
} }
if( channel.getMaxFrequency() > maxLockedFrequency ) if( channel.getMaxFrequency() > maxLockedFrequency )
{ {
return ( channel.getMaxFrequency() - minLockedFrequency ) <= getBandwidth() - 1E5; return ( channel.getMaxFrequency() - minLockedFrequency ) <= usable;
} }
} }
return false; return false;
} }
/**
* Limits the usable bandwidth of the tuner to 90% of the bandwidth to
* account for roll-off at the band edges
*/
private int getUsableBandwidth()
{
return (int)( (double)getBandwidth() * 0.9d );
}
/**
* Overrides the default tuner controller method to limit the total bandwidth
* of the tuner to 90% and adjust the min tuned frequency accordingly
*/
public long getMinTunedFrequency()
{
return mFrequencyController.getFrequency() - ( getUsableBandwidth() / 2 );
}
/**
* Overrides the default tuner controller method to limit the total bandwidth
* of the tuner to 90% and adjust the max tuned frequency accordingly
*/
public long getMaxTunedFrequency()
{
return mFrequencyController.getFrequency() + ( getUsableBandwidth() / 2 );
}
public TunerChannelSource getChannel( ThreadPoolManager threadPoolManager, public TunerChannelSource getChannel( ThreadPoolManager threadPoolManager,
Tuner tuner, TunerChannel tunerChannel ) Tuner tuner, TunerChannel tunerChannel )
@@ -886,11 +915,12 @@ public class AirspyTunerController extends TunerController
long min = mTunedChannels.get( 0 ).getMinFrequency(); long min = mTunedChannels.get( 0 ).getMinFrequency();
long max = mTunedChannels.get( mTunedChannels.size() - 1 ).getMaxFrequency(); long max = mTunedChannels.get( mTunedChannels.size() - 1 ).getMaxFrequency();
if( !( getMinTunedFrequency() <= min && /* Adjust the center frequency if the set of tuner channels don't
max <= getMaxTunedFrequency() ) ) * currently fit within the usable bandwidth and current center frequency */
if( !( getMinTunedFrequency() <= min && max <= getMaxTunedFrequency() ) )
{ {
long freq = min + ( mFrequencyController.getBandwidth() / 2 ) + 50000; long freq = min + ( ( max - min ) / 2 );
mFrequencyController.setFrequency( freq ); mFrequencyController.setFrequency( freq );
} }