mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-16 18:47:33 -05:00
#1511 Resolves issue with SDRPlay library crashes application when linux service is in stopped state. (#1514)
Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
@@ -185,9 +185,19 @@ public class TunerFactory
|
|||||||
{
|
{
|
||||||
//API instance is retained across the lifecycle of the constructed device, so we only close it if we don't get
|
//API instance is retained across the lifecycle of the constructed device, so we only close it if we don't get
|
||||||
//a device from it.
|
//a device from it.
|
||||||
SDRplay api = new SDRplay();
|
SDRplay api = null;
|
||||||
|
|
||||||
if(api.isAvailable())
|
try
|
||||||
|
{
|
||||||
|
api = new SDRplay();
|
||||||
|
}
|
||||||
|
catch(SDRPlayException se)
|
||||||
|
{
|
||||||
|
mLog.info("Caught the exception here ...", se);
|
||||||
|
api = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(api != null && api.isAvailable())
|
||||||
{
|
{
|
||||||
Device device = api.getDevice(deviceInfo);
|
Device device = api.getDevice(deviceInfo);
|
||||||
|
|
||||||
|
|||||||
@@ -299,9 +299,18 @@ public class TunerManager implements IDiscoveredTunerStatusListener
|
|||||||
|
|
||||||
//Note: we have to keep this first API instance open while we use any RSP tuners, otherwise the additional API
|
//Note: we have to keep this first API instance open while we use any RSP tuners, otherwise the additional API
|
||||||
//instance(s) used by the individual tuners become unresponsive. Note sure why.
|
//instance(s) used by the individual tuners become unresponsive. Note sure why.
|
||||||
mSDRplay = new SDRplay();
|
|
||||||
|
|
||||||
if(mSDRplay.isAvailable())
|
try
|
||||||
|
{
|
||||||
|
mSDRplay = new SDRplay();
|
||||||
|
}
|
||||||
|
catch(SDRPlayException se)
|
||||||
|
{
|
||||||
|
mLog.error("Couldn't load SDRPlay API");
|
||||||
|
mSDRplay = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mSDRplay != null && mSDRplay.isAvailable())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -333,7 +342,11 @@ public class TunerManager implements IDiscoveredTunerStatusListener
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mSDRplay.close();
|
if(mSDRplay != null)
|
||||||
|
{
|
||||||
|
mSDRplay.close();
|
||||||
|
}
|
||||||
|
|
||||||
mSDRplay = null;
|
mSDRplay = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class SDRplay
|
|||||||
/**
|
/**
|
||||||
* Constructs an instance of the SDRPLay API
|
* Constructs an instance of the SDRPLay API
|
||||||
*/
|
*/
|
||||||
public SDRplay()
|
public SDRplay() throws SDRPlayException
|
||||||
{
|
{
|
||||||
mSdrplayLibraryLoaded = loadLibrary();
|
mSdrplayLibraryLoaded = loadLibrary();
|
||||||
|
|
||||||
@@ -116,6 +116,11 @@ public class SDRplay
|
|||||||
mLog.info("API library - open status: " + openStatus);
|
mLog.info("API library - open status: " + openStatus);
|
||||||
}
|
}
|
||||||
mAvailable = openStatus.success() && getVersion().isSupported();
|
mAvailable = openStatus.success() && getVersion().isSupported();
|
||||||
|
|
||||||
|
if(openStatus == Status.FAIL)
|
||||||
|
{
|
||||||
|
throw new SDRPlayException("Service not available");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -693,23 +698,23 @@ public class SDRplay
|
|||||||
* Java will look there for the library, without having to specify it as a launcher
|
* Java will look there for the library, without having to specify it as a launcher
|
||||||
* option. This would allow for users that have installed the API to an alternate location.
|
* option. This would allow for users that have installed the API to an alternate location.
|
||||||
*/
|
*/
|
||||||
SDRplay sdrplay = new SDRplay();
|
|
||||||
Status status = sdrplay.open();
|
|
||||||
mLog.info("Open Status: " + status);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
SDRplay sdrplay = new SDRplay();
|
||||||
|
Status status = sdrplay.open();
|
||||||
|
mLog.info("Open Status: " + status);
|
||||||
|
|
||||||
for(DeviceInfo deviceInfo: sdrplay.getDeviceInfos())
|
for(DeviceInfo deviceInfo: sdrplay.getDeviceInfos())
|
||||||
{
|
{
|
||||||
mLog.info("Found: " + deviceInfo);
|
mLog.info("Found: " + deviceInfo);
|
||||||
}
|
}
|
||||||
|
Status closeStatus = sdrplay.close();
|
||||||
|
mLog.info("Close Status: " + closeStatus);
|
||||||
}
|
}
|
||||||
catch(SDRPlayException se)
|
catch(SDRPlayException se)
|
||||||
{
|
{
|
||||||
mLog.info("Error", se);
|
mLog.info("Error", se);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status closeStatus = sdrplay.close();
|
|
||||||
mLog.info("Close Status: " + closeStatus);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user