BUGFIX: fix startup crash of dvmbridge when using analog audio mode; add transmit voice frame status for analog audio; correct core network issue determining length of analog audio frames;

r05a04_dev
Bryan Biedenkapp 1 month ago
parent 2e1ab42964
commit 4f2a3b9f49

@ -494,9 +494,11 @@ int HostBridge::run()
m_encoder = new vocoder::MBEEncoder(vocoder::ENCODE_88BIT_IMBE);
}
m_decoder->setGainAdjust(m_vocoderDecoderAudioGain);
m_decoder->setAutoGain(m_vocoderDecoderAutoGain);
m_encoder->setGainAdjust(m_vocoderEncoderAudioGain);
if (m_txMode != TX_MODE_ANALOG) {
m_decoder->setGainAdjust(m_vocoderDecoderAudioGain);
m_decoder->setAutoGain(m_vocoderDecoderAutoGain);
m_encoder->setGainAdjust(m_vocoderEncoderAudioGain);
}
#if defined(_WIN32)
initializeAMBEDLL();
@ -2870,6 +2872,10 @@ void HostBridge::encodeAnalogAudioFrame(uint8_t* pcm, uint32_t forcedSrcId, uint
analogData.setAudio(outPcm);
if (analogData.getFrameType() == AudioFrameType::VOICE) {
LogInfoEx(LOG_NET, ANO_VOICE ", audio, srcId = %u, dstId = %u, seqNo = %u", srcId, dstId, analogData.getSeqNo());
}
m_network->writeAnalog(analogData);
m_txStreamId = m_network->getAnalogStreamId();
m_analogN++;

@ -892,25 +892,15 @@ UInt8Array BaseNetwork::readAnalog(bool& ret, uint32_t& frameLength)
return nullptr;
}
uint8_t length = 0U;
m_rxAnalogData.get(&length, 1U);
if (length == 0U) {
ret = false;
return nullptr;
}
uint8_t lenOffs = 0U;
m_rxAnalogData.get(&lenOffs, 1U);
if (length < 254U) {
// if the length is less than 254, the analog packet is malformed, analog packets should never be less than 254 bytes
LogError(LOG_NET, "malformed analog packet, length < 254 (%u), shouldn't happen", length);
uint16_t length = 254U + lenOffs;
if (length == 254U) {
ret = false;
return nullptr;
}
if (length == 254U) {
m_rxAnalogData.get(&length, 1U); // read the next byte for the actual length
length += 254U; // a packet length of 254 is a special case for P25 frames, so we need to add the 254 to the length
}
UInt8Array buffer;
frameLength = length;
buffer = std::unique_ptr<uint8_t[]>(new uint8_t[length]);

@ -93,7 +93,7 @@ namespace network
const uint32_t P25_TSDU_PACKET_LENGTH = 69U; // 24 byte header + TSDU data
const uint32_t P25_TDULC_PACKET_LENGTH = 78U; // 24 byte header + TDULC data
const uint32_t NXDN_PACKET_LENGTH = 70U; // 20 byte header + NXDN_FRAME_LENGTH_BYTES + 2 byte trailer
const uint32_t ANALOG_PACKET_LENGTH = 324U; // 20 byte header + AUDIO_SAMPLES_LENGTH_BYTES + 4 byte trailer
const uint32_t ANALOG_PACKET_LENGTH = 344U; // 20 byte header + AUDIO_SAMPLES_LENGTH_BYTES + 4 byte trailer
const uint32_t HA_PARAMS_ENTRY_LEN = 20U;

@ -674,12 +674,10 @@ void Network::clock(uint32_t ms)
LogError(LOG_NET, "Analog Stream %u, frame oversized? this shouldn't happen, pktSeq = %u, len = %u", streamId, m_pktSeq, length);
// Analog frames are larger then 254 bytes, but we need to handle the case where the frame is larger than 255 bytes
uint8_t len = 254U;
m_rxAnalogData.addData(&len, 1U);
len = length - 254U;
uint8_t len = length - 254U;
m_rxAnalogData.addData(&len, 1U);
m_rxAnalogData.addData(buffer.get(), len);
m_rxAnalogData.addData(buffer.get(), length);
}
}
}

Loading…
Cancel
Save

Powered by TurnKey Linux.