mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-11 08:07:24 -05:00
Patch from @ImagoTrigger to implement headless operation: 9e4d2adfa9..c597d1967b (#1191)
Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
@@ -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 <http://www.gnu.org/licenses/>
|
||||
* * *****************************************************************************
|
||||
* 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 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<ChannelEvent>
|
||||
{
|
||||
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<ChannelEvent>
|
||||
|
||||
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(() -> {
|
||||
|
||||
@@ -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<TunerEvent>
|
||||
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<TunerEvent>
|
||||
|
||||
public SDRTrunk()
|
||||
{
|
||||
if(!GraphicsEnvironment.isHeadless())
|
||||
{
|
||||
mMainGui = new JFrame();
|
||||
}
|
||||
|
||||
mApplicationLog = new ApplicationLog(mUserPreferences);
|
||||
mApplicationLog.start();
|
||||
|
||||
@@ -163,7 +169,11 @@ public class SDRTrunk implements Listener<TunerEvent>
|
||||
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<TunerEvent>
|
||||
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<TunerEvent>
|
||||
|
||||
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<TunerEvent>
|
||||
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<TunerEvent>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user