AudioEncoder: change Encode and EncodeInternal return type to void

After code cleanup done on issues:
https://webrtc-codereview.appspot.com/34259004/
https://webrtc-codereview.appspot.com/43409004/
https://webrtc-codereview.appspot.com/34309004/
https://webrtc-codereview.appspot.com/34309004/
https://webrtc-codereview.appspot.com/36209004/
https://webrtc-codereview.appspot.com/40899004/
https://webrtc-codereview.appspot.com/39279004/
https://webrtc-codereview.appspot.com/42099005/
and the similar work done for AudioEncoderDecoderIsacT,  methods AudioEncoder::Encode and AudioEncoder::EncodeInternal will always succeed. Therefore, there is no need for them to return bool value that represents success or failure.

R=kwiberg@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#8518}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8518 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/codecs/audio_encoder.cc b/webrtc/modules/audio_coding/codecs/audio_encoder.cc
index ae82509..1d83e54 100644
--- a/webrtc/modules/audio_coding/codecs/audio_encoder.cc
+++ b/webrtc/modules/audio_coding/codecs/audio_encoder.cc
@@ -19,7 +19,7 @@
 AudioEncoder::EncodedInfo::~EncodedInfo() {
 }
 
-bool AudioEncoder::Encode(uint32_t rtp_timestamp,
+void AudioEncoder::Encode(uint32_t rtp_timestamp,
                           const int16_t* audio,
                           size_t num_samples_per_channel,
                           size_t max_encoded_bytes,
@@ -27,10 +27,8 @@
                           EncodedInfo* info) {
   CHECK_EQ(num_samples_per_channel,
            static_cast<size_t>(SampleRateHz() / 100));
-  bool ret =
-      EncodeInternal(rtp_timestamp, audio, max_encoded_bytes, encoded, info);
+  EncodeInternal(rtp_timestamp, audio, max_encoded_bytes, encoded, info);
   CHECK_LE(info->encoded_bytes, max_encoded_bytes);
-  return ret;
 }
 
 int AudioEncoder::RtpTimestampRateHz() const {
diff --git a/webrtc/modules/audio_coding/codecs/audio_encoder.h b/webrtc/modules/audio_coding/codecs/audio_encoder.h
index c02c3ef..08cf66f 100644
--- a/webrtc/modules/audio_coding/codecs/audio_encoder.h
+++ b/webrtc/modules/audio_coding/codecs/audio_encoder.h
@@ -56,12 +56,11 @@
 
   // Accepts one 10 ms block of input audio (i.e., sample_rate_hz() / 100 *
   // num_channels() samples). Multi-channel audio must be sample-interleaved.
-  // If successful, the encoder produces zero or more bytes of output in
-  // |encoded|, and provides the number of encoded bytes in |encoded_bytes|.
-  // In case of error, false is returned, otherwise true. It is an error for the
-  // encoder to attempt to produce more than |max_encoded_bytes| bytes of
-  // output.
-  bool Encode(uint32_t rtp_timestamp,
+  // The encoder produces zero or more bytes of output in |encoded|,
+  // and provides the number of encoded bytes in |encoded_bytes|.
+  // The caller is responsible for making sure that |max_encoded_bytes| is
+  // not smaller than the number of bytes actually produced by the encoder.
+  void Encode(uint32_t rtp_timestamp,
               const int16_t* audio,
               size_t num_samples_per_channel,
               size_t max_encoded_bytes,
@@ -98,7 +97,7 @@
   virtual void SetProjectedPacketLossRate(double fraction) {}
 
  protected:
-  virtual bool EncodeInternal(uint32_t rtp_timestamp,
+  virtual void EncodeInternal(uint32_t rtp_timestamp,
                               const int16_t* audio,
                               size_t max_encoded_bytes,
                               uint8_t* encoded,
diff --git a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
index ffab9ec..e14ac93 100644
--- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
+++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
@@ -95,15 +95,12 @@
   speech_encoder_->SetProjectedPacketLossRate(fraction);
 }
 
-bool AudioEncoderCng::EncodeInternal(uint32_t rtp_timestamp,
+void AudioEncoderCng::EncodeInternal(uint32_t rtp_timestamp,
                                      const int16_t* audio,
                                      size_t max_encoded_bytes,
                                      uint8_t* encoded,
                                      EncodedInfo* info) {
-  DCHECK_GE(max_encoded_bytes, static_cast<size_t>(num_cng_coefficients_ + 1));
-  if (max_encoded_bytes < static_cast<size_t>(num_cng_coefficients_ + 1)) {
-    return false;
-  }
+  CHECK_GE(max_encoded_bytes, static_cast<size_t>(num_cng_coefficients_ + 1));
   info->encoded_bytes = 0;
   const int num_samples = SampleRateHz() / 100 * NumChannels();
   if (speech_buffer_.empty()) {
@@ -115,7 +112,7 @@
   }
   ++frames_in_buffer_;
   if (frames_in_buffer_ < speech_encoder_->Num10MsFramesInNextPacket()) {
-    return true;
+    return;
   }
   CHECK_LE(frames_in_buffer_, 6)
       << "Frame size cannot be larger than 60 ms when using VAD/CNG.";
@@ -169,7 +166,6 @@
 
   speech_buffer_.clear();
   frames_in_buffer_ = 0;
-  return true;
 }
 
 void AudioEncoderCng::EncodePassive(uint8_t* encoded, size_t* encoded_bytes) {
@@ -196,10 +192,10 @@
                                    EncodedInfo* info) {
   const size_t samples_per_10ms_frame = 10 * SampleRateHz() / 1000;
   for (int i = 0; i < frames_in_buffer_; ++i) {
-    CHECK(speech_encoder_->Encode(first_timestamp_in_buffer_,
-                                  &speech_buffer_[i * samples_per_10ms_frame],
-                                  samples_per_10ms_frame, max_encoded_bytes,
-                                  encoded, info));
+    speech_encoder_->Encode(first_timestamp_in_buffer_,
+                            &speech_buffer_[i * samples_per_10ms_frame],
+                            samples_per_10ms_frame, max_encoded_bytes,
+                            encoded, info);
     if (i < frames_in_buffer_ - 1) {
       CHECK_EQ(info->encoded_bytes, 0u) << "Encoder delivered data too early.";
     }
diff --git a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
index 8478839..c2a9ce3 100644
--- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
+++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
@@ -72,8 +72,8 @@
   void Encode() {
     ASSERT_TRUE(cng_) << "Must call CreateCng() first.";
     encoded_info_ = AudioEncoder::EncodedInfo();
-    ASSERT_TRUE(cng_->Encode(timestamp_, audio_, num_audio_samples_10ms_,
-                             kMaxEncodedBytes, encoded_, &encoded_info_));
+    cng_->Encode(timestamp_, audio_, num_audio_samples_10ms_,
+                 kMaxEncodedBytes, encoded_, &encoded_info_);
     timestamp_ += num_audio_samples_10ms_;
   }
 
@@ -101,11 +101,11 @@
       InSequence s;
       for (int j = 0; j < blocks_per_frame - 1; ++j) {
         EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
-            .WillOnce(DoAll(SetArgPointee<4>(info), Return(true)));
+            .WillOnce(SetArgPointee<4>(info));
       }
       info.encoded_bytes = kMockReturnEncodedBytes;
       EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
-          .WillOnce(DoAll(SetArgPointee<4>(info), Return(true)));
+          .WillOnce(SetArgPointee<4>(info));
     }
     Encode();
     if (active_speech) {
@@ -280,20 +280,17 @@
 
   // All of the frame is active speech.
   EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
-      .Times(6)
-      .WillRepeatedly(Return(true));
+      .Times(6);
   EXPECT_TRUE(CheckMixedActivePassive(Vad::kActive, Vad::kActive));
 
   // First half of the frame is active speech.
   EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
-      .Times(6)
-      .WillRepeatedly(Return(true));
+      .Times(6);
   EXPECT_TRUE(CheckMixedActivePassive(Vad::kActive, Vad::kPassive));
 
   // Second half of the frame is active speech.
   EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
-      .Times(6)
-      .WillRepeatedly(Return(true));
+      .Times(6);
   EXPECT_TRUE(CheckMixedActivePassive(Vad::kPassive, Vad::kActive));
 
   // All of the frame is passive speech. Expect no calls to |mock_encoder_|.
@@ -335,8 +332,7 @@
 // speech encoder.
 TEST_F(AudioEncoderCngTest, VerifyEncoderInfoPropagation) {
   CreateCng();
-  EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, &encoded_info_))
-      .WillOnce(Return(true));
+  EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, &encoded_info_));
   EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(1));
   EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
       .WillOnce(Return(Vad::kActive));
@@ -381,7 +377,7 @@
   AudioEncoder::EncodedInfo info;
   info.encoded_bytes = kMockReturnEncodedBytes;
   EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
-      .WillOnce(DoAll(SetArgPointee<4>(info), Return(true)));
+      .WillOnce(SetArgPointee<4>(info));
   Encode();
   EXPECT_EQ(kMockReturnEncodedBytes, encoded_info_.encoded_bytes);
 
diff --git a/webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h b/webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h
index 46ad727..2f51676 100644
--- a/webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h
+++ b/webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h
@@ -55,7 +55,7 @@
   void SetProjectedPacketLossRate(double fraction) override;
 
  protected:
-  virtual bool EncodeInternal(uint32_t rtp_timestamp,
+  virtual void EncodeInternal(uint32_t rtp_timestamp,
                               const int16_t* audio,
                               size_t max_encoded_bytes,
                               uint8_t* encoded,
diff --git a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
index 2b5b690..284a086 100644
--- a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
+++ b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
@@ -60,7 +60,7 @@
   return num_10ms_frames_per_packet_;
 }
 
-bool AudioEncoderPcm::EncodeInternal(uint32_t rtp_timestamp,
+void AudioEncoderPcm::EncodeInternal(uint32_t rtp_timestamp,
                                      const int16_t* audio,
                                      size_t max_encoded_bytes,
                                      uint8_t* encoded,
@@ -74,7 +74,7 @@
   }
   if (speech_buffer_.size() < static_cast<size_t>(full_frame_samples_)) {
     info->encoded_bytes = 0;
-    return true;
+    return;
   }
   CHECK_EQ(speech_buffer_.size(), static_cast<size_t>(full_frame_samples_));
   int16_t ret = EncodeCall(&speech_buffer_[0], full_frame_samples_, encoded);
@@ -83,7 +83,6 @@
   info->encoded_timestamp = first_timestamp_in_buffer_;
   info->payload_type = payload_type_;
   info->encoded_bytes = static_cast<size_t>(ret);
-  return true;
 }
 
 int16_t AudioEncoderPcmA::EncodeCall(const int16_t* audio,
diff --git a/webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h b/webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h
index 9365c43..903b220 100644
--- a/webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h
+++ b/webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h
@@ -40,7 +40,7 @@
  protected:
   AudioEncoderPcm(const Config& config, int sample_rate_hz);
 
-  virtual bool EncodeInternal(uint32_t rtp_timestamp,
+  virtual void EncodeInternal(uint32_t rtp_timestamp,
                               const int16_t* audio,
                               size_t max_encoded_bytes,
                               uint8_t* encoded,
diff --git a/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc b/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc
index 7a2ec62..f02bda0 100644
--- a/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc
+++ b/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc
@@ -69,7 +69,7 @@
   return num_10ms_frames_per_packet_;
 }
 
-bool AudioEncoderG722::EncodeInternal(uint32_t rtp_timestamp,
+void AudioEncoderG722::EncodeInternal(uint32_t rtp_timestamp,
                                       const int16_t* audio,
                                       size_t max_encoded_bytes,
                                       uint8_t* encoded,
@@ -91,7 +91,7 @@
   // If we don't yet have enough samples for a packet, we're done for now.
   if (++num_10ms_frames_buffered_ < num_10ms_frames_per_packet_) {
     info->encoded_bytes = 0;
-    return true;
+    return;
   }
 
   // Encode each channel separately.
@@ -121,7 +121,6 @@
   info->encoded_bytes = samples_per_channel / 2 * num_channels_;
   info->encoded_timestamp = first_timestamp_in_buffer_;
   info->payload_type = payload_type_;
-  return true;
 }
 
 }  // namespace webrtc
diff --git a/webrtc/modules/audio_coding/codecs/g722/include/audio_encoder_g722.h b/webrtc/modules/audio_coding/codecs/g722/include/audio_encoder_g722.h
index 4439bc1..65a0d4b 100644
--- a/webrtc/modules/audio_coding/codecs/g722/include/audio_encoder_g722.h
+++ b/webrtc/modules/audio_coding/codecs/g722/include/audio_encoder_g722.h
@@ -37,7 +37,7 @@
   virtual int Max10MsFramesInAPacket() const OVERRIDE;
 
  protected:
-  virtual bool EncodeInternal(uint32_t rtp_timestamp,
+  virtual void EncodeInternal(uint32_t rtp_timestamp,
                               const int16_t* audio,
                               size_t max_encoded_bytes,
                               uint8_t* encoded,
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc b/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc
index 79c01dd..b939341 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc
+++ b/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc
@@ -56,7 +56,7 @@
   return num_10ms_frames_per_packet_;
 }
 
-bool AudioEncoderIlbc::EncodeInternal(uint32_t rtp_timestamp,
+void AudioEncoderIlbc::EncodeInternal(uint32_t rtp_timestamp,
                                       const int16_t* audio,
                                       size_t max_encoded_bytes,
                                       uint8_t* encoded,
@@ -93,7 +93,7 @@
   // for now.
   if (++num_10ms_frames_buffered_ < num_10ms_frames_per_packet_) {
     info->encoded_bytes = 0;
-    return true;
+    return;
   }
 
   // Encode buffered input.
@@ -109,7 +109,6 @@
   info->encoded_bytes = output_len;
   info->encoded_timestamp = first_timestamp_in_buffer_;
   info->payload_type = payload_type_;
-  return true;
 }
 
 }  // namespace webrtc
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/interface/audio_encoder_ilbc.h b/webrtc/modules/audio_coding/codecs/ilbc/interface/audio_encoder_ilbc.h
index 15c0e00..25c397a 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/interface/audio_encoder_ilbc.h
+++ b/webrtc/modules/audio_coding/codecs/ilbc/interface/audio_encoder_ilbc.h
@@ -37,7 +37,7 @@
   virtual int Max10MsFramesInAPacket() const OVERRIDE;
 
  protected:
-  virtual bool EncodeInternal(uint32_t rtp_timestamp,
+  virtual void EncodeInternal(uint32_t rtp_timestamp,
                               const int16_t* audio,
                               size_t max_encoded_bytes,
                               uint8_t* encoded,
diff --git a/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h b/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h
index 2279c3d..4b56b91 100644
--- a/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h
+++ b/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h
@@ -95,7 +95,7 @@
 
  protected:
   // AudioEncoder protected method.
-  virtual bool EncodeInternal(uint32_t rtp_timestamp,
+  virtual void EncodeInternal(uint32_t rtp_timestamp,
                               const int16_t* audio,
                               size_t max_encoded_bytes,
                               uint8_t* encoded,
diff --git a/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h b/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h
index d9cec82..7ac51b6 100644
--- a/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h
+++ b/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h
@@ -186,7 +186,7 @@
 }
 
 template <typename T>
-bool AudioEncoderDecoderIsacT<T>::EncodeInternal(uint32_t rtp_timestamp,
+void AudioEncoderDecoderIsacT<T>::EncodeInternal(uint32_t rtp_timestamp,
                                                  const int16_t* audio,
                                                  size_t max_encoded_bytes,
                                                  uint8_t* encoded,
@@ -202,11 +202,7 @@
     CriticalSectionScoped cs(state_lock_.get());
     r = T::Encode(isac_state_, audio, encoded);
   }
-  if (r < 0) {
-    // An error occurred; propagate it to the caller.
-    packet_in_progress_ = false;
-    return false;
-  }
+  CHECK_GE(r, 0);
 
   // T::Encode doesn't allow us to tell it the size of the output
   // buffer. All we can do is check for an overrun after the fact.
@@ -214,7 +210,7 @@
 
   info->encoded_bytes = r;
   if (r == 0)
-    return true;
+    return;
 
   // Got enough input to produce a packet. Return the saved timestamp from
   // the first chunk of input that went into the packet.
@@ -223,7 +219,7 @@
   info->payload_type = payload_type_;
 
   if (!T::has_redundant_encoder)
-    return true;
+    return;
 
   if (redundant_length_bytes_ == 0) {
     // Do not emit the first output frame when using redundant encoding.
@@ -260,7 +256,6 @@
   DCHECK_LE(redundant_length_bytes_, sizeof(redundant_payload_));
   DCHECK_GE(redundant_length_bytes_, 0u);
   last_encoded_timestamp_ = packet_timestamp_;
-  return true;
 }
 
 template <typename T>
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_red_unittest.cc b/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_red_unittest.cc
index 48d7ae7..0372523 100644
--- a/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_red_unittest.cc
+++ b/webrtc/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_red_unittest.cc
@@ -51,11 +51,10 @@
     EXPECT_EQ(0u, red_info.encoded_bytes);
     EXPECT_EQ(0u, red_info.redundant.size());
     const uint32_t timestamp = static_cast<uint32_t>(i);
-    EXPECT_TRUE(isac_encoder.Encode(timestamp, input, k10MsSamples,
-                                    kMaxEncodedSizeBytes, encoded, &info));
-    EXPECT_TRUE(isac_red_encoder.Encode(timestamp, input, k10MsSamples,
-                                        kMaxEncodedSizeBytes, red_encoded,
-                                        &red_info));
+    isac_encoder.Encode(timestamp, input, k10MsSamples, kMaxEncodedSizeBytes,
+                        encoded, &info);
+    isac_red_encoder.Encode(timestamp, input, k10MsSamples,
+                            kMaxEncodedSizeBytes, red_encoded, &red_info);
   }
   EXPECT_GT(info.encoded_bytes, 0u)
       << "Regular codec did not produce any output";
diff --git a/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h b/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h
index e424bc6..70ee497 100644
--- a/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h
+++ b/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h
@@ -29,7 +29,7 @@
   MOCK_METHOD1(SetProjectedPacketLossRate, void(double));
   // Note, we explicitly chose not to create a mock for the Encode method.
   MOCK_METHOD5(EncodeInternal,
-               bool(uint32_t timestamp,
+               void(uint32_t timestamp,
                     const int16_t* audio,
                     size_t max_encoded_bytes,
                     uint8_t* encoded,
diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
index 25256bc..688fb64 100644
--- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
+++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
@@ -166,7 +166,7 @@
   }
 }
 
-bool AudioEncoderOpus::EncodeInternal(uint32_t rtp_timestamp,
+void AudioEncoderOpus::EncodeInternal(uint32_t rtp_timestamp,
                                       const int16_t* audio,
                                       size_t max_encoded_bytes,
                                       uint8_t* encoded,
@@ -178,7 +178,7 @@
   if (input_buffer_.size() < (static_cast<size_t>(num_10ms_frames_per_packet_) *
                               samples_per_10ms_frame_)) {
     info->encoded_bytes = 0;
-    return true;
+    return;
   }
   CHECK_EQ(input_buffer_.size(),
            static_cast<size_t>(num_10ms_frames_per_packet_) *
@@ -193,7 +193,6 @@
   info->encoded_bytes = r;
   info->encoded_timestamp = first_timestamp_in_buffer_;
   info->payload_type = payload_type_;
-  return true;
 }
 
 }  // namespace webrtc
diff --git a/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h b/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h
index d330eeb..e2ad601 100644
--- a/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h
+++ b/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h
@@ -54,7 +54,7 @@
   ApplicationMode application() const { return application_; }
 
  protected:
-  virtual bool EncodeInternal(uint32_t rtp_timestamp,
+  virtual void EncodeInternal(uint32_t rtp_timestamp,
                               const int16_t* audio,
                               size_t max_encoded_bytes,
                               uint8_t* encoded,
diff --git a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc
index c1ffa53..afc6391 100644
--- a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc
+++ b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc
@@ -56,14 +56,14 @@
   speech_encoder_->SetProjectedPacketLossRate(fraction);
 }
 
-bool AudioEncoderCopyRed::EncodeInternal(uint32_t rtp_timestamp,
+void AudioEncoderCopyRed::EncodeInternal(uint32_t rtp_timestamp,
                                          const int16_t* audio,
                                          size_t max_encoded_bytes,
                                          uint8_t* encoded,
                                          EncodedInfo* info) {
-  CHECK(speech_encoder_->Encode(rtp_timestamp, audio,
-                                static_cast<size_t>(SampleRateHz() / 100),
-                                max_encoded_bytes, encoded, info));
+  speech_encoder_->Encode(rtp_timestamp, audio,
+                          static_cast<size_t>(SampleRateHz() / 100),
+                          max_encoded_bytes, encoded, info);
   CHECK_GE(max_encoded_bytes,
            info->encoded_bytes + secondary_info_.encoded_bytes);
   CHECK(info->redundant.empty()) << "Cannot use nested redundant encoders.";
@@ -97,7 +97,6 @@
        it != info->redundant.end(); ++it) {
     info->encoded_bytes += it->encoded_bytes;
   }
-  return true;
 }
 
 }  // namespace webrtc
diff --git a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h
index 4414d04..beea1cf 100644
--- a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h
+++ b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h
@@ -44,7 +44,7 @@
   void SetProjectedPacketLossRate(double fraction) override;
 
  protected:
-  virtual bool EncodeInternal(uint32_t rtp_timestamp,
+  virtual void EncodeInternal(uint32_t rtp_timestamp,
                               const int16_t* audio,
                               size_t max_encoded_bytes,
                               uint8_t* encoded,
diff --git a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc
index 56ada5f..b3a76a5 100644
--- a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc
+++ b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc
@@ -57,8 +57,8 @@
   void Encode() {
     ASSERT_TRUE(red_.get() != NULL);
     encoded_info_ = AudioEncoder::EncodedInfo();
-    ASSERT_TRUE(red_->Encode(timestamp_, audio_, num_audio_samples_10ms,
-                             kMaxEncodedBytes, encoded_, &encoded_info_));
+    red_->Encode(timestamp_, audio_, num_audio_samples_10ms,
+                 kMaxEncodedBytes, encoded_, &encoded_info_);
     timestamp_ += num_audio_samples_10ms;
   }
 
@@ -79,7 +79,7 @@
     memset(&info_, 0, sizeof(info_));
   }
 
-  bool Encode(uint32_t timestamp,
+  void Encode(uint32_t timestamp,
               const int16_t* audio,
               size_t max_encoded_bytes,
               uint8_t* encoded,
@@ -91,7 +91,6 @@
     }
     CHECK(info);
     *info = info_;
-    return true;
   }
 
   AudioEncoder::EncodedInfo info_;
@@ -141,8 +140,7 @@
   InSequence s;
   MockFunction<void(int check_point_id)> check;
   for (int i = 1; i <= 6; ++i) {
-    EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
-        .WillOnce(Return(true));
+    EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _));
     EXPECT_CALL(check, Call(i));
     Encode();
     check.Call(i);
@@ -157,7 +155,7 @@
   AudioEncoder::EncodedInfo info;
   info.encoded_bytes = kEncodedSize;
   EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
-      .WillOnce(DoAll(SetArgPointee<4>(info), Return(true)));
+      .WillOnce(SetArgPointee<4>(info));
   Encode();
   // First call is a special case, since it does not include a secondary
   // payload.
@@ -167,14 +165,14 @@
   // Next call to the speech encoder will not produce any output.
   info.encoded_bytes = 0;
   EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
-      .WillOnce(DoAll(SetArgPointee<4>(info), Return(true)));
+      .WillOnce(SetArgPointee<4>(info));
   Encode();
   EXPECT_EQ(0u, encoded_info_.encoded_bytes);
 
   // Final call to the speech encoder will produce output.
   info.encoded_bytes = kEncodedSize;
   EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
-      .WillOnce(DoAll(SetArgPointee<4>(info), Return(true)));
+      .WillOnce(SetArgPointee<4>(info));
   Encode();
   EXPECT_EQ(2 * kEncodedSize, encoded_info_.encoded_bytes);
   ASSERT_EQ(2u, encoded_info_.redundant.size());
@@ -191,7 +189,7 @@
     AudioEncoder::EncodedInfo info;
     info.encoded_bytes = encode_size;
     EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
-        .WillOnce(DoAll(SetArgPointee<4>(info), Return(true)));
+        .WillOnce(SetArgPointee<4>(info));
   }
 
   // First call is a special case, since it does not include a secondary
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_generic_codec.cc b/webrtc/modules/audio_coding/main/acm2/acm_generic_codec.cc
index 71df8a3..d40615b 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_generic_codec.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_generic_codec.cc
@@ -236,9 +236,9 @@
                                 AudioEncoder::EncodedInfo* encoded_info) {
   WriteLockScoped wl(codec_wrapper_lock_);
   CHECK(!input_.empty());
-  CHECK(encoder_->Encode(rtp_timestamp_, &input_[0],
-                         input_.size() / encoder_->NumChannels(),
-                         2 * MAX_PAYLOAD_SIZE_BYTE, bitstream, encoded_info));
+  encoder_->Encode(rtp_timestamp_, &input_[0],
+                   input_.size() / encoder_->NumChannels(),
+                   2 * MAX_PAYLOAD_SIZE_BYTE, bitstream, encoded_info);
   input_.clear();
   *bitstream_len_byte = static_cast<int16_t>(encoded_info->encoded_bytes);
   *timestamp = encoded_info->encoded_timestamp;
diff --git a/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc b/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc
index 4c326cc..e8823b3 100644
--- a/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc
@@ -150,9 +150,9 @@
                                                  samples_per_10ms, channels_,
                                                  interleaved_input.get());
 
-      EXPECT_TRUE(audio_encoder_->Encode(
-          0, interleaved_input.get(), audio_encoder_->SampleRateHz() / 100,
-          data_length_ * 2, output, &encoded_info_));
+      audio_encoder_->Encode(0, interleaved_input.get(),
+                             audio_encoder_->SampleRateHz() / 100,
+                             data_length_ * 2, output, &encoded_info_);
     }
     EXPECT_EQ(payload_type_, encoded_info_.payload_type);
     return static_cast<int>(encoded_info_.encoded_bytes);