talk/media/webrtc/webrtcvoiceengine: Delay Agnostic AEC should not override HW-AEC

In https://webrtc-codereview.appspot.com/48699004/ I made the audio option delay_agnostic_aec override HW-AEC if such exists. That is not an expected behavior and is fixed in this CL.

In addition we now check if EnableBuiltInAEC() was successful before disabling the SW-AEC. This revealed a bug in that return value, also fixed here.

BUG=4472
R=henrika@webrtc.org, perkj@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#8936}
diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc
index 592d4ac..32a80bb 100644
--- a/talk/media/webrtc/webrtcvoiceengine.cc
+++ b/talk/media/webrtc/webrtcvoiceengine.cc
@@ -848,13 +848,10 @@
     // in combination with Open SL ES audio.
     const bool built_in_aec = voe_wrapper_->hw()->BuiltInAECIsAvailable();
     if (built_in_aec) {
-      // Enabled built-in EC if the device has one and delay agnostic AEC is not
-      // enabled.
-      const bool enable_built_in_aec = echo_cancellation &
-          !use_delay_agnostic_aec;
-      // Set mode of built-in EC according to the audio options.
-      voe_wrapper_->hw()->EnableBuiltInAEC(enable_built_in_aec);
-      if (enable_built_in_aec) {
+      // Built-in EC exists on this device. Enable/Disable it according to the
+      // echo_cancellation audio option.
+      if (voe_wrapper_->hw()->EnableBuiltInAEC(echo_cancellation) == 0 &&
+          echo_cancellation) {
         // Disable internal software EC if built-in EC is enabled,
         // i.e., replace the software EC with the built-in EC.
         options.echo_cancellation.Set(false);
diff --git a/webrtc/voice_engine/voe_hardware_impl.cc b/webrtc/voice_engine/voe_hardware_impl.cc
index 2099562..e8388ee 100644
--- a/webrtc/voice_engine/voe_hardware_impl.cc
+++ b/webrtc/voice_engine/voe_hardware_impl.cc
@@ -579,7 +579,7 @@
 int VoEHardwareImpl::EnableBuiltInAEC(bool enable) {
 if (!_shared->statistics().Initialized()) {
     _shared->SetLastError(VE_NOT_INITED, kTraceError);
-    return false;
+    return -1;
   }
   return _shared->audio_device()->EnableBuiltInAEC(enable);
 }