mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
Fully implements application shutdown procedure that is invoked when the
user closes the the main gui window or invokes exit from the file menu.
This commit is contained in:
@@ -98,8 +98,12 @@ public abstract class Tuner implements ISourceEventProcessor
|
||||
return mName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose and prepare for shutdown
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
getTunerController().dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,6 +61,11 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
mSourceEventListener = new SourceEventListenerToProcessorAdapter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose of this tuner controller and prepare for shutdown.
|
||||
*/
|
||||
public abstract void dispose();
|
||||
|
||||
/**
|
||||
* Implements the ISourceEventListener interface to receive requests from sample consumers
|
||||
*/
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
/*******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
* sdr-trunk
|
||||
* Copyright (C) 2014-2018 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 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.
|
||||
* 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/>
|
||||
* 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.source.tuner;
|
||||
@@ -74,7 +71,15 @@ public class TunerManager
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
mLog.info("Shutting down LibUsb ...");
|
||||
try
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("Error shutting down LibUsb", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,6 +222,22 @@ public class TunerManager
|
||||
return new TunerInitStatus(null, "Unknown Device");
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases all tuners in preparation for shutdown
|
||||
*/
|
||||
public void releaseTuners()
|
||||
{
|
||||
mLog.info("Releasing [" + mTunerModel.getTuners().size() + "] tuner(s) ...");
|
||||
Tuner tuner = mTunerModel.getTuner(0);
|
||||
|
||||
while(tuner != null)
|
||||
{
|
||||
mTunerModel.removeTuner(tuner);
|
||||
tuner.dispose();
|
||||
tuner = mTunerModel.getTuner(0);
|
||||
}
|
||||
}
|
||||
|
||||
private TunerInitStatus initAirspyTuner(Device device,
|
||||
DeviceDescriptor descriptor)
|
||||
{
|
||||
|
||||
@@ -180,6 +180,24 @@ public class AirspyTunerController extends USBTunerController
|
||||
USB_TRANSFER_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose()
|
||||
{
|
||||
if(mDeviceHandle != null)
|
||||
{
|
||||
mLog.info("Releasing Airspy Tuner - " + getDeviceInfo().getSerialNumber());
|
||||
try
|
||||
{
|
||||
LibUsb.close(mDeviceHandle);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("error while closing device handle", e);
|
||||
}
|
||||
|
||||
mDeviceHandle = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected USBTransferProcessor getUSBTransferProcessor()
|
||||
|
||||
@@ -37,10 +37,6 @@ public class HackRFTuner extends Tuner
|
||||
return (HackRFTunerController)getTunerController();
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TunerClass getTunerClass()
|
||||
{
|
||||
|
||||
@@ -157,6 +157,25 @@ public class HackRFTunerController extends USBTunerController
|
||||
mUSBTransferProcessor = new USBTransferProcessor(name, mDeviceHandle, mNativeBufferConverter, USB_TRANSFER_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose()
|
||||
{
|
||||
if(mDeviceHandle != null)
|
||||
{
|
||||
mLog.info("Releasing HackRF Tuner");
|
||||
try
|
||||
{
|
||||
LibUsb.close(mDeviceHandle);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("error while closing device handle", e);
|
||||
}
|
||||
|
||||
mDeviceHandle = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected USBTransferProcessor getUSBTransferProcessor()
|
||||
{
|
||||
|
||||
@@ -38,10 +38,6 @@ public class RTL2832Tuner extends Tuner
|
||||
mTunerClass = tunerClass;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public RTL2832TunerController getController()
|
||||
{
|
||||
return (RTL2832TunerController)getTunerController();
|
||||
|
||||
@@ -256,6 +256,26 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
USB_TRANSFER_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose()
|
||||
{
|
||||
if(mDeviceHandle != null)
|
||||
{
|
||||
mLog.info("Releasing E4000 Tuner");
|
||||
|
||||
try
|
||||
{
|
||||
LibUsb.close(mDeviceHandle);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("error while closing device handle", e);
|
||||
}
|
||||
|
||||
mDeviceHandle = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IF filters (mixer, channel and RC) to the correct filter setting
|
||||
* for the selected bandwidth/sample rate
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.usb4java.Device;
|
||||
import org.usb4java.DeviceDescriptor;
|
||||
import org.usb4java.LibUsb;
|
||||
import org.usb4java.LibUsbException;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
@@ -260,6 +261,26 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose()
|
||||
{
|
||||
mLog.info("Releasing R820T Tuner");
|
||||
|
||||
if(mDeviceHandle != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
LibUsb.close(mDeviceHandle);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("error while closing device handle", e);
|
||||
}
|
||||
|
||||
mDeviceHandle = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the tuner section.
|
||||
*/
|
||||
|
||||
@@ -65,6 +65,12 @@ public class TestTunerController extends TunerController
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose()
|
||||
{
|
||||
//no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBufferListener(Listener<ReusableComplexBuffer> listener)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user