mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-04 06:54:41 -04:00
TH_CLEAN_3: Use of non-blocking try_pop() when possible,
AudioThread concurrent access hardening and simplified, and misc.
This commit is contained in:
@@ -215,11 +215,14 @@ void SDRPostThread::run() {
|
||||
if (doUpdate) {
|
||||
updateActiveDemodulators();
|
||||
}
|
||||
}
|
||||
} //end while
|
||||
|
||||
if (iqVisualQueue && !iqVisualQueue->empty()) {
|
||||
DemodulatorThreadIQData *visualDataDummy;
|
||||
iqVisualQueue->pop(visualDataDummy);
|
||||
//TODO: Why only 1 element was removed before ?
|
||||
DemodulatorThreadIQData *visualDataDummy;
|
||||
while (iqVisualQueue && iqVisualQueue->try_pop(visualDataDummy)) {
|
||||
//nothing
|
||||
//TODO: What about the refcounts ?
|
||||
|
||||
}
|
||||
|
||||
// buffers.purge();
|
||||
|
||||
@@ -162,6 +162,7 @@ void SDRThread::readStream(SDRThreadIQDataQueue* iqDataOutQueue) {
|
||||
int nElems = numElems.load();
|
||||
int mtElems = mtuElems.load();
|
||||
|
||||
//If overflow occured on the previous readStream(), transfer it in inpBuffer now
|
||||
if (numOverflow > 0) {
|
||||
int n_overflow = numOverflow;
|
||||
if (n_overflow > nElems) {
|
||||
@@ -176,9 +177,18 @@ void SDRThread::readStream(SDRThreadIQDataQueue* iqDataOutQueue) {
|
||||
}
|
||||
}
|
||||
|
||||
//attempt readStream() at most nElems, by mtElems-sized chunks, append inpBuffer.
|
||||
while (n_read < nElems && !stopping) {
|
||||
int n_requested = nElems-n_read;
|
||||
|
||||
int n_stream_read = device->readStream(stream, buffs, mtElems, flags, timeNs);
|
||||
|
||||
//if the n_stream_read <= 0, bail out from reading.
|
||||
if (n_stream_read <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
//sucess read beyond nElems, with overflow
|
||||
if ((n_read + n_stream_read) > nElems) {
|
||||
memcpy(&inpBuffer.data[n_read], buffs[0], n_requested * sizeof(float) * 2);
|
||||
numOverflow = n_stream_read-n_requested;
|
||||
|
||||
Reference in New Issue
Block a user