2016-10-17 22:03:51 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// 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 as version 3 of the License, or //
|
2019-04-11 12:32:15 +00:00
|
|
|
// (at your option) any later version. //
|
2016-10-17 22:03:51 +00:00
|
|
|
// //
|
|
|
|
// 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. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-09-25 22:22:08 +00:00
|
|
|
#include <plugin/plugininstancegui.h>
|
2016-10-17 22:03:51 +00:00
|
|
|
#include "device/devicesinkapi.h"
|
2016-12-29 11:41:10 +00:00
|
|
|
#include "device/devicesourceapi.h"
|
2017-09-17 15:35:03 +00:00
|
|
|
#include "dsp/devicesamplesink.h"
|
2016-10-17 22:03:51 +00:00
|
|
|
#include "plugin/plugininterface.h"
|
|
|
|
#include "settings/preset.h"
|
2017-10-24 14:58:12 +00:00
|
|
|
#include "dsp/dspengine.h"
|
2017-11-19 02:38:07 +00:00
|
|
|
#include "channel/channelsourceapi.h"
|
2016-10-17 22:03:51 +00:00
|
|
|
|
2017-10-24 14:58:12 +00:00
|
|
|
DeviceSinkAPI::DeviceSinkAPI(int deviceTabIndex,
|
2017-10-31 23:18:10 +00:00
|
|
|
DSPDeviceSinkEngine *deviceSinkEngine) :
|
2016-10-17 22:03:51 +00:00
|
|
|
m_deviceTabIndex(deviceTabIndex),
|
|
|
|
m_deviceSinkEngine(deviceSinkEngine),
|
|
|
|
m_sampleSinkSequence(0),
|
2017-11-19 00:05:16 +00:00
|
|
|
m_nbItems(1),
|
2017-11-02 08:17:38 +00:00
|
|
|
m_itemIndex(0),
|
2017-09-14 23:49:18 +00:00
|
|
|
m_pluginInterface(0),
|
2017-09-03 18:24:17 +00:00
|
|
|
m_sampleSinkPluginInstanceUI(0),
|
2017-07-03 06:59:48 +00:00
|
|
|
m_buddySharedPtr(0),
|
2017-09-14 11:55:57 +00:00
|
|
|
m_isBuddyLeader(false),
|
2017-10-24 14:58:12 +00:00
|
|
|
m_masterTimer(DSPEngine::instance()->getMasterTimer())
|
2016-10-17 22:03:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceSinkAPI::~DeviceSinkAPI()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-24 16:06:44 +00:00
|
|
|
void DeviceSinkAPI::addSpectrumSink(BasebandSampleSink *spectrumSink)
|
2016-10-17 22:03:51 +00:00
|
|
|
{
|
2016-10-24 16:06:44 +00:00
|
|
|
m_deviceSinkEngine->addSpectrumSink(spectrumSink);
|
2016-10-17 22:03:51 +00:00
|
|
|
}
|
|
|
|
|
2016-10-24 16:06:44 +00:00
|
|
|
void DeviceSinkAPI::removeSpectrumSink(BasebandSampleSink* spectrumSink)
|
2016-10-17 22:03:51 +00:00
|
|
|
{
|
2016-10-24 16:06:44 +00:00
|
|
|
m_deviceSinkEngine->removeSpectrumSink(spectrumSink);
|
2016-10-17 22:03:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceSinkAPI::addSource(BasebandSampleSource *source)
|
|
|
|
{
|
|
|
|
m_deviceSinkEngine->addSource(source);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceSinkAPI::removeSource(BasebandSampleSource* source)
|
|
|
|
{
|
|
|
|
m_deviceSinkEngine->removeSource(source);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceSinkAPI::addThreadedSource(ThreadedBasebandSampleSource* source)
|
|
|
|
{
|
|
|
|
m_deviceSinkEngine->addThreadedSource(source);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceSinkAPI::removeThreadedSource(ThreadedBasebandSampleSource* source)
|
|
|
|
{
|
|
|
|
m_deviceSinkEngine->removeThreadedSource(source);
|
|
|
|
}
|
|
|
|
|
2017-11-19 02:38:07 +00:00
|
|
|
void DeviceSinkAPI::addChannelAPI(ChannelSourceAPI* channelAPI)
|
|
|
|
{
|
|
|
|
m_channelAPIs.append(channelAPI);
|
|
|
|
renumerateChannels();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceSinkAPI::removeChannelAPI(ChannelSourceAPI* channelAPI)
|
|
|
|
{
|
|
|
|
if (m_channelAPIs.removeOne(channelAPI)) {
|
|
|
|
renumerateChannels();
|
|
|
|
}
|
|
|
|
|
|
|
|
channelAPI->setIndexInDeviceSet(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
ChannelSourceAPI *DeviceSinkAPI::getChanelAPIAt(int index)
|
|
|
|
{
|
|
|
|
if (index < m_channelAPIs.size()) {
|
|
|
|
return m_channelAPIs.at(index);
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceSinkAPI::renumerateChannels()
|
|
|
|
{
|
2019-03-25 00:15:27 +00:00
|
|
|
for (int i = 0; i < m_channelAPIs.size(); ++i)
|
|
|
|
{
|
2017-11-19 02:38:07 +00:00
|
|
|
m_channelAPIs.at(i)->setIndexInDeviceSet(i);
|
2019-03-25 00:15:27 +00:00
|
|
|
m_channelAPIs.at(i)->setDeviceSetIndex(m_deviceTabIndex);
|
2019-05-02 02:02:40 +00:00
|
|
|
m_channelAPIs.at(i)->setDeviceSinkAPI(this);
|
2017-11-19 02:38:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-26 14:26:25 +00:00
|
|
|
uint32_t DeviceSinkAPI::getNumberOfSources()
|
|
|
|
{
|
|
|
|
return m_deviceSinkEngine->getNumberOfSources();
|
|
|
|
}
|
|
|
|
|
2017-09-16 09:34:25 +00:00
|
|
|
void DeviceSinkAPI::setSampleSink(DeviceSampleSink* sink)
|
2016-10-17 22:03:51 +00:00
|
|
|
{
|
|
|
|
m_deviceSinkEngine->setSink(sink);
|
|
|
|
}
|
|
|
|
|
2017-09-16 09:34:25 +00:00
|
|
|
DeviceSampleSink *DeviceSinkAPI::getSampleSink()
|
|
|
|
{
|
|
|
|
return m_deviceSinkEngine->getSink();
|
|
|
|
}
|
|
|
|
|
2016-10-17 22:03:51 +00:00
|
|
|
bool DeviceSinkAPI::initGeneration()
|
|
|
|
{
|
|
|
|
return m_deviceSinkEngine->initGeneration();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DeviceSinkAPI::startGeneration()
|
|
|
|
{
|
|
|
|
return m_deviceSinkEngine->startGeneration();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceSinkAPI::stopGeneration()
|
|
|
|
{
|
|
|
|
m_deviceSinkEngine->stopGeneration();
|
|
|
|
}
|
|
|
|
DSPDeviceSinkEngine::State DeviceSinkAPI::state() const
|
|
|
|
{
|
|
|
|
return m_deviceSinkEngine->state();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString DeviceSinkAPI::errorMessage()
|
|
|
|
{
|
|
|
|
return m_deviceSinkEngine->errorMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint DeviceSinkAPI::getDeviceUID() const
|
|
|
|
{
|
|
|
|
return m_deviceSinkEngine->getUID();
|
|
|
|
}
|
|
|
|
|
2017-09-13 21:42:28 +00:00
|
|
|
MessageQueue *DeviceSinkAPI::getDeviceEngineInputMessageQueue()
|
2016-10-17 22:03:51 +00:00
|
|
|
{
|
|
|
|
return m_deviceSinkEngine->getInputMessageQueue();
|
|
|
|
}
|
|
|
|
|
2017-09-17 15:35:03 +00:00
|
|
|
MessageQueue *DeviceSinkAPI::getSampleSinkInputMessageQueue()
|
2016-10-17 22:03:51 +00:00
|
|
|
{
|
2017-09-17 15:35:03 +00:00
|
|
|
return getSampleSink()->getInputMessageQueue();
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueue *DeviceSinkAPI::getSampleSinkGUIMessageQueue()
|
|
|
|
{
|
|
|
|
return getSampleSink()->getMessageQueueToGUI();
|
2016-10-17 22:03:51 +00:00
|
|
|
}
|
|
|
|
|
2016-12-29 11:41:10 +00:00
|
|
|
void DeviceSinkAPI::setHardwareId(const QString& id)
|
|
|
|
{
|
|
|
|
m_hardwareId = id;
|
|
|
|
}
|
|
|
|
|
2016-10-17 22:03:51 +00:00
|
|
|
void DeviceSinkAPI::setSampleSinkId(const QString& id)
|
|
|
|
{
|
|
|
|
m_sampleSinkId = id;
|
|
|
|
}
|
|
|
|
|
2017-09-16 09:34:25 +00:00
|
|
|
void DeviceSinkAPI::resetSampleSinkId()
|
|
|
|
{
|
|
|
|
m_sampleSinkId.clear();
|
|
|
|
}
|
|
|
|
|
2016-10-17 22:03:51 +00:00
|
|
|
void DeviceSinkAPI::setSampleSinkSerial(const QString& serial)
|
|
|
|
{
|
|
|
|
m_sampleSinkSerial = serial;
|
|
|
|
}
|
|
|
|
|
2017-09-14 23:49:18 +00:00
|
|
|
void DeviceSinkAPI::setSampleSinkDisplayName(const QString& name)
|
|
|
|
{
|
|
|
|
m_sampleSinkDisplayName = name;
|
|
|
|
}
|
|
|
|
|
2016-10-17 22:03:51 +00:00
|
|
|
void DeviceSinkAPI::setSampleSinkSequence(int sequence)
|
|
|
|
{
|
|
|
|
m_sampleSinkSequence = sequence;
|
|
|
|
m_deviceSinkEngine->setSinkSequence(sequence);
|
|
|
|
}
|
|
|
|
|
2017-11-19 00:05:16 +00:00
|
|
|
void DeviceSinkAPI::setNbItems(uint32_t nbItems)
|
|
|
|
{
|
|
|
|
m_nbItems = nbItems;
|
|
|
|
}
|
|
|
|
|
2017-11-02 08:17:38 +00:00
|
|
|
void DeviceSinkAPI::setItemIndex(uint32_t index)
|
|
|
|
{
|
|
|
|
m_itemIndex = index;
|
|
|
|
}
|
|
|
|
|
2017-09-15 16:48:30 +00:00
|
|
|
void DeviceSinkAPI::setSampleSinkPluginInterface(PluginInterface *iface)
|
2017-09-14 23:49:18 +00:00
|
|
|
{
|
2017-09-15 16:48:30 +00:00
|
|
|
m_pluginInterface = iface;
|
2017-09-14 23:49:18 +00:00
|
|
|
}
|
|
|
|
|
2017-09-25 22:22:08 +00:00
|
|
|
void DeviceSinkAPI::setSampleSinkPluginInstanceUI(PluginInstanceGUI *gui)
|
2016-10-17 22:03:51 +00:00
|
|
|
{
|
2017-09-03 18:24:17 +00:00
|
|
|
m_sampleSinkPluginInstanceUI = gui;
|
2016-10-17 22:03:51 +00:00
|
|
|
}
|
|
|
|
|
2017-11-19 00:05:16 +00:00
|
|
|
void DeviceSinkAPI::getDeviceEngineStateStr(QString& state)
|
|
|
|
{
|
|
|
|
if (m_deviceSinkEngine)
|
|
|
|
{
|
|
|
|
switch(m_deviceSinkEngine->state())
|
|
|
|
{
|
|
|
|
case DSPDeviceSinkEngine::StNotStarted:
|
|
|
|
state = "notStarted";
|
|
|
|
break;
|
|
|
|
case DSPDeviceSinkEngine::StIdle:
|
|
|
|
state = "idle";
|
|
|
|
break;
|
|
|
|
case DSPDeviceSinkEngine::StReady:
|
|
|
|
state = "ready";
|
|
|
|
break;
|
|
|
|
case DSPDeviceSinkEngine::StRunning:
|
|
|
|
state = "running";
|
|
|
|
break;
|
|
|
|
case DSPDeviceSinkEngine::StError:
|
|
|
|
state = "error";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
state = "notStarted";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
state = "notStarted";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-17 22:03:51 +00:00
|
|
|
void DeviceSinkAPI::loadSinkSettings(const Preset* preset)
|
|
|
|
{
|
2016-10-18 22:07:42 +00:00
|
|
|
if (preset->isSourcePreset())
|
2016-10-17 22:03:51 +00:00
|
|
|
{
|
2016-10-22 08:10:17 +00:00
|
|
|
qDebug("DeviceSinkAPI::loadSinkSettings: Preset [%s | %s] is not a sink preset", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
2016-10-18 22:07:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-22 08:10:17 +00:00
|
|
|
qDebug("DeviceSinkAPI::loadSinkSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
2016-10-17 22:03:51 +00:00
|
|
|
|
2017-12-28 03:04:50 +00:00
|
|
|
const QByteArray* sinkConfig = preset->findBestDeviceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence);
|
|
|
|
qint64 centerFrequency = preset->getCenterFrequency();
|
|
|
|
qDebug("DeviceSinkAPI::loadSinkSettings: center frequency: %llu Hz", centerFrequency);
|
|
|
|
|
|
|
|
if (sinkConfig != 0)
|
2016-10-17 22:03:51 +00:00
|
|
|
{
|
2017-12-28 03:04:50 +00:00
|
|
|
qDebug("DeviceSinkAPI::loadSinkSettings: deserializing sink %s[%d]: %s", qPrintable(m_sampleSinkId), m_sampleSinkSequence, qPrintable(m_sampleSinkSerial));
|
2016-10-17 22:03:51 +00:00
|
|
|
|
2017-12-28 03:04:50 +00:00
|
|
|
if (m_sampleSinkPluginInstanceUI != 0) // GUI flavor
|
2016-10-18 22:07:42 +00:00
|
|
|
{
|
2017-12-28 03:04:50 +00:00
|
|
|
m_sampleSinkPluginInstanceUI->deserialize(*sinkConfig);
|
|
|
|
m_sampleSinkPluginInstanceUI->setCenterFrequency(centerFrequency);
|
|
|
|
}
|
|
|
|
else if (m_deviceSinkEngine->getSink() != 0) // Server flavor
|
|
|
|
{
|
|
|
|
m_deviceSinkEngine->getSink()->deserialize(*sinkConfig);
|
|
|
|
m_deviceSinkEngine->getSink()->setCenterFrequency(centerFrequency);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("DeviceSinkAPI::loadSinkSettings: no sink");
|
2016-10-18 22:07:42 +00:00
|
|
|
}
|
2017-12-28 03:04:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("DeviceSinkAPI::loadSinkSettings: sink %s[%d]: %s not found", qPrintable(m_sampleSinkId), m_sampleSinkSequence, qPrintable(m_sampleSinkSerial));
|
2016-10-18 22:07:42 +00:00
|
|
|
}
|
2016-10-17 22:03:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceSinkAPI::saveSinkSettings(Preset* preset)
|
|
|
|
{
|
2016-10-18 22:07:42 +00:00
|
|
|
if (preset->isSourcePreset())
|
2016-10-17 22:03:51 +00:00
|
|
|
{
|
2016-10-18 22:07:42 +00:00
|
|
|
qDebug("DeviceSinkAPI::saveSinkSettings: not a sink preset");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-28 16:22:18 +00:00
|
|
|
qDebug("DeviceSinkAPI::saveSourceSettings: serializing sink %s[%d]: %s", qPrintable(m_sampleSinkId), m_sampleSinkSequence, qPrintable(m_sampleSinkSerial));
|
2017-12-28 03:04:50 +00:00
|
|
|
|
|
|
|
if (m_sampleSinkPluginInstanceUI != 0) // GUI flavor
|
|
|
|
{
|
|
|
|
preset->addOrUpdateDeviceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence, m_deviceSinkEngine->getSink()->serialize());
|
|
|
|
preset->setCenterFrequency(m_deviceSinkEngine->getSink()->getCenterFrequency());
|
|
|
|
}
|
|
|
|
else if (m_deviceSinkEngine->getSink() != 0) // Server flavor
|
2016-10-18 22:07:42 +00:00
|
|
|
{
|
2017-12-28 03:04:50 +00:00
|
|
|
preset->addOrUpdateDeviceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence, m_deviceSinkEngine->getSink()->serialize());
|
|
|
|
preset->setCenterFrequency(m_deviceSinkEngine->getSink()->getCenterFrequency());
|
2016-10-18 22:07:42 +00:00
|
|
|
}
|
2016-10-22 08:10:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("DeviceSinkAPI::saveSinkSettings: no sink");
|
|
|
|
}
|
2016-10-17 22:03:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-29 11:41:10 +00:00
|
|
|
void DeviceSinkAPI::addSourceBuddy(DeviceSourceAPI* buddy)
|
|
|
|
{
|
|
|
|
m_sourceBuddies.push_back(buddy);
|
2017-01-02 22:30:50 +00:00
|
|
|
buddy->m_sinkBuddies.push_back(this);
|
2019-04-15 11:02:39 +00:00
|
|
|
qDebug("DeviceSinkAPI::addSourceBuddy: added buddy %s(%s) to the list [%llu] <-> [%llu]",
|
2016-12-29 11:41:10 +00:00
|
|
|
qPrintable(buddy->getHardwareId()),
|
2016-12-29 18:26:45 +00:00
|
|
|
qPrintable(buddy->getSampleSourceSerial()),
|
2019-04-15 11:02:39 +00:00
|
|
|
(quint64) buddy,
|
|
|
|
(quint64) this);
|
2016-12-29 11:41:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceSinkAPI::addSinkBuddy(DeviceSinkAPI* buddy)
|
|
|
|
{
|
|
|
|
m_sinkBuddies.push_back(buddy);
|
2017-01-02 22:30:50 +00:00
|
|
|
buddy->m_sinkBuddies.push_back(this);
|
2019-04-15 11:02:39 +00:00
|
|
|
qDebug("DeviceSinkAPI::addSinkBuddy: added buddy %s(%s) to the list [%llu] <-> [%llu]",
|
2016-12-29 11:41:10 +00:00
|
|
|
qPrintable(buddy->getHardwareId()),
|
2016-12-29 18:26:45 +00:00
|
|
|
qPrintable(buddy->getSampleSinkSerial()),
|
2019-04-15 11:02:39 +00:00
|
|
|
(quint64) buddy,
|
|
|
|
(quint64) this);
|
2016-12-29 11:41:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceSinkAPI::removeSourceBuddy(DeviceSourceAPI* buddy)
|
|
|
|
{
|
|
|
|
std::vector<DeviceSourceAPI*>::iterator it = m_sourceBuddies.begin();
|
|
|
|
|
|
|
|
for (;it != m_sourceBuddies.end(); ++it)
|
|
|
|
{
|
2016-12-29 18:26:45 +00:00
|
|
|
if (*it == buddy)
|
2016-12-29 11:41:10 +00:00
|
|
|
{
|
2019-04-15 11:02:39 +00:00
|
|
|
qDebug("DeviceSinkAPI::removeSourceBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]",
|
2016-12-29 11:41:10 +00:00
|
|
|
qPrintable(buddy->getHardwareId()),
|
2016-12-29 18:26:45 +00:00
|
|
|
qPrintable(buddy->getSampleSourceSerial()),
|
2019-04-15 11:02:39 +00:00
|
|
|
(quint64) (*it),
|
|
|
|
(quint64) this);
|
2016-12-29 18:26:45 +00:00
|
|
|
m_sourceBuddies.erase(it);
|
2016-12-29 11:41:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-15 11:02:39 +00:00
|
|
|
qDebug("DeviceSinkAPI::removeSourceBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]",
|
2016-12-29 11:41:10 +00:00
|
|
|
qPrintable(buddy->getHardwareId()),
|
2016-12-29 18:26:45 +00:00
|
|
|
qPrintable(buddy->getSampleSourceSerial()),
|
2019-04-15 11:02:39 +00:00
|
|
|
(quint64) buddy,
|
|
|
|
(quint64) this);
|
2016-12-29 11:41:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceSinkAPI::removeSinkBuddy(DeviceSinkAPI* buddy)
|
|
|
|
{
|
|
|
|
std::vector<DeviceSinkAPI*>::iterator it = m_sinkBuddies.begin();
|
|
|
|
|
|
|
|
for (;it != m_sinkBuddies.end(); ++it)
|
|
|
|
{
|
2016-12-29 18:26:45 +00:00
|
|
|
if (*it == buddy)
|
2016-12-29 11:41:10 +00:00
|
|
|
{
|
2019-04-15 11:02:39 +00:00
|
|
|
qDebug("DeviceSinkAPI::removeSinkBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]",
|
2016-12-29 11:41:10 +00:00
|
|
|
qPrintable(buddy->getHardwareId()),
|
2016-12-29 18:26:45 +00:00
|
|
|
qPrintable(buddy->getSampleSinkSerial()),
|
2019-04-15 11:02:39 +00:00
|
|
|
(quint64) (*it),
|
|
|
|
(quint64) this);
|
2016-12-29 18:26:45 +00:00
|
|
|
m_sinkBuddies.erase(it);
|
2016-12-29 11:41:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-15 11:02:39 +00:00
|
|
|
qDebug("DeviceSinkAPI::removeSinkBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]",
|
2016-12-29 11:41:10 +00:00
|
|
|
qPrintable(buddy->getHardwareId()),
|
2016-12-29 18:26:45 +00:00
|
|
|
qPrintable(buddy->getSampleSinkSerial()),
|
2019-04-15 11:02:39 +00:00
|
|
|
(quint64) buddy,
|
|
|
|
(quint64) this);
|
2016-12-29 11:41:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-29 18:26:45 +00:00
|
|
|
void DeviceSinkAPI::clearBuddiesLists()
|
2016-12-29 11:41:10 +00:00
|
|
|
{
|
|
|
|
std::vector<DeviceSourceAPI*>::iterator itSource = m_sourceBuddies.begin();
|
|
|
|
std::vector<DeviceSinkAPI*>::iterator itSink = m_sinkBuddies.begin();
|
2017-07-03 06:59:48 +00:00
|
|
|
bool leaderElected = false;
|
2016-12-29 11:41:10 +00:00
|
|
|
|
|
|
|
for (;itSource != m_sourceBuddies.end(); ++itSource)
|
|
|
|
{
|
2017-07-03 06:59:48 +00:00
|
|
|
if (isBuddyLeader() && !leaderElected)
|
|
|
|
{
|
|
|
|
(*itSource)->setBuddyLeader(true);
|
|
|
|
leaderElected = true;
|
|
|
|
}
|
|
|
|
|
2016-12-29 11:41:10 +00:00
|
|
|
(*itSource)->removeSinkBuddy(this);
|
|
|
|
}
|
|
|
|
|
2016-12-29 18:26:45 +00:00
|
|
|
m_sourceBuddies.clear();
|
|
|
|
|
2016-12-29 11:41:10 +00:00
|
|
|
for (;itSink != m_sinkBuddies.end(); ++itSink)
|
|
|
|
{
|
2017-07-03 06:59:48 +00:00
|
|
|
if (isBuddyLeader() && !leaderElected)
|
|
|
|
{
|
|
|
|
(*itSink)->setBuddyLeader(true);
|
|
|
|
leaderElected = true;
|
|
|
|
}
|
|
|
|
|
2016-12-29 11:41:10 +00:00
|
|
|
(*itSink)->removeSinkBuddy(this);
|
|
|
|
}
|
2016-12-29 18:26:45 +00:00
|
|
|
|
|
|
|
m_sinkBuddies.clear();
|
2016-12-29 11:41:10 +00:00
|
|
|
}
|
2016-10-17 22:03:51 +00:00
|
|
|
|