From 5a83dc09a57fd121031a22a55a38f5222b095342 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 29 Dec 2016 19:26:45 +0100 Subject: [PATCH] Tx support: reviewed and corrected buddy mechanism --- Readme.md | 2 - sdrbase/device/devicesinkapi.cpp | 76 +++++++++++++---------------- sdrbase/device/devicesinkapi.h | 2 +- sdrbase/device/devicesourceapi.cpp | 77 +++++++++++++----------------- sdrbase/device/devicesourceapi.h | 2 +- sdrbase/gui/aboutdialog.ui | 18 +------ sdrbase/mainwindow.cpp | 8 +++- sdrbase/plugin/pluginmanager.cpp | 2 - 8 files changed, 76 insertions(+), 111 deletions(-) diff --git a/Readme.md b/Readme.md index 53aa86a06..b8c873cac 100644 --- a/Readme.md +++ b/Readme.md @@ -2,8 +2,6 @@ **SDRangel** is an Open Source Qt5/OpenGL SDR and signal analyzer frontend to various hardware. -Although it keeps the same look and feel as its parent application **SDRangelove** it is a major redesign from it hitting more than half the lines of the code. Therefore the code base cannot be kept in sync anymore with its parent. It also contains enhancements and major differences. So it should now fly with its own wings and with its own name: **SDRangel** -

Source code

Repository branches

diff --git a/sdrbase/device/devicesinkapi.cpp b/sdrbase/device/devicesinkapi.cpp index 4301970b3..7f3532106 100644 --- a/sdrbase/device/devicesinkapi.cpp +++ b/sdrbase/device/devicesinkapi.cpp @@ -387,44 +387,24 @@ void DeviceSinkAPI::addSourceBuddy(DeviceSourceAPI* buddy) { std::vector::iterator it = m_sourceBuddies.begin(); - for (;it != m_sourceBuddies.end(); ++it) - { - if (((*it)->getHardwareId() == buddy->getHardwareId()) && - ((*it)->getSampleSourceSerial() == buddy->getSampleSourceSerial())) - { - qDebug("DeviceSinkAPI::addSourceBuddy: buddy %s(%s) already in the list", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial())); - return; - } - } - m_sourceBuddies.push_back(buddy); - qDebug("DeviceSinkAPI::addSourceBuddy: added buddy %s(%s) to the list", + qDebug("DeviceSinkAPI::addSourceBuddy: added buddy %s(%s) to the list [%lx] <-> [%lx]", qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial())); + qPrintable(buddy->getSampleSourceSerial()), + (uint64_t) buddy, + (uint64_t) this); } void DeviceSinkAPI::addSinkBuddy(DeviceSinkAPI* buddy) { std::vector::iterator it = m_sinkBuddies.begin(); - for (;it != m_sinkBuddies.end(); ++it) - { - if (((*it)->getHardwareId() == buddy->getHardwareId()) && - ((*it)->getSampleSinkSerial() == buddy->getSampleSinkSerial())) - { - qDebug("DeviceSinkAPI::addSinkBuddy: buddy %s(%s) already in the list", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial())); - return; - } - } - m_sinkBuddies.push_back(buddy); - qDebug("DeviceSinkAPI::addSinkBuddy: added buddy %s(%s) to the list", + qDebug("DeviceSinkAPI::addSinkBuddy: added buddy %s(%s) to the list [%lx] <-> [%lx]", qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial())); + qPrintable(buddy->getSampleSinkSerial()), + (uint64_t) buddy, + (uint64_t) this); } void DeviceSinkAPI::removeSourceBuddy(DeviceSourceAPI* buddy) @@ -433,20 +413,23 @@ void DeviceSinkAPI::removeSourceBuddy(DeviceSourceAPI* buddy) for (;it != m_sourceBuddies.end(); ++it) { - if (((*it)->getHardwareId() == buddy->getHardwareId()) && - ((*it)->getSampleSourceSerial() == buddy->getSampleSourceSerial())) + if (*it == buddy) { - m_sourceBuddies.erase(it); - qDebug("DeviceSinkAPI::removeSourceBuddy: buddy %s(%s) removed from the list", + qDebug("DeviceSinkAPI::removeSourceBuddy: buddy %s(%s) [%lx] removed from the list of [%lx]", qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial())); + qPrintable(buddy->getSampleSourceSerial()), + (uint64_t) (*it), + (uint64_t) this); + m_sourceBuddies.erase(it); return; } } - qDebug("DeviceSinkAPI::removeSourceBuddy: buddy %s(%s) not found in the list", + qDebug("DeviceSinkAPI::removeSourceBuddy: buddy %s(%s) [%lx] not found in the list of [%lx]", qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial())); + qPrintable(buddy->getSampleSourceSerial()), + (uint64_t) buddy, + (uint64_t) this); } void DeviceSinkAPI::removeSinkBuddy(DeviceSinkAPI* buddy) @@ -455,23 +438,26 @@ void DeviceSinkAPI::removeSinkBuddy(DeviceSinkAPI* buddy) for (;it != m_sinkBuddies.end(); ++it) { - if (((*it)->getHardwareId() == buddy->getHardwareId()) && - ((*it)->getSampleSinkSerial() == buddy->getSampleSinkSerial())) + if (*it == buddy) { - m_sinkBuddies.erase(it); - qDebug("DeviceSinkAPI::removeSinkBuddy: buddy %s(%s) removed from the list", + qDebug("DeviceSinkAPI::removeSinkBuddy: buddy %s(%s) [%lx] removed from the list of [%lx]", qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial())); + qPrintable(buddy->getSampleSinkSerial()), + (uint64_t) (*it), + (uint64_t) this); + m_sinkBuddies.erase(it); return; } } - qDebug("DeviceSinkAPI::removeSinkBuddy: buddy %s(%s) not found in the list", + qDebug("DeviceSinkAPI::removeSinkBuddy: buddy %s(%s) [%lx] not found in the list of [%lx]", qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial())); + qPrintable(buddy->getSampleSinkSerial()), + (uint64_t) buddy, + (uint64_t) this); } -void DeviceSinkAPI::removeFromBuddies() +void DeviceSinkAPI::clearBuddiesLists() { std::vector::iterator itSource = m_sourceBuddies.begin(); std::vector::iterator itSink = m_sinkBuddies.begin(); @@ -481,9 +467,13 @@ void DeviceSinkAPI::removeFromBuddies() (*itSource)->removeSinkBuddy(this); } + m_sourceBuddies.clear(); + for (;itSink != m_sinkBuddies.end(); ++itSink) { (*itSink)->removeSinkBuddy(this); } + + m_sinkBuddies.clear(); } diff --git a/sdrbase/device/devicesinkapi.h b/sdrbase/device/devicesinkapi.h index 66ddfe0f8..fe5561ae0 100644 --- a/sdrbase/device/devicesinkapi.h +++ b/sdrbase/device/devicesinkapi.h @@ -95,7 +95,7 @@ public: void addSinkBuddy(DeviceSinkAPI* buddy); void removeSourceBuddy(DeviceSourceAPI* buddy); void removeSinkBuddy(DeviceSinkAPI* buddy); - void removeFromBuddies(); + void clearBuddiesLists(); protected: struct ChannelInstanceRegistration diff --git a/sdrbase/device/devicesourceapi.cpp b/sdrbase/device/devicesourceapi.cpp index 5b7f16c2e..d0911e143 100644 --- a/sdrbase/device/devicesourceapi.cpp +++ b/sdrbase/device/devicesourceapi.cpp @@ -384,44 +384,25 @@ void DeviceSourceAPI::addSourceBuddy(DeviceSourceAPI* buddy) { std::vector::iterator it = m_sourceBuddies.begin(); - for (;it != m_sourceBuddies.end(); ++it) - { - if (((*it)->getHardwareId() == buddy->getHardwareId()) && - ((*it)->getSampleSourceSerial() == buddy->getSampleSourceSerial())) - { - qDebug("DeviceSourceAPI::addSourceBuddy: buddy %s(%s) already in the list", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial())); - return; - } - } - m_sourceBuddies.push_back(buddy); - qDebug("DeviceSourceAPI::addSourceBuddy: added buddy %s(%s) to the list", + buddy->m_sourceBuddies.push_back(this); + qDebug("DeviceSourceAPI::addSourceBuddy: added buddy %s(%s) [%lx] <-> [%lx]", qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial())); + qPrintable(buddy->getSampleSourceSerial()), + (uint64_t) buddy, + (uint64_t) this); } void DeviceSourceAPI::addSinkBuddy(DeviceSinkAPI* buddy) { std::vector::iterator it = m_sinkBuddies.begin(); - for (;it != m_sinkBuddies.end(); ++it) - { - if (((*it)->getHardwareId() == buddy->getHardwareId()) && - ((*it)->getSampleSinkSerial() == buddy->getSampleSinkSerial())) - { - qDebug("DeviceSourceAPI::addSinkBuddy: buddy %s(%s) already in the list", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial())); - return; - } - } - m_sinkBuddies.push_back(buddy); - qDebug("DeviceSourceAPI::addSinkBuddy: added buddy %s(%s) to the list", + qDebug("DeviceSourceAPI::addSinkBuddy: added buddy %s(%s) [%lx] <-> [%lx]", qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial())); + qPrintable(buddy->getSampleSinkSerial()), + (uint64_t) buddy, + (uint64_t) this); } void DeviceSourceAPI::removeSourceBuddy(DeviceSourceAPI* buddy) @@ -430,20 +411,23 @@ void DeviceSourceAPI::removeSourceBuddy(DeviceSourceAPI* buddy) for (;it != m_sourceBuddies.end(); ++it) { - if (((*it)->getHardwareId() == buddy->getHardwareId()) && - ((*it)->getSampleSourceSerial() == buddy->getSampleSourceSerial())) + if (*it == buddy) { - m_sourceBuddies.erase(it); - qDebug("DeviceSourceAPI::removeSourceBuddy: buddy %s(%s) removed from the list", + qDebug("DeviceSourceAPI::removeSourceBuddy: buddy %s(%s) [%lx] removed from the list of [%lx]", qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial())); + qPrintable(buddy->getSampleSourceSerial()), + (uint64_t) (*it), + (uint64_t) this); + m_sourceBuddies.erase(it); return; } } - qDebug("DeviceSourceAPI::removeSourceBuddy: buddy %s(%s) not found in the list", + qDebug("DeviceSourceAPI::removeSourceBuddy: buddy %s(%s) [%lx] not found in the list of [%lx]", qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial())); + qPrintable(buddy->getSampleSourceSerial()), + (uint64_t) buddy, + (uint64_t) this); } void DeviceSourceAPI::removeSinkBuddy(DeviceSinkAPI* buddy) @@ -452,23 +436,26 @@ void DeviceSourceAPI::removeSinkBuddy(DeviceSinkAPI* buddy) for (;it != m_sinkBuddies.end(); ++it) { - if (((*it)->getHardwareId() == buddy->getHardwareId()) && - ((*it)->getSampleSinkSerial() == buddy->getSampleSinkSerial())) + if (*it == buddy) { - m_sinkBuddies.erase(it); - qDebug("DeviceSourceAPI::removeSinkBuddy: buddy %s(%s) removed from the list", + qDebug("DeviceSourceAPI::removeSinkBuddy: buddy %s(%s) [%lx] removed from the list of [%lx]", qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial())); + qPrintable(buddy->getSampleSinkSerial()), + (uint64_t) (*it), + (uint64_t) this); + m_sinkBuddies.erase(it); return; } } - qDebug("DeviceSourceAPI::removeSinkBuddy: buddy %s(%s) not found in the list", + qDebug("DeviceSourceAPI::removeSinkBuddy: buddy %s(%s) [%lx] not found in the list of [%lx]", qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial())); + qPrintable(buddy->getSampleSinkSerial()), + (uint64_t) buddy, + (uint64_t) this); } -void DeviceSourceAPI::removeFromBuddies() +void DeviceSourceAPI::clearBuddiesLists() { std::vector::iterator itSource = m_sourceBuddies.begin(); std::vector::iterator itSink = m_sinkBuddies.begin(); @@ -478,8 +465,12 @@ void DeviceSourceAPI::removeFromBuddies() (*itSource)->removeSourceBuddy(this); } + m_sourceBuddies.clear(); + for (;itSink != m_sinkBuddies.end(); ++itSink) { (*itSink)->removeSourceBuddy(this); } + + m_sinkBuddies.clear(); } diff --git a/sdrbase/device/devicesourceapi.h b/sdrbase/device/devicesourceapi.h index 1564192fa..33f7ee36c 100644 --- a/sdrbase/device/devicesourceapi.h +++ b/sdrbase/device/devicesourceapi.h @@ -95,7 +95,7 @@ public: void addSinkBuddy(DeviceSinkAPI* buddy); void removeSourceBuddy(DeviceSourceAPI* buddy); void removeSinkBuddy(DeviceSinkAPI* buddy); - void removeFromBuddies(); + void clearBuddiesLists(); protected: struct ChannelInstanceRegistration diff --git a/sdrbase/gui/aboutdialog.ui b/sdrbase/gui/aboutdialog.ui index f413e97d1..317b547c0 100644 --- a/sdrbase/gui/aboutdialog.ui +++ b/sdrbase/gui/aboutdialog.ui @@ -84,7 +84,7 @@ - <html><head/><body><p>Version 3.0.0 - Copyright (C) 2015-2016 Edouard Griffiths, F4EXB. </p><p>Code at <a href="https://github.com/f4exb/sdrangel"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/f4exb/sdrangel</span></a> This is a complete redesign from RTL-SDRangelove at <a href="https://github.com/hexameron/rtl-sdrangelove"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/hexameron/rtl-sdrangelove</span></a></p><p>Many thanks to the original developers:</p><p>The osmocom developer team - especially horizon, Hoernchen &amp; tnt.</p><p>Christian Daniel from maintech GmbH.</p><p>John Greb (hexameron) for the contributions in RTL-SDRangelove</p><p>The following rules apply to the SDRangel main application and libsdrbase:<br/>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 2 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. You should have received a copy of the GNU General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/"><span style=" text-decoration: underline; color:#0000ff;">http://www.gnu.org/licenses/</span></a>.</p><p>For the license of installed plugins, look into the plugin list.</p></body></html> + <html><head/><body><p>Version 3.0.0 - Copyright (C) 2015-2017 Edouard Griffiths, F4EXB. </p><p>Code at <a href="https://github.com/f4exb/sdrangel"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/f4exb/sdrangel</span></a></p><p>Many thanks to the original developers:</p><p>The osmocom developer team - especially horizon, Hoernchen &amp; tnt.</p><p>Christian Daniel from maintech GmbH.</p><p>John Greb (hexameron) for the contributions in <a href="https://github.com/hexameron/rtl-sdrangelove"><span style=" text-decoration: underline; color:#0000ff;">RTL-SDRangelove</span></a></p><p>The following rules apply to the SDRangel main application and libsdrbase:<br/>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 2 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. You should have received a copy of the GNU General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/"><span style=" text-decoration: underline; color:#0000ff;">http://www.gnu.org/licenses/</span></a>.</p><p>For the license of installed plugins, look into the plugin list.</p></body></html> true @@ -121,22 +121,6 @@ - - - - - - - - - - - - - - - - diff --git a/sdrbase/mainwindow.cpp b/sdrbase/mainwindow.cpp index 47ee013ab..192705704 100644 --- a/sdrbase/mainwindow.cpp +++ b/sdrbase/mainwindow.cpp @@ -271,6 +271,7 @@ void MainWindow::removeLastDevice() ui->tabSpectra->removeTab(ui->tabSpectra->count() - 1); m_deviceUIs.back()->m_deviceSourceAPI->freeAll(); + m_deviceUIs.back()->m_deviceSourceAPI->clearBuddiesLists(); // remove old API from buddies lists ui->tabChannels->removeTab(ui->tabChannels->count() - 1); @@ -301,6 +302,7 @@ void MainWindow::removeLastDevice() ui->tabSpectra->removeTab(ui->tabSpectra->count() - 1); m_deviceUIs.back()->m_deviceSinkAPI->freeAll(); + m_deviceUIs.back()->m_deviceSinkAPI->clearBuddiesLists(); // remove old API from buddies lists ui->tabChannels->removeTab(ui->tabChannels->count() - 1); @@ -788,9 +790,10 @@ void MainWindow::on_sampleSource_confirmClicked(bool checked) qDebug("MainWindow::on_sampleSource_confirmClicked: tab at %d", currentSourceTabIndex); DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex]; deviceUI->m_deviceSourceAPI->saveSourceSettings(m_settings.getWorkingPreset()); // save old API settings - deviceUI->m_deviceSourceAPI->removeFromBuddies(); // remove old API from buddies lists int selectedComboIndex = deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(); void *devicePtr = deviceUI->m_samplingDeviceControl->getDeviceSelector()->itemData(selectedComboIndex).value(); + deviceUI->m_deviceSourceAPI->stopAcquisition(); + deviceUI->m_deviceSourceAPI->clearBuddiesLists(); // clear old API buddies lists m_pluginManager->selectSampleSourceByDevice(devicePtr, deviceUI->m_deviceSourceAPI); // sets the new API deviceUI->m_deviceSourceAPI->loadSourceSettings(m_settings.getWorkingPreset()); // load new API settings @@ -837,9 +840,10 @@ void MainWindow::on_sampleSink_confirmClicked(bool checked) qDebug("MainWindow::on_sampleSink_confirmClicked: tab at %d", currentSinkTabIndex); DeviceUISet *deviceUI = m_deviceUIs[currentSinkTabIndex]; deviceUI->m_deviceSinkAPI->saveSinkSettings(m_settings.getWorkingPreset()); // save old API settings - deviceUI->m_deviceSinkAPI->removeFromBuddies(); // remove old API from buddies lists int selectedComboIndex = deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(); void *devicePtr = deviceUI->m_samplingDeviceControl->getDeviceSelector()->itemData(selectedComboIndex).value(); + deviceUI->m_deviceSinkAPI->stopGeneration(); + deviceUI->m_deviceSinkAPI->clearBuddiesLists(); // remove old API from buddies lists m_pluginManager->selectSampleSinkByDevice(devicePtr, deviceUI->m_deviceSinkAPI); // sets the new API deviceUI->m_deviceSinkAPI->loadSinkSettings(m_settings.getWorkingPreset()); // load new API settings diff --git a/sdrbase/plugin/pluginmanager.cpp b/sdrbase/plugin/pluginmanager.cpp index 876a62f61..a4ffaa51c 100644 --- a/sdrbase/plugin/pluginmanager.cpp +++ b/sdrbase/plugin/pluginmanager.cpp @@ -663,7 +663,6 @@ void PluginManager::selectSampleSourceByDevice(void *devicePtr, DeviceSourceAPI << " ser: " << sampleSourceDevice->m_deviceSerial.toStdString().c_str() << " seq: " << sampleSourceDevice->m_deviceSequence; - deviceAPI->stopAcquisition(); deviceAPI->setSampleSourcePluginGUI(0); // this effectively destroys the previous GUI if it exists QWidget *gui; @@ -688,7 +687,6 @@ void PluginManager::selectSampleSinkByDevice(void *devicePtr, DeviceSinkAPI *dev << " ser: " << sampleSinkDevice->m_deviceSerial.toStdString().c_str() << " seq: " << sampleSinkDevice->m_deviceSequence; - deviceAPI->stopGeneration(); deviceAPI->setSampleSinkPluginGUI(0); // this effectively destroys the previous GUI if it exists QWidget *gui;