Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: webrtc/modules/audio_processing/level_estimator_impl.cc

Issue 1523483002: Make LevelEstimation not a ProcessingComponent. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/audio_processing/level_estimator_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_processing/level_estimator_impl.cc
diff --git a/webrtc/modules/audio_processing/level_estimator_impl.cc b/webrtc/modules/audio_processing/level_estimator_impl.cc
index 52f6697a57e44c79765d53ee0ff0d82375ecfb8f..aa676a870f838d74246ecc72ced301ac7d870001 100644
--- a/webrtc/modules/audio_processing/level_estimator_impl.cc
+++ b/webrtc/modules/audio_processing/level_estimator_impl.cc
@@ -11,83 +11,55 @@
#include "webrtc/modules/audio_processing/level_estimator_impl.h"
#include "webrtc/modules/audio_processing/audio_buffer.h"
-#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/modules/audio_processing/rms_level.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
namespace webrtc {
-LevelEstimatorImpl::LevelEstimatorImpl(const AudioProcessing* apm,
- rtc::CriticalSection* crit)
- : ProcessingComponent(), crit_(crit) {
- RTC_DCHECK(apm);
+LevelEstimatorImpl::LevelEstimatorImpl(rtc::CriticalSection* crit)
+ : crit_(crit), rms_(new RMSLevel()) {
RTC_DCHECK(crit);
}
LevelEstimatorImpl::~LevelEstimatorImpl() {}
-int LevelEstimatorImpl::ProcessStream(AudioBuffer* audio) {
+void LevelEstimatorImpl::Initialize() {
rtc::CritScope cs(crit_);
+ rms_->Reset();
+}
- if (!is_component_enabled()) {
- return AudioProcessing::kNoError;
+void LevelEstimatorImpl::ProcessStream(AudioBuffer* audio) {
+ RTC_DCHECK(audio);
+ rtc::CritScope cs(crit_);
+ if (!enabled_) {
+ return;
}
- RMSLevel* rms_level = static_cast<RMSLevel*>(handle(0));
- for (int i = 0; i < audio->num_channels(); ++i) {
- rms_level->Process(audio->channels_const()[i],
- audio->num_frames());
+ for (int i = 0; i < audio->num_channels(); i++) {
+ rms_->Process(audio->channels_const()[i], audio->num_frames());
}
-
- return AudioProcessing::kNoError;
}
int LevelEstimatorImpl::Enable(bool enable) {
rtc::CritScope cs(crit_);
- return EnableComponent(enable);
+ if (enable && !enabled_) {
+ rms_->Reset();
+ }
+ enabled_ = enable;
+ return AudioProcessing::kNoError;
}
bool LevelEstimatorImpl::is_enabled() const {
rtc::CritScope cs(crit_);
- return is_component_enabled();
+ return enabled_;
}
int LevelEstimatorImpl::RMS() {
rtc::CritScope cs(crit_);
- if (!is_component_enabled()) {
+ if (!enabled_) {
return AudioProcessing::kNotEnabledError;
}
- RMSLevel* rms_level = static_cast<RMSLevel*>(handle(0));
- return rms_level->RMS();
-}
-
-// The ProcessingComponent implementation is pretty weird in this class since
-// we have only a single instance of the trivial underlying component.
-void* LevelEstimatorImpl::CreateHandle() const {
- return new RMSLevel;
-}
-
-void LevelEstimatorImpl::DestroyHandle(void* handle) const {
- delete static_cast<RMSLevel*>(handle);
-}
-
-int LevelEstimatorImpl::InitializeHandle(void* handle) const {
- rtc::CritScope cs(crit_);
- static_cast<RMSLevel*>(handle)->Reset();
- return AudioProcessing::kNoError;
-}
-
-int LevelEstimatorImpl::ConfigureHandle(void* /*handle*/) const {
- return AudioProcessing::kNoError;
+ return rms_->RMS();
}
-
-int LevelEstimatorImpl::num_handles_required() const {
- return 1;
-}
-
-int LevelEstimatorImpl::GetHandleError(void* /*handle*/) const {
- return AudioProcessing::kUnspecifiedError;
-}
-
} // namespace webrtc
« no previous file with comments | « webrtc/modules/audio_processing/level_estimator_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698