mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-08-04 14:42:26 -04:00
Unsafe vector demod queues replaced /w mutex lock
This commit is contained in:
parent
0237c563a0
commit
3efb036099
@ -109,6 +109,8 @@ bool CubicSDR::OnInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int CubicSDR::OnExit() {
|
int CubicSDR::OnExit() {
|
||||||
|
demodMgr.terminateAll();
|
||||||
|
|
||||||
std::cout << "Terminating SDR thread.." << std::endl;
|
std::cout << "Terminating SDR thread.." << std::endl;
|
||||||
sdrThread->terminate();
|
sdrThread->terminate();
|
||||||
t_SDR->join();
|
t_SDR->join();
|
||||||
@ -123,8 +125,6 @@ int CubicSDR::OnExit() {
|
|||||||
delete sdrPostThread;
|
delete sdrPostThread;
|
||||||
delete t_PostSDR;
|
delete t_PostSDR;
|
||||||
|
|
||||||
demodMgr.terminateAll();
|
|
||||||
|
|
||||||
delete threadCmdQueueSDR;
|
delete threadCmdQueueSDR;
|
||||||
|
|
||||||
delete iqVisualQueue;
|
delete iqVisualQueue;
|
||||||
|
@ -27,7 +27,9 @@ SDRPostThread::~SDRPostThread() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SDRPostThread::bindDemodulator(DemodulatorInstance *demod) {
|
void SDRPostThread::bindDemodulator(DemodulatorInstance *demod) {
|
||||||
demodulators_add.push_back(demod);
|
busy_demod.lock();
|
||||||
|
demodulators.push_back(demod);
|
||||||
|
busy_demod.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRPostThread::removeDemodulator(DemodulatorInstance *demod) {
|
void SDRPostThread::removeDemodulator(DemodulatorInstance *demod) {
|
||||||
@ -35,7 +37,13 @@ void SDRPostThread::removeDemodulator(DemodulatorInstance *demod) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
demodulators_remove.push_back(demod);
|
busy_demod.lock();
|
||||||
|
std::vector<DemodulatorInstance *>::iterator i = std::find(demodulators.begin(), demodulators.end(), demod);
|
||||||
|
|
||||||
|
if (i != demodulators.end()) {
|
||||||
|
demodulators.erase(i);
|
||||||
|
}
|
||||||
|
busy_demod.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRPostThread::setIQDataInQueue(SDRThreadIQDataQueue* iqDataQueue) {
|
void SDRPostThread::setIQDataInQueue(SDRThreadIQDataQueue* iqDataQueue) {
|
||||||
@ -129,25 +137,8 @@ void SDRPostThread::threadMain() {
|
|||||||
|
|
||||||
iqVisualQueue.load()->push(visualDataOut);
|
iqVisualQueue.load()->push(visualDataOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demodulators_add.size()) {
|
busy_demod.lock();
|
||||||
while (!demodulators_add.empty()) {
|
|
||||||
demodulators.push_back(demodulators_add.back());
|
|
||||||
demodulators_add.pop_back();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (demodulators_remove.size()) {
|
|
||||||
while (!demodulators_remove.empty()) {
|
|
||||||
DemodulatorInstance *demod = demodulators_remove.back();
|
|
||||||
demodulators_remove.pop_back();
|
|
||||||
|
|
||||||
std::vector<DemodulatorInstance *>::iterator i = std::find(demodulators.begin(), demodulators.end(), demod);
|
|
||||||
|
|
||||||
if (i != demodulators.end()) {
|
|
||||||
demodulators.erase(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int activeDemods = 0;
|
int activeDemods = 0;
|
||||||
bool pushedData = false;
|
bool pushedData = false;
|
||||||
@ -226,6 +217,8 @@ void SDRPostThread::threadMain() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
busy_demod.unlock();
|
||||||
}
|
}
|
||||||
data_in->decRefCount();
|
data_in->decRefCount();
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,9 @@ protected:
|
|||||||
std::atomic<SDRThreadIQDataQueue *> iqDataInQueue;
|
std::atomic<SDRThreadIQDataQueue *> iqDataInQueue;
|
||||||
std::atomic<DemodulatorThreadInputQueue *> iqDataOutQueue;
|
std::atomic<DemodulatorThreadInputQueue *> iqDataOutQueue;
|
||||||
std::atomic<DemodulatorThreadInputQueue *> iqVisualQueue;
|
std::atomic<DemodulatorThreadInputQueue *> iqVisualQueue;
|
||||||
|
|
||||||
|
std::mutex busy_demod;
|
||||||
std::vector<DemodulatorInstance *> demodulators;
|
std::vector<DemodulatorInstance *> demodulators;
|
||||||
std::vector<DemodulatorInstance *> demodulators_add;
|
|
||||||
std::vector<DemodulatorInstance *> demodulators_remove;
|
|
||||||
std::atomic<bool> terminated;
|
std::atomic<bool> terminated;
|
||||||
iirfilt_crcf dcFilter;
|
iirfilt_crcf dcFilter;
|
||||||
int num_vis_samples;
|
int num_vis_samples;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user