Revert of AcmReceiver: Ask NetEq to delete all decoders at once instead of one by one (patchset #2 id:20001 of https://codereview.webrtc.org/2342313002/ )

Reason for revert:
Seems to have broken Chromium tests.

Original issue's description:
> AcmReceiver: Ask NetEq to delete all decoders at once instead of one by one
>
> It requires a new NetEq method, but it can no longer fail. And we no
> longer need to use AcmReceiver::decoders_, which we're trying to
> eliminate.
>
> BUG=webrtc:5801
>
> Committed: https://crrev.com/f6232b43a176e1717354b671a0a52b887d70de59
> Cr-Commit-Position: refs/heads/master@{#14275}

TBR=ossu@webrtc.org,henrik.lundin@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:5801

Review-Url: https://codereview.webrtc.org/2349973002
Cr-Commit-Position: refs/heads/master@{#14278}
diff --git a/webrtc/modules/audio_coding/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/acm2/acm_receiver.cc
index b89091f..2ae7548 100644
--- a/webrtc/modules/audio_coding/acm2/acm_receiver.cc
+++ b/webrtc/modules/audio_coding/acm2/acm_receiver.cc
@@ -245,12 +245,27 @@
   neteq_->FlushBuffers();
 }
 
-void AcmReceiver::RemoveAllCodecs() {
+// If failed in removing one of the codecs, this method continues to remove as
+// many as it can.
+int AcmReceiver::RemoveAllCodecs() {
+  int ret_val = 0;
   rtc::CritScope lock(&crit_sect_);
-  neteq_->RemoveAllPayloadTypes();
-  decoders_.clear();
+  for (auto it = decoders_.begin(); it != decoders_.end(); ) {
+    auto cur = it;
+    ++it;  // it will be valid even if we erase cur
+    if (neteq_->RemovePayloadType(cur->second.payload_type) == 0) {
+      decoders_.erase(cur);
+    } else {
+      LOG_F(LS_ERROR) << "Cannot remove payload "
+                      << static_cast<int>(cur->second.payload_type);
+      ret_val = -1;
+    }
+  }
+
+  // No codec is registered, invalidate last audio decoder.
   last_audio_decoder_ = rtc::Optional<CodecInst>();
   last_packet_sample_rate_hz_ = rtc::Optional<int>();
+  return ret_val;
 }
 
 int AcmReceiver::RemoveCodec(uint8_t payload_type) {
diff --git a/webrtc/modules/audio_coding/acm2/acm_receiver.h b/webrtc/modules/audio_coding/acm2/acm_receiver.h
index ee3f81d..5b864c2 100644
--- a/webrtc/modules/audio_coding/acm2/acm_receiver.h
+++ b/webrtc/modules/audio_coding/acm2/acm_receiver.h
@@ -186,7 +186,7 @@
   //
   // Remove all registered codecs.
   //
-  void RemoveAllCodecs();
+  int RemoveAllCodecs();
 
   // Returns the RTP timestamp for the last sample delivered by GetAudio().
   // The return value will be empty if no valid timestamp is available.
diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module.cc
index 73f03a4..4784a87 100644
--- a/webrtc/modules/audio_coding/acm2/audio_coding_module.cc
+++ b/webrtc/modules/audio_coding/acm2/audio_coding_module.cc
@@ -948,8 +948,10 @@
   // If the receiver is already initialized then we want to destroy any
   // existing decoders. After a call to this function, we should have a clean
   // start-up.
-  if (receiver_initialized_)
-    receiver_.RemoveAllCodecs();
+  if (receiver_initialized_) {
+    if (receiver_.RemoveAllCodecs() < 0)
+      return -1;
+  }
   receiver_.ResetInitialDelay();
   receiver_.SetMinimumDelay(0);
   receiver_.SetMaximumDelay(0);