Removed the ProcessingComponent class
BUG= Review URL: https://codereview.webrtc.org/1772553002 Cr-Commit-Position: refs/heads/master@{#11950}
This commit is contained in:
@ -86,8 +86,7 @@ source_set("audio_processing") {
|
||||
"logging/aec_logging_file_handling.h",
|
||||
"noise_suppression_impl.cc",
|
||||
"noise_suppression_impl.h",
|
||||
"processing_component.cc",
|
||||
"processing_component.h",
|
||||
"render_queue_item_verifier.h",
|
||||
"rms_level.cc",
|
||||
"rms_level.h",
|
||||
"splitting_filter.cc",
|
||||
|
||||
@ -96,8 +96,7 @@
|
||||
'logging/aec_logging_file_handling.h',
|
||||
'noise_suppression_impl.cc',
|
||||
'noise_suppression_impl.h',
|
||||
'processing_component.cc',
|
||||
'processing_component.h',
|
||||
'render_queue_item_verifier.h',
|
||||
'rms_level.cc',
|
||||
'rms_level.h',
|
||||
'splitting_filter.cc',
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
#include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.h"
|
||||
#include "webrtc/modules/audio_processing/level_estimator_impl.h"
|
||||
#include "webrtc/modules/audio_processing/noise_suppression_impl.h"
|
||||
#include "webrtc/modules/audio_processing/processing_component.h"
|
||||
#include "webrtc/modules/audio_processing/transient/transient_suppressor.h"
|
||||
#include "webrtc/modules/audio_processing/voice_detection_impl.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
@ -101,7 +100,6 @@ struct AudioProcessingImpl::ApmPrivateSubmodules {
|
||||
explicit ApmPrivateSubmodules(Beamformer<float>* beamformer)
|
||||
: beamformer(beamformer) {}
|
||||
// Accessed internally from capture or during initialization
|
||||
std::list<ProcessingComponent*> component_list;
|
||||
std::unique_ptr<Beamformer<float>> beamformer;
|
||||
std::unique_ptr<AgcManagerDirect> agc_manager;
|
||||
};
|
||||
@ -197,13 +195,6 @@ AudioProcessingImpl::~AudioProcessingImpl() {
|
||||
private_submodules_->agc_manager.reset();
|
||||
// Depends on gain_control_.
|
||||
public_submodules_->gain_control_for_experimental_agc.reset();
|
||||
while (!private_submodules_->component_list.empty()) {
|
||||
ProcessingComponent* component =
|
||||
private_submodules_->component_list.front();
|
||||
component->Destroy();
|
||||
delete component;
|
||||
private_submodules_->component_list.pop_front();
|
||||
}
|
||||
|
||||
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||
if (debug_dump_.debug_file->Open()) {
|
||||
@ -308,14 +299,6 @@ int AudioProcessingImpl::InitializeLocked() {
|
||||
fwd_audio_buffer_channels,
|
||||
formats_.api_format.output_stream().num_frames()));
|
||||
|
||||
// Initialize all components.
|
||||
for (auto item : private_submodules_->component_list) {
|
||||
int err = item->Initialize();
|
||||
if (err != kNoError) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
InitializeGainController();
|
||||
InitializeEchoCanceller();
|
||||
InitializeEchoControlMobile();
|
||||
@ -416,9 +399,6 @@ void AudioProcessingImpl::SetExtraOptions(const Config& config) {
|
||||
// Run in a single-threaded manner when setting the extra options.
|
||||
rtc::CritScope cs_render(&crit_render_);
|
||||
rtc::CritScope cs_capture(&crit_capture_);
|
||||
for (auto item : private_submodules_->component_list) {
|
||||
item->SetExtraOptions(config);
|
||||
}
|
||||
|
||||
public_submodules_->echo_cancellation->SetExtraOptions(config);
|
||||
|
||||
@ -1131,13 +1111,6 @@ bool AudioProcessingImpl::is_data_processed() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
// All of the private submodules modify the data.
|
||||
for (auto item : private_submodules_->component_list) {
|
||||
if (item->is_component_enabled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// The capture data is otherwise unchanged.
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/common_audio/swap_queue.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
#include "webrtc/modules/audio_processing/processing_component.h"
|
||||
#include "webrtc/modules/audio_processing/render_queue_item_verifier.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/common_audio/swap_queue.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
#include "webrtc/modules/audio_processing/processing_component.h"
|
||||
#include "webrtc/modules/audio_processing/render_queue_item_verifier.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/common_audio/swap_queue.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
#include "webrtc/modules/audio_processing/processing_component.h"
|
||||
#include "webrtc/modules/audio_processing/render_queue_item_verifier.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "webrtc/common_audio/channel_buffer.h"
|
||||
#include "webrtc/common_audio/swap_queue.h"
|
||||
#include "webrtc/modules/audio_processing/intelligibility/intelligibility_utils.h"
|
||||
#include "webrtc/modules/audio_processing/processing_component.h"
|
||||
#include "webrtc/modules/audio_processing/render_queue_item_verifier.h"
|
||||
#include "webrtc/modules/audio_processing/vad/voice_activity_detector.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/audio_processing/processing_component.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ProcessingComponent::ProcessingComponent()
|
||||
: initialized_(false),
|
||||
enabled_(false),
|
||||
num_handles_(0) {}
|
||||
|
||||
ProcessingComponent::~ProcessingComponent() {
|
||||
assert(initialized_ == false);
|
||||
}
|
||||
|
||||
int ProcessingComponent::Destroy() {
|
||||
while (!handles_.empty()) {
|
||||
DestroyHandle(handles_.back());
|
||||
handles_.pop_back();
|
||||
}
|
||||
initialized_ = false;
|
||||
|
||||
return AudioProcessing::kNoError;
|
||||
}
|
||||
|
||||
int ProcessingComponent::EnableComponent(bool enable) {
|
||||
if (enable && !enabled_) {
|
||||
enabled_ = enable; // Must be set before Initialize() is called.
|
||||
|
||||
int err = Initialize();
|
||||
if (err != AudioProcessing::kNoError) {
|
||||
enabled_ = false;
|
||||
return err;
|
||||
}
|
||||
} else {
|
||||
enabled_ = enable;
|
||||
}
|
||||
|
||||
return AudioProcessing::kNoError;
|
||||
}
|
||||
|
||||
bool ProcessingComponent::is_component_enabled() const {
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
void* ProcessingComponent::handle(size_t index) const {
|
||||
assert(index < num_handles_);
|
||||
return handles_[index];
|
||||
}
|
||||
|
||||
size_t ProcessingComponent::num_handles() const {
|
||||
return num_handles_;
|
||||
}
|
||||
|
||||
int ProcessingComponent::Initialize() {
|
||||
if (!enabled_) {
|
||||
return AudioProcessing::kNoError;
|
||||
}
|
||||
|
||||
num_handles_ = num_handles_required();
|
||||
if (num_handles_ > handles_.size()) {
|
||||
handles_.resize(num_handles_, NULL);
|
||||
}
|
||||
|
||||
assert(handles_.size() >= num_handles_);
|
||||
for (size_t i = 0; i < num_handles_; i++) {
|
||||
if (handles_[i] == NULL) {
|
||||
handles_[i] = CreateHandle();
|
||||
if (handles_[i] == NULL) {
|
||||
return AudioProcessing::kCreationFailedError;
|
||||
}
|
||||
}
|
||||
|
||||
int err = InitializeHandle(handles_[i]);
|
||||
if (err != AudioProcessing::kNoError) {
|
||||
return GetHandleError(handles_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
initialized_ = true;
|
||||
return Configure();
|
||||
}
|
||||
|
||||
int ProcessingComponent::Configure() {
|
||||
if (!initialized_) {
|
||||
return AudioProcessing::kNoError;
|
||||
}
|
||||
|
||||
assert(handles_.size() >= num_handles_);
|
||||
for (size_t i = 0; i < num_handles_; i++) {
|
||||
int err = ConfigureHandle(handles_[i]);
|
||||
if (err != AudioProcessing::kNoError) {
|
||||
return GetHandleError(handles_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return AudioProcessing::kNoError;
|
||||
}
|
||||
} // namespace webrtc
|
||||
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/common.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Functor to use when supplying a verifier function for the queue item
|
||||
// verifcation.
|
||||
template <typename T>
|
||||
class RenderQueueItemVerifier {
|
||||
public:
|
||||
explicit RenderQueueItemVerifier(size_t minimum_capacity)
|
||||
: minimum_capacity_(minimum_capacity) {}
|
||||
|
||||
bool operator()(const std::vector<T>& v) const {
|
||||
return v.capacity() >= minimum_capacity_;
|
||||
}
|
||||
|
||||
private:
|
||||
size_t minimum_capacity_;
|
||||
};
|
||||
|
||||
class ProcessingComponent {
|
||||
public:
|
||||
ProcessingComponent();
|
||||
virtual ~ProcessingComponent();
|
||||
|
||||
virtual int Initialize();
|
||||
virtual void SetExtraOptions(const Config& config) {}
|
||||
virtual int Destroy();
|
||||
|
||||
bool is_component_enabled() const;
|
||||
|
||||
protected:
|
||||
virtual int Configure();
|
||||
int EnableComponent(bool enable);
|
||||
void* handle(size_t index) const;
|
||||
size_t num_handles() const;
|
||||
|
||||
private:
|
||||
virtual void* CreateHandle() const = 0;
|
||||
virtual int InitializeHandle(void* handle) const = 0;
|
||||
virtual int ConfigureHandle(void* handle) const = 0;
|
||||
virtual void DestroyHandle(void* handle) const = 0;
|
||||
virtual size_t num_handles_required() const = 0;
|
||||
virtual int GetHandleError(void* handle) const = 0;
|
||||
|
||||
std::vector<void*> handles_;
|
||||
bool initialized_;
|
||||
bool enabled_;
|
||||
size_t num_handles_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H__
|
||||
36
webrtc/modules/audio_processing/render_queue_item_verifier.h
Normal file
36
webrtc/modules/audio_processing/render_queue_item_verifier.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_RENDER_QUEUE_ITEM_VERIFIER_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_RENDER_QUEUE_ITEM_VERIFIER_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Functor to use when supplying a verifier function for the queue item
|
||||
// verifcation.
|
||||
template <typename T>
|
||||
class RenderQueueItemVerifier {
|
||||
public:
|
||||
explicit RenderQueueItemVerifier(size_t minimum_capacity)
|
||||
: minimum_capacity_(minimum_capacity) {}
|
||||
|
||||
bool operator()(const std::vector<T>& v) const {
|
||||
return v.capacity() >= minimum_capacity_;
|
||||
}
|
||||
|
||||
private:
|
||||
size_t minimum_capacity_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_RENDER_QUEUE_ITEM_VERIFIER_H__
|
||||
Reference in New Issue
Block a user