From 04a41a728b0cb2aca302f7fd59c8c02936e31575 Mon Sep 17 00:00:00 2001 From: Dennis Sheirer Date: Sun, 11 Feb 2024 05:18:53 -0500 Subject: [PATCH] #1845 Updates polyphase tuner channel manager to avoid retuning for a new channel if all channels will continue to fit using the current center frequency --- .../source/tuner/TunerController.java | 39 ------------------- .../PolyphaseChannelSourceManager.java | 9 ++--- 2 files changed, 4 insertions(+), 44 deletions(-) diff --git a/src/main/java/io/github/dsheirer/source/tuner/TunerController.java b/src/main/java/io/github/dsheirer/source/tuner/TunerController.java index 952ea3e12..46c8dde4c 100644 --- a/src/main/java/io/github/dsheirer/source/tuner/TunerController.java +++ b/src/main/java/io/github/dsheirer/source/tuner/TunerController.java @@ -647,45 +647,6 @@ public void receive(INativeBuffer nativeBuffer) broadcast(nativeBuffer); } - /** - * Indicates if the current center frequency and bandwidth is correct to source the tuner channel - * - * @param tunerChannel to test - * @return true if the current center frequency and bandwidth is correct for the channel - */ - public boolean isTunedFor(TunerChannel tunerChannel) - { - try - { - if(tunerChannel.getMinFrequency() < getMinTunedFrequency()) - { - return false; - } - - if(tunerChannel.getMaxFrequency() > getMaxTunedFrequency()) - { - return false; - } - - if(hasMiddleUnusableBandwidth()) - { - long minAvoid = getFrequency() - getMiddleUnusableHalfBandwidth(); - long maxAvoid = getFrequency() + getMiddleUnusableHalfBandwidth(); - - if(tunerChannel.overlaps(minAvoid, maxAvoid)) - { - return false; - } - } - } - catch(SourceException se) - { - return false; - } - - return true; - } - /** * Indicates if the current center frequency and bandwidth is correct to source the tuner channel set * diff --git a/src/main/java/io/github/dsheirer/source/tuner/manager/PolyphaseChannelSourceManager.java b/src/main/java/io/github/dsheirer/source/tuner/manager/PolyphaseChannelSourceManager.java index 5855437b5..2ce4c3088 100644 --- a/src/main/java/io/github/dsheirer/source/tuner/manager/PolyphaseChannelSourceManager.java +++ b/src/main/java/io/github/dsheirer/source/tuner/manager/PolyphaseChannelSourceManager.java @@ -195,15 +195,14 @@ protected long getCenterFrequency(SortedSet channels, long current throw new IllegalArgumentException("Channel set bandwidth is greater than tuner's available bandwidth"); } - long bestIntegralFrequency = getIntegralFrequency(channels); - - //Strategy 1: reuse the current frequency if it's a good integral and the channels fit - if(isIntegralSpacing(currentCenterFrequency, bestIntegralFrequency) && - isValidCenterFrequency(channels, currentCenterFrequency)) + //Strategy 1: reuse the current frequency if the channels fit + if(isValidCenterFrequency(channels, currentCenterFrequency)) { return currentCenterFrequency; } + long bestIntegralFrequency = getIntegralFrequency(channels); + double usableHalfBandwidth = mTunerController.getUsableHalfBandwidth(); //Strategy 2: start by placing the center frequency exactly one channel width below the first channel frequency