From 05b07bb833328515f7e86b769a7660008f0f498e Mon Sep 17 00:00:00 2001 From: eladalon Date: Thu, 24 Aug 2017 07:40:16 -0700 Subject: [PATCH] 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} --- .../audio_processing/aec3/adaptive_fir_filter.cc | 4 ++-- .../aec3/adaptive_fir_filter_unittest.cc | 4 ++-- .../aec3/residual_echo_estimator.cc | 4 ++-- webrtc/pc/channel_unittest.cc | 14 ++++---------- webrtc/video/end_to_end_tests.cc | 13 ++++--------- 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc b/webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc index 09347e8324..303ff7735d 100644 --- a/webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc +++ b/webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc @@ -507,9 +507,9 @@ void AdaptiveFirFilter::Constrain() { std::array 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, diff --git a/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc b/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc index b9ab201991..ddc7896de6 100644 --- a/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc +++ b/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc @@ -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); diff --git a/webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc b/webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc index 8905846743..c708664db4 100644 --- a/webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc +++ b/webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc @@ -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)); } diff --git a/webrtc/pc/channel_unittest.cc b/webrtc/pc/channel_unittest.cc index 0eaffc426d..3f30201874 100644 --- a/webrtc/pc/channel_unittest.cc +++ b/webrtc/pc/channel_unittest.cc @@ -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(RTC_FROM_HERE, [this, - kLocalNetId, kRemoteNetId, - kLastPacketId] { + network_thread_->Invoke(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 */); diff --git a/webrtc/video/end_to_end_tests.cc b/webrtc/video/end_to_end_tests.cc index f0cbf3e5c5..7e62f6da0d 100644 --- a/webrtc/video/end_to_end_tests.cc +++ b/webrtc/video/end_to_end_tests.cc @@ -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_);