diff --git a/sdrbase/CMakeLists.txt b/sdrbase/CMakeLists.txt index 7df3db634..ae5d534f0 100644 --- a/sdrbase/CMakeLists.txt +++ b/sdrbase/CMakeLists.txt @@ -16,8 +16,6 @@ set(sdrbase_SOURCES audio/audioresampler.cpp channel/channelapi.cpp - # channel/channelsinkapi.cpp - # channel/channelsourceapi.cpp channel/remotedataqueue.cpp channel/remotedatareadqueue.cpp @@ -68,8 +66,6 @@ set(sdrbase_SOURCES dsp/devicesamplesource.cpp dsp/devicesamplesink.cpp - # device/devicesourceapi.cpp - # device/devicesinkapi.cpp device/deviceapi.cpp device/deviceenumerator.cpp @@ -115,8 +111,6 @@ set(sdrbase_HEADERS audio/audioresampler.h channel/channelapi.h - # channel/channelsinkapi.h - # channel/channelsourceapi.h channel/remotedataqueue.h channel/remotedatareadqueue.h channel/remotedatablock.h @@ -191,8 +185,6 @@ set(sdrbase_HEADERS dsp/devicesamplesource.h dsp/devicesamplesink.h - # device/devicesourceapi.h - # device/devicesinkapi.h device/deviceapi.h device/deviceenumerator.h diff --git a/sdrbase/channel/channelapi.cpp b/sdrbase/channel/channelapi.cpp index 416c331f9..0eecc57b8 100644 --- a/sdrbase/channel/channelapi.cpp +++ b/sdrbase/channel/channelapi.cpp @@ -21,8 +21,8 @@ #include "channelapi.h" ChannelAPI::ChannelAPI(const QString& name, StreamType streamType) : - m_name(name), m_streamType(streamType), + m_name(name), m_indexInDeviceSet(-1), m_deviceAPI(0), m_uid(UidCalculator::getNewObjectId()) diff --git a/sdrbase/channel/channelsinkapi.cpp b/sdrbase/channel/channelsinkapi.cpp deleted file mode 100644 index 8441aff9f..000000000 --- a/sdrbase/channel/channelsinkapi.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2017 Edouard Griffiths, F4EXB // -// // -// API for Rx channels // -// // -// 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 // -// (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. 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#include "util/uid.h" -#include "channelsinkapi.h" - -ChannelSinkAPI::ChannelSinkAPI(const QString& name) : - m_name(name), - m_indexInDeviceSet(-1), - m_deviceSourceAPI(0), - m_uid(UidCalculator::getNewObjectId()) -{ -} diff --git a/sdrbase/channel/channelsinkapi.h b/sdrbase/channel/channelsinkapi.h deleted file mode 100644 index d7d9ab244..000000000 --- a/sdrbase/channel/channelsinkapi.h +++ /dev/null @@ -1,102 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2017 Edouard Griffiths, F4EXB // -// // -// API for Rx channels // -// // -// 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 // -// (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. 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_CHANNEL_CHANNELSINKAPI_H_ -#define SDRBASE_CHANNEL_CHANNELSINKAPI_H_ - -#include -#include -#include - -#include "export.h" - -class DeviceAPI; - -namespace SWGSDRangel -{ - class SWGChannelSettings; - class SWGChannelReport; -} - -class SDRBASE_API ChannelSinkAPI { -public: - ChannelSinkAPI(const QString& name); - virtual ~ChannelSinkAPI() {} - virtual void destroy() = 0; - - virtual void getIdentifier(QString& id) = 0; - virtual void getTitle(QString& title) = 0; - virtual void setName(const QString& name) { m_name = name; } - virtual const QString& getName() const { return m_name; } - virtual qint64 getCenterFrequency() const = 0; - - virtual QByteArray serialize() const = 0; - virtual bool deserialize(const QByteArray& data) = 0; - - virtual int webapiSettingsGet( - SWGSDRangel::SWGChannelSettings& response, - QString& errorMessage) - { - (void) response; - errorMessage = "Not implemented"; return 501; - } - - virtual int webapiSettingsPutPatch( - bool force, - const QStringList& channelSettingsKeys, - SWGSDRangel::SWGChannelSettings& response, - QString& errorMessage) - { - (void) force; - (void) channelSettingsKeys; - (void) response; - errorMessage = "Not implemented"; return 501; - } - - virtual int webapiReportGet( - SWGSDRangel::SWGChannelReport& response, - QString& errorMessage) - { - (void) response; - errorMessage = "Not implemented"; return 501; - } - - int getIndexInDeviceSet() const { return m_indexInDeviceSet; } - void setIndexInDeviceSet(int indexInDeviceSet) { m_indexInDeviceSet = indexInDeviceSet; } - int getDeviceSetIndex() const { return m_deviceSetIndex; } - void setDeviceSetIndex(int deviceSetIndex) { m_deviceSetIndex = deviceSetIndex; } - DeviceAPI *getDeviceSourceAPI() { return m_deviceSourceAPI; } - void setDeviceSourceAPI(DeviceAPI *deviceSourceAPI) { m_deviceSourceAPI = deviceSourceAPI; } - uint64_t getUID() const { return m_uid; } - -private: - /** Unique identifier in a device set used for sorting. Used when there is no GUI. - * In GUI version it is supported by GUI object name accessed through PluginInstanceGUI. - */ - QString m_name; - - int m_indexInDeviceSet; - int m_deviceSetIndex; - DeviceAPI *m_deviceSourceAPI; - uint64_t m_uid; -}; - - - -#endif /* SDRBASE_CHANNEL_CHANNELSINKAPI_H_ */ diff --git a/sdrbase/channel/channelsourceapi.cpp b/sdrbase/channel/channelsourceapi.cpp deleted file mode 100644 index 37e637f35..000000000 --- a/sdrbase/channel/channelsourceapi.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2016 Edouard Griffiths, F4EXB // -// // -// API for Tx channels // -// // -// 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 // -// (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. 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#include "util/uid.h" -#include "channelsourceapi.h" - -ChannelSourceAPI::ChannelSourceAPI(const QString& name) : - m_name(name), - m_indexInDeviceSet(-1), - m_deviceSinkAPI(0), - m_uid(UidCalculator::getNewObjectId()) -{ } - diff --git a/sdrbase/channel/channelsourceapi.h b/sdrbase/channel/channelsourceapi.h deleted file mode 100644 index 137513b37..000000000 --- a/sdrbase/channel/channelsourceapi.h +++ /dev/null @@ -1,101 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2016 Edouard Griffiths, F4EXB // -// // -// API for Tx channels // -// // -// 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 // -// (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. 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_CHANNEL_CHANNELSOURCEAPI_H_ -#define SDRBASE_CHANNEL_CHANNELSOURCEAPI_H_ - -#include -#include - -#include "export.h" - -class DeviceAPI; - -namespace SWGSDRangel -{ - class SWGChannelSettings; - class SWGChannelReport; -} - -class SDRBASE_API ChannelSourceAPI { -public: - ChannelSourceAPI(const QString& name); - virtual ~ChannelSourceAPI() {} - virtual void destroy() = 0; - - virtual void getIdentifier(QString& id) = 0; - virtual void getTitle(QString& title) = 0; - virtual void setName(const QString& name) { m_name = name; } - virtual QString getName() const { return m_name; } - virtual qint64 getCenterFrequency() const = 0; - - virtual QByteArray serialize() const = 0; - virtual bool deserialize(const QByteArray& data) = 0; - - virtual int webapiSettingsGet( - SWGSDRangel::SWGChannelSettings& response, - QString& errorMessage) - { - (void) response; - errorMessage = "Not implemented"; return 501; - } - - virtual int webapiSettingsPutPatch( - bool force, - const QStringList& channelSettingsKeys, - SWGSDRangel::SWGChannelSettings& response, - QString& errorMessage) - { - (void) force; - (void) channelSettingsKeys; - (void) response; - errorMessage = "Not implemented"; return 501; - } - - virtual int webapiReportGet( - SWGSDRangel::SWGChannelReport& response, - QString& errorMessage) - { - (void) response; - errorMessage = "Not implemented"; return 501; - } - - int getIndexInDeviceSet() const { return m_indexInDeviceSet; } - void setIndexInDeviceSet(int indexInDeviceSet) { m_indexInDeviceSet = indexInDeviceSet; } - int getDeviceSetIndex() const { return m_deviceSetIndex; } - void setDeviceSetIndex(int deviceSetIndex) { m_deviceSetIndex = deviceSetIndex; } - DeviceAPI *getDeviceSinkAPI() { return m_deviceSinkAPI; } - void setDeviceSinkAPI(DeviceAPI *deviceSinkAPI) { m_deviceSinkAPI = deviceSinkAPI; } - uint64_t getUID() const { return m_uid; } - -private: - /** Unique identifier in a device set used for sorting. Used when there is no GUI. - * In GUI version it is supported by GUI object name accessed through PluginInstanceGUI. - */ - QString m_name; - - int m_indexInDeviceSet; - int m_deviceSetIndex; - DeviceAPI *m_deviceSinkAPI; - uint64_t m_uid; -}; - - - -#endif /* SDRBASE_CHANNEL_CHANNELSOURCEAPI_H_ */ diff --git a/sdrbase/device/devicesinkapi.cpp b/sdrbase/device/devicesinkapi.cpp deleted file mode 100644 index 382c66152..000000000 --- a/sdrbase/device/devicesinkapi.cpp +++ /dev/null @@ -1,409 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// 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 // -// (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. 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#include -#include "device/devicesinkapi.h" -#include "device/devicesourceapi.h" -#include "dsp/devicesamplesink.h" -#include "plugin/plugininterface.h" -#include "settings/preset.h" -#include "dsp/dspengine.h" -#include "channel/channelsourceapi.h" - -DeviceSinkAPI::DeviceSinkAPI(int deviceTabIndex, - DSPDeviceSinkEngine *deviceSinkEngine) : - m_deviceTabIndex(deviceTabIndex), - m_deviceSinkEngine(deviceSinkEngine), - m_sampleSinkSequence(0), - m_nbItems(1), - m_itemIndex(0), - m_pluginInterface(0), - m_sampleSinkPluginInstanceUI(0), - m_buddySharedPtr(0), - m_isBuddyLeader(false), - m_masterTimer(DSPEngine::instance()->getMasterTimer()) -{ -} - -DeviceSinkAPI::~DeviceSinkAPI() -{ -} - -void DeviceSinkAPI::addSpectrumSink(BasebandSampleSink *spectrumSink) -{ - m_deviceSinkEngine->addSpectrumSink(spectrumSink); -} - -void DeviceSinkAPI::removeSpectrumSink(BasebandSampleSink* spectrumSink) -{ - m_deviceSinkEngine->removeSpectrumSink(spectrumSink); -} - -void DeviceSinkAPI::addThreadedSource(ThreadedBasebandSampleSource* source) -{ - m_deviceSinkEngine->addThreadedSource(source); -} - -void DeviceSinkAPI::removeThreadedSource(ThreadedBasebandSampleSource* source) -{ - m_deviceSinkEngine->removeThreadedSource(source); -} - -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() -{ - for (int i = 0; i < m_channelAPIs.size(); ++i) - { - m_channelAPIs.at(i)->setIndexInDeviceSet(i); - m_channelAPIs.at(i)->setDeviceSetIndex(m_deviceTabIndex); - m_channelAPIs.at(i)->setDeviceSinkAPI(this); - } -} - - -void DeviceSinkAPI::setSampleSink(DeviceSampleSink* sink) -{ - m_deviceSinkEngine->setSink(sink); -} - -DeviceSampleSink *DeviceSinkAPI::getSampleSink() -{ - return m_deviceSinkEngine->getSink(); -} - -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(); -} - -MessageQueue *DeviceSinkAPI::getDeviceEngineInputMessageQueue() -{ - return m_deviceSinkEngine->getInputMessageQueue(); -} - -MessageQueue *DeviceSinkAPI::getSampleSinkInputMessageQueue() -{ - return getSampleSink()->getInputMessageQueue(); -} - -MessageQueue *DeviceSinkAPI::getSampleSinkGUIMessageQueue() -{ - return getSampleSink()->getMessageQueueToGUI(); -} - -void DeviceSinkAPI::setHardwareId(const QString& id) -{ - m_hardwareId = id; -} - -void DeviceSinkAPI::setSampleSinkId(const QString& id) -{ - m_sampleSinkId = id; -} - -void DeviceSinkAPI::resetSampleSinkId() -{ - m_sampleSinkId.clear(); -} - -void DeviceSinkAPI::setSampleSinkSerial(const QString& serial) -{ - m_sampleSinkSerial = serial; -} - -void DeviceSinkAPI::setSampleSinkDisplayName(const QString& name) -{ - m_sampleSinkDisplayName = name; -} - -void DeviceSinkAPI::setSampleSinkSequence(int sequence) -{ - m_sampleSinkSequence = sequence; - m_deviceSinkEngine->setSinkSequence(sequence); -} - -void DeviceSinkAPI::setNbItems(uint32_t nbItems) -{ - m_nbItems = nbItems; -} - -void DeviceSinkAPI::setItemIndex(uint32_t index) -{ - m_itemIndex = index; -} - -void DeviceSinkAPI::setSampleSinkPluginInterface(PluginInterface *iface) -{ - m_pluginInterface = iface; -} - -void DeviceSinkAPI::setSampleSinkPluginInstanceUI(PluginInstanceGUI *gui) -{ - m_sampleSinkPluginInstanceUI = gui; -} - -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"; - } -} - -void DeviceSinkAPI::loadSinkSettings(const Preset* preset) -{ - if (preset->isSourcePreset()) - { - qDebug("DeviceSinkAPI::loadSinkSettings: Preset [%s | %s] is not a sink preset", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); - } - else - { - qDebug("DeviceSinkAPI::loadSinkSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); - - 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) - { - qDebug("DeviceSinkAPI::loadSinkSettings: deserializing sink %s[%d]: %s", qPrintable(m_sampleSinkId), m_sampleSinkSequence, qPrintable(m_sampleSinkSerial)); - - if (m_sampleSinkPluginInstanceUI != 0) // GUI flavor - { - 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"); - } - } - else - { - qDebug("DeviceSinkAPI::loadSinkSettings: sink %s[%d]: %s not found", qPrintable(m_sampleSinkId), m_sampleSinkSequence, qPrintable(m_sampleSinkSerial)); - } - } -} - -void DeviceSinkAPI::saveSinkSettings(Preset* preset) -{ - if (preset->isSourcePreset()) - { - qDebug("DeviceSinkAPI::saveSinkSettings: not a sink preset"); - } - else - { - qDebug("DeviceSinkAPI::saveSourceSettings: serializing sink %s[%d]: %s", qPrintable(m_sampleSinkId), m_sampleSinkSequence, qPrintable(m_sampleSinkSerial)); - - 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 - { - preset->addOrUpdateDeviceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence, m_deviceSinkEngine->getSink()->serialize()); - preset->setCenterFrequency(m_deviceSinkEngine->getSink()->getCenterFrequency()); - } - else - { - qDebug("DeviceSinkAPI::saveSinkSettings: no sink"); - } - } -} - -void DeviceSinkAPI::addSourceBuddy(DeviceSourceAPI* buddy) -{ - m_sourceBuddies.push_back(buddy); - buddy->m_sinkBuddies.push_back(this); - qDebug("DeviceSinkAPI::addSourceBuddy: added buddy %s(%s) to the list [%llu] <-> [%llu]", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial()), - (quint64) buddy, - (quint64) this); -} - -void DeviceSinkAPI::addSinkBuddy(DeviceSinkAPI* buddy) -{ - m_sinkBuddies.push_back(buddy); - buddy->m_sinkBuddies.push_back(this); - qDebug("DeviceSinkAPI::addSinkBuddy: added buddy %s(%s) to the list [%llu] <-> [%llu]", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial()), - (quint64) buddy, - (quint64) this); -} - -void DeviceSinkAPI::removeSourceBuddy(DeviceSourceAPI* buddy) -{ - std::vector::iterator it = m_sourceBuddies.begin(); - - for (;it != m_sourceBuddies.end(); ++it) - { - if (*it == buddy) - { - qDebug("DeviceSinkAPI::removeSourceBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial()), - (quint64) (*it), - (quint64) this); - m_sourceBuddies.erase(it); - return; - } - } - - qDebug("DeviceSinkAPI::removeSourceBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial()), - (quint64) buddy, - (quint64) this); -} - -void DeviceSinkAPI::removeSinkBuddy(DeviceSinkAPI* buddy) -{ - std::vector::iterator it = m_sinkBuddies.begin(); - - for (;it != m_sinkBuddies.end(); ++it) - { - if (*it == buddy) - { - qDebug("DeviceSinkAPI::removeSinkBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial()), - (quint64) (*it), - (quint64) this); - m_sinkBuddies.erase(it); - return; - } - } - - qDebug("DeviceSinkAPI::removeSinkBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial()), - (quint64) buddy, - (quint64) this); -} - -void DeviceSinkAPI::clearBuddiesLists() -{ - std::vector::iterator itSource = m_sourceBuddies.begin(); - std::vector::iterator itSink = m_sinkBuddies.begin(); - bool leaderElected = false; - - for (;itSource != m_sourceBuddies.end(); ++itSource) - { - if (isBuddyLeader() && !leaderElected) - { - (*itSource)->setBuddyLeader(true); - leaderElected = true; - } - - (*itSource)->removeSinkBuddy(this); - } - - m_sourceBuddies.clear(); - - for (;itSink != m_sinkBuddies.end(); ++itSink) - { - if (isBuddyLeader() && !leaderElected) - { - (*itSink)->setBuddyLeader(true); - leaderElected = true; - } - - (*itSink)->removeSinkBuddy(this); - } - - m_sinkBuddies.clear(); -} - diff --git a/sdrbase/device/devicesinkapi.h b/sdrbase/device/devicesinkapi.h deleted file mode 100644 index 8feb69184..000000000 --- a/sdrbase/device/devicesinkapi.h +++ /dev/null @@ -1,139 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// 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 // -// (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. 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_DEVICE_DEVICESINKAPI_H_ -#define SDRBASE_DEVICE_DEVICESINKAPI_H_ - -#include -#include - -#include "dsp/dspdevicesinkengine.h" -#include "export.h" - -class BasebandSampleSource; -class ThreadedBasebandSampleSource; -class DeviceSampleSink; -class MessageQueue; -class PluginInstanceGUI; -class PluginInterface; -class Preset; -class DeviceSourceAPI; -class ChannelSourceAPI; - -class SDRBASE_API DeviceSinkAPI : public QObject { - Q_OBJECT - -public: - DeviceSinkAPI(int deviceTabIndex, - DSPDeviceSinkEngine *deviceEngine); - ~DeviceSinkAPI(); - - // Device engine stuff - void addSpectrumSink(BasebandSampleSink* sink); //!< Add the spectrum sample sink to device engine (spectrum vis) - void removeSpectrumSink(BasebandSampleSink* sink); //!< Remove the spectrum sample sink from device engine (spectrum vis) - void removeSource(BasebandSampleSource* sink); //!< Remove a baseband sample source from device engine - void addThreadedSource(ThreadedBasebandSampleSource* sink); //!< Add a baseband sample source that will run on its own thread to device engine - void removeThreadedSource(ThreadedBasebandSampleSource* sink); //!< Remove a baseband sample source that runs on its own thread from device engine - void addChannelAPI(ChannelSourceAPI* channelAPI); - void removeChannelAPI(ChannelSourceAPI* channelAPI); - void setSampleSink(DeviceSampleSink* sink); //!< Set device engine sample sink type - DeviceSampleSink *getSampleSink(); //!< Return pointer to the device sample sink - bool initGeneration(); //!< Initialize device engine generation sequence - bool startGeneration(); //!< Start device engine generation sequence - void stopGeneration(); //!< Stop device engine generation sequence - DSPDeviceSinkEngine::State state() const; //!< device engine state - QString errorMessage(); //!< Return the current device engine error message - uint getDeviceUID() const; //!< Return the current device engine unique ID - MessageQueue *getDeviceEngineInputMessageQueue(); - MessageQueue *getSampleSinkInputMessageQueue(); - MessageQueue *getSampleSinkGUIMessageQueue(); - - void setHardwareId(const QString& id); - void setSampleSinkId(const QString& id); - void resetSampleSinkId(); - void setSampleSinkSerial(const QString& serial); - void setSampleSinkDisplayName(const QString& serial); - void setSampleSinkSequence(int sequence); - void setNbItems(uint32_t nbItems); - void setItemIndex(uint32_t index); - void setSampleSinkPluginInterface(PluginInterface *iface); - void setSampleSinkPluginInstanceUI(PluginInstanceGUI *gui); - - const QString& getHardwareId() const { return m_hardwareId; } - const QString& getSampleSinkId() const { return m_sampleSinkId; } - const QString& getSampleSinkSerial() const { return m_sampleSinkSerial; } - const QString& getSampleSinkDisplayName() const { return m_sampleSinkDisplayName; } - uint32_t getSampleSinkSequence() const { return m_sampleSinkSequence; } - uint32_t getNbItems() const { return m_nbItems; } - uint32_t getItemIndex() const { return m_itemIndex; } - int getDeviceSetIndex() const { return m_deviceTabIndex; } - PluginInterface *getPluginInterface() { return m_pluginInterface; } - PluginInstanceGUI *getSampleSinkPluginInstanceGUI() { return m_sampleSinkPluginInstanceUI; } - void getDeviceEngineStateStr(QString& state); - ChannelSourceAPI *getChanelAPIAt(int index); - int getNbChannels() const { return m_channelAPIs.size(); } - - void loadSinkSettings(const Preset* preset); - void saveSinkSettings(Preset* preset); - - DSPDeviceSinkEngine *getDeviceSinkEngine() { return m_deviceSinkEngine; } - - const std::vector& getSourceBuddies() const { return m_sourceBuddies; } - const std::vector& getSinkBuddies() const { return m_sinkBuddies; } - void addSourceBuddy(DeviceSourceAPI* buddy); - void addSinkBuddy(DeviceSinkAPI* buddy); - void removeSourceBuddy(DeviceSourceAPI* buddy); - void removeSinkBuddy(DeviceSinkAPI* buddy); - void clearBuddiesLists(); - void *getBuddySharedPtr() const { return m_buddySharedPtr; } - void setBuddySharedPtr(void *ptr) { m_buddySharedPtr = ptr; } - bool isBuddyLeader() const { return m_isBuddyLeader; } - void setBuddyLeader(bool isBuddyLeader) { m_isBuddyLeader = isBuddyLeader; } - - const QTimer& getMasterTimer() const { return m_masterTimer; } //!< This is the DSPEngine master timer - -protected: - int m_deviceTabIndex; - DSPDeviceSinkEngine *m_deviceSinkEngine; - - QString m_hardwareId; //!< The internal id that identifies the type of hardware (i.e. HackRF, BladeRF, ...) - QString m_sampleSinkId; //!< The internal plugin ID corresponding to the device (i.e. for HackRF input, for HackRF output ...) - QString m_sampleSinkSerial; //!< The device serial number defined by the vendor - QString m_sampleSinkDisplayName; //!< The human readable name identifying this instance - uint32_t m_sampleSinkSequence; //!< The device sequence. >0 when more than one device of the same type is connected - uint32_t m_nbItems; //!< Number of items or streams in the device. Can be >1 for NxM devices (i.e. 2 for LimeSDR) - uint32_t m_itemIndex; //!< The Tx stream index. Can be >0 for NxM devices (i.e. 0 or 1 for LimeSDR) - PluginInterface* m_pluginInterface; - PluginInstanceGUI* m_sampleSinkPluginInstanceUI; - - std::vector m_sourceBuddies; //!< Device source APIs referencing the same physical device - std::vector m_sinkBuddies; //!< Device sink APIs referencing the same physical device - void *m_buddySharedPtr; - bool m_isBuddyLeader; - const QTimer& m_masterTimer; //!< This is the DSPEngine master timer - - QList m_channelAPIs; - - friend class DeviceSourceAPI; - -private: - void renumerateChannels(); -}; - - - -#endif /* SDRBASE_DEVICE_DEVICESINKAPI_H_ */ diff --git a/sdrbase/device/devicesourceapi.cpp b/sdrbase/device/devicesourceapi.cpp deleted file mode 100644 index b98b6e4e1..000000000 --- a/sdrbase/device/devicesourceapi.cpp +++ /dev/null @@ -1,426 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// 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 // -// (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. 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#include -#include "device/devicesourceapi.h" -#include "device/devicesinkapi.h" -#include "dsp/devicesamplesource.h" -#include "plugin/plugininterface.h" -#include "settings/preset.h" -#include "dsp/dspengine.h" -#include "channel/channelsinkapi.h" - -DeviceSourceAPI::DeviceSourceAPI(int deviceTabIndex, - DSPDeviceSourceEngine *deviceSourceEngine) : - m_deviceTabIndex(deviceTabIndex), - m_deviceSourceEngine(deviceSourceEngine), - m_sampleSourceSequence(0), - m_nbItems(1), - m_itemIndex(0), - m_pluginInterface(0), - m_sampleSourcePluginInstanceUI(0), - m_buddySharedPtr(0), - m_isBuddyLeader(false), - m_masterTimer(DSPEngine::instance()->getMasterTimer()) -{ -} - -DeviceSourceAPI::~DeviceSourceAPI() -{ -} - -void DeviceSourceAPI::addSink(BasebandSampleSink *sink) -{ - m_deviceSourceEngine->addSink(sink); -} - -void DeviceSourceAPI::removeSink(BasebandSampleSink* sink) -{ - m_deviceSourceEngine->removeSink(sink); -} - -void DeviceSourceAPI::addThreadedSink(ThreadedBasebandSampleSink* sink) -{ - m_deviceSourceEngine->addThreadedSink(sink); -} - -void DeviceSourceAPI::removeThreadedSink(ThreadedBasebandSampleSink* sink) -{ - m_deviceSourceEngine->removeThreadedSink(sink); -} - -void DeviceSourceAPI::addChannelAPI(ChannelSinkAPI* channelAPI) -{ - m_channelAPIs.append(channelAPI); - renumerateChannels(); -} - -void DeviceSourceAPI::removeChannelAPI(ChannelSinkAPI* channelAPI) -{ - if (m_channelAPIs.removeOne(channelAPI)) { - renumerateChannels(); - } - - channelAPI->setIndexInDeviceSet(-1); -} - -ChannelSinkAPI *DeviceSourceAPI::getChanelAPIAt(int index) -{ - if (index < m_channelAPIs.size()) { - return m_channelAPIs.at(index); - } else { - return 0; - } -} - -void DeviceSourceAPI::renumerateChannels() -{ - for (int i = 0; i < m_channelAPIs.size(); ++i) - { - m_channelAPIs.at(i)->setIndexInDeviceSet(i); - m_channelAPIs.at(i)->setDeviceSetIndex(m_deviceTabIndex); - m_channelAPIs.at(i)->setDeviceSourceAPI(this); - } -} - -void DeviceSourceAPI::setSampleSource(DeviceSampleSource* source) -{ - m_deviceSourceEngine->setSource(source); -} - -DeviceSampleSource *DeviceSourceAPI::getSampleSource() -{ - return m_deviceSourceEngine->getSource(); -} - -bool DeviceSourceAPI::initAcquisition() -{ - return m_deviceSourceEngine->initAcquisition(); -} - -bool DeviceSourceAPI::startAcquisition() -{ - return m_deviceSourceEngine->startAcquisition(); -} - -void DeviceSourceAPI::stopAcquisition() -{ - m_deviceSourceEngine->stopAcquistion(); -} - -DSPDeviceSourceEngine::State DeviceSourceAPI::state() const -{ - return m_deviceSourceEngine->state(); -} - -QString DeviceSourceAPI::errorMessage() -{ - return m_deviceSourceEngine->errorMessage(); -} - -uint DeviceSourceAPI::getDeviceUID() const -{ - return m_deviceSourceEngine->getUID(); -} - -MessageQueue *DeviceSourceAPI::getDeviceEngineInputMessageQueue() -{ - return m_deviceSourceEngine->getInputMessageQueue(); -} - -MessageQueue *DeviceSourceAPI::getSampleSourceInputMessageQueue() -{ - return getSampleSource()->getInputMessageQueue(); -} - -MessageQueue *DeviceSourceAPI::getSampleSourceGUIMessageQueue() -{ - return getSampleSource()->getMessageQueueToGUI(); -} - - -void DeviceSourceAPI::configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection) -{ - m_deviceSourceEngine->configureCorrections(dcOffsetCorrection, iqImbalanceCorrection); -} - -void DeviceSourceAPI::setHardwareId(const QString& id) -{ - m_hardwareId = id; -} - -void DeviceSourceAPI::setSampleSourceId(const QString& id) -{ - m_sampleSourceId = id; -} - -void DeviceSourceAPI::resetSampleSourceId() -{ - m_sampleSourceId.clear(); -} - -void DeviceSourceAPI::setSampleSourceSerial(const QString& serial) -{ - m_sampleSourceSerial = serial; -} - -void DeviceSourceAPI::setSampleSourceDisplayName(const QString& name) -{ - m_sampleSourceDisplayName = name; -} - -void DeviceSourceAPI::setSampleSourceSequence(int sequence) -{ - m_sampleSourceSequence = sequence; - m_deviceSourceEngine->setSourceSequence(sequence); -} - -void DeviceSourceAPI::setNbItems(uint32_t nbItems) -{ - m_nbItems = nbItems; -} - -void DeviceSourceAPI::setItemIndex(uint32_t index) -{ - m_itemIndex = index; -} - -void DeviceSourceAPI::setSampleSourcePluginInterface(PluginInterface *iface) -{ - m_pluginInterface = iface; -} - -void DeviceSourceAPI::setSampleSourcePluginInstanceGUI(PluginInstanceGUI *gui) -{ - m_sampleSourcePluginInstanceUI = gui; -} - -void DeviceSourceAPI::getDeviceEngineStateStr(QString& state) -{ - if (m_deviceSourceEngine) - { - switch(m_deviceSourceEngine->state()) - { - case DSPDeviceSourceEngine::StNotStarted: - state = "notStarted"; - break; - case DSPDeviceSourceEngine::StIdle: - state = "idle"; - break; - case DSPDeviceSourceEngine::StReady: - state = "ready"; - break; - case DSPDeviceSourceEngine::StRunning: - state = "running"; - break; - case DSPDeviceSourceEngine::StError: - state = "error"; - break; - default: - state = "notStarted"; - break; - } - } - else - { - state = "notStarted"; - } -} - -void DeviceSourceAPI::loadSourceSettings(const Preset* preset) -{ - if (preset->isSourcePreset()) - { - qDebug("DeviceSourceAPI::loadSourceSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); - - const QByteArray* sourceConfig = preset->findBestDeviceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence); - qint64 centerFrequency = preset->getCenterFrequency(); - qDebug("DeviceSourceAPI::loadSourceSettings: center frequency: %llu Hz", centerFrequency); - - if (sourceConfig != 0) - { - qDebug("DeviceSourceAPI::loadSourceSettings: deserializing source %s[%d]: %s", qPrintable(m_sampleSourceId), m_sampleSourceSequence, qPrintable(m_sampleSourceSerial)); - - if (m_sampleSourcePluginInstanceUI != 0) // GUI flavor - { - m_sampleSourcePluginInstanceUI->deserialize(*sourceConfig); - } - else if (m_deviceSourceEngine->getSource() != 0) // Server flavor - { - m_deviceSourceEngine->getSource()->deserialize(*sourceConfig); - } - else - { - qDebug("DeviceSourceAPI::loadSourceSettings: deserializing no source"); - } - } - else - { - qDebug("DeviceSourceAPI::loadSourceSettings: source %s[%d]: %s not found", qPrintable(m_sampleSourceId), m_sampleSourceSequence, qPrintable(m_sampleSourceSerial)); - } - - // set center frequency anyway - if (m_sampleSourcePluginInstanceUI != 0) // GUI flavor - { - m_sampleSourcePluginInstanceUI->setCenterFrequency(centerFrequency); - } - else if (m_deviceSourceEngine->getSource() != 0) // Server flavor - { - m_deviceSourceEngine->getSource()->setCenterFrequency(centerFrequency); - } - else - { - qDebug("DeviceSourceAPI::loadSourceSettings: no source"); - } - } - else - { - qDebug("DeviceSourceAPI::loadSourceSettings: Loading preset [%s | %s] is not a source preset", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); - } -} - -void DeviceSourceAPI::saveSourceSettings(Preset* preset) -{ - if (preset->isSourcePreset()) - { - qDebug("DeviceSourceAPI::saveSourceSettings: serializing source %s[%d]: %s", qPrintable(m_sampleSourceId), m_sampleSourceSequence, qPrintable(m_sampleSourceSerial)); - - if (m_sampleSourcePluginInstanceUI != 0) - { - preset->addOrUpdateDeviceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_sampleSourcePluginInstanceUI->serialize()); - preset->setCenterFrequency(m_sampleSourcePluginInstanceUI->getCenterFrequency()); - } - else if (m_deviceSourceEngine->getSource() != 0) - { - preset->addOrUpdateDeviceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_deviceSourceEngine->getSource()->serialize()); - preset->setCenterFrequency(m_deviceSourceEngine->getSource()->getCenterFrequency()); - } - else - { - qDebug("DeviceSourceAPI::saveSourceSettings: no source"); - } - } - else - { - qDebug("DeviceSourceAPI::saveSourceSettings: not a source preset"); - } -} - -void DeviceSourceAPI::addSourceBuddy(DeviceSourceAPI* buddy) -{ - m_sourceBuddies.push_back(buddy); - buddy->m_sourceBuddies.push_back(this); - qDebug("DeviceSourceAPI::addSourceBuddy: added buddy %s(%s) [%llu] <-> [%llu]", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial()), - (quint64) buddy, - (quint64) this); -} - -void DeviceSourceAPI::addSinkBuddy(DeviceSinkAPI* buddy) -{ - m_sinkBuddies.push_back(buddy); - buddy->m_sourceBuddies.push_back(this); - qDebug("DeviceSourceAPI::addSinkBuddy: added buddy %s(%s) [%llu] <-> [%llu]", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial()), - (quint64) buddy, - (quint64) this); -} - -void DeviceSourceAPI::removeSourceBuddy(DeviceSourceAPI* buddy) -{ - std::vector::iterator it = m_sourceBuddies.begin(); - - for (;it != m_sourceBuddies.end(); ++it) - { - if (*it == buddy) - { - qDebug("DeviceSourceAPI::removeSourceBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial()), - (quint64) (*it), - (quint64) this); - m_sourceBuddies.erase(it); - return; - } - } - - qDebug("DeviceSourceAPI::removeSourceBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSourceSerial()), - (quint64) buddy, - (quint64) this); -} - -void DeviceSourceAPI::removeSinkBuddy(DeviceSinkAPI* buddy) -{ - std::vector::iterator it = m_sinkBuddies.begin(); - - for (;it != m_sinkBuddies.end(); ++it) - { - if (*it == buddy) - { - qDebug("DeviceSourceAPI::removeSinkBuddy: buddy %s(%s) [%llu] removed from the list of [%llu]", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial()), - (quint64) (*it), - (quint64) this); - m_sinkBuddies.erase(it); - return; - } - } - - qDebug("DeviceSourceAPI::removeSinkBuddy: buddy %s(%s) [%llu] not found in the list of [%llu]", - qPrintable(buddy->getHardwareId()), - qPrintable(buddy->getSampleSinkSerial()), - (quint64) buddy, - (quint64) this); -} - -void DeviceSourceAPI::clearBuddiesLists() -{ - std::vector::iterator itSource = m_sourceBuddies.begin(); - std::vector::iterator itSink = m_sinkBuddies.begin(); - bool leaderElected = false; - - for (;itSource != m_sourceBuddies.end(); ++itSource) - { - if (isBuddyLeader() && !leaderElected) - { - (*itSource)->setBuddyLeader(true); - leaderElected = true; - } - - (*itSource)->removeSourceBuddy(this); - } - - m_sourceBuddies.clear(); - - for (;itSink != m_sinkBuddies.end(); ++itSink) - { - if (isBuddyLeader() && !leaderElected) - { - (*itSink)->setBuddyLeader(true); - leaderElected = true; - } - - (*itSink)->removeSourceBuddy(this); - } - - m_sinkBuddies.clear(); -} diff --git a/sdrbase/device/devicesourceapi.h b/sdrbase/device/devicesourceapi.h deleted file mode 100644 index 0e2ad8c54..000000000 --- a/sdrbase/device/devicesourceapi.h +++ /dev/null @@ -1,140 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// 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 // -// (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. 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 . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef SDRBASE_DEVICE_DEVICESOURCEAPI_H_ -#define SDRBASE_DEVICE_DEVICESOURCEAPI_H_ - -#include -#include -#include - -#include "dsp/dspdevicesourceengine.h" - -#include "export.h" - -class BasebandSampleSink; -class ThreadedBasebandSampleSink; -class DeviceSampleSource; -class MessageQueue; -class PluginInstanceGUI; -class PluginInterface; -class Preset; -class DeviceSinkAPI; -class ChannelSinkAPI; - -class SDRBASE_API DeviceSourceAPI : public QObject { - Q_OBJECT - -public: - DeviceSourceAPI(int deviceTabIndex, - DSPDeviceSourceEngine *deviceSourceEngine); - ~DeviceSourceAPI(); - - // Device engine stuff - void addSink(BasebandSampleSink* sink); //!< Add a sample sink to device engine - void removeSink(BasebandSampleSink* sink); //!< Remove a sample sink from device engine - void addThreadedSink(ThreadedBasebandSampleSink* sink); //!< Add a sample sink that will run on its own thread to device engine - void removeThreadedSink(ThreadedBasebandSampleSink* sink); //!< Remove a sample sink that runs on its own thread from device engine - void addChannelAPI(ChannelSinkAPI* channelAPI); - void removeChannelAPI(ChannelSinkAPI* channelAPI); - void setSampleSource(DeviceSampleSource* source); //!< Set device sample source - DeviceSampleSource *getSampleSource(); //!< Return pointer to the device sample source - bool initAcquisition(); //!< Initialize device engine acquisition sequence - bool startAcquisition(); //!< Start device engine acquisition sequence - void stopAcquisition(); //!< Stop device engine acquisition sequence - DSPDeviceSourceEngine::State state() const; //!< device engine state - QString errorMessage(); //!< Return the current device engine error message - uint getDeviceUID() const; //!< Return the current device engine unique ID - MessageQueue *getDeviceEngineInputMessageQueue(); - MessageQueue *getSampleSourceInputMessageQueue(); - MessageQueue *getSampleSourceGUIMessageQueue(); - void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection); //!< Configure current device engine DSP corrections - - void setHardwareId(const QString& id); - void setSampleSourceId(const QString& id); - void resetSampleSourceId(); - void setSampleSourceSerial(const QString& serial); - void setSampleSourceDisplayName(const QString& serial); - void setSampleSourceSequence(int sequence); - void setNbItems(uint32_t nbItems); - void setItemIndex(uint32_t index); - void setSampleSourcePluginInterface(PluginInterface *iface); - void setSampleSourcePluginInstanceGUI(PluginInstanceGUI *gui); - - const QString& getHardwareId() const { return m_hardwareId; } - const QString& getSampleSourceId() const { return m_sampleSourceId; } - const QString& getSampleSourceSerial() const { return m_sampleSourceSerial; } - const QString& getSampleSourceDisplayName() const { return m_sampleSourceDisplayName; } - uint32_t getSampleSourceSequence() const { return m_sampleSourceSequence; } - uint32_t getNbItems() const { return m_nbItems; } - uint32_t getItemIndex() const { return m_itemIndex; } - int getDeviceSetIndex() const { return m_deviceTabIndex; } - PluginInterface *getPluginInterface() { return m_pluginInterface; } - PluginInstanceGUI *getSampleSourcePluginInstanceGUI() { return m_sampleSourcePluginInstanceUI; } - void getDeviceEngineStateStr(QString& state); - ChannelSinkAPI *getChanelAPIAt(int index); - int getNbChannels() const { return m_channelAPIs.size(); } - - void loadSourceSettings(const Preset* preset); - void saveSourceSettings(Preset* preset); - - DSPDeviceSourceEngine *getDeviceSourceEngine() { return m_deviceSourceEngine; } - - const std::vector& getSourceBuddies() const { return m_sourceBuddies; } - const std::vector& getSinkBuddies() const { return m_sinkBuddies; } - void addSourceBuddy(DeviceSourceAPI* buddy); - void addSinkBuddy(DeviceSinkAPI* buddy); - void removeSourceBuddy(DeviceSourceAPI* buddy); - void removeSinkBuddy(DeviceSinkAPI* buddy); - void clearBuddiesLists(); - void *getBuddySharedPtr() const { return m_buddySharedPtr; } - void setBuddySharedPtr(void *ptr) { m_buddySharedPtr = ptr; } - bool isBuddyLeader() const { return m_isBuddyLeader; } - void setBuddyLeader(bool isBuddyLeader) { m_isBuddyLeader = isBuddyLeader; } - - const QTimer& getMasterTimer() const { return m_masterTimer; } //!< This is the DSPEngine master timer - -protected: - int m_deviceTabIndex; //!< This is the tab index in the GUI and also the device set index - DSPDeviceSourceEngine *m_deviceSourceEngine; - - QString m_hardwareId; //!< The internal id that identifies the type of hardware (i.e. HackRF, BladeRF, ...) - QString m_sampleSourceId; //!< The internal plugin ID corresponding to the device (i.e. for HackRF input, for HackRF output ...) - QString m_sampleSourceSerial; //!< The device serial number defined by the vendor or a fake one (SDRplay) - QString m_sampleSourceDisplayName; //!< The human readable name identifying this instance - uint32_t m_sampleSourceSequence; //!< The device sequence. >0 when more than one device of the same type is connected - uint32_t m_nbItems; //!< Number of items or streams in the device. Can be >1 for NxM devices (i.e. 2 for LimeSDR) - uint32_t m_itemIndex; //!< The Rx stream index. Can be >0 for NxM devices (i.e. 0 or 1 for LimeSDR) - PluginInterface* m_pluginInterface; - PluginInstanceGUI* m_sampleSourcePluginInstanceUI; - - std::vector m_sourceBuddies; //!< Device source APIs referencing the same physical device - std::vector m_sinkBuddies; //!< Device sink APIs referencing the same physical device - void *m_buddySharedPtr; - bool m_isBuddyLeader; - const QTimer& m_masterTimer; //!< This is the DSPEngine master timer - - QList m_channelAPIs; - - friend class DeviceSinkAPI; - -private: - void renumerateChannels(); -}; - - -#endif /* SDRBASE_DEVICE_DEVICESOURCEAPI_H_ */ diff --git a/sdrbase/sdrbase.pro b/sdrbase/sdrbase.pro index a105edab1..8a0f29740 100644 --- a/sdrbase/sdrbase.pro +++ b/sdrbase/sdrbase.pro @@ -65,14 +65,10 @@ SOURCES += audio/audiodevicemanager.cpp\ audio/audioinput.cpp\ audio/audionetsink.cpp\ audio/audioresampler.cpp\ -# channel/channelsinkapi.cpp\ -# channel/channelsourceapi.cpp\ channel/remotedataqueue.cpp\ channel/remotedatareadqueue.cpp\ commands/command.cpp\ device/deviceapi.cpp\ -# device/devicesourceapi.cpp\ -# device/devicesinkapi.cpp\ device/deviceenumerator.cpp\ dsp/afsquelch.cpp\ dsp/agc.cpp\ @@ -149,15 +145,11 @@ HEADERS += audio/audiodevicemanager.h\ audio/audioinput.h\ audio/audionetsink.h\ audio/audioresampler.h\ -# channel/channelsinkapi.h\ -# channel/channelsourceapi.h\ channel/remotedataqueue.h\ channel/remotedatareadqueue.h\ channel/remotedatablock.h\ commands/command.h\ device/deviceapi.h\ -# device/devicesourceapi.h\ -# device/devicesinkapi.h\ device/deviceenumerator.h\ dsp/afsquelch.h\ dsp/decimatorsfi.h\