mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-08 08:55:07 -04:00
Use the nuclear option to solve the hung problem:
Besides deadlocks, a thread can in theory get stuck in a blocking pop(), not seeing the stopping flag in particular. So assure liveness by making all pop() timed pop.
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
#include <memory.h>
|
||||
#include <mutex>
|
||||
|
||||
//50 ms
|
||||
#define HEARTBEAT_CHECK_PERIOD_MICROS (50 * 1000)
|
||||
|
||||
std::map<int, AudioThread *> AudioThread::deviceController;
|
||||
std::map<int, int> AudioThread::deviceSampleRate;
|
||||
@@ -429,7 +431,9 @@ void AudioThread::run() {
|
||||
while (!stopping) {
|
||||
AudioThreadCommand command;
|
||||
|
||||
cmdQueue.pop(command);
|
||||
if (!cmdQueue.pop(command, HEARTBEAT_CHECK_PERIOD_MICROS)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (command.cmd == AudioThreadCommand::AUDIO_THREAD_CMD_SET_DEVICE) {
|
||||
setupDevice(command.int_value);
|
||||
|
||||
Reference in New Issue
Block a user