Implement a test for an old corner-case in NetEq

This CL implements a unit test to cover an case where comfort noise
packets should be discarded. The situation arises when NetEq gets a
duplicate comfort noise packet. Without this check, the duplicate would
be decoded, and a the timing would shift.

As it turned out, the corner-case funcionality was not completely
accurate in NetEq4. This is because decision_logic_::cng_state_ is set
after the corner-case check. In the old NetEq3, the corresponding state
was changed before the check. This is now fixed.

R=turaj@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/9639005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5685 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 4ffe3e7..aa3370f 100644
--- a/webrtc/modules/audio_coding/neteq4/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq4/neteq_impl.cc
@@ -870,7 +870,7 @@
   }
   const RTPHeader* header = packet_buffer_->NextRtpHeader();
 
-  if (decision_logic_->CngRfc3389On()) {
+  if (decision_logic_->CngRfc3389On() || last_mode_ == kModeRfc3389Cng) {
     // 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.
@@ -878,7 +878,6 @@
         decoder_database_->IsComfortNoise(header->payloadType) &&
         end_timestamp >= header->timestamp) {
       // Don't use this packet, discard it.
-      // TODO(hlundin): Write test for this case.
       if (packet_buffer_->DiscardNextPacket() != PacketBuffer::kOK) {
         assert(false);  // Must be ok by design.
       }