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;
if (g_TCServer.Receive(m_CSModule, pack, 8))
if (g_TCServer.Receive(m_CSModule, &pack, 8))
{
// 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)
{
m_RTMin = rt;

@ -19,10 +19,6 @@
#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 };
using STCPacket = struct tcpacket_tag {

@ -127,9 +127,9 @@ bool CTCSocket::Send(const STCPacket *packet)
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)
{
perror("Receive recv");
@ -139,18 +139,18 @@ bool CTCSocket::receive(int fd, STCPacket &packet)
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);
return true;
}
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;
}
// 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;
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)
{
auto p_tcpack = std::make_unique<STCPacket>();
if (receive(pfd.fd, *p_tcpack))
if (receive(pfd.fd, p_tcpack.get()))
{
p_tcpack.reset();
}

@ -37,7 +37,7 @@ public:
void Close(); // close all open sockets
void Close(char module); // close a specific module
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
bool Send(const STCPacket *packet);
@ -57,7 +57,7 @@ public:
~CTCServer() {}
bool Open(const std::string &address, const std::string &modules, uint16_t port);
// Returns true if there is data
bool Receive(char module, STCPacket &packet, int ms);
bool Receive(char module, STCPacket *packet, int ms);
bool Accept();
private:

Loading…
Cancel
Save

Powered by TurnKey Linux.