Check the channels in receive-side processing frames.

The number of channels must be set correctly before calling ProcessStream. This
was preventing stereo frames from being processed.

Also fix voe_cmd_test, which wasn't enabling rx NS properly.

BUG=issue713, 7375579

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@3047 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/voice_engine/channel.cc b/voice_engine/channel.cc
index 6bb5454..3cca5db 100644
--- a/voice_engine/channel.cc
+++ b/voice_engine/channel.cc
@@ -4744,7 +4744,6 @@
     }
 
     _rxAgcIsEnabled = enable;
-
     _rxApmIsEnabled = ((_rxAgcIsEnabled == true) || (_rxNsIsEnabled == true));
 
     return 0;
@@ -6622,26 +6621,27 @@
     WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId),
                  "Channel::ApmProcessRx()");
 
-    // Reset the APM frequency if the frequency has changed
-    if (_rxAudioProcessingModulePtr->sample_rate_hz() !=
-        audioFrame.sample_rate_hz_)
-    {
-        if (_rxAudioProcessingModulePtr->set_sample_rate_hz(
+    // Register the (possibly new) frame parameters.
+    if (_rxAudioProcessingModulePtr->set_sample_rate_hz(
             audioFrame.sample_rate_hz_) != 0)
-        {
-            WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,-1),
-                         "AudioProcessingModule::set_sample_rate_hz("
-                         "sample_rate_hz_=%u) => error",
-                         _audioFrame.sample_rate_hz_);
-        }
+    {
+        WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,-1),
+                     "AudioProcessingModule::set_sample_rate_hz(%u) => error",
+                     audioFrame.sample_rate_hz_);
+    }
+    if (_rxAudioProcessingModulePtr->set_num_channels(audioFrame.num_channels_,
+            audioFrame.num_channels_) != 0)
+    {
+        WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,-1),
+                     "AudioProcessingModule::set_num_channels(%u, %u) => error",
+                     audioFrame.num_channels_, audioFrame.num_channels_);
     }
 
     if (_rxAudioProcessingModulePtr->ProcessStream(&audioFrame) != 0)
     {
         WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,-1),
-                   "AudioProcessingModule::ProcessStream() => error");
+                     "AudioProcessingModule::ProcessStream() => error");
     }
-
     return 0;
 }
 
diff --git a/voice_engine/test/cmd_test/voe_cmd_test.cc b/voice_engine/test/cmd_test/voe_cmd_test.cc
index 8753002..bf60946 100644
--- a/voice_engine/test/cmd_test/voe_cmd_test.cc
+++ b/voice_engine/test/cmd_test/voe_cmd_test.cc
@@ -235,10 +235,10 @@
   int codecinput;
   bool AEC = false;
   bool AGC = true;
-  bool AGC1 = false;
+  bool rx_agc = false;
   bool VAD = false;
   bool NS = false;
-  bool NS1 = false;
+  bool rx_ns = false;
   bool typing_detection = false;
   bool muted = false;
   bool on_hold = false;
@@ -677,20 +677,20 @@
       }
       else if (codecinput == (noCodecs + 14)) {
         // Remote AGC
-        AGC1 = !AGC1;
-        res = apm->SetRxAgcStatus(chan, AGC1);
+        rx_agc = !rx_agc;
+        res = apm->SetRxAgcStatus(chan, rx_agc);
         VALIDATE;
-        if (AGC1)
+        if (rx_agc)
           printf("\n Receive-side AGC is now on! \n");
         else
           printf("\n Receive-side AGC is now off! \n");
       }
       else if (codecinput == (noCodecs + 15)) {
         // Remote NS
-        NS1 = !NS1;
-        res = apm->SetRxNsStatus(chan, NS);
+        rx_ns = !rx_ns;
+        res = apm->SetRxNsStatus(chan, rx_ns);
         VALIDATE;
-        if (NS1)
+        if (rx_ns)
           printf("\n Receive-side NS is now on! \n");
         else
           printf("\n Receive-side NS is now off! \n");
diff --git a/voice_engine/voe_audio_processing_impl.cc b/voice_engine/voe_audio_processing_impl.cc
index 6390970..62440f4 100644
--- a/voice_engine/voe_audio_processing_impl.cc
+++ b/voice_engine/voe_audio_processing_impl.cc
@@ -356,7 +356,7 @@
   WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
                "SetRxNsStatus(channel=%d, enable=%d, mode=%d)",
                channel, (int)enable, (int)mode);
-#ifdef WEBRTC_VOICE_ENGINE_AGC
+#ifdef WEBRTC_VOICE_ENGINE_NR
   if (!_shared->statistics().Initialized()) {
     _shared->SetLastError(VE_NOT_INITED, kTraceError);
     return -1;
@@ -372,7 +372,7 @@
   return channelPtr->SetRxNsStatus(enable, mode);
 #else
   _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
-      "SetRxNsStatus() AGC is not supported");
+      "SetRxNsStatus() NS is not supported");
   return -1;
 #endif
 }
@@ -382,7 +382,7 @@
                                           NsModes& mode) {
   WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
                "GetRxNsStatus(channel=%d, enable=?, mode=?)", channel);
-#ifdef WEBRTC_VOICE_ENGINE_AGC
+#ifdef WEBRTC_VOICE_ENGINE_NR
   if (!_shared->statistics().Initialized()) {
     _shared->SetLastError(VE_NOT_INITED, kTraceError);
     return -1;
@@ -398,7 +398,7 @@
   return channelPtr->GetRxNsStatus(enabled, mode);
 #else
   _shared->SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
-      "GetRxNsStatus() Agc is not supported");
+      "GetRxNsStatus() NS is not supported");
   return -1;
 #endif
 }