Fix a bug where network freeze during CNG causes delay
Wrote a new NetEq unit test to test a network freeze during comfort
noise playout. The network freezes and resumes during the silence
period, and then resumes speech. It was verified that the delay
increased due to the freeze, and this CL contains a fix for that
problem.
BUG=2995
R=turaj@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/9849004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5701 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/neteq4/neteq_impl.cc b/webrtc/modules/audio_coding/neteq4/neteq_impl.cc
index aa3370f..2b98d05 100644
--- a/webrtc/modules/audio_coding/neteq4/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq4/neteq_impl.cc
@@ -874,9 +874,10 @@
// Because of timestamp peculiarities, we have to "manually" disallow using
// a CNG packet with the same timestamp as the one that was last played.
// This can happen when using redundancy and will cause the timing to shift.
- while (header &&
- decoder_database_->IsComfortNoise(header->payloadType) &&
- end_timestamp >= header->timestamp) {
+ while (header && decoder_database_->IsComfortNoise(header->payloadType) &&
+ (end_timestamp >= header->timestamp ||
+ end_timestamp + decision_logic_->generated_noise_samples() >
+ header->timestamp)) {
// Don't use this packet, discard it.
if (packet_buffer_->DiscardNextPacket() != PacketBuffer::kOK) {
assert(false); // Must be ok by design.