diff --git a/src/main/java/io/github/dsheirer/controller/channel/ChannelProcessingManager.java b/src/main/java/io/github/dsheirer/controller/channel/ChannelProcessingManager.java
index 01327525..642a540d 100644
--- a/src/main/java/io/github/dsheirer/controller/channel/ChannelProcessingManager.java
+++ b/src/main/java/io/github/dsheirer/controller/channel/ChannelProcessingManager.java
@@ -1,23 +1,20 @@
/*
+ * *****************************************************************************
+ * Copyright (C) 2014-2022 Dennis Sheirer
*
- * * ******************************************************************************
- * * Copyright (C) 2014-2020 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
- * * *****************************************************************************
+ * 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
+ * ****************************************************************************
*/
package io.github.dsheirer.controller.channel;
@@ -55,6 +52,7 @@ import javafx.application.Platform;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -439,8 +437,15 @@ public class ChannelProcessingManager implements Listener
{
processingChain.start();
- //This has to be done on the FX event thread when the playlist editor is constructed
- Platform.runLater(() -> channel.setProcessing(true));
+ if(GraphicsEnvironment.isHeadless())
+ {
+ channel.setProcessing(true);
+ }
+ else
+ {
+ //This has to be done on the FX event thread when the playlist editor is constructed
+ Platform.runLater(() -> channel.setProcessing(true));
+ }
mChannelEventBroadcaster.broadcast(new ChannelEvent(channel, ChannelEvent.Event.NOTIFICATION_PROCESSING_START));
}
@@ -530,8 +535,15 @@ public class ChannelProcessingManager implements Listener
if(processingChain != null)
{
- //This has to be done on the FX event thread when the playlist editor is constructed
- Platform.runLater(() -> channel.setProcessing(false));
+ if(GraphicsEnvironment.isHeadless())
+ {
+ channel.setProcessing(false);
+ }
+ else
+ {
+ //This has to be done on the FX event thread when the playlist editor is constructed
+ Platform.runLater(() -> channel.setProcessing(false));
+ }
//Since the processing chain's source will block on stop(), throw it to the thread pool to run
ThreadPool.CACHED.submit(() -> {
diff --git a/src/main/java/io/github/dsheirer/gui/SDRTrunk.java b/src/main/java/io/github/dsheirer/gui/SDRTrunk.java
index 3e499d0b..3b212860 100644
--- a/src/main/java/io/github/dsheirer/gui/SDRTrunk.java
+++ b/src/main/java/io/github/dsheirer/gui/SDRTrunk.java
@@ -29,6 +29,7 @@ import io.github.dsheirer.audio.playback.AudioPlaybackManager;
import io.github.dsheirer.controller.ControllerPanel;
import io.github.dsheirer.controller.channel.Channel;
import io.github.dsheirer.controller.channel.ChannelAutoStartFrame;
+import io.github.dsheirer.controller.channel.ChannelException;
import io.github.dsheirer.controller.channel.ChannelSelectionManager;
import io.github.dsheirer.eventbus.MyEventBus;
import io.github.dsheirer.gui.icon.ViewIconManagerRequest;
@@ -107,7 +108,7 @@ public class SDRTrunk implements Listener
private SourceManager mSourceManager;
private SettingsManager mSettingsManager;
private SpectralDisplayPanel mSpectralPanel;
- private JFrame mMainGui = new JFrame();
+ private JFrame mMainGui;
private JideSplitPane mSplitPane;
private JavaFxWindowManager mJavaFxWindowManager;
private UserPreferences mUserPreferences = new UserPreferences();
@@ -117,6 +118,11 @@ public class SDRTrunk implements Listener
public SDRTrunk()
{
+ if(!GraphicsEnvironment.isHeadless())
+ {
+ mMainGui = new JFrame();
+ }
+
mApplicationLog = new ApplicationLog(mUserPreferences);
mApplicationLog.start();
@@ -163,7 +169,11 @@ public class SDRTrunk implements Listener
AliasModel aliasModel = new AliasModel();
EventLogManager eventLogManager = new EventLogManager(aliasModel, mUserPreferences);
mPlaylistManager = new PlaylistManager(mUserPreferences, mSourceManager, aliasModel, eventLogManager, mIconModel);
- mJavaFxWindowManager = new JavaFxWindowManager(mUserPreferences, mPlaylistManager);
+
+ if(!GraphicsEnvironment.isHeadless())
+ {
+ mJavaFxWindowManager = new JavaFxWindowManager(mUserPreferences, mPlaylistManager);
+ }
CalibrationManager calibrationManager = CalibrationManager.getInstance(mUserPreferences);
final boolean calibrating = !calibrationManager.isCalibrated() &&
@@ -190,8 +200,11 @@ public class SDRTrunk implements Listener
MapService mapService = new MapService(mIconModel);
mPlaylistManager.getChannelProcessingManager().addDecodeEventListener(mapService);
- mControllerPanel = new ControllerPanel(mPlaylistManager, audioPlaybackManager, mIconModel, mapService,
- mSettingsManager, mSourceManager, mUserPreferences);
+ if(!GraphicsEnvironment.isHeadless())
+ {
+ mControllerPanel = new ControllerPanel(mPlaylistManager, audioPlaybackManager, mIconModel, mapService,
+ mSettingsManager, mSourceManager, mUserPreferences);
+ }
mSpectralPanel = new SpectralDisplayPanel(mPlaylistManager, mSettingsManager, tunerModel);
@@ -202,10 +215,17 @@ public class SDRTrunk implements Listener
mPlaylistManager.init();
- mLog.info("starting main application gui");
+ if(GraphicsEnvironment.isHeadless())
+ {
+ mLog.info("starting main application headless");
+ }
+ else
+ {
+ mLog.info("starting main application gui");
- //Initialize the GUI
- initGUI();
+ //Initialize the GUI
+ initGUI();
+ }
tunerModel.requestFirstTunerDisplay();
@@ -213,9 +233,12 @@ public class SDRTrunk implements Listener
EventQueue.invokeLater(() -> {
try
{
- mMainGui.setVisible(true);
+ if(!GraphicsEnvironment.isHeadless())
+ {
+ mMainGui.setVisible(true);
+ }
- if(calibrating)
+ if(calibrating && !GraphicsEnvironment.isHeadless())
{
Platform.runLater(() ->
{
@@ -256,8 +279,25 @@ public class SDRTrunk implements Listener
if(channels.size() > 0)
{
- ChannelAutoStartFrame autoStartFrame = new ChannelAutoStartFrame(mPlaylistManager.getChannelProcessingManager(),
- channels);
+ if(GraphicsEnvironment.isHeadless())
+ {
+ for(Channel channel: channels)
+ {
+ try
+ {
+ mLog.info("Auto-starting channel " + channel.getName());
+ mPlaylistManager.getChannelProcessingManager().start(channel);
+ }
+ catch(ChannelException ce)
+ {
+ mLog.error("Channel: " + channel.getName() + " auto-start failed: " + ce.getMessage());
+ }
+ }
+ }
+ else
+ {
+ new ChannelAutoStartFrame(mPlaylistManager.getChannelProcessingManager(), channels);
+ }
}
}