Skip to content

Commit 1c787b4

Browse files
committed
ignore m_audioDetect flag for UDP audio outbound to the FNE; attempt to correct becoming stuck on incoming RTP timestamps;
1 parent d961a9e commit 1c787b4

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

src/bridge/HostBridge.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,12 +2230,15 @@ void* HostBridge::threadUDPAudioProcess(void* arg)
22302230
// RTP timestamps increment by samples per frame
22312231
uint32_t expectedTimestamp = (uint32_t)lastFrameTime + (RTP_GENERIC_CLOCK_RATE / 50);
22322232
if (rtpTimestamp < expectedTimestamp) {
2233-
// frame is too early, already processed a more recent frame
2234-
/*
2235-
if (bridge->m_debug)
2236-
LogDebugEx(LOG_HOST, "HostBridge::threadUDPAudioProcess()", "RTP frame too early, rtpTs = %u, expected >= %u, pktSeq = %u",
2237-
rtpTimestamp, expectedTimestamp, pktSeq);
2238-
*/
2233+
// frame is stale (already processed a more recent frame) - discard it
2234+
// rather than spinning on it forever at the head of the queue
2235+
LogWarning(LOG_NET, "RTP frame stale/out-of-order, discarding; rtpTs = %u, expected >= %u, pktSeq = %u",
2236+
rtpTimestamp, expectedTimestamp, pktSeq);
2237+
bridge->m_udpPackets.pop_front();
2238+
if (req->pcm != nullptr)
2239+
delete[] req->pcm;
2240+
delete req;
2241+
req = nullptr;
22392242
shouldProcess = false;
22402243
} else {
22412244
// frame is ready to process - update RTP timestamp marker
@@ -2347,8 +2350,7 @@ void* HostBridge::threadUDPAudioProcess(void* arg)
23472350
bridge->m_udpDstId = bridge->m_dstId;
23482351

23492352
// force start a call if one isn't already in progress
2350-
if ((!bridge->m_audioDetect && !bridge->m_callInProgress) || forceCallStart) {
2351-
bridge->m_audioDetect = true;
2353+
if (!bridge->m_callInProgress || forceCallStart) {
23522354
if (bridge->m_txStreamId == 0U) {
23532355
bridge->m_txStreamId = 1U;
23542356
if (forceCallStart)
@@ -2432,20 +2434,18 @@ void* HostBridge::threadUDPAudioProcess(void* arg)
24322434

24332435
// encode and transmit UDP audio if audio detection is active
24342436
// Note: We encode even if a network call is in progress, since UDP audio takes priority
2435-
if (bridge->m_audioDetect) {
2436-
bridge->m_udpDropTime.start();
2437-
2438-
switch (bridge->m_txMode) {
2439-
case TX_MODE_DMR:
2440-
bridge->encodeDMRAudioFrame(pcm, bridge->m_udpSrcId);
2441-
break;
2442-
case TX_MODE_P25:
2443-
bridge->encodeP25AudioFrame(pcm, bridge->m_udpSrcId);
2444-
break;
2445-
case TX_MODE_ANALOG:
2446-
bridge->encodeAnalogAudioFrame(pcm, bridge->m_udpSrcId);
2447-
break;
2448-
}
2437+
bridge->m_udpDropTime.start();
2438+
2439+
switch (bridge->m_txMode) {
2440+
case TX_MODE_DMR:
2441+
bridge->encodeDMRAudioFrame(pcm, bridge->m_udpSrcId);
2442+
break;
2443+
case TX_MODE_P25:
2444+
bridge->encodeP25AudioFrame(pcm, bridge->m_udpSrcId);
2445+
break;
2446+
case TX_MODE_ANALOG:
2447+
bridge->encodeAnalogAudioFrame(pcm, bridge->m_udpSrcId);
2448+
break;
24492449
}
24502450

24512451
bridge->m_udpFrameCnt++;

0 commit comments

Comments
 (0)