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
This commit is contained in:
jmarusic@webrtc.org
2015-02-26 15:38:10 +00:00
parent 00b8f6b364
commit b1f0de30be
22 changed files with 66 additions and 90 deletions

View File

@ -56,14 +56,14 @@ void AudioEncoderCopyRed::SetProjectedPacketLossRate(double fraction) {
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 @@ bool AudioEncoderCopyRed::EncodeInternal(uint32_t rtp_timestamp,
it != info->redundant.end(); ++it) {
info->encoded_bytes += it->encoded_bytes;
}
return true;
}
} // namespace webrtc

View File

@ -44,7 +44,7 @@ class AudioEncoderCopyRed : public AudioEncoder {
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,

View File

@ -57,8 +57,8 @@ class AudioEncoderCopyRedTest : public ::testing::Test {
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 @@ class MockEncodeHelper {
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 @@ class MockEncodeHelper {
}
CHECK(info);
*info = info_;
return true;
}
AudioEncoder::EncodedInfo info_;
@ -141,8 +140,7 @@ TEST_F(AudioEncoderCopyRedTest, CheckImmediateEncode) {
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 @@ TEST_F(AudioEncoderCopyRedTest, CheckNoOuput) {
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 @@ TEST_F(AudioEncoderCopyRedTest, CheckNoOuput) {
// 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 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes) {
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