Threading crash fixes, reusable IQ buffer queue

This commit is contained in:
Charles J. Cliffe
2014-12-23 23:37:18 -05:00
parent ef78ffc6f3
commit b7375ce09f
3 changed files with 37 additions and 6 deletions
+2
View File
@@ -5,6 +5,7 @@
#include "liquid/liquid.h"
#include <atomic>
#include <mutex>
enum DemodulatorType {
DEMOD_TYPE_NULL,
@@ -60,6 +61,7 @@ public:
unsigned int frequency;
unsigned int bandwidth;
std::vector<signed char> data;
mutable std::mutex m_mutex;
DemodulatorThreadIQData() :
frequency(0), bandwidth(0), refCount(0) {
+4 -3
View File
@@ -157,6 +157,7 @@ void DemodulatorPreThread::threadMain() {
continue;
}
std::lock_guard < std::mutex > lock(inp->m_mutex);
std::vector<signed char> *data = &inp->data;
if (data->size()) {
int bufSize = data->size() / 2;
@@ -173,6 +174,8 @@ void DemodulatorPreThread::threadMain() {
in_buf[i].imag = (float) (*data)[i * 2 + 1] / 127.0f;
}
inp->decRefCount();
if (shift_freq != 0) {
if (shift_freq < 0) {
nco_crcf_mix_block_up(nco_shift, in_buf, out_buf, bufSize);
@@ -195,10 +198,8 @@ void DemodulatorPreThread::threadMain() {
resamp->resampler = resampler;
postInputQueue->push(resamp);
} else {
inp->decRefCount();
if (inp->getRefCount()<=0) {
delete inp;
}
}
if (!workerResults->empty()) {