mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 17:47:32 -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
|
||||||
*
|
*
|
||||||
* * ******************************************************************************
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* * Copyright (C) 2014-2020 Dennis Sheirer
|
* it under the terms of the GNU General Public License as published by
|
||||||
* *
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* * This program is free software: you can redistribute it and/or modify
|
* (at your option) any later version.
|
||||||
* * 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 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;
|
package io.github.dsheirer.controller.channel;
|
||||||
|
|
||||||
@@ -55,6 +52,7 @@ import javafx.application.Platform;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -439,8 +437,15 @@ public class ChannelProcessingManager implements Listener<ChannelEvent>
|
|||||||
{
|
{
|
||||||
processingChain.start();
|
processingChain.start();
|
||||||
|
|
||||||
//This has to be done on the FX event thread when the playlist editor is constructed
|
if(GraphicsEnvironment.isHeadless())
|
||||||
Platform.runLater(() -> channel.setProcessing(true));
|
{
|
||||||
|
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));
|
mChannelEventBroadcaster.broadcast(new ChannelEvent(channel, ChannelEvent.Event.NOTIFICATION_PROCESSING_START));
|
||||||
}
|
}
|
||||||
@@ -530,8 +535,15 @@ public class ChannelProcessingManager implements Listener<ChannelEvent>
|
|||||||
|
|
||||||
if(processingChain != null)
|
if(processingChain != null)
|
||||||
{
|
{
|
||||||
//This has to be done on the FX event thread when the playlist editor is constructed
|
if(GraphicsEnvironment.isHeadless())
|
||||||
Platform.runLater(() -> channel.setProcessing(false));
|
{
|
||||||
|
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
|
//Since the processing chain's source will block on stop(), throw it to the thread pool to run
|
||||||
ThreadPool.CACHED.submit(() -> {
|
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.ControllerPanel;
|
||||||
import io.github.dsheirer.controller.channel.Channel;
|
import io.github.dsheirer.controller.channel.Channel;
|
||||||
import io.github.dsheirer.controller.channel.ChannelAutoStartFrame;
|
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.controller.channel.ChannelSelectionManager;
|
||||||
import io.github.dsheirer.eventbus.MyEventBus;
|
import io.github.dsheirer.eventbus.MyEventBus;
|
||||||
import io.github.dsheirer.gui.icon.ViewIconManagerRequest;
|
import io.github.dsheirer.gui.icon.ViewIconManagerRequest;
|
||||||
@@ -107,7 +108,7 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
private SourceManager mSourceManager;
|
private SourceManager mSourceManager;
|
||||||
private SettingsManager mSettingsManager;
|
private SettingsManager mSettingsManager;
|
||||||
private SpectralDisplayPanel mSpectralPanel;
|
private SpectralDisplayPanel mSpectralPanel;
|
||||||
private JFrame mMainGui = new JFrame();
|
private JFrame mMainGui;
|
||||||
private JideSplitPane mSplitPane;
|
private JideSplitPane mSplitPane;
|
||||||
private JavaFxWindowManager mJavaFxWindowManager;
|
private JavaFxWindowManager mJavaFxWindowManager;
|
||||||
private UserPreferences mUserPreferences = new UserPreferences();
|
private UserPreferences mUserPreferences = new UserPreferences();
|
||||||
@@ -117,6 +118,11 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
|
|
||||||
public SDRTrunk()
|
public SDRTrunk()
|
||||||
{
|
{
|
||||||
|
if(!GraphicsEnvironment.isHeadless())
|
||||||
|
{
|
||||||
|
mMainGui = new JFrame();
|
||||||
|
}
|
||||||
|
|
||||||
mApplicationLog = new ApplicationLog(mUserPreferences);
|
mApplicationLog = new ApplicationLog(mUserPreferences);
|
||||||
mApplicationLog.start();
|
mApplicationLog.start();
|
||||||
|
|
||||||
@@ -163,7 +169,11 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
AliasModel aliasModel = new AliasModel();
|
AliasModel aliasModel = new AliasModel();
|
||||||
EventLogManager eventLogManager = new EventLogManager(aliasModel, mUserPreferences);
|
EventLogManager eventLogManager = new EventLogManager(aliasModel, mUserPreferences);
|
||||||
mPlaylistManager = new PlaylistManager(mUserPreferences, mSourceManager, aliasModel, eventLogManager, mIconModel);
|
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);
|
CalibrationManager calibrationManager = CalibrationManager.getInstance(mUserPreferences);
|
||||||
final boolean calibrating = !calibrationManager.isCalibrated() &&
|
final boolean calibrating = !calibrationManager.isCalibrated() &&
|
||||||
@@ -190,8 +200,11 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
MapService mapService = new MapService(mIconModel);
|
MapService mapService = new MapService(mIconModel);
|
||||||
mPlaylistManager.getChannelProcessingManager().addDecodeEventListener(mapService);
|
mPlaylistManager.getChannelProcessingManager().addDecodeEventListener(mapService);
|
||||||
|
|
||||||
mControllerPanel = new ControllerPanel(mPlaylistManager, audioPlaybackManager, mIconModel, mapService,
|
if(!GraphicsEnvironment.isHeadless())
|
||||||
mSettingsManager, mSourceManager, mUserPreferences);
|
{
|
||||||
|
mControllerPanel = new ControllerPanel(mPlaylistManager, audioPlaybackManager, mIconModel, mapService,
|
||||||
|
mSettingsManager, mSourceManager, mUserPreferences);
|
||||||
|
}
|
||||||
|
|
||||||
mSpectralPanel = new SpectralDisplayPanel(mPlaylistManager, mSettingsManager, tunerModel);
|
mSpectralPanel = new SpectralDisplayPanel(mPlaylistManager, mSettingsManager, tunerModel);
|
||||||
|
|
||||||
@@ -202,10 +215,17 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
|
|
||||||
mPlaylistManager.init();
|
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
|
//Initialize the GUI
|
||||||
initGUI();
|
initGUI();
|
||||||
|
}
|
||||||
|
|
||||||
tunerModel.requestFirstTunerDisplay();
|
tunerModel.requestFirstTunerDisplay();
|
||||||
|
|
||||||
@@ -213,9 +233,12 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
EventQueue.invokeLater(() -> {
|
EventQueue.invokeLater(() -> {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mMainGui.setVisible(true);
|
if(!GraphicsEnvironment.isHeadless())
|
||||||
|
{
|
||||||
|
mMainGui.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
if(calibrating)
|
if(calibrating && !GraphicsEnvironment.isHeadless())
|
||||||
{
|
{
|
||||||
Platform.runLater(() ->
|
Platform.runLater(() ->
|
||||||
{
|
{
|
||||||
@@ -256,8 +279,25 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
|
|
||||||
if(channels.size() > 0)
|
if(channels.size() > 0)
|
||||||
{
|
{
|
||||||
ChannelAutoStartFrame autoStartFrame = new ChannelAutoStartFrame(mPlaylistManager.getChannelProcessingManager(),
|
if(GraphicsEnvironment.isHeadless())
|
||||||
channels);
|
{
|
||||||
|
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