diff --git a/plugins/samplesink/soapysdroutput/readme.md b/plugins/samplesink/soapysdroutput/readme.md
index 69e49d74a..7e2b33f28 100644
--- a/plugins/samplesink/soapysdroutput/readme.md
+++ b/plugins/samplesink/soapysdroutput/readme.md
@@ -30,6 +30,8 @@ Occasionally some devices may require to have the user specifying keyword parame
In such a case you will use the device user arguments (Preferences -> Devices -> User arguments) with the dialog as described [here](../../../sdrgui/deviceuserargs.md)
+If you use Soapy Remote make sure you read [this Wiki page](https://github.com/f4exb/sdrangel/wiki/Soapy-Remote) first as user arguments are mandatory.
+
SoapySDR API implementation
Not all parts are implemented. Currently the following have been left out:
diff --git a/plugins/samplesink/soapysdroutput/soapysdroutput.cpp b/plugins/samplesink/soapysdroutput/soapysdroutput.cpp
index fc2dae9ad..5804c4ed1 100644
--- a/plugins/samplesink/soapysdroutput/soapysdroutput.cpp
+++ b/plugins/samplesink/soapysdroutput/soapysdroutput.cpp
@@ -42,10 +42,10 @@ SoapySDROutput::SoapySDROutput(DeviceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
m_deviceDescription("SoapySDROutput"),
m_running(false),
- m_thread(0)
+ m_thread(nullptr)
{
m_deviceAPI->setNbSinkStreams(1);
- openDevice();
+ m_openSuccess = openDevice();
initGainSettings(m_settings);
initTunableElementsSettings(m_settings);
initStreamArgSettings(m_settings);
@@ -94,7 +94,7 @@ bool SoapySDROutput::openDevice()
DeviceAPI *sinkBuddy = m_deviceAPI->getSinkBuddies()[0];
DeviceSoapySDRShared *deviceSoapySDRShared = (DeviceSoapySDRShared*) sinkBuddy->getBuddySharedPtr();
- if (deviceSoapySDRShared == 0)
+ if (!deviceSoapySDRShared)
{
qCritical("SoapySDROutput::openDevice: the sink buddy shared pointer is null");
return false;
@@ -102,7 +102,7 @@ bool SoapySDROutput::openDevice()
SoapySDR::Device *device = deviceSoapySDRShared->m_device;
- if (device == 0)
+ if (!device)
{
qCritical("SoapySDROutput::openDevice: cannot get device pointer from Tx buddy");
return false;
@@ -119,7 +119,7 @@ bool SoapySDROutput::openDevice()
DeviceAPI *sourceBuddy = m_deviceAPI->getSourceBuddies()[0];
DeviceSoapySDRShared *deviceSoapySDRShared = (DeviceSoapySDRShared*) sourceBuddy->getBuddySharedPtr();
- if (deviceSoapySDRShared == 0)
+ if (!deviceSoapySDRShared)
{
qCritical("SoapySDROutput::openDevice: the source buddy shared pointer is null");
return false;
@@ -127,7 +127,7 @@ bool SoapySDROutput::openDevice()
SoapySDR::Device *device = deviceSoapySDRShared->m_device;
- if (device == 0)
+ if (!device)
{
qCritical("SoapySDROutput::openDevice: cannot get device pointer from Rx buddy");
return false;
@@ -160,7 +160,7 @@ bool SoapySDROutput::openDevice()
void SoapySDROutput::closeDevice()
{
- if (m_deviceShared.m_device == 0) { // was never open
+ if (!m_deviceShared.m_device) { // was never open
return;
}
@@ -173,7 +173,7 @@ void SoapySDROutput::closeDevice()
}
m_deviceShared.m_channel = -1; // publicly release channel
- m_deviceShared.m_sink = 0;
+ m_deviceShared.m_sink = nullptr;
// No buddies so effectively close the device
@@ -181,7 +181,7 @@ void SoapySDROutput::closeDevice()
{
DeviceSoapySDR& deviceSoapySDR = DeviceSoapySDR::instance();
deviceSoapySDR.closeSoapySdr(m_deviceShared.m_device);
- m_deviceShared.m_device = 0;
+ m_deviceShared.m_device = nullptr;
}
}
@@ -371,9 +371,9 @@ void SoapySDROutput::init()
SoapySDROutputThread *SoapySDROutput::findThread()
{
- if (m_thread == 0) // this does not own the thread
+ if (!m_thread) // this does not own the thread
{
- SoapySDROutputThread *soapySDROutputThread = 0;
+ SoapySDROutputThread *soapySDROutputThread = nullptr;
// find a buddy that has allocated the thread
const std::vector& sinkBuddies = m_deviceAPI->getSinkBuddies();
@@ -413,7 +413,7 @@ void SoapySDROutput::moveThreadToBuddy()
if (buddySink)
{
buddySink->setThread(m_thread);
- m_thread = 0; // zero for others
+ m_thread = nullptr; // zero for others
}
}
}
@@ -452,6 +452,11 @@ bool SoapySDROutput::start()
// Note: this is quite similar to the BladeRF2 start handling. The main difference is that the channel allocation (enabling) process is
// done in the thread object.
+ if (!m_openSuccess)
+ {
+ qWarning("SoapySDROutput::start: cannot start device");
+ return false;
+ }
if (!m_deviceShared.m_device)
{
@@ -559,7 +564,7 @@ void SoapySDROutput::stop()
int requestedChannel = m_deviceAPI->getDeviceItemIndex();
SoapySDROutputThread *soapySDROutputThread = findThread();
- if (soapySDROutputThread == 0) { // no thread allocated
+ if (!soapySDROutputThread) { // no thread allocated
return;
}
@@ -570,7 +575,7 @@ void SoapySDROutput::stop()
qDebug("SoapySDROutput::stop: SO mode. Just stop and delete the thread");
soapySDROutputThread->stopWork();
delete soapySDROutputThread;
- m_thread = 0;
+ m_thread = nullptr;
// remove old thread address from buddies (reset in all buddies)
const std::vector& sinkBuddies = m_deviceAPI->getSinkBuddies();
@@ -592,7 +597,7 @@ void SoapySDROutput::stop()
{
fifos[i] = soapySDROutputThread->getFifo(i);
- if ((soapySDROutputThread->getFifo(i) != 0) && (i > highestActiveChannelIndex)) {
+ if ((soapySDROutputThread->getFifo(i)) && (i > highestActiveChannelIndex)) {
highestActiveChannelIndex = i;
}
@@ -600,7 +605,7 @@ void SoapySDROutput::stop()
}
delete soapySDROutputThread;
- m_thread = 0;
+ m_thread = nullptr;
if (highestActiveChannelIndex >= 0)
{
@@ -638,7 +643,7 @@ void SoapySDROutput::stop()
else // remove channel from existing thread
{
qDebug("SoapySDROutput::stop: MO mode. Not changing MO configuration. Just remove FIFO reference");
- soapySDROutputThread->setFifo(requestedChannel, 0); // remove FIFO
+ soapySDROutputThread->setFifo(requestedChannel, nullptr); // remove FIFO
}
applySettings(m_settings, true); // re-apply forcibly to set sample rate with the new number of channels
@@ -727,7 +732,7 @@ bool SoapySDROutput::setDeviceCenterFrequency(SoapySDR::Device *dev, int request
void SoapySDROutput::updateGains(SoapySDR::Device *dev, int requestedChannel, SoapySDROutputSettings& settings)
{
- if (dev == 0) {
+ if (!dev) {
return;
}
@@ -747,7 +752,7 @@ void SoapySDROutput::updateGains(SoapySDR::Device *dev, int requestedChannel, So
void SoapySDROutput::updateTunableElements(SoapySDR::Device *dev, int requestedChannel, SoapySDROutputSettings& settings)
{
- if (dev == 0) {
+ if (!dev) {
return;
}
@@ -886,7 +891,7 @@ bool SoapySDROutput::applySettings(const SoapySDROutputSettings& settings, bool
if (soapySDROutputThread)
{
fifo = soapySDROutputThread->getFifo(requestedChannel);
- soapySDROutputThread->setFifo(requestedChannel, 0);
+ soapySDROutputThread->setFifo(requestedChannel, nullptr);
}
unsigned int fifoRate = std::max(
@@ -905,7 +910,7 @@ bool SoapySDROutput::applySettings(const SoapySDROutputSettings& settings, bool
forwardChangeOwnDSP = true;
forwardChangeToBuddies = true;
- if (dev != 0)
+ if (dev)
{
try
{
@@ -936,7 +941,7 @@ bool SoapySDROutput::applySettings(const SoapySDROutputSettings& settings, bool
reverseAPIKeys.append("log2Interp");
forwardChangeOwnDSP = true;
- if (outputThread != 0)
+ if (outputThread)
{
outputThread->setLog2Interpolation(requestedChannel, settings.m_log2Interp);
qDebug() << "SoapySDROutput::applySettings: set decimation to " << (1< Devices -> User arguments) with the dialog as described [here](../../../sdrgui/deviceuserargs.md)
+If you use Soapy Remote make sure you read [this Wiki page](https://github.com/f4exb/sdrangel/wiki/Soapy-Remote) first as user arguments are mandatory.
+
SoapySDR API implementation
Not all parts are implemented. Currently the following have been left out:
diff --git a/plugins/samplesource/soapysdrinput/soapysdrinput.cpp b/plugins/samplesource/soapysdrinput/soapysdrinput.cpp
index 3eaa5dc37..d18141952 100644
--- a/plugins/samplesource/soapysdrinput/soapysdrinput.cpp
+++ b/plugins/samplesource/soapysdrinput/soapysdrinput.cpp
@@ -47,7 +47,7 @@ SoapySDRInput::SoapySDRInput(DeviceAPI *deviceAPI) :
m_thread(nullptr)
{
m_sampleFifo.setLabel(m_deviceDescription);
- openDevice();
+ m_openSuccess = openDevice();
initGainSettings(m_settings);
initTunableElementsSettings(m_settings);
initStreamArgSettings(m_settings);
@@ -106,7 +106,7 @@ bool SoapySDRInput::openDevice()
DeviceAPI *sourceBuddy = m_deviceAPI->getSourceBuddies()[0];
DeviceSoapySDRShared *deviceSoapySDRShared = (DeviceSoapySDRShared*) sourceBuddy->getBuddySharedPtr();
- if (deviceSoapySDRShared == 0)
+ if (!deviceSoapySDRShared)
{
qCritical("SoapySDRInput::openDevice: the source buddy shared pointer is null");
return false;
@@ -114,7 +114,7 @@ bool SoapySDRInput::openDevice()
SoapySDR::Device *device = deviceSoapySDRShared->m_device;
- if (device == 0)
+ if (!device)
{
qCritical("SoapySDRInput::openDevice: cannot get device pointer from Rx buddy");
return false;
@@ -131,7 +131,7 @@ bool SoapySDRInput::openDevice()
DeviceAPI *sinkBuddy = m_deviceAPI->getSinkBuddies()[0];
DeviceSoapySDRShared *deviceSoapySDRShared = (DeviceSoapySDRShared*) sinkBuddy->getBuddySharedPtr();
- if (deviceSoapySDRShared == 0)
+ if (!deviceSoapySDRShared)
{
qCritical("SoapySDRInput::openDevice: the sink buddy shared pointer is null");
return false;
@@ -139,7 +139,7 @@ bool SoapySDRInput::openDevice()
SoapySDR::Device *device = deviceSoapySDRShared->m_device;
- if (device == 0)
+ if (!device)
{
qCritical("SoapySDRInput::openDevice: cannot get device pointer from Tx buddy");
return false;
@@ -172,7 +172,7 @@ bool SoapySDRInput::openDevice()
void SoapySDRInput::closeDevice()
{
- if (m_deviceShared.m_device == 0) { // was never open
+ if (!m_deviceShared.m_device) { // was never open
return;
}
@@ -185,17 +185,17 @@ void SoapySDRInput::closeDevice()
}
m_deviceShared.m_channel = -1; // publicly release channel
- m_deviceShared.m_source = 0;
+ m_deviceShared.m_source = nullptr;
// No buddies so effectively close the device and delete parameters
if ((m_deviceAPI->getSinkBuddies().size() == 0) && (m_deviceAPI->getSourceBuddies().size() == 0))
{
delete m_deviceShared.m_deviceParams;
- m_deviceShared.m_deviceParams = 0;
+ m_deviceShared.m_deviceParams = nullptr;
DeviceSoapySDR& deviceSoapySDR = DeviceSoapySDR::instance();
deviceSoapySDR.closeSoapySdr(m_deviceShared.m_device);
- m_deviceShared.m_device = 0;
+ m_deviceShared.m_device = nullptr;
}
}
@@ -399,7 +399,7 @@ SoapySDRInputThread *SoapySDRInput::findThread()
{
if (!m_thread) // this does not own the thread
{
- SoapySDRInputThread *soapySDRInputThread = 0;
+ SoapySDRInputThread *soapySDRInputThread = nullptr;
// find a buddy that has allocated the thread
const std::vector& sourceBuddies = m_deviceAPI->getSourceBuddies();
@@ -480,6 +480,12 @@ bool SoapySDRInput::start()
// Note: this is quite similar to the BladeRF2 start handling. The main difference is that the channel allocation (enabling) process is
// done in the thread object.
+ if (!m_openSuccess)
+ {
+ qWarning("SoapySDRInput::start: cannot start device");
+ return false;
+ }
+
if (!m_deviceShared.m_device)
{
qDebug("SoapySDRInput::start: no device object");
@@ -595,7 +601,7 @@ void SoapySDRInput::stop()
int requestedChannel = m_deviceAPI->getDeviceItemIndex();
SoapySDRInputThread *soapySDRInputThread = findThread();
- if (soapySDRInputThread == 0) { // no thread allocated
+ if (!soapySDRInputThread) { // no thread allocated
return;
}
@@ -678,7 +684,7 @@ void SoapySDRInput::stop()
else // remove channel from existing thread
{
qDebug("SoapySDRInput::stop: MI mode. Not changing MI configuration. Just remove FIFO reference");
- soapySDRInputThread->setFifo(requestedChannel, 0); // remove FIFO
+ soapySDRInputThread->setFifo(requestedChannel, nullptr); // remove FIFO
}
m_running = false;
@@ -750,7 +756,7 @@ bool SoapySDRInput::setDeviceCenterFrequency(SoapySDR::Device *dev, int requeste
void SoapySDRInput::updateGains(SoapySDR::Device *dev, int requestedChannel, SoapySDRInputSettings& settings)
{
- if (dev == 0) {
+ if (!dev) {
return;
}
@@ -770,7 +776,7 @@ void SoapySDRInput::updateGains(SoapySDR::Device *dev, int requestedChannel, Soa
void SoapySDRInput::updateTunableElements(SoapySDR::Device *dev, int requestedChannel, SoapySDRInputSettings& settings)
{
- if (dev == 0) {
+ if (!dev) {
return;
}
@@ -925,7 +931,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
forwardChangeOwnDSP = true;
forwardChangeToBuddies = true;
- if (dev != 0)
+ if (dev)
{
try
{
@@ -1020,7 +1026,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
forwardChangeOwnDSP = true;
forwardChangeToBuddies = true;
- if (dev != 0) {
+ if (dev) {
setDeviceCenterFrequency(dev, requestedChannel, deviceCenterFrequency, settings.m_LOppmTenths);
}
}
@@ -1029,7 +1035,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
{
reverseAPIKeys.append("antenna");
- if (dev != 0)
+ if (dev)
{
try
{
@@ -1049,7 +1055,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
reverseAPIKeys.append("bandwidth");
forwardChangeToBuddies = true;
- if (dev != 0)
+ if (dev)
{
try
{
@@ -1070,7 +1076,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
if (nvalue != settings.m_tunableElements.end() && ((m_settings.m_tunableElements[oname] != *nvalue) ||force))
{
- if (dev != 0)
+ if (dev)
{
try
{
@@ -1093,7 +1099,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
{
reverseAPIKeys.append("globalGain");
- if (dev != 0)
+ if (dev)
{
try
{
@@ -1115,7 +1121,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
if (nvalue != settings.m_individualGains.end() && ((m_settings.m_individualGains[oname] != *nvalue) || force))
{
- if (dev != 0)
+ if (dev)
{
try
{
@@ -1139,7 +1145,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
{
reverseAPIKeys.append("autoGain");
- if (dev != 0)
+ if (dev)
{
try
{
@@ -1157,7 +1163,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
{
reverseAPIKeys.append("autoDCCorrection");
- if ((dev != 0) && hasDCAutoCorrection())
+ if ((dev) && hasDCAutoCorrection())
{
try
{
@@ -1175,7 +1181,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
{
reverseAPIKeys.append("dcCorrection");
- if ((dev != 0) && hasDCCorrectionValue())
+ if ((dev) && hasDCCorrectionValue())
{
try
{
@@ -1193,7 +1199,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
{
reverseAPIKeys.append("iqCorrection");
- if ((dev != 0) && hasIQCorrectionValue())
+ if ((dev) && hasIQCorrectionValue())
{
try
{
@@ -1213,7 +1219,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
if (nvalue != settings.m_streamArgSettings.end() && ((m_settings.m_streamArgSettings[oname] != *nvalue) || force))
{
- if (dev != 0)
+ if (dev)
{
try
{
@@ -1238,7 +1244,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
if (nvalue != settings.m_deviceArgSettings.end() && ((m_settings.m_deviceArgSettings[oname] != *nvalue) || force))
{
- if (dev != 0)
+ if (dev)
{
try
{
diff --git a/plugins/samplesource/soapysdrinput/soapysdrinput.h b/plugins/samplesource/soapysdrinput/soapysdrinput.h
index 55e3844ed..cebadb642 100644
--- a/plugins/samplesource/soapysdrinput/soapysdrinput.h
+++ b/plugins/samplesource/soapysdrinput/soapysdrinput.h
@@ -195,6 +195,7 @@ public:
private:
DeviceAPI *m_deviceAPI;
QMutex m_mutex;
+ bool m_openSuccess;
SoapySDRInputSettings m_settings;
QString m_deviceDescription;
bool m_running;