Make IOThreads terminate() fully non-blocking and misc.

- Thanks to timed-pop() usage, it is no longer needed to nudge queues with dummy to wake them
- Less bad luck to be stuck there
- Misc: leave the trace about the audio thread staturation, useful despite it raises some alarm among users...
This commit is contained in:
vsonnier 2017-08-14 09:10:24 +02:00
parent acc6d2a31d
commit e32e687fe8
6 changed files with 3 additions and 25 deletions

View File

@ -476,9 +476,6 @@ void AudioThread::run() {
void AudioThread::terminate() {
IOThread::terminate();
AudioThreadCommand endCond; // push an empty input to bump the queue
//VSO: blocking push
cmdQueue.push(endCond);
}
bool AudioThread::isActive() {

View File

@ -348,18 +348,10 @@ int DemodulatorPreThread::getAudioSampleRate() {
void DemodulatorPreThread::terminate() {
//make non-blocking calls to be sure threads are flagged for termination before attempting the blocking calls.
//make non-blocking calls to be sure threads are flagged for termination.
IOThread::terminate();
workerThread->terminate();
DemodulatorThreadIQDataPtr inp(new DemodulatorThreadIQData); // push dummy to nudge queue
//VSO: blocking push :
iqInputQueue->push(inp);
DemodulatorWorkerThreadCommand command;
//VSO: blocking push :
workerQueue->push(command);
//wait blocking for termination here, it could be long with lots of modems and we MUST terminate properly,
//else better kill the whole application...
workerThread->isTerminated(5000);

View File

@ -313,8 +313,8 @@ void DemodulatorThread::run() {
if (!muted.load() && (!wxGetApp().getSoloMode() || (demodInstance == wxGetApp().getDemodMgr().getLastActiveDemodulator()))) {
//non-blocking push needed for audio out
if (!audioOutputQueue->try_push(ati)) {
//Comment this trace, it creates to many false alarms :)
//std::cout << "DemodulatorThread::run() cannot push ati into audioOutputQueue, is full !" << std::endl;
std::cout << "DemodulatorThread::run() cannot push ati into audioOutputQueue, is full !" << std::endl;
std::this_thread::yield();
}
}
@ -348,10 +348,6 @@ void DemodulatorThread::run() {
void DemodulatorThread::terminate() {
IOThread::terminate();
DemodulatorThreadPostIQDataPtr inp(new DemodulatorThreadPostIQData); // push dummy to nudge queue
//VSO: blocking push
iqInputQueue->push(inp);
}
bool DemodulatorThread::isMuted() {

View File

@ -116,6 +116,4 @@ void DemodulatorWorkerThread::run() {
void DemodulatorWorkerThread::terminate() {
IOThread::terminate();
DemodulatorWorkerThreadCommand inp; // push dummy to nudge queue
commandQueue->push(inp);
}

View File

@ -32,8 +32,6 @@ public:
msresamp_crcf iqResampler;
double iqResampleRatio;
DemodulatorThread *demodThread;
long long sampleRate;
unsigned int bandwidth;

View File

@ -235,9 +235,6 @@ void SDRPostThread::run() {
void SDRPostThread::terminate() {
IOThread::terminate();
SDRThreadIQDataPtr dummy(new SDRThreadIQData);
//VSO: blocking push
iqDataInQueue->push(dummy);
}
void SDRPostThread::runSingleCH(SDRThreadIQData *data_in) {