From ea4720bc74e15d93f1b882a3c4364a29b4364a42 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Tue, 21 Dec 2021 12:04:32 -0700 Subject: [PATCH] added a couple of std::mutex --- Controller.cpp | 10 +++------- Controller.h | 2 ++ DV3003.cpp | 8 ++++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Controller.cpp b/Controller.cpp index a5cd7f3..fd89b17 100644 --- a/Controller.cpp +++ b/Controller.cpp @@ -126,7 +126,7 @@ void CController::ReadReflectorThread() c2_mux.unlock(); break; default: - Dump(packet, "ERROR: Got a reflector packet with unknown Codec:"); + Dump(packet, "ERROR: Received a reflector packet with unknown Codec:"); break; } } @@ -159,14 +159,10 @@ void CController::AudiotoCodec2(std::shared_ptr packet) // we might be all done... if (packet->AllCodecsAreSet()) { + send_mux.lock(); SendToReflector(packet); + send_mux.unlock(); } -#ifdef DEBUG - if (packet->IsSecond()) - { - AppendM17(packet); - } -#endif } // The original incoming coded was M17, so we will calculate the audio and then diff --git a/Controller.h b/Controller.h index 698cc07..115e99a 100644 --- a/Controller.h +++ b/Controller.h @@ -33,6 +33,8 @@ enum class EAmbeType { dstar, dmr }; class CController { public: + std::mutex dstar_mux, dmr_mux; + CController(); bool Start(); void Stop(); diff --git a/DV3003.cpp b/DV3003.cpp index b2f7c09..7673edb 100644 --- a/DV3003.cpp +++ b/DV3003.cpp @@ -451,9 +451,17 @@ void CDV3003::ReadDevice() continue; } if (Encoding::dstar == type) + { + Controller.dstar_mux.lock(); Controller.RouteDstPacket(packet); + Controller.dstar_mux.unlock(); + } else + { + Controller.dmr_mux.lock(); Controller.RouteDmrPacket(packet); + Controller.dmr_mux.unlock(); + } } } }