From 00342c763a7f380f737f3ba5f718ccc9f95e3307 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sat, 18 Apr 2020 22:33:24 +0100 Subject: [PATCH] Abort the voice prompt if network traffic appears on the same slot. --- DMRGateway.cpp | 10 ++++++++++ DynVoice.cpp | 11 +++++++++++ DynVoice.h | 2 ++ RewriteDynTGRF.cpp | 8 +++++++- RewriteDynTGRF.h | 2 ++ Version.h | 2 +- 6 files changed, 33 insertions(+), 2 deletions(-) diff --git a/DMRGateway.cpp b/DMRGateway.cpp index 0adb93b..4f961d6 100644 --- a/DMRGateway.cpp +++ b/DMRGateway.cpp @@ -909,6 +909,8 @@ int CDMRGateway::run() // Check that the rewritten slot is free to use. slotNo = data.getSlotNo(); if (m_status[slotNo] == DMRGWS_NONE || m_status[slotNo] == DMRGWS_DMRNETWORK1) { + for (std::vector::iterator it = m_dynRF.begin(); it != m_dynRF.end(); ++it) + (*it)->stopVoice(slotNo); m_repeater->write(data); m_status[slotNo] = DMRGWS_DMRNETWORK1; timer[slotNo]->setTimeout(netTimeout); @@ -957,6 +959,8 @@ int CDMRGateway::run() // Check that the rewritten slot is free to use. slotNo = data.getSlotNo(); if (m_status[slotNo] == DMRGWS_NONE || m_status[slotNo] == DMRGWS_DMRNETWORK2) { + for (std::vector::iterator it = m_dynRF.begin(); it != m_dynRF.end(); ++it) + (*it)->stopVoice(slotNo); m_repeater->write(data); m_status[slotNo] = DMRGWS_DMRNETWORK2; timer[slotNo]->setTimeout(netTimeout); @@ -1005,6 +1009,8 @@ int CDMRGateway::run() // Check that the rewritten slot is free to use. slotNo = data.getSlotNo(); if (m_status[slotNo] == DMRGWS_NONE || m_status[slotNo] == DMRGWS_DMRNETWORK3) { + for (std::vector::iterator it = m_dynRF.begin(); it != m_dynRF.end(); ++it) + (*it)->stopVoice(slotNo); m_repeater->write(data); m_status[slotNo] = DMRGWS_DMRNETWORK3; timer[slotNo]->setTimeout(netTimeout); @@ -1053,6 +1059,8 @@ int CDMRGateway::run() // Check that the rewritten slot is free to use. slotNo = data.getSlotNo(); if (m_status[slotNo] == DMRGWS_NONE || m_status[slotNo] == DMRGWS_DMRNETWORK4) { + for (std::vector::iterator it = m_dynRF.begin(); it != m_dynRF.end(); ++it) + (*it)->stopVoice(slotNo); m_repeater->write(data); m_status[slotNo] = DMRGWS_DMRNETWORK4; timer[slotNo]->setTimeout(netTimeout); @@ -1101,6 +1109,8 @@ int CDMRGateway::run() // Check that the rewritten slot is free to use. slotNo = data.getSlotNo(); if (m_status[slotNo] == DMRGWS_NONE || m_status[slotNo] == DMRGWS_DMRNETWORK5) { + for (std::vector::iterator it = m_dynRF.begin(); it != m_dynRF.end(); ++it) + (*it)->stopVoice(slotNo); m_repeater->write(data); m_status[slotNo] = DMRGWS_DMRNETWORK5; timer[slotNo]->setTimeout(netTimeout); diff --git a/DynVoice.cpp b/DynVoice.cpp index 380a890..46d1e04 100644 --- a/DynVoice.cpp +++ b/DynVoice.cpp @@ -162,6 +162,17 @@ void CDynVoice::unlinked() createVoice(words); } +void CDynVoice::abort() +{ + for (std::vector::iterator it = m_data.begin(); it != m_data.end(); ++it) + delete* it; + + m_data.clear(); + m_timer.stop(); + + m_status = DYNVS_NONE; +} + void CDynVoice::createVoice(const std::vector& words) { unsigned int ambeLength = 0U; diff --git a/DynVoice.h b/DynVoice.h index 53b269f..64abd2e 100644 --- a/DynVoice.h +++ b/DynVoice.h @@ -52,6 +52,8 @@ public: bool read(CDMRData& data); + void abort(); + void clock(unsigned int ms); private: diff --git a/RewriteDynTGRF.cpp b/RewriteDynTGRF.cpp index 2c39577..728b472 100644 --- a/RewriteDynTGRF.cpp +++ b/RewriteDynTGRF.cpp @@ -171,4 +171,10 @@ void CRewriteDynTGRF::tgChange(unsigned int slot, unsigned int tg) } return; } -} \ No newline at end of file +} + +void CRewriteDynTGRF::stopVoice(unsigned int slot) +{ + if (slot == m_slot && m_voice != NULL) + m_voice->abort(); +} diff --git a/RewriteDynTGRF.h b/RewriteDynTGRF.h index d263e84..d5a2b06 100644 --- a/RewriteDynTGRF.h +++ b/RewriteDynTGRF.h @@ -35,6 +35,8 @@ public: virtual PROCESS_RESULT process(CDMRData& data, bool trace); + void stopVoice(unsigned int slot); + void tgChange(unsigned int slot, unsigned int tg); private: diff --git a/Version.h b/Version.h index 1442d4b..049e6ea 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200413"; +const char* VERSION = "20200418"; #endif