From 939773f54b4bf69b8f224752b22fb8729511f46f Mon Sep 17 00:00:00 2001 From: Tom Early Date: Wed, 22 Feb 2023 03:08:44 -0700 Subject: [PATCH] still some problems with CPacketQueue locking --- reflector/CallsignList.cpp | 1 - reflector/CodecStream.cpp | 7 +++++-- reflector/Configure.cpp | 2 +- reflector/GateKeeper.cpp | 5 ----- reflector/LookupYsf.cpp | 2 +- reflector/Main.cpp | 3 ++- reflector/Makefile | 2 +- reflector/PacketStream.cpp | 13 +++++++------ reflector/PacketStream.h | 5 +++-- reflector/Protocol.h | 4 ++++ reflector/Reflector.cpp | 9 +++++++-- 11 files changed, 31 insertions(+), 22 deletions(-) diff --git a/reflector/CallsignList.cpp b/reflector/CallsignList.cpp index e1d4a0d..954bb5a 100644 --- a/reflector/CallsignList.cpp +++ b/reflector/CallsignList.cpp @@ -28,7 +28,6 @@ CCallsignList::CCallsignList() { - m_Filename = nullptr; memset(&m_LastModTime, 0, sizeof(time_t)); } diff --git a/reflector/CodecStream.cpp b/reflector/CodecStream.cpp index a1f641f..a6258e0 100644 --- a/reflector/CodecStream.cpp +++ b/reflector/CodecStream.cpp @@ -18,9 +18,9 @@ #include -#include "CodecStream.h" #include "DVFramePacket.h" -#include "Reflector.h" +#include "PacketStream.h" +#include "CodecStream.h" //////////////////////////////////////////////////////////////////////////////////////// // constructor @@ -78,6 +78,9 @@ void CCodecStream::ReportStats() bool CCodecStream::InitCodecStream(char module) { +#ifdef DEBUG + std::cout << "Initializing codec stream for module '" << module << "'" << std::endl; +#endif m_TCWriter.SetUp(REF2TC); std::string name(TC2REF); name.append(1, module); diff --git a/reflector/Configure.cpp b/reflector/Configure.cpp index 886dce4..c832377 100644 --- a/reflector/Configure.cpp +++ b/reflector/Configure.cpp @@ -571,7 +571,7 @@ bool CConfigure::ReadData(const std::string &path) } else { - data[g_Keys.ip.ipv4bind] = nullptr; + data[g_Keys.ip.ipv6bind] = nullptr; data[g_Keys.ip.ipv6address] = nullptr; } diff --git a/reflector/GateKeeper.cpp b/reflector/GateKeeper.cpp index 8949377..28065fc 100644 --- a/reflector/GateKeeper.cpp +++ b/reflector/GateKeeper.cpp @@ -20,11 +20,6 @@ #include "Timer.h" #include "Global.h" -//////////////////////////////////////////////////////////////////////////////////////// - -CGateKeeper g_GateKeeper; - - //////////////////////////////////////////////////////////////////////////////////////// // constructor diff --git a/reflector/LookupYsf.cpp b/reflector/LookupYsf.cpp index 6150ea7..e2fc5a3 100644 --- a/reflector/LookupYsf.cpp +++ b/reflector/LookupYsf.cpp @@ -70,7 +70,7 @@ void CLookupYsf::UpdateContent(std::stringstream &ss, Eaction action) } } if (Eaction::normal == action) - std::cout << "DMR Id database size now is " << m_map.size() << std::endl; + std::cout << "YSF frequency database size now is " << m_map.size() << std::endl; } void CLookupYsf::FindFrequencies(const CCallsign &cs, uint32_t &txfreq, uint32_t &rxfreq) diff --git a/reflector/Main.cpp b/reflector/Main.cpp index c6af52f..c309ed8 100644 --- a/reflector/Main.cpp +++ b/reflector/Main.cpp @@ -46,6 +46,7 @@ int main(int argc, char *argv[]) if (g_Conf.ReadData(argv[1])) return EXIT_FAILURE; + std::cout << "IPv4 binding address is '" << g_Conf.GetString(g_Keys.ip.ipv4bind) << "'" << std::endl; // remove pidfile const std::string pidpath(g_Conf.GetString(g_Keys.files.pid)); const std::string callsign(g_Conf.GetString(g_Keys.names.cs)); @@ -61,7 +62,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - std::cout << "Reflector " << callsign << "started and listening" << std::endl; + std::cout << "Reflector " << callsign << " started and listening" << std::endl; // write new pid file std::ofstream ofs(pidpath, std::ofstream::out); diff --git a/reflector/Makefile b/reflector/Makefile index 88a545d..8bf07f7 100644 --- a/reflector/Makefile +++ b/reflector/Makefile @@ -27,7 +27,7 @@ DBUTIL = dbutil include configure.mk ifeq ($(debug), true) -CFLAGS = -ggdb3 -DDEBUG -W -Werror -c -std=c++11 -MMD -MD +CFLAGS = -ggdb3 -DDEBUG -W -Werror -std=c++11 -MMD -MD else CFLAGS = -W -Werror -std=c++11 -MMD -MD endif diff --git a/reflector/PacketStream.cpp b/reflector/PacketStream.cpp index 2f6ea53..7774020 100644 --- a/reflector/PacketStream.cpp +++ b/reflector/PacketStream.cpp @@ -22,7 +22,7 @@ //////////////////////////////////////////////////////////////////////////////////////// // constructor -CPacketStream::CPacketStream() +CPacketStream::CPacketStream(char module) : m_PSModule(module) { m_bOpen = false; m_uiStreamId = 0; @@ -31,12 +31,13 @@ CPacketStream::CPacketStream() m_CodecStream = nullptr; } -bool CPacketStream::InitPacketStream(bool is_transcoded) +bool CPacketStream::InitCodecStream() { - if (is_transcoded) - m_CodecStream = std::unique_ptr(new CCodecStream(this)); - - return nullptr == m_CodecStream; + m_CodecStream = std::unique_ptr(new CCodecStream(this)); + if (m_CodecStream) + return m_CodecStream->InitCodecStream(m_PSModule); + else + return true; } //////////////////////////////////////////////////////////////////////////////////////// diff --git a/reflector/PacketStream.h b/reflector/PacketStream.h index ac067b3..607d918 100644 --- a/reflector/PacketStream.h +++ b/reflector/PacketStream.h @@ -35,8 +35,8 @@ class CPacketStream : public CPacketQueue { public: - CPacketStream(); - bool InitPacketStream(bool is_transcoded); + CPacketStream(char module); + bool InitCodecStream(); // open / close bool OpenPacketStream(const CDvHeaderPacket &, std::shared_ptr); @@ -57,6 +57,7 @@ public: protected: // data + const char m_PSModule; bool m_bOpen; uint16_t m_uiStreamId; uint32_t m_uiPacketCntr; diff --git a/reflector/Protocol.h b/reflector/Protocol.h index 799ca76..201764a 100644 --- a/reflector/Protocol.h +++ b/reflector/Protocol.h @@ -114,6 +114,10 @@ protected: void Send(const CBuffer &buf, const CIp &Ip, uint16_t port) const; void Send(const char *buf, const CIp &Ip, uint16_t port) const; void Send(const SM17Frame &frame, const CIp &Ip) const; +#ifdef DEBUG + void Dump(const char *title, const uint8_t *data, int length); +#endif + // socket CUdpSocket m_Socket4; diff --git a/reflector/Reflector.cpp b/reflector/Reflector.cpp index 9686361..032984f 100644 --- a/reflector/Reflector.cpp +++ b/reflector/Reflector.cpp @@ -76,10 +76,15 @@ bool CReflector::Start(void) // start one thread per reflector module for (auto c : m_Modules) { - auto stream = std::make_shared(); + auto stream = std::make_shared(c); if (stream) { - stream->InitPacketStream(std::string::npos != tcmods.find(c)); + // if it's a transcoded module, then we need to initialize the codec stream + if (std::string::npos != tcmods.find(c)) + { + if (stream->InitCodecStream()) + return true; + } } else {