RT Stats bug (pass pointers)

pull/3/head
Tom Early 2 years ago
parent 1a66c49dca
commit d4ad8a2e9c

@ -127,10 +127,10 @@ void CCodecStream::Task(void)
} }
STCPacket pack; STCPacket pack;
if (g_TCServer.Receive(m_CSModule, pack, 8)) if (g_TCServer.Receive(m_CSModule, &pack, 8))
{ {
// update statistics // update statistics
double rt = pack.rt_timer.time(); // the round-trip time auto rt = pack.rt_timer.time(); // the round-trip time
if (0 == m_RTCount) if (0 == m_RTCount)
{ {
m_RTMin = rt; m_RTMin = rt;

@ -19,10 +19,6 @@
#include "Timer.h" #include "Timer.h"
// unix socket names
#define TC2REF "TC2URFMod"
#define REF2TC "URF2TC"
enum class ECodecType : std::uint8_t { none = 0, dstar = 1, dmr = 2, c2_1600 = 3, c2_3200 = 4, p25 = 5, usrp = 6 }; enum class ECodecType : std::uint8_t { none = 0, dstar = 1, dmr = 2, c2_1600 = 3, c2_3200 = 4, p25 = 5, usrp = 6 };
using STCPacket = struct tcpacket_tag { using STCPacket = struct tcpacket_tag {

@ -127,9 +127,9 @@ bool CTCSocket::Send(const STCPacket *packet)
return false; return false;
} }
bool CTCSocket::receive(int fd, STCPacket &packet) bool CTCSocket::receive(int fd, STCPacket *packet)
{ {
auto n = recv(fd, &packet, sizeof(STCPacket), MSG_WAITALL); auto n = recv(fd, packet, sizeof(STCPacket), MSG_WAITALL);
if (n < 0) if (n < 0)
{ {
perror("Receive recv"); perror("Receive recv");
@ -139,18 +139,18 @@ bool CTCSocket::receive(int fd, STCPacket &packet)
if (0 == n) if (0 == n)
{ {
std::cerr << "recv() returned zero bytes from mdule '" << GetMod(fd) << "'"; std::cerr << "recv(): Module '" << GetMod(fd) << "' has been closed on the server" << std::endl;
Close(fd); Close(fd);
return true; return true;
} }
if (n != sizeof(STCPacket)) if (n != sizeof(STCPacket))
std::cout << "WARNING: Receive only read " << n << " bytes of the transcoder packet from module '" << GetMod(fd) << "'" << std::endl; std::cout << "receive() only read " << n << " bytes of the transcoder packet from module '" << GetMod(fd) << "'" << std::endl;
return false; return false;
} }
// returns true if there is data to return // returns true if there is data to return
bool CTCServer::Receive(char module, STCPacket &packet, int ms) bool CTCServer::Receive(char module, STCPacket *packet, int ms)
{ {
bool rv = false; bool rv = false;
const auto pos = m_Modules.find(module); const auto pos = m_Modules.find(module);
@ -432,7 +432,7 @@ bool CTCClient::Receive(std::queue<std::unique_ptr<STCPacket>> &queue, int ms)
if (pfd.revents & POLLIN) if (pfd.revents & POLLIN)
{ {
auto p_tcpack = std::make_unique<STCPacket>(); auto p_tcpack = std::make_unique<STCPacket>();
if (receive(pfd.fd, *p_tcpack)) if (receive(pfd.fd, p_tcpack.get()))
{ {
p_tcpack.reset(); p_tcpack.reset();
} }

@ -37,7 +37,7 @@ public:
void Close(); // close all open sockets void Close(); // close all open sockets
void Close(char module); // close a specific module void Close(char module); // close a specific module
void Close(int fd); // close a specific file descriptor void Close(int fd); // close a specific file descriptor
bool receive(int fd, STCPacket &packet); bool receive(int fd, STCPacket *packet);
// All bool functions, except Server Receive, return true if there was an error // All bool functions, except Server Receive, return true if there was an error
bool Send(const STCPacket *packet); bool Send(const STCPacket *packet);
@ -57,7 +57,7 @@ public:
~CTCServer() {} ~CTCServer() {}
bool Open(const std::string &address, const std::string &modules, uint16_t port); bool Open(const std::string &address, const std::string &modules, uint16_t port);
// Returns true if there is data // Returns true if there is data
bool Receive(char module, STCPacket &packet, int ms); bool Receive(char module, STCPacket *packet, int ms);
bool Accept(); bool Accept();
private: private:

Loading…
Cancel
Save

Powered by TurnKey Linux.