Added configuration of max delay to ACM and NetEq

R=turaj@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4499 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/neteq/automode.c b/webrtc/modules/audio_coding/neteq/automode.c
index 646f164..a922448 100644
--- a/webrtc/modules/audio_coding/neteq/automode.c
+++ b/webrtc/modules/audio_coding/neteq/automode.c
@@ -224,6 +224,10 @@
              */
             int32_t minimum_delay_q8 = ((inst->minimum_delay_ms *
                 (fsHz / 1000)) << 8) / packetLenSamp;
+
+            int32_t maximum_delay_q8 = ((inst->maximum_delay_ms *
+              (fsHz / 1000)) << 8) / packetLenSamp;
+
             inst->optBufLevel = tempvar;
 
             if (streamingMode != 0)
@@ -239,6 +243,12 @@
             inst->optBufLevel = WEBRTC_SPL_MAX(inst->optBufLevel,
                                                minimum_delay_q8);
 
+            if (maximum_delay_q8 > 0) {
+              // Make sure that max is at least one packet length.
+              maximum_delay_q8 = WEBRTC_SPL_MAX(maximum_delay_q8, (1 << 8));
+              inst->optBufLevel = WEBRTC_SPL_MIN(inst->optBufLevel,
+                                                 maximum_delay_q8);
+            }
             /*********/
             /* Limit */
             /*********/