TH_CLEAN_3: Use of non-blocking try_pop() when possible,

AudioThread concurrent access hardening and simplified,
and misc.
This commit is contained in:
vsonnier
2016-07-05 21:43:45 +02:00
parent 3bf17d0f40
commit b495b388c9
16 changed files with 223 additions and 149 deletions
+7 -4
View File
@@ -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();
+10
View File
@@ -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;