Fix places that trigger no-unused-lambda-capture - change to using static-constexpr.

Follow up on https://codereview.webrtc.org/3005433002/.

BUG=webrtc:7133
TBR=stefan@webrtc.org

Review-Url: https://codereview.webrtc.org/3003723002
Cr-Commit-Position: refs/heads/master@{#19499}
This commit is contained in:
eladalon 2017-08-24 07:40:16 -07:00 committed by Commit Bot
parent 3651fdd137
commit 05b07bb833
5 changed files with 14 additions and 25 deletions

View File

@ -507,9 +507,9 @@ void AdaptiveFirFilter::Constrain() {
std::array<float, kFftLength> h;
fft_.Ifft(H_[partition_to_constrain_], &h);
const float kScale = 1.0f / kFftLengthBy2;
static constexpr float kScale = 1.0f / kFftLengthBy2;
std::for_each(h.begin(), h.begin() + kFftLengthBy2,
[kScale](float& a) { a *= kScale; });
[](float& a) { a *= kScale; });
std::fill(h.begin() + kFftLengthBy2, h.end(), 0.f);
std::copy(h.begin(), h.begin() + kFftLengthBy2,

View File

@ -337,10 +337,10 @@ TEST(AdaptiveFirFilter, FilterAndAdapt) {
delay_buffer.Delay(x[0], y);
RandomizeSampleVector(&random_generator, n);
const float kNoiseScaling = 1.f / 100.f;
static constexpr float kNoiseScaling = 1.f / 100.f;
std::transform(
y.begin(), y.end(), n.begin(), y.begin(),
[kNoiseScaling](float a, float b) { return a + b * kNoiseScaling; });
[](float a, float b) { return a + b * kNoiseScaling; });
x_hp_filter.Process(x[0]);
y_hp_filter.Process(y);

View File

@ -32,8 +32,8 @@ void EchoGeneratingPower(const RenderBuffer& render_buffer,
}
// Apply soft noise gate of -78 dBFS.
const float kNoiseGatePower = 27509.42f;
std::for_each(X2->begin(), X2->end(), [kNoiseGatePower](float& a) {
static constexpr float kNoiseGatePower = 27509.42f;
std::for_each(X2->begin(), X2->end(), [](float& a) {
if (kNoiseGatePower > a) {
a = std::max(0.f, a - 0.3f * (kNoiseGatePower - a));
}

View File

@ -1205,13 +1205,9 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
// Tests that when the transport channel signals a candidate pair change
// event, the media channel will receive a call on the network route change.
void TestNetworkRouteChanges() {
// These would have been declared as constexpr, but then some compilers
// require them to be captured in the lambda, and other compilers complain
// about no-ununused-lambda-capture. Keeping them as normal variables was
// the easiest work-around.
uint16_t kLocalNetId = 1;
uint16_t kRemoteNetId = 2;
int kLastPacketId = 100;
static constexpr uint16_t kLocalNetId = 1;
static constexpr uint16_t kRemoteNetId = 2;
static constexpr int kLastPacketId = 100;
CreateChannels(0, 0);
@ -1231,9 +1227,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
EXPECT_FALSE(media_channel1->last_network_route().connected);
media_channel1->set_num_network_route_changes(0);
network_thread_->Invoke<void>(RTC_FROM_HERE, [this,
kLocalNetId, kRemoteNetId,
kLastPacketId] {
network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
// The transport channel becomes connected.
rtc::SocketAddress local_address("192.168.1.1", 1000 /* port number */);
rtc::SocketAddress remote_address("192.168.1.2", 2000 /* port number */);

View File

@ -4278,13 +4278,9 @@ TEST_F(EndToEndTest, MAYBE_TestFlexfecRtpStatePreservation) {
rtc::CriticalSection crit_;
} observer;
// These would have been declared as constexpr, but then some compilers
// require them to be captured in the lambda, and other compilers complain
// about no-ununused-lambda-capture. Keeping them as normal variables was
// the easiest work-around.
int kFrameMaxWidth = 320;
int kFrameMaxHeight = 180;
int kFrameRate = 15;
static constexpr int kFrameMaxWidth = 320;
static constexpr int kFrameMaxHeight = 180;
static constexpr int kFrameRate = 15;
Call::Config config(event_log_.get());
@ -4371,8 +4367,7 @@ TEST_F(EndToEndTest, MAYBE_TestFlexfecRtpStatePreservation) {
EXPECT_TRUE(observer.Wait()) << "Timed out waiting for packets.";
task_queue_.SendTask([this, &observer,
kFrameRate, kFrameMaxWidth, kFrameMaxHeight]() {
task_queue_.SendTask([this, &observer]() {
// Ensure monotonicity when the VideoSendStream is recreated.
frame_generator_capturer_->Stop();
sender_call_->DestroyVideoSendStream(video_send_stream_);