From 5e8837410f372f95afedb0bdc0747355ee5f8ff8 Mon Sep 17 00:00:00 2001 From: denny Date: Mon, 16 Nov 2026 03:16:34 -0500 Subject: [PATCH] #315 Adds Tuner column to Now Playing channels view --- .../gui/nowplaying/ChannelMetadataView.java | 23 ++++++++++++++++++- .../MultiFrequencyTunerChannelSource.java | 13 ++++++++++- .../tuner/channel/TunerChannelSource.java | 19 +++++++++++++++ .../source/tuner/manager/TunerManager.java | 6 +++++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/dsheirer/gui/nowplaying/ChannelMetadataView.java b/src/main/java/io/github/dsheirer/gui/nowplaying/ChannelMetadataView.java index 52d9fde1..6d28cca4 100644 --- a/src/main/java/io/github/dsheirer/gui/nowplaying/ChannelMetadataView.java +++ b/src/main/java/io/github/dsheirer/gui/nowplaying/ChannelMetadataView.java @@ -40,6 +40,7 @@ import io.github.dsheirer.preference.UserPreferences; import io.github.dsheirer.preference.identifier.TalkgroupFormatPreference; import io.github.dsheirer.sample.Broadcaster; import io.github.dsheirer.sample.Listener; +import io.github.dsheirer.source.tuner.channel.TunerChannelSource; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; @@ -356,6 +357,10 @@ public class ChannelMetadataView extends VBox implements ChannelMetadataModel.Li frequency.setCellFactory(NowPlayingCells.formatted(value -> frequencyFormat.format(value / 1e6d))); columns.add(frequency); + //Tuner that sources the channel + columns.add(NowPlayingCells.column("tuner", "Tuner", null, Pos.CENTER, + row -> getTunerName(row.getChannelMetadata()), Row::revisionProperty)); + columns.add(NowPlayingCells.column("channel.name", "Channel Name", null, Pos.CENTER, row -> toText(row.getChannelMetadata().getChannelNameConfigurationIdentifier()), Row::revisionProperty)); @@ -365,7 +370,7 @@ public class ChannelMetadataView extends VBox implements ChannelMetadataModel.Li column.setSortable(false); } - //Column numbers in the Swing version of the table, for its stored column widths. Talker is a new column. + //Column numbers in the Swing version of the table, for its stored column widths. Talker and Tuner are new columns. String[] swingColumns = {"status", "decoder", "from", "from.alias", "to", "to.alias", "channel", "frequency", "channel.name"}; @@ -382,6 +387,22 @@ public class ChannelMetadataView extends VBox implements ChannelMetadataModel.Li return columns; } + /** + * Name of the tuner that sources the channel, or null if the channel isn't sourced by a tuner. + */ + private String getTunerName(ChannelMetadata channelMetadata) + { + Channel channel = mChannelMetadataModel.getChannelFromMetadata(channelMetadata); + ProcessingChain processingChain = channel != null ? mChannelProcessingManager.getProcessingChain(channel) : null; + + if(processingChain != null && processingChain.getSource() instanceof TunerChannelSource tunerChannelSource) + { + return tunerChannelSource.getTunerName(); + } + + return null; + } + /** * Decoder logical channel name with the timeslot, if any */ diff --git a/src/main/java/io/github/dsheirer/source/tuner/channel/MultiFrequencyTunerChannelSource.java b/src/main/java/io/github/dsheirer/source/tuner/channel/MultiFrequencyTunerChannelSource.java index e2e99753..da7047cc 100644 --- a/src/main/java/io/github/dsheirer/source/tuner/channel/MultiFrequencyTunerChannelSource.java +++ b/src/main/java/io/github/dsheirer/source/tuner/channel/MultiFrequencyTunerChannelSource.java @@ -47,7 +47,7 @@ public class MultiFrequencyTunerChannelSource extends TunerChannelSource private final static Logger mLog = LoggerFactory.getLogger(MultiFrequencyTunerChannelSource.class); private TunerManager mTunerManager; - private TunerChannelSource mTunerChannelSource; + private volatile TunerChannelSource mTunerChannelSource; private List mFrequencies; private List mLockedFrequencies = new ArrayList<>(); private int mFrequencyListPointer = 0; @@ -73,6 +73,17 @@ public class MultiFrequencyTunerChannelSource extends TunerChannelSource mPreferredTuner = preferredTuner; } + /** + * Name of the tuner that provides the current frequency's tuner channel source, which can change as the + * frequencies rotate. + */ + @Override + public String getTunerName() + { + TunerChannelSource source = mTunerChannelSource; + return source != null ? source.getTunerName() : null; + } + /** * Applies the channel decoder requested frequency correction. * @param correction requested by the downstream processors. diff --git a/src/main/java/io/github/dsheirer/source/tuner/channel/TunerChannelSource.java b/src/main/java/io/github/dsheirer/source/tuner/channel/TunerChannelSource.java index 66cd308f..f961f763 100644 --- a/src/main/java/io/github/dsheirer/source/tuner/channel/TunerChannelSource.java +++ b/src/main/java/io/github/dsheirer/source/tuner/channel/TunerChannelSource.java @@ -41,6 +41,7 @@ public abstract class TunerChannelSource extends ComplexSource implements ISourc protected String mThreadName; private final ChannelFrequencyErrorManager mChannelFrequencyErrorManager; private volatile long mStartTimestamp; + private volatile String mTunerName; /** * Tuner Channel Source is a Digital Drop Channel (DDC) abstract class that defines the minimum functionality @@ -112,6 +113,24 @@ public abstract class TunerChannelSource extends ComplexSource implements ISourc return mTunerChannel; } + /** + * Name of the tuner that provides this channel source. + * @return preferred name of the tuner or null if not set + */ + public String getTunerName() + { + return mTunerName; + } + + /** + * Sets the name of the tuner that provides this channel source. + * @param tunerName preferred name of the tuner + */ + public void setTunerName(String tunerName) + { + mTunerName = tunerName; + } + /** * Sets the timestamp for the oldest samples to provide to this channel when it starts. This only applies to * sources where the producer incorporates a sample delay buffer. diff --git a/src/main/java/io/github/dsheirer/source/tuner/manager/TunerManager.java b/src/main/java/io/github/dsheirer/source/tuner/manager/TunerManager.java index 7811c3e8..7b98ed08 100644 --- a/src/main/java/io/github/dsheirer/source/tuner/manager/TunerManager.java +++ b/src/main/java/io/github/dsheirer/source/tuner/manager/TunerManager.java @@ -655,6 +655,7 @@ public class TunerManager implements IDiscoveredTunerStatusListener if(source != null) { + source.setTunerName(discoveredTuner.getTuner().getPreferredName()); return source; } } @@ -680,6 +681,11 @@ public class TunerManager implements IDiscoveredTunerStatusListener { source = discoveredTuner.getTuner().getChannelSourceManager().getSource(tunerChannel, channelSpecification, threadName); + + if(source != null) + { + source.setTunerName(discoveredTuner.getTuner().getPreferredName()); + } } catch(Exception e) {