mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-29 23:28:39 -05:00
More minor tweaks; getBuffer refcount 1 init suggestion from @vsonnier
This commit is contained in:
parent
2bdefca263
commit
b54ab38a47
@ -82,7 +82,6 @@ public:
|
|||||||
|
|
||||||
static void addGarbage(ReferenceCounter *ref) {
|
static void addGarbage(ReferenceCounter *ref) {
|
||||||
std::lock_guard < std::mutex > lock(g_mutex);
|
std::lock_guard < std::mutex > lock(g_mutex);
|
||||||
std::cout << "Added garbage.." << std::endl;
|
|
||||||
garbage.insert(ref);
|
garbage.insert(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +106,7 @@ public:
|
|||||||
for (outputBuffersI = outputBuffers.begin(); outputBuffersI != outputBuffers.end(); outputBuffersI++) {
|
for (outputBuffersI = outputBuffers.begin(); outputBuffersI != outputBuffers.end(); outputBuffersI++) {
|
||||||
if (buf == nullptr && (*outputBuffersI)->getRefCount() <= 0) {
|
if (buf == nullptr && (*outputBuffersI)->getRefCount() <= 0) {
|
||||||
buf = (*outputBuffersI);
|
buf = (*outputBuffersI);
|
||||||
buf->setRefCount(0);
|
buf->setRefCount(1);
|
||||||
} else if ((*outputBuffersI)->getRefCount() <= 0) {
|
} else if ((*outputBuffersI)->getRefCount() <= 0) {
|
||||||
(*outputBuffersI)->decRefCount();
|
(*outputBuffersI)->decRefCount();
|
||||||
}
|
}
|
||||||
@ -128,6 +127,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf = new BufferType();
|
buf = new BufferType();
|
||||||
|
buf->setRefCount(1);
|
||||||
outputBuffers.push_back(buf);
|
outputBuffers.push_back(buf);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
@ -142,7 +142,7 @@ public:
|
|||||||
delete ref;
|
delete ref;
|
||||||
} else {
|
} else {
|
||||||
// Something isn't done with it yet; throw it on the pile..
|
// Something isn't done with it yet; throw it on the pile..
|
||||||
std::cout << bufferId << "pushed garbage.." << std::endl;
|
std::cout << "'" << bufferId << "' pushed garbage.." << std::endl;
|
||||||
ReBufferGC::addGarbage(ref);
|
ReBufferGC::addGarbage(ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,6 +394,15 @@ void AudioThread::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Drain any remaining inputs
|
||||||
|
while (!inputQueue->empty()) {
|
||||||
|
AudioThreadInput *ref;
|
||||||
|
inputQueue->pop(ref);
|
||||||
|
if (ref) {
|
||||||
|
ref->decRefCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (deviceController[parameters.deviceId] != this) {
|
if (deviceController[parameters.deviceId] != this) {
|
||||||
deviceController[parameters.deviceId]->removeThread(this);
|
deviceController[parameters.deviceId]->removeThread(this);
|
||||||
} else {
|
} else {
|
||||||
@ -409,14 +418,6 @@ void AudioThread::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!inputQueue->empty()) { // flush queue
|
|
||||||
AudioThreadInput *dummy;
|
|
||||||
inputQueue->pop(dummy);
|
|
||||||
if (dummy) {
|
|
||||||
dummy->setRefCount(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (threadQueueNotify != NULL) {
|
if (threadQueueNotify != NULL) {
|
||||||
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED);
|
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED);
|
||||||
tCmd.context = this;
|
tCmd.context = this;
|
||||||
@ -439,23 +440,19 @@ void AudioThread::setActive(bool state) {
|
|||||||
|
|
||||||
AudioThreadInput *dummy;
|
AudioThreadInput *dummy;
|
||||||
if (state && !active && inputQueue) {
|
if (state && !active && inputQueue) {
|
||||||
|
deviceController[parameters.deviceId]->bindThread(this);
|
||||||
|
} else if (!state && active) {
|
||||||
|
deviceController[parameters.deviceId]->removeThread(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activity state changing, clear any inputs
|
||||||
|
if(inputQueue) {
|
||||||
while (!inputQueue->empty()) { // flush queue
|
while (!inputQueue->empty()) { // flush queue
|
||||||
inputQueue->pop(dummy);
|
inputQueue->pop(dummy);
|
||||||
if (dummy) {
|
if (dummy) {
|
||||||
dummy->decRefCount();
|
dummy->decRefCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deviceController[parameters.deviceId]->bindThread(this);
|
|
||||||
} else if (!state && active) {
|
|
||||||
deviceController[parameters.deviceId]->removeThread(this);
|
|
||||||
if(inputQueue) {
|
|
||||||
while (!inputQueue->empty()) { // flush queue
|
|
||||||
inputQueue->pop(dummy);
|
|
||||||
if (dummy) {
|
|
||||||
dummy->decRefCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
active = state;
|
active = state;
|
||||||
}
|
}
|
||||||
|
@ -132,13 +132,11 @@ void DemodulatorThread::run() {
|
|||||||
|
|
||||||
ati->sampleRate = cModemKit->audioSampleRate;
|
ati->sampleRate = cModemKit->audioSampleRate;
|
||||||
ati->inputRate = inp->sampleRate;
|
ati->inputRate = inp->sampleRate;
|
||||||
ati->setRefCount(1);
|
|
||||||
} else if (modemDigital != nullptr) {
|
} else if (modemDigital != nullptr) {
|
||||||
ati = outputBuffers.getBuffer();
|
ati = outputBuffers.getBuffer();
|
||||||
|
|
||||||
ati->sampleRate = cModemKit->sampleRate;
|
ati->sampleRate = cModemKit->sampleRate;
|
||||||
ati->inputRate = inp->sampleRate;
|
ati->inputRate = inp->sampleRate;
|
||||||
ati->setRefCount(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cModem->demodulate(cModemKit, &modemData, ati);
|
cModem->demodulate(cModemKit, &modemData, ati);
|
||||||
@ -281,14 +279,14 @@ void DemodulatorThread::run() {
|
|||||||
while (!iqInputQueue->empty()) {
|
while (!iqInputQueue->empty()) {
|
||||||
DemodulatorThreadPostIQData *ref;
|
DemodulatorThreadPostIQData *ref;
|
||||||
iqInputQueue->pop(ref);
|
iqInputQueue->pop(ref);
|
||||||
if (ref) {
|
if (ref) { // May have other consumers; just decrement
|
||||||
ref->setRefCount(0);
|
ref->decRefCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (!audioOutputQueue->empty()) {
|
while (!audioOutputQueue->empty()) {
|
||||||
AudioThreadInput *ref;
|
AudioThreadInput *ref;
|
||||||
audioOutputQueue->pop(ref);
|
audioOutputQueue->pop(ref);
|
||||||
if (ref) {
|
if (ref) { // Originated here; set RefCount to 0
|
||||||
ref->setRefCount(0);
|
ref->setRefCount(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user