1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 13:51:47 -05:00

Prevent use of not existent devices when fiddling with user device parameters. Fixes issue #510 partially

This commit is contained in:
f4exb 2020-05-20 08:27:39 +02:00
parent 3823f2b621
commit 187502b5f3
2 changed files with 90 additions and 0 deletions

View File

@ -1656,6 +1656,21 @@ void MainWindow::sampleSourceChanged()
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()));
if (deviceUI->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainWindow::sampleSourceChanged: non existent device replaced by File Input");
int deviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex();
samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex);
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceUI->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceUI->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceUI->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(deviceIndex));
}
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {
@ -1751,6 +1766,21 @@ void MainWindow::sampleSinkChanged()
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()));
if (deviceUI->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainWindow::sampleSinkChanged: non existent device replaced by File Sink");
int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileSinkDeviceIndex();
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceUI->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceUI->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceUI->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
}
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {
@ -1841,6 +1871,21 @@ void MainWindow::sampleMIMOChanged()
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(
DeviceEnumerator::instance()->getMIMOPluginInterface(deviceUI->m_samplingDeviceControl->getSelectedDeviceIndex()));
if (deviceUI->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainWindow::sampleMIMOChanged: non existent device replaced by Test MIMO");
int testMIMODeviceIndex = DeviceEnumerator::instance()->getTestMIMODeviceIndex();
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(testMIMODeviceIndex);
deviceUI->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceUI->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceUI->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceUI->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceUI->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceUI->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceUI->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceUI->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(testMIMODeviceIndex));
}
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {

View File

@ -437,6 +437,21 @@ void MainCore::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(selectedDeviceIndex));
if (deviceSet->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainCore::changeSampleSource: non existent device replaced by File Input");
int deviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex();
samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex);
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(deviceIndex));
}
// add to buddies list
std::vector<DeviceSet*>::iterator it = m_deviceSets.begin();
int nbOfBuddies = 0;
@ -505,6 +520,21 @@ void MainCore::changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(selectedDeviceIndex));
if (deviceSet->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainCore::changeSampleSink: non existent device replaced by File Sink");
int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileSinkDeviceIndex();
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
}
// add to buddies list
std::vector<DeviceSet*>::iterator it = m_deviceSets.begin();
int nbOfBuddies = 0;
@ -572,6 +602,21 @@ void MainCore::changeSampleMIMO(int deviceSetIndex, int selectedDeviceIndex)
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(selectedDeviceIndex));
if (deviceSet->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
{
qDebug("MainCore::changeSampleMIMO: non existent device replaced by Test MIMO");
int testMIMODeviceIndex = DeviceEnumerator::instance()->getTestMIMODeviceIndex();
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(testMIMODeviceIndex);
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(testMIMODeviceIndex));
}
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {