Fixing warning C4267 on Win (more_configs).
This is a follow-up of https://webrtc-review.googlesource.com/c/src/+/12921.
Bug: chromium:759980
Change-Id: Ifd39adb6541c0c7e0337f587a8b34b84a07331ed
Reviewed-on: https://webrtc-review.googlesource.com/13122
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20341}
diff --git a/modules/audio_coding/acm2/acm_receiver_unittest.cc b/modules/audio_coding/acm2/acm_receiver_unittest.cc
index 8fbea84..c420c7e 100644
--- a/modules/audio_coding/acm2/acm_receiver_unittest.cc
+++ b/modules/audio_coding/acm2/acm_receiver_unittest.cc
@@ -108,7 +108,7 @@
last_packet_send_timestamp_ = timestamp_;
while (!packet_sent_) {
frame.timestamp_ = timestamp_;
- timestamp_ += frame.samples_per_channel_;
+ timestamp_ += rtc::checked_cast<uint32_t>(frame.samples_per_channel_);
ASSERT_GE(acm_->Add10MsData(frame), 0);
}
}
@@ -175,8 +175,9 @@
for (size_t n = 0; n < codecs_.size(); ++n) {
if (n & 0x1) { // Just add codecs with odd index.
EXPECT_EQ(
- 0, receiver_->AddCodec(n, codecs_[n].pltype, codecs_[n].channels,
- codecs_[n].plfreq, NULL, codecs_[n].plname));
+ 0, receiver_->AddCodec(rtc::checked_cast<int>(n), codecs_[n].pltype,
+ codecs_[n].channels, codecs_[n].plfreq, NULL,
+ codecs_[n].plname));
}
}
// Get codec and compare.
@@ -338,7 +339,7 @@
EXPECT_EQ(0,
receiver_->GetAudio(output_sample_rate_hz, &frame, &muted));
EXPECT_EQ(expected_output_ts, frame.timestamp_);
- expected_output_ts += 10 * samples_per_ms;
+ expected_output_ts += rtc::checked_cast<uint32_t>(10 * samples_per_ms);
EXPECT_EQ(10 * samples_per_ms, frame.samples_per_channel_);
EXPECT_EQ(output_sample_rate_hz, frame.sample_rate_hz_);
EXPECT_EQ(output_channels, frame.num_channels_);
diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
index f95dca2..bd1e884 100644
--- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc
+++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
@@ -37,6 +37,7 @@
#include "rtc_base/md5digest.h"
#include "rtc_base/platform_thread.h"
#include "rtc_base/refcountedobject.h"
+#include "rtc_base/safe_conversions.h"
#include "rtc_base/thread_annotations.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/event_wrapper.h"
@@ -122,7 +123,7 @@
int last_payload_len_bytes() const {
rtc::CritScope lock(&crit_sect_);
- return last_payload_vec_.size();
+ return rtc::checked_cast<int>(last_payload_vec_.size());
}
FrameType last_frame_type() const {
@@ -1158,9 +1159,9 @@
bool RegisterExternalSendCodec(AudioEncoder* external_speech_encoder,
int payload_type) {
payload_type_ = payload_type;
- frame_size_rtp_timestamps_ =
+ frame_size_rtp_timestamps_ = rtc::checked_cast<uint32_t>(
external_speech_encoder->Num10MsFramesInNextPacket() *
- external_speech_encoder->RtpTimestampRateHz() / 100;
+ external_speech_encoder->RtpTimestampRateHz() / 100);
return send_test_->RegisterExternalCodec(external_speech_encoder);
}
@@ -1589,7 +1590,7 @@
int nr_bytes = 0;
while (std::unique_ptr<test::Packet> next_packet =
send_test_->NextPacket()) {
- nr_bytes += next_packet->payload_length_bytes();
+ nr_bytes += rtc::checked_cast<int>(next_packet->payload_length_bytes());
}
EXPECT_EQ(expected_total_bits, nr_bytes * 8);
}
@@ -1742,9 +1743,11 @@
if (packet_counter == nr_packets / 2)
send_test_->acm()->SetBitRate(target_bitrate_bps);
if (packet_counter < nr_packets / 2)
- nr_bytes_before += next_packet->payload_length_bytes();
+ nr_bytes_before += rtc::checked_cast<int>(
+ next_packet->payload_length_bytes());
else
- nr_bytes_after += next_packet->payload_length_bytes();
+ nr_bytes_after += rtc::checked_cast<int>(
+ next_packet->payload_length_bytes());
packet_counter++;
}
EXPECT_EQ(expected_before_switch_bits, nr_bytes_before * 8);