From 74f3674cff6c25f6abd29017f2fe2176b40133a1 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 20 Mar 2018 22:23:06 +0000 Subject: [PATCH] Start the voice timer after the end of the transmission. --- NXDNGateway/NXDNGateway.cpp | 9 ++++++++- NXDNGateway/Voice.cpp | 14 +++++++------- NXDNGateway/Voice.h | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/NXDNGateway/NXDNGateway.cpp b/NXDNGateway/NXDNGateway.cpp index a5ec813..250f634 100644 --- a/NXDNGateway/NXDNGateway.cpp +++ b/NXDNGateway/NXDNGateway.cpp @@ -258,7 +258,8 @@ void CNXDNGateway::run() // From the MMDVM to the reflector or control data len = localNetwork.read(buffer, address, port); if (len > 0U) { - if (buffer[0U] == 0x81U || buffer[0U] == 0x83U) { + // Only process the beginning and ending blocks here + if ((buffer[0U] == 0x81U || buffer[0U] == 0x83U) && (buffer[5U] == 0x01U || buffer[5U] == 0x08U)) { grp = (buffer[7U] & 0x20U) == 0x20U; srcId = (buffer[8U] << 8) & 0xFF00U; @@ -314,6 +315,12 @@ void CNXDNGateway::run() lostTimer.start(); } } + + // If it's the end of the transmission, start the voice + if (buffer[5U] == 0x08U) { + if (voice != NULL) + voice->eof(); + } } // If we're linked and we have a network, send it on diff --git a/NXDNGateway/Voice.cpp b/NXDNGateway/Voice.cpp index dd66996..8aa67bb 100644 --- a/NXDNGateway/Voice.cpp +++ b/NXDNGateway/Voice.cpp @@ -255,9 +255,6 @@ void CVoice::createVoice(unsigned int tg, const std::vector& words) createTrailer(true, tg); delete[] ambeData; - - m_status = VS_WAITING; - m_timer.start(); } unsigned int CVoice::read(unsigned char* data) @@ -288,11 +285,14 @@ unsigned int CVoice::read(unsigned char* data) return 0U; } -void CVoice::abort() +void CVoice::eof() { - m_status = VS_NONE; - m_voiceLength = 0U; - m_sent = 0U; + if (m_voiceLength == 0U) + return; + + m_status = VS_WAITING; + + m_timer.start(); } void CVoice::clock(unsigned int ms) diff --git a/NXDNGateway/Voice.h b/NXDNGateway/Voice.h index 6515014..8cc0789 100644 --- a/NXDNGateway/Voice.h +++ b/NXDNGateway/Voice.h @@ -49,7 +49,7 @@ public: unsigned int read(unsigned char* data); - void abort(); + void eof(); void clock(unsigned int ms);