ensure threads die immediately if the g_killed flag is set when the threads are started; block clocking operations when performing CW;

pull/42/head
Bryan Biedenkapp 2 years ago
parent 7a90f953fd
commit 5a1f672dfe

@ -771,6 +771,9 @@ int Host::run()
/** Digital Mobile Radio */ /** Digital Mobile Radio */
ThreadFunc dmrFrameReadThread([&, this]() { ThreadFunc dmrFrameReadThread([&, this]() {
#if defined(ENABLE_DMR) #if defined(ENABLE_DMR)
if (g_killed)
return;
if (dmr != nullptr) { if (dmr != nullptr) {
LogDebug(LOG_HOST, "DMR, started frame processor (modem read)"); LogDebug(LOG_HOST, "DMR, started frame processor (modem read)");
while (!g_killed) { while (!g_killed) {
@ -836,6 +839,9 @@ int Host::run()
ThreadFunc dmrFrameWriteThread([&, this]() { ThreadFunc dmrFrameWriteThread([&, this]() {
#if defined(ENABLE_DMR) #if defined(ENABLE_DMR)
if (g_killed)
return;
if (dmr != nullptr) { if (dmr != nullptr) {
LogDebug(LOG_HOST, "DMR, started frame processor (modem write)"); LogDebug(LOG_HOST, "DMR, started frame processor (modem write)");
while (!g_killed) { while (!g_killed) {
@ -894,6 +900,9 @@ int Host::run()
/** Project 25 */ /** Project 25 */
ThreadFunc p25FrameReadThread([&, this]() { ThreadFunc p25FrameReadThread([&, this]() {
#if defined(ENABLE_P25) #if defined(ENABLE_P25)
if (g_killed)
return;
if (p25 != nullptr) { if (p25 != nullptr) {
LogDebug(LOG_HOST, "P25, started frame processor (modem read)"); LogDebug(LOG_HOST, "P25, started frame processor (modem read)");
while (!g_killed) { while (!g_killed) {
@ -931,6 +940,9 @@ int Host::run()
ThreadFunc p25FrameWriteThread([&, this]() { ThreadFunc p25FrameWriteThread([&, this]() {
#if defined(ENABLE_P25) #if defined(ENABLE_P25)
if (g_killed)
return;
if (p25 != nullptr) { if (p25 != nullptr) {
LogDebug(LOG_HOST, "P25, started frame processor (modem write)"); LogDebug(LOG_HOST, "P25, started frame processor (modem write)");
while (!g_killed) { while (!g_killed) {
@ -969,6 +981,9 @@ int Host::run()
/** Next Generation Digital Narrowband */ /** Next Generation Digital Narrowband */
ThreadFunc nxdnFrameReadThread([&, this]() { ThreadFunc nxdnFrameReadThread([&, this]() {
#if defined(ENABLE_NXDN) #if defined(ENABLE_NXDN)
if (g_killed)
return;
if (nxdn != nullptr) { if (nxdn != nullptr) {
LogDebug(LOG_HOST, "NXDN, started frame processor (modem read)"); LogDebug(LOG_HOST, "NXDN, started frame processor (modem read)");
while (!g_killed) { while (!g_killed) {
@ -1006,6 +1021,9 @@ int Host::run()
ThreadFunc nxdnFrameWriteThread([&, this]() { ThreadFunc nxdnFrameWriteThread([&, this]() {
#if defined(ENABLE_NXDN) #if defined(ENABLE_NXDN)
if (g_killed)
return;
if (nxdn != nullptr) { if (nxdn != nullptr) {
LogDebug(LOG_HOST, "NXDN, started frame processor (modem write)"); LogDebug(LOG_HOST, "NXDN, started frame processor (modem write)");
while (!g_killed) { while (!g_killed) {
@ -1127,6 +1145,7 @@ int Host::run()
} }
LogDebug(LOG_HOST, "CW, start transmitting"); LogDebug(LOG_HOST, "CW, start transmitting");
clockingMutex.lock();
setState(STATE_IDLE); setState(STATE_IDLE);
m_modem->sendCWId(m_cwCallsign); m_modem->sendCWId(m_cwCallsign);
@ -1157,6 +1176,7 @@ int Host::run()
Thread::sleep(CW_IDLE_SLEEP_MS); Thread::sleep(CW_IDLE_SLEEP_MS);
} while (true); } while (true);
clockingMutex.unlock();
m_cwIdTimer.setTimeout(m_cwIdTime); m_cwIdTimer.setTimeout(m_cwIdTime);
m_cwIdTimer.start(); m_cwIdTimer.start();
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.