diff --git a/src/bridge/HostBridge.cpp b/src/bridge/HostBridge.cpp index 935ed36c..4922641a 100644 --- a/src/bridge/HostBridge.cpp +++ b/src/bridge/HostBridge.cpp @@ -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++; diff --git a/src/common/network/BaseNetwork.cpp b/src/common/network/BaseNetwork.cpp index 1b81f5d7..159cc1c4 100644 --- a/src/common/network/BaseNetwork.cpp +++ b/src/common/network/BaseNetwork.cpp @@ -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(new uint8_t[length]); diff --git a/src/common/network/BaseNetwork.h b/src/common/network/BaseNetwork.h index 13f0b1f5..e6d0d6a1 100644 --- a/src/common/network/BaseNetwork.h +++ b/src/common/network/BaseNetwork.h @@ -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; diff --git a/src/common/network/Network.cpp b/src/common/network/Network.cpp index e8259b01..2989d08b 100644 --- a/src/common/network/Network.cpp +++ b/src/common/network/Network.cpp @@ -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); } } }