mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-25 20:22:10 -05:00
Fix not remove source buddy
This commit is contained in:
parent
64cb4cf890
commit
aeafe51220
@ -29,6 +29,7 @@
|
||||
#include "util/simpleserializer.h"
|
||||
|
||||
#include "deviceapi.h"
|
||||
#include <algorithm>
|
||||
|
||||
DeviceAPI::DeviceAPI(
|
||||
StreamType streamType,
|
||||
@ -738,28 +739,32 @@ void DeviceAPI::saveSamplingDeviceSettings(Preset* preset)
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceAPI::addSourceBuddy(DeviceAPI* buddy)
|
||||
void DeviceAPI::addBuddy(DeviceAPI* buddy)
|
||||
{
|
||||
if (buddy->m_streamType != StreamSingleRx)
|
||||
if (buddy->m_streamType == StreamSingleRx)
|
||||
{
|
||||
qDebug("DeviceAPI::addSourceBuddy: buddy %s(%s) is not of single Rx type",
|
||||
qPrintable(buddy->getHardwareId()),
|
||||
qPrintable(buddy->getSamplingDeviceSerial()));
|
||||
m_sourceBuddies.push_back(buddy); // this is a source
|
||||
}
|
||||
else if (buddy->m_streamType == StreamSingleTx)
|
||||
{
|
||||
m_sinkBuddies.push_back(buddy); // this is a sink
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("DeviceAPI::addBuddy: not relevant if buddy is not a single Rx or Tx");
|
||||
return;
|
||||
}
|
||||
|
||||
m_sourceBuddies.push_back(buddy);
|
||||
|
||||
if (m_streamType == StreamSingleRx) {
|
||||
buddy->m_sourceBuddies.push_back(this); // this is a source
|
||||
} else if (m_streamType == StreamSingleTx) {
|
||||
buddy->m_sinkBuddies.push_back(this); // this is a sink
|
||||
} else {
|
||||
qDebug("DeviceAPI::addSourceBuddy: not relevant if this is not a single Rx or Tx");
|
||||
qDebug("DeviceAPI::addBuddy: not relevant if this is not a single Rx or Tx");
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug("DeviceAPI::addSourceBuddy: added buddy %s(%s) [%llu] <-> [%llu]",
|
||||
qDebug("DeviceAPI::addBuddy: added buddy %s(%s) [%llu] <-> [%llu]",
|
||||
qPrintable(buddy->getHardwareId()),
|
||||
qPrintable(buddy->getSamplingDeviceSerial()),
|
||||
(quint64) buddy,
|
||||
@ -767,98 +772,21 @@ void DeviceAPI::addSourceBuddy(DeviceAPI* buddy)
|
||||
}
|
||||
|
||||
|
||||
void DeviceAPI::addSinkBuddy(DeviceAPI* buddy)
|
||||
void DeviceAPI::removeBuddy(DeviceAPI* buddy)
|
||||
{
|
||||
if (buddy->m_streamType != StreamSingleTx)
|
||||
{
|
||||
qDebug("DeviceAPI::addSinkBuddy: buddy %s(%s) is not of single Tx type",
|
||||
switch(buddy->m_streamType) {
|
||||
case StreamSingleRx:
|
||||
m_sourceBuddies.erase(std::find(m_sourceBuddies.begin(), m_sourceBuddies.end(), buddy));
|
||||
break;
|
||||
case StreamSingleTx:
|
||||
m_sinkBuddies.erase(std::find(m_sinkBuddies.begin(), m_sinkBuddies.end(), buddy));
|
||||
break;
|
||||
default:
|
||||
qDebug("DeviceAPI::removeSourceBuddy: buddy %s(%s) is not of single Rx or Tx type",
|
||||
qPrintable(buddy->getHardwareId()),
|
||||
qPrintable(buddy->getSamplingDeviceSerial()));
|
||||
return;
|
||||
}
|
||||
|
||||
m_sinkBuddies.push_back(buddy);
|
||||
|
||||
if (m_streamType == StreamSingleRx) {
|
||||
buddy->m_sourceBuddies.push_back(this); // this is a source
|
||||
} else if (m_streamType == StreamSingleTx) {
|
||||
buddy->m_sinkBuddies.push_back(this); // this is a sink
|
||||
} else {
|
||||
qDebug("DeviceAPI::addSinkBuddy: not relevant if this is not a single Rx or Tx");
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug("DeviceAPI::addSinkBuddy: added buddy %s(%s) [%llu] <-> [%llu]",
|
||||
qPrintable(buddy->getHardwareId()),
|
||||
qPrintable(buddy->getSamplingDeviceSerial()),
|
||||
(quint64) buddy,
|
||||
(quint64) this);
|
||||
}
|
||||
|
||||
void DeviceAPI::removeSourceBuddy(DeviceAPI* buddy)
|
||||
{
|
||||
if (buddy->m_streamType != StreamSingleRx)
|
||||
{
|
||||
qDebug("DeviceAPI::removeSourceBuddy: buddy %s(%s) is not of single Rx type",
|
||||
qPrintable(buddy->getHardwareId()),
|
||||
qPrintable(buddy->getSamplingDeviceSerial()));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<DeviceAPI*>::iterator it = m_sourceBuddies.begin();
|
||||
|
||||
for (;it != m_sourceBuddies.end(); ++it)
|
||||
{
|
||||
if (*it == buddy)
|
||||
{
|
||||
qDebug("DeviceAPI::removeSourceBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]",
|
||||
qPrintable(buddy->getHardwareId()),
|
||||
qPrintable(buddy->getSamplingDeviceSerial()),
|
||||
(quint64) (*it),
|
||||
(quint64) this);
|
||||
m_sourceBuddies.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug("DeviceAPI::removeSourceBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]",
|
||||
qPrintable(buddy->getHardwareId()),
|
||||
qPrintable(buddy->getSamplingDeviceSerial()),
|
||||
(quint64) buddy,
|
||||
(quint64) this);
|
||||
}
|
||||
|
||||
void DeviceAPI::removeSinkBuddy(DeviceAPI* buddy)
|
||||
{
|
||||
if (buddy->m_streamType != StreamSingleTx)
|
||||
{
|
||||
qDebug("DeviceAPI::removeSinkBuddy: buddy %s(%s) is not of single Tx type",
|
||||
qPrintable(buddy->getHardwareId()),
|
||||
qPrintable(buddy->getSamplingDeviceSerial()));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<DeviceAPI*>::iterator it = m_sinkBuddies.begin();
|
||||
|
||||
for (;it != m_sinkBuddies.end(); ++it)
|
||||
{
|
||||
if (*it == buddy)
|
||||
{
|
||||
qDebug("DeviceAPI::removeSinkBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]",
|
||||
qPrintable(buddy->getHardwareId()),
|
||||
qPrintable(buddy->getSamplingDeviceSerial()),
|
||||
(quint64) (*it),
|
||||
(quint64) this);
|
||||
m_sinkBuddies.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug("DeviceAPI::removeSourceBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]",
|
||||
qPrintable(buddy->getHardwareId()),
|
||||
qPrintable(buddy->getSamplingDeviceSerial()),
|
||||
(quint64) buddy,
|
||||
(quint64) this);
|
||||
}
|
||||
|
||||
void DeviceAPI::clearBuddiesLists()
|
||||
@ -875,7 +803,7 @@ void DeviceAPI::clearBuddiesLists()
|
||||
leaderElected = true;
|
||||
}
|
||||
|
||||
(*itSource)->removeSinkBuddy(this);
|
||||
(*itSource)->removeBuddy(this);
|
||||
}
|
||||
|
||||
m_sourceBuddies.clear();
|
||||
@ -888,7 +816,7 @@ void DeviceAPI::clearBuddiesLists()
|
||||
leaderElected = true;
|
||||
}
|
||||
|
||||
(*itSink)->removeSinkBuddy(this);
|
||||
(*itSink)->removeBuddy(this);
|
||||
}
|
||||
|
||||
m_sinkBuddies.clear();
|
||||
|
@ -159,10 +159,8 @@ public:
|
||||
DSPDeviceSinkEngine *getDeviceSinkEngine() { return m_deviceSinkEngine; }
|
||||
DSPDeviceMIMOEngine *getDeviceMIMOEngine() { return m_deviceMIMOEngine; }
|
||||
|
||||
void addSourceBuddy(DeviceAPI* buddy);
|
||||
void addSinkBuddy(DeviceAPI* buddy);
|
||||
void removeSourceBuddy(DeviceAPI* buddy);
|
||||
void removeSinkBuddy(DeviceAPI* buddy);
|
||||
void addBuddy(DeviceAPI* buddy);
|
||||
void removeBuddy(DeviceAPI* buddy);
|
||||
void clearBuddiesLists();
|
||||
void *getBuddySharedPtr() const { return m_buddySharedPtr; }
|
||||
void setBuddySharedPtr(void *ptr) { m_buddySharedPtr = ptr; }
|
||||
|
@ -482,24 +482,11 @@ void MainWindow::sampleSourceCreate(
|
||||
{
|
||||
if (*it != deviceUISet) // do not add to itself
|
||||
{
|
||||
if ((*it)->m_deviceSourceEngine) // it is a source device
|
||||
if ((deviceUISet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
||||
(deviceUISet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
||||
{
|
||||
if ((deviceUISet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
||||
(deviceUISet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
||||
{
|
||||
(*it)->m_deviceAPI->addSourceBuddy(deviceUISet->m_deviceAPI);
|
||||
nbOfBuddies++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*it)->m_deviceSinkEngine) // it is a sink device
|
||||
{
|
||||
if ((deviceUISet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
||||
(deviceUISet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
||||
{
|
||||
(*it)->m_deviceAPI->addSourceBuddy(deviceUISet->m_deviceAPI);
|
||||
nbOfBuddies++;
|
||||
}
|
||||
(*it)->m_deviceAPI->addBuddy(deviceUISet->m_deviceAPI);
|
||||
nbOfBuddies++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -713,24 +700,11 @@ void MainWindow::sampleSinkCreate(
|
||||
{
|
||||
if (*it != deviceUISet) // do not add to itself
|
||||
{
|
||||
if ((*it)->m_deviceSourceEngine) // it is a source device
|
||||
if ((deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
||||
(deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
||||
{
|
||||
if ((deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
||||
(deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
||||
{
|
||||
(*it)->m_deviceAPI->addSinkBuddy(deviceAPI);
|
||||
nbOfBuddies++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*it)->m_deviceSinkEngine) // it is a sink device
|
||||
{
|
||||
if ((deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
||||
(deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
||||
{
|
||||
(*it)->m_deviceAPI->addSinkBuddy(deviceAPI);
|
||||
nbOfBuddies++;
|
||||
}
|
||||
(*it)->m_deviceAPI->addBuddy(deviceAPI);
|
||||
nbOfBuddies++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -501,24 +501,11 @@ void MainServer::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
|
||||
{
|
||||
if (*it != deviceSet) // do not add to itself
|
||||
{
|
||||
if ((*it)->m_deviceSourceEngine) // it is a source device
|
||||
if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
||||
(deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
||||
{
|
||||
if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
||||
(deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
||||
{
|
||||
(*it)->m_deviceAPI->addSourceBuddy(deviceSet->m_deviceAPI);
|
||||
nbOfBuddies++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*it)->m_deviceSinkEngine) // it is a sink device
|
||||
{
|
||||
if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
||||
(deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
||||
{
|
||||
(*it)->m_deviceAPI->addSourceBuddy(deviceSet->m_deviceAPI);
|
||||
nbOfBuddies++;
|
||||
}
|
||||
(*it)->m_deviceAPI->addBuddy(deviceSet->m_deviceAPI);
|
||||
nbOfBuddies++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -587,24 +574,11 @@ void MainServer::changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
|
||||
{
|
||||
if (*it != deviceSet) // do not add to itself
|
||||
{
|
||||
if ((*it)->m_deviceSourceEngine) // it is a source device
|
||||
if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
||||
(deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
||||
{
|
||||
if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
||||
(deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
||||
{
|
||||
(*it)->m_deviceAPI->addSinkBuddy(deviceSet->m_deviceAPI);
|
||||
nbOfBuddies++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*it)->m_deviceSinkEngine) // it is a sink device
|
||||
{
|
||||
if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
||||
(deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
||||
{
|
||||
(*it)->m_deviceAPI->addSinkBuddy(deviceSet->m_deviceAPI);
|
||||
nbOfBuddies++;
|
||||
}
|
||||
(*it)->m_deviceAPI->addBuddy(deviceSet->m_deviceAPI);
|
||||
nbOfBuddies++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user