only return packet once

main
Tom Early 4 years ago
parent b226aad52f
commit efa604935f

@ -258,7 +258,7 @@ void CController::AudiotoCodec2(std::shared_ptr<CTranscoderPacket> packet)
} }
// we might be all done... // we might be all done...
send_mux.lock(); send_mux.lock();
if (packet->AllCodecsAreSet()) SendToReflector(packet); if (packet->AllCodecsAreSet() && packet->HasNotBeenSent()) SendToReflector(packet);
send_mux.unlock(); send_mux.unlock();
} }
@ -345,6 +345,7 @@ void CController::SendToReflector(std::shared_ptr<CTranscoderPacket> packet)
// send the packet over the socket // send the packet over the socket
socket.Send(packet->GetTCPacket()); socket.Send(packet->GetTCPacket());
// the socket will automatically close after sending // the socket will automatically close after sending
packet->Sent();
} }
void CController::RouteDstPacket(std::shared_ptr<CTranscoderPacket> packet) void CController::RouteDstPacket(std::shared_ptr<CTranscoderPacket> packet)
@ -358,7 +359,7 @@ void CController::RouteDstPacket(std::shared_ptr<CTranscoderPacket> packet)
else else
{ {
send_mux.lock(); send_mux.lock();
if (packet->AllCodecsAreSet()) SendToReflector(packet); if (packet->AllCodecsAreSet() && packet->HasNotBeenSent()) SendToReflector(packet);
send_mux.unlock(); send_mux.unlock();
} }
} }
@ -373,7 +374,7 @@ void CController::RouteDmrPacket(std::shared_ptr<CTranscoderPacket> packet)
else else
{ {
send_mux.lock(); send_mux.lock();
if (packet->AllCodecsAreSet()) SendToReflector(packet); if (packet->AllCodecsAreSet() && packet->HasNotBeenSent()) SendToReflector(packet);
send_mux.unlock(); send_mux.unlock();
} }
} }

@ -19,7 +19,7 @@
#include "TranscoderPacket.h" #include "TranscoderPacket.h"
CTranscoderPacket::CTranscoderPacket(const STCPacket &tcp) : dstar_set(false), dmr_set(false), m17_set(false) CTranscoderPacket::CTranscoderPacket(const STCPacket &tcp) : dstar_set(false), dmr_set(false), m17_set(false), not_sent(true)
{ {
tcpacket.module = tcp.module; tcpacket.module = tcp.module;
tcpacket.is_last = tcp.is_last; tcpacket.is_last = tcp.is_last;
@ -147,3 +147,13 @@ bool CTranscoderPacket::AllCodecsAreSet() const
{ {
return (dstar_set && dmr_set && m17_set); return (dstar_set && dmr_set && m17_set);
} }
void CTranscoderPacket::Sent()
{
not_sent = false;
}
bool CTranscoderPacket::HasNotBeenSent() const
{
return not_sent;
}

@ -55,6 +55,8 @@ public:
bool DMRIsSet() const; bool DMRIsSet() const;
bool M17IsSet() const; bool M17IsSet() const;
bool AllCodecsAreSet() const; bool AllCodecsAreSet() const;
void Sent();
bool HasNotBeenSent() const;
// the all important packet // the all important packet
const STCPacket *GetTCPacket() const; const STCPacket *GetTCPacket() const;
@ -62,5 +64,5 @@ public:
private: private:
STCPacket tcpacket; STCPacket tcpacket;
int16_t audio[160]; int16_t audio[160];
std::atomic<bool> dstar_set, dmr_set, m17_set; std::atomic_bool dstar_set, dmr_set, m17_set, not_sent;
}; };

Loading…
Cancel
Save

Powered by TurnKey Linux.