1From b6ad4b7086a6487b36d626248322f4c9d5bf420a Mon Sep 17 00:00:00 2001
2From: "thomas.georgec" <thomas.georgec@lge.com>
3Date: Sun, 12 Mar 2023 14:28:50 +0530
4Subject: [PATCH] Fix return-type errors
5
6Fix "control reaches end of non-void function" in code when -Werror=return-type
7is used.
8
9  webrtc-audio-processing-1.3/webrtc/modules/audio_processing/agc2/adaptive_mode_level_estimator.cc: In function 'float webrtc::{anonymous}::GetLevel(const webrtc::VadLevelAnalyzer::Result&, LevelEstimatorType)':
10  webrtc-audio-processing-1.3/webrtc/modules/audio_processing/agc2/adaptive_mode_level_estimator.cc:45:1: error: control reaches end of non-void function [-Werror=return-type]
11     45 | }
12        | ^
13  webrtc-audio-processing-1.3/webrtc/modules/audio_processing/audio_processing_impl.cc: In function 'webrtc::GainControl::Mode webrtc::{anonymous}::Agc1ConfigModeToInterfaceMode(webrtc::AudioProcessing::Config::GainController1::Mode)':
14  webrtc-audio-processing-1.3/webrtc/modules/audio_processing/audio_processing_impl.cc:117:1: error: control reaches end of non-void function [-Werror=return-type]
15    117 | }
16        | ^
17  webrtc-audio-processing-1.3/webrtc/modules/audio_processing/audio_processing_impl.cc: In lambda function:
18  webrtc-audio-processing-1.3/webrtc/modules/audio_processing/audio_processing_impl.cc:1853:13: error: control reaches end of non-void function  -Werror=return-type]
19   1853 |             default:
20        |             ^~~~~~~
21
22Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
23---
24Upstream-Status: Submitted [https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing/-/merge_requests/28]
25
26 .../audio_processing/agc2/adaptive_mode_level_estimator.cc  | 2 ++
27 webrtc/modules/audio_processing/audio_processing_impl.cc    | 3 +++
28 webrtc/modules/audio_processing/include/audio_processing.cc | 6 ++++++
29 3 files changed, 11 insertions(+)
30
31diff --git a/webrtc/modules/audio_processing/agc2/adaptive_mode_level_estimator.cc b/webrtc/modules/audio_processing/agc2/adaptive_mode_level_estimator.cc
32index f09f63b..9cdf6ca 100644
33--- a/webrtc/modules/audio_processing/agc2/adaptive_mode_level_estimator.cc
34+++ b/webrtc/modules/audio_processing/agc2/adaptive_mode_level_estimator.cc
35@@ -42,6 +42,8 @@ float GetLevel(const VadLevelAnalyzer::Result& vad_level,
36       return vad_level.peak_dbfs;
37       break;
38   }
39+  RTC_NOTREACHED();
40+  __builtin_unreachable ();
41 }
42
43 }  // namespace
44diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
45index 67208df..3b8262a 100644
46--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
47+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
48@@ -114,6 +114,8 @@ GainControl::Mode Agc1ConfigModeToInterfaceMode(
49     case Agc1Config::kFixedDigital:
50       return GainControl::kFixedDigital;
51   }
52+  RTC_NOTREACHED();
53+  __builtin_unreachable ();
54 }
55
56 // Maximum lengths that frame of samples being passed from the render side to
57@@ -1852,6 +1854,7 @@ void AudioProcessingImpl::InitializeNoiseSuppressor() {
58               return NsConfig::SuppressionLevel::k21dB;
59             default:
60               RTC_NOTREACHED();
61+              __builtin_unreachable ();
62           }
63         };
64
65diff --git a/webrtc/modules/audio_processing/include/audio_processing.cc b/webrtc/modules/audio_processing/include/audio_processing.cc
66index 8854415..cc8752b 100644
67--- a/webrtc/modules/audio_processing/include/audio_processing.cc
68+++ b/webrtc/modules/audio_processing/include/audio_processing.cc
69@@ -28,6 +28,8 @@ std::string NoiseSuppressionLevelToString(
70     case AudioProcessing::Config::NoiseSuppression::Level::kVeryHigh:
71       return "VeryHigh";
72   }
73+  RTC_NOTREACHED();
74+  __builtin_unreachable ();
75 }
76
77 std::string GainController1ModeToString(
78@@ -40,6 +42,8 @@ std::string GainController1ModeToString(
79     case AudioProcessing::Config::GainController1::Mode::kFixedDigital:
80       return "FixedDigital";
81   }
82+  RTC_NOTREACHED();
83+  __builtin_unreachable ();
84 }
85
86 std::string GainController2LevelEstimatorToString(
87@@ -50,6 +54,8 @@ std::string GainController2LevelEstimatorToString(
88     case AudioProcessing::Config::GainController2::LevelEstimator::kPeak:
89       return "Peak";
90   }
91+  RTC_NOTREACHED();
92+  __builtin_unreachable ();
93 }
94
95 int GetDefaultMaxInternalRate() {
96