Tx support: reviewed and corrected buddy mechanism

This commit is contained in:
f4exb 2016-12-29 19:26:45 +01:00
parent f68f949c19
commit 5a83dc09a5
8 changed files with 76 additions and 111 deletions

View File

@ -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**
<h1>Source code</h1>
<h2>Repository branches</h2>

View File

@ -387,44 +387,24 @@ void DeviceSinkAPI::addSourceBuddy(DeviceSourceAPI* buddy)
{
std::vector<DeviceSourceAPI*>::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<DeviceSinkAPI*>::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<DeviceSourceAPI*>::iterator itSource = m_sourceBuddies.begin();
std::vector<DeviceSinkAPI*>::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();
}

View File

@ -95,7 +95,7 @@ public:
void addSinkBuddy(DeviceSinkAPI* buddy);
void removeSourceBuddy(DeviceSourceAPI* buddy);
void removeSinkBuddy(DeviceSinkAPI* buddy);
void removeFromBuddies();
void clearBuddiesLists();
protected:
struct ChannelInstanceRegistration

View File

@ -384,44 +384,25 @@ void DeviceSourceAPI::addSourceBuddy(DeviceSourceAPI* buddy)
{
std::vector<DeviceSourceAPI*>::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<DeviceSinkAPI*>::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<DeviceSourceAPI*>::iterator itSource = m_sourceBuddies.begin();
std::vector<DeviceSinkAPI*>::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();
}

View File

@ -95,7 +95,7 @@ public:
void addSinkBuddy(DeviceSinkAPI* buddy);
void removeSourceBuddy(DeviceSourceAPI* buddy);
void removeSinkBuddy(DeviceSinkAPI* buddy);
void removeFromBuddies();
void clearBuddiesLists();
protected:
struct ChannelInstanceRegistration

View File

@ -84,7 +84,7 @@
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Version 3.0.0 - Copyright (C) 2015-2016 Edouard Griffiths, F4EXB. &lt;/p&gt;&lt;p&gt;Code at &lt;a href=&quot;https://github.com/f4exb/sdrangel&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://github.com/f4exb/sdrangel&lt;/span&gt;&lt;/a&gt; This is a complete redesign from RTL-SDRangelove at &lt;a href=&quot;https://github.com/hexameron/rtl-sdrangelove&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://github.com/hexameron/rtl-sdrangelove&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Many thanks to the original developers:&lt;/p&gt;&lt;p&gt;The osmocom developer team - especially horizon, Hoernchen &amp;amp; tnt.&lt;/p&gt;&lt;p&gt;Christian Daniel from maintech GmbH.&lt;/p&gt;&lt;p&gt;John Greb (hexameron) for the contributions in RTL-SDRangelove&lt;/p&gt;&lt;p&gt;The following rules apply to the SDRangel main application and libsdrbase:&lt;br/&gt;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 &lt;a href=&quot;http://www.gnu.org/licenses/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://www.gnu.org/licenses/&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;For the license of installed plugins, look into the plugin list.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Version 3.0.0 - Copyright (C) 2015-2017 Edouard Griffiths, F4EXB. &lt;/p&gt;&lt;p&gt;Code at &lt;a href=&quot;https://github.com/f4exb/sdrangel&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://github.com/f4exb/sdrangel&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Many thanks to the original developers:&lt;/p&gt;&lt;p&gt;The osmocom developer team - especially horizon, Hoernchen &amp;amp; tnt.&lt;/p&gt;&lt;p&gt;Christian Daniel from maintech GmbH.&lt;/p&gt;&lt;p&gt;John Greb (hexameron) for the contributions in &lt;a href=&quot;https://github.com/hexameron/rtl-sdrangelove&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;RTL-SDRangelove&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The following rules apply to the SDRangel main application and libsdrbase:&lt;br/&gt;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 &lt;a href=&quot;http://www.gnu.org/licenses/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://www.gnu.org/licenses/&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;For the license of installed plugins, look into the plugin list.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -121,22 +121,6 @@
</widget>
<resources>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
<include location="../resources/res.qrc"/>
</resources>
<connections>
<connection>

View File

@ -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<void *>();
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<void *>();
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

View File

@ -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;