CubicSDR/src/demod/DemodulatorMgr.h

110 lines
3.4 KiB
C
Raw Normal View History

// Copyright (c) Charles J. Cliffe
// SPDX-License-Identifier: GPL-2.0+
#pragma once
#include <vector>
#include <map>
#include <thread>
#include "DemodulatorInstance.h"
class DataNode;
class DemodulatorMgr {
public:
2014-11-22 22:33:32 -05:00
DemodulatorMgr();
~DemodulatorMgr();
2017-08-27 11:11:30 +02:00
DemodulatorInstancePtr newThread();
//return snapshot-copy of the list purposefully
std::vector<DemodulatorInstancePtr> getDemodulators();
std::vector<DemodulatorInstancePtr> getOrderedDemodulators(bool actives = true);
std::vector<DemodulatorInstancePtr> getDemodulatorsAt(long long freq, int bandwidth);
DemodulatorInstancePtr getPreviousDemodulator(DemodulatorInstancePtr demod, bool actives = true);
DemodulatorInstancePtr getNextDemodulator(DemodulatorInstancePtr demod, bool actives = true);
DemodulatorInstancePtr getLastDemodulator();
DemodulatorInstancePtr getFirstDemodulator();
bool anyDemodulatorsAt(long long freq, int bandwidth);
2017-08-27 11:11:30 +02:00
void deleteThread(DemodulatorInstancePtr);
void terminateAll();
2017-08-27 11:11:30 +02:00
void setActiveDemodulator(DemodulatorInstancePtr demod, bool temporary = true);
//Dangerous: this is only intended by some internal classes,
// and only set a pre-existing demod
void setActiveDemodulatorByRawPointer(DemodulatorInstance* demod, bool temporary = true);
DemodulatorInstancePtr getActiveDemodulator();
DemodulatorInstancePtr getLastActiveDemodulator();
DemodulatorInstancePtr getLastDemodulatorWith(const std::string& type,
const std::wstring& userLabel,
long long frequency,
int bandwidth);
int getLastBandwidth() const;
void setLastBandwidth(int lastBandwidth);
std::string getLastDemodulatorType() const;
void setLastDemodulatorType(std::string lastDemodType);
float getLastGain() const;
void setLastGain(float lastGain);
bool getLastDeltaLock() const;
void setLastDeltaLock(bool lock);
float getLastSquelchLevel() const;
void setLastSquelchLevel(float lastSquelch);
bool isLastSquelchEnabled() const;
void setLastSquelchEnabled(bool lastSquelchEnabled);
2015-11-20 21:55:37 -05:00
bool isLastMuted() const;
void setLastMuted(bool lastMuted);
ModemSettings getLastModemSettings(std::string);
void setLastModemSettings(std::string, ModemSettings);
void updateLastState();
void setOutputDevices(std::map<int,RtAudio::DeviceInfo> devs);
2019-01-22 00:01:31 -05:00
std::map<int, RtAudio::DeviceInfo> getOutputDevices();
2017-08-27 11:11:30 +02:00
void saveInstance(DataNode *node, DemodulatorInstancePtr inst);
2017-08-27 11:11:30 +02:00
DemodulatorInstancePtr loadInstance(DataNode *node);
2014-11-22 22:33:32 -05:00
private:
2014-12-11 19:07:21 -05:00
//utility method that attemts to decode node value as std::wstring, else as std::string, else
//return an empty string.
static std::wstring getSafeWstringValue(DataNode* node);
2017-08-27 11:11:30 +02:00
std::vector<DemodulatorInstancePtr> demods;
2017-08-27 11:11:30 +02:00
DemodulatorInstancePtr activeDemodulator;
DemodulatorInstancePtr lastActiveDemodulator;
DemodulatorInstancePtr activeVisualDemodulator;
2014-12-11 19:07:21 -05:00
int lastBandwidth;
std::string lastDemodType;
bool lastDemodLock;
bool lastSquelchEnabled;
float lastSquelch;
float lastGain;
2015-11-20 21:55:37 -05:00
bool lastMuted;
bool lastDeltaLock;
//protects access to demods lists and such, need to be recursive
//because of the usage of public re-entrant methods
std::recursive_mutex demods_busy;
2017-08-27 11:11:30 +02:00
std::map<std::string, ModemSettings> lastModemSettings;
std::map<int,RtAudio::DeviceInfo> outputDevices;
};