mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-22 03:36:24 -05:00
Handle stream init errors
This commit is contained in:
parent
884f740030
commit
8f1b68d20f
@ -55,7 +55,7 @@ SoapySDR::Kwargs SDRThread::combineArgs(SoapySDR::Kwargs a, SoapySDR::Kwargs b)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRThread::init() {
|
bool SDRThread::init() {
|
||||||
//#warning Debug On
|
//#warning Debug On
|
||||||
// SoapySDR_setLogLevel(SOAPY_SDR_DEBUG);
|
// SoapySDR_setLogLevel(SOAPY_SDR_DEBUG);
|
||||||
|
|
||||||
@ -77,7 +77,20 @@ void SDRThread::init() {
|
|||||||
device = devInfo->getSoapyDevice();
|
device = devInfo->getSoapyDevice();
|
||||||
|
|
||||||
SoapySDR::Kwargs currentStreamArgs = combineArgs(devInfo->getStreamArgs(),streamArgs);
|
SoapySDR::Kwargs currentStreamArgs = combineArgs(devInfo->getStreamArgs(),streamArgs);
|
||||||
stream = device->setupStream(SOAPY_SDR_RX,"CF32", std::vector<size_t>(), currentStreamArgs);
|
|
||||||
|
std::string streamExceptionStr("");
|
||||||
|
|
||||||
|
try {
|
||||||
|
stream = device->setupStream(SOAPY_SDR_RX,"CF32", std::vector<size_t>(), currentStreamArgs);
|
||||||
|
} catch(exception e) {
|
||||||
|
streamExceptionStr = e.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stream) {
|
||||||
|
wxGetApp().sdrThreadNotify(SDRThread::SDR_THREAD_FAILED, std::string("Stream setup failed, stream is null. ") + streamExceptionStr);
|
||||||
|
std::cout << "Stream setup failed, stream is null. " << streamExceptionStr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int streamMTU = device->getStreamMTU(stream);
|
int streamMTU = device->getStreamMTU(stream);
|
||||||
mtuElems.store(streamMTU);
|
mtuElems.store(streamMTU);
|
||||||
@ -152,6 +165,8 @@ void SDRThread::init() {
|
|||||||
updateSettings();
|
updateSettings();
|
||||||
|
|
||||||
wxGetApp().sdrThreadNotify(SDRThread::SDR_THREAD_INITIALIZED, std::string("Device Initialized."));
|
wxGetApp().sdrThreadNotify(SDRThread::SDR_THREAD_INITIALIZED, std::string("Device Initialized."));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRThread::deinit() {
|
void SDRThread::deinit() {
|
||||||
@ -276,6 +291,10 @@ void SDRThread::updateGains() {
|
|||||||
void SDRThread::updateSettings() {
|
void SDRThread::updateSettings() {
|
||||||
bool doUpdate = false;
|
bool doUpdate = false;
|
||||||
|
|
||||||
|
if (!stream) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (offset_changed.load()) {
|
if (offset_changed.load()) {
|
||||||
if (!freq_changed.load()) {
|
if (!freq_changed.load()) {
|
||||||
frequency.store(frequency.load());
|
frequency.store(frequency.load());
|
||||||
@ -394,7 +413,10 @@ void SDRThread::run() {
|
|||||||
|
|
||||||
if (activeDev != NULL) {
|
if (activeDev != NULL) {
|
||||||
std::cout << "device init()" << std::endl;
|
std::cout << "device init()" << std::endl;
|
||||||
init();
|
if (!init()) {
|
||||||
|
std::cout << "SDR Thread stream init error." << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::cout << "starting readLoop()" << std::endl;
|
std::cout << "starting readLoop()" << std::endl;
|
||||||
activeDev->setActive(true);
|
activeDev->setActive(true);
|
||||||
readLoop();
|
readLoop();
|
||||||
|
@ -40,7 +40,7 @@ typedef ThreadQueue<SDRThreadIQData *> SDRThreadIQDataQueue;
|
|||||||
|
|
||||||
class SDRThread : public IOThread {
|
class SDRThread : public IOThread {
|
||||||
private:
|
private:
|
||||||
void init();
|
bool init();
|
||||||
void deinit();
|
void deinit();
|
||||||
void readStream(SDRThreadIQDataQueue* iqDataOutQueue);
|
void readStream(SDRThreadIQDataQueue* iqDataOutQueue);
|
||||||
void readLoop();
|
void readLoop();
|
||||||
|
Loading…
Reference in New Issue
Block a user