main
Tom Early 4 years ago
parent de5decceb7
commit 6600750911

@ -109,29 +109,17 @@ void CController::ReadReflectorThread()
switch (packet->GetCodecIn())
{
case ECodecType::dstar:
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Ref packet to dstar device:");
#endif
add_dst_mux.lock();
dstar_device.AddPacket(packet);
add_dst_mux.unlock();
break;
case ECodecType::dmr:
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Ref packet to dmr device:");
#endif
add_dmr_mux.lock();
dmr_device.AddPacket(packet);
add_dmr_mux.unlock();
break;
case ECodecType::c2_1600:
case ECodecType::c2_3200:
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Ref packet to Codec2 vocoder:");
#endif
c2_mux.lock();
codec2_queue.push(packet);
c2_mux.unlock();
@ -157,6 +145,7 @@ void CController::AudiotoCodec2(std::shared_ptr<CTranscoderPacket> packet)
memcpy(m17data, data_store[packet->GetModule()], 8);
// and then calculate the second half
c2_32.codec2_encode(m17data+8, packet->GetAudio());
packet->SetM17Data(m17data, true);
}
else /* the packet is first */
{
@ -164,13 +153,9 @@ void CController::AudiotoCodec2(std::shared_ptr<CTranscoderPacket> packet)
c2_32.codec2_encode(m17data, packet->GetAudio());
// and then copy the calculated data to the data_store
memcpy(data_store[packet->GetModule()], m17data, 8);
// set the m17_is_set flag if this is the last packet
packet->SetM17Data(m17data, packet->IsLast());
}
// put the M17 data into the packet
packet->SetM17Data(m17data);
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Encoded M17:");
#endif
// we might be all done...
if (packet->AllCodecsAreSet())
{
@ -226,10 +211,6 @@ void CController::Codec2toAudio(std::shared_ptr<CTranscoderPacket> packet)
add_dmr_mux.lock();
dmr_device.AddPacket(packet);
add_dmr_mux.unlock();
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Sent to both dstar and dmr device:");
#endif
}
void CController::ProcessC2Thread()
@ -271,10 +252,6 @@ void CController::SendToReflector(std::shared_ptr<CTranscoderPacket> packet)
// send the packet over the socket
socket.Send(packet->GetTCPacket());
// the socket will automatically close after sending
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "Sent to reflector:");
#endif
}
void CController::RouteDstPacket(std::shared_ptr<CTranscoderPacket> packet)
@ -288,10 +265,6 @@ void CController::RouteDstPacket(std::shared_ptr<CTranscoderPacket> packet)
add_dmr_mux.lock();
dmr_device.AddPacket(packet);
add_dmr_mux.unlock();
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "DStar audio routed to codec2 and dmr:");
#endif
}
else if (packet->AllCodecsAreSet())
{
@ -311,16 +284,15 @@ void CController::RouteDmrPacket(std::shared_ptr<CTranscoderPacket> packet)
add_dst_mux.lock();
dstar_device.AddPacket(packet);
add_dst_mux.unlock();
#ifdef DEBUG
if (packet->IsLast())
Dump(packet, "DMR audio routed to dstar:");
#endif
}
else if (packet->AllCodecsAreSet())
{
send_mux.lock();
SendToReflector(packet);
send_mux.unlock();
#ifdef DEBUG
AppendWave(packet);
#endif
}
}

@ -138,14 +138,14 @@ bool CDV3003::OpenDevice(const std::string &ttyname, int baudrate)
if (SetBaudRate(baudrate))
return true;
#ifdef DEBUG
#ifdef DEBUG
std::cout << ttyname << " baudrate it set to " << baudrate << std::endl;
#endif
#endif
devicepath.assign(ttyname);
#ifdef DEBUG
#ifdef DEBUG
std::cout << "Opened " << devicepath << " using fd " << fd << std::endl;
#endif
#endif
if (InitDV3003())
return true;
@ -183,9 +183,9 @@ bool CDV3003::InitDV3003()
std::cerr << "InitDV3003: invalid response to reset" << std::endl;
return true;
}
#ifdef DEBUG
#ifdef DEBUG
std::cout << "Successfully reset " << devicepath << std::endl;
#endif
#endif
// ********** turn off parity *********
ctrlPacket.header.payload_length = htons(4);
@ -211,9 +211,9 @@ bool CDV3003::InitDV3003()
return true;
}
#ifdef DEBUG
#ifdef DEBUG
std::cout << "Successfully disabled parity on " << devicepath << std::endl;
#endif
#endif
// ********* Product ID and Version *************
ctrlPacket.header.payload_length = htons(1);
@ -314,9 +314,9 @@ bool CDV3003::ConfigureVocoder(uint8_t pkt_ch, Encoding type)
dump("Configuration response was:", &responsePacket, sizeof(responsePacket));
return true;
};
#ifdef DEBUG
#ifdef DEBUG
std::cout << devicepath << " channel " << (unsigned int)(pkt_ch - PKT_CHANNEL0) << " is now configured for " << ((Encoding::dstar == type) ? "D-Star" : "DMR") << std::endl;
#endif
#endif
return false;
}
@ -383,11 +383,6 @@ void CDV3003::FeedDevice()
auto packet = inq.pop();
if (packet)
{
#ifdef DEBUG
if (packet->IsLast())
Controller.Dump(packet, "FeedDevice got a packet from inq:");
#endif
const bool needs_audio = (Encoding::dstar==type) ? packet->DStarIsSet() : packet->DMRIsSet();
while (keep_running) // wait until there is room
@ -416,19 +411,11 @@ void CDV3003::FeedDevice()
{
SendData(current_vocoder, (Encoding::dstar==type) ? packet->GetDStarData() : packet->GetDMRData());
ch_depth++;
#ifdef DEBUG
if (packet->IsLast())
Controller.Dump(packet, "Queued for decoding:");
#endif
}
else
{
SendAudio(current_vocoder, packet->GetAudio());
sp_depth++;
#ifdef DEBUG
if (packet->IsLast())
Controller.Dump(packet, "Queued for encoding:");
#endif
}
if(++current_vocoder > 2)
current_vocoder = 0;
@ -476,10 +463,6 @@ void CDV3003::ReadDevice()
else
packet->SetDMRData(p.payload.ambe.data);
#ifdef DEBUG
if (packet->IsLast())
Controller.Dump(packet, "Data from device is now set:");
#endif
}
else if (PKT_SPEECH == p.header.packet_type)
{
@ -488,10 +471,6 @@ void CDV3003::ReadDevice()
for (unsigned int i=0; i<160; i++)
pPCM[i] = ntohs(p.payload.audio.samples[i]);
#ifdef DEBUG
if (packet->IsLast())
Controller.Dump(packet, "Audio from device is now set:");
#endif
}
else
{
@ -517,7 +496,7 @@ void CDV3003::ReadDevice()
void CDV3003::AddPacket(const std::shared_ptr<CTranscoderPacket> packet)
{
inq.push(packet);
#ifdef DEBUG
#ifdef DEBUG
static unsigned int maxsize = 0;
unsigned int s = inq.size();
if (s > maxsize)
@ -525,7 +504,7 @@ void CDV3003::AddPacket(const std::shared_ptr<CTranscoderPacket> packet)
std::cout << "inq size=" << s << std::endl;
maxsize = s;
}
#endif
#endif
}
bool CDV3003::SendAudio(const uint8_t channel, const int16_t *audio) const

@ -35,7 +35,7 @@ CTranscoderPacket::CTranscoderPacket(const STCPacket &tcp) : dstar_set(false), d
break;
case ECodecType::c2_1600:
case ECodecType::c2_3200:
SetM17Data(tcp.m17);
SetM17Data(tcp.m17, true);
break;
default:
std::cerr << "Trying to allocate CTranscoderPacket with an unknown codec type!" << std::endl;
@ -68,10 +68,10 @@ const STCPacket *CTranscoderPacket::GetTCPacket() const
return &tcpacket;
}
void CTranscoderPacket::SetM17Data(const uint8_t *data)
void CTranscoderPacket::SetM17Data(const uint8_t *data, bool is_set)
{
memcpy(tcpacket.m17, data, 16);
m17_set = true;
m17_set = is_set;
}
void CTranscoderPacket::SetDStarData(const uint8_t *dstar)

@ -38,7 +38,7 @@ public:
const uint8_t *GetM17Data() const;
void SetDStarData(const uint8_t *dstar);
void SetDMRData(const uint8_t *dmr);
void SetM17Data(const uint8_t *m17);
void SetM17Data(const uint8_t *m17, bool is_set);
// audio
int16_t *GetAudio();

Loading…
Cancel
Save

Powered by TurnKey Linux.