From 5a71a4c092a6f255cb35af835388bee3d3ac31c2 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 7 Jun 2021 23:20:40 -0500 Subject: [PATCH] Use 10ms packets for slow Opus decoders With the old 20ms packets, an FEC block was 80ms of audio data. This is enough data that waiting for the FEC shards can cause an audio data underflow. The burst of 80ms of audio data after reassembly fails can then lead clients to drop samples due to excessive queued data. --- src/SdpGenerator.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/SdpGenerator.c b/src/SdpGenerator.c index 046b63a..0717c79 100644 --- a/src/SdpGenerator.c +++ b/src/SdpGenerator.c @@ -412,13 +412,10 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) { err |= addAttributeString(&optionHead, "x-nv-audio.surround.AudioQuality", "0"); HighQualitySurroundEnabled = false; - if ((AudioCallbacks.capabilities & CAPABILITY_SLOW_OPUS_DECODER) != 0) { - // Use 20 ms packets for slow decoders to save CPU time - AudioPacketDuration = 20; - } - else if ((AudioCallbacks.capabilities & CAPABILITY_SUPPORTS_ARBITRARY_AUDIO_DURATION) != 0 && - OriginalVideoBitrate < LOW_AUDIO_BITRATE_TRESHOLD) { - // Use 10 ms packets for slow networks to balance latency and bandwidth usage + if ((AudioCallbacks.capabilities & CAPABILITY_SLOW_OPUS_DECODER) || + ((AudioCallbacks.capabilities & CAPABILITY_SUPPORTS_ARBITRARY_AUDIO_DURATION) != 0 && + OriginalVideoBitrate < LOW_AUDIO_BITRATE_TRESHOLD)) { + // Use 10 ms packets for slow devices and networks to balance latency and bandwidth usage AudioPacketDuration = 10; } else {