mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-17 07:37:51 +01:00
Remove one acquisition of capture lock in APM AudioFrame API
This brings the two ProcessStream functions closer in implementation. Additionally, the error checking that is currently done in the period of not holding the lock seems cheaper than releasing and reacquiring the capture lock. Bug: webrtc:11235 Change-Id: Ib4afc68afb419fcabbb8cf08a3a2e61d2c12acda Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/163021 Reviewed-by: Per Åhgren <peah@webrtc.org> Commit-Queue: Sam Zackrisson <saza@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30140}
This commit is contained in:
parent
2bd85ab039
commit
308bc646e0
1 changed files with 28 additions and 27 deletions
|
@ -843,9 +843,13 @@ int AudioProcessingImpl::ProcessStream(const float* const* src,
|
||||||
ProcessingConfig processing_config;
|
ProcessingConfig processing_config;
|
||||||
bool reinitialization_required = false;
|
bool reinitialization_required = false;
|
||||||
{
|
{
|
||||||
// Acquire the capture lock in order to safely call the function
|
// Acquire the capture lock in order to:
|
||||||
// that retrieves the render side data. This function accesses apm
|
// - Safely call the function that retrieves the render side data. This
|
||||||
// getters that need the capture lock held when being called.
|
// function accesses APM getters that need the capture lock held when
|
||||||
|
// being called.
|
||||||
|
// - Access api_format. The lock is released immediately due to the
|
||||||
|
// conditional reinitialization.
|
||||||
|
|
||||||
rtc::CritScope cs_capture(&crit_capture_);
|
rtc::CritScope cs_capture(&crit_capture_);
|
||||||
EmptyQueuedRenderAudio();
|
EmptyQueuedRenderAudio();
|
||||||
|
|
||||||
|
@ -1101,13 +1105,18 @@ void AudioProcessingImpl::EmptyQueuedRenderAudio() {
|
||||||
|
|
||||||
int AudioProcessingImpl::ProcessStream(AudioFrame* frame) {
|
int AudioProcessingImpl::ProcessStream(AudioFrame* frame) {
|
||||||
TRACE_EVENT0("webrtc", "AudioProcessing::ProcessStream_AudioFrame");
|
TRACE_EVENT0("webrtc", "AudioProcessing::ProcessStream_AudioFrame");
|
||||||
|
|
||||||
|
ProcessingConfig processing_config;
|
||||||
|
bool reinitialization_required = false;
|
||||||
{
|
{
|
||||||
// Acquire the capture lock in order to safely call the function
|
// Acquire the capture lock in order to:
|
||||||
// that retrieves the render side data. This function accesses APM
|
// - Safely call the function that retrieves the render side data. This
|
||||||
// getters that need the capture lock held when being called.
|
// function accesses APM getters that need the capture lock held when
|
||||||
|
// being called.
|
||||||
|
// - Access api_format. The lock is released immediately due to the
|
||||||
|
// conditional reinitialization.
|
||||||
rtc::CritScope cs_capture(&crit_capture_);
|
rtc::CritScope cs_capture(&crit_capture_);
|
||||||
EmptyQueuedRenderAudio();
|
EmptyQueuedRenderAudio();
|
||||||
}
|
|
||||||
|
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
return kNullPointerError;
|
return kNullPointerError;
|
||||||
|
@ -1120,13 +1129,6 @@ int AudioProcessingImpl::ProcessStream(AudioFrame* frame) {
|
||||||
return kBadSampleRateError;
|
return kBadSampleRateError;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessingConfig processing_config;
|
|
||||||
bool reinitialization_required = false;
|
|
||||||
{
|
|
||||||
// Aquire lock for the access of api_format.
|
|
||||||
// The lock is released immediately due to the conditional
|
|
||||||
// reinitialization.
|
|
||||||
rtc::CritScope cs_capture(&crit_capture_);
|
|
||||||
// TODO(ajm): The input and output rates and channels are currently
|
// TODO(ajm): The input and output rates and channels are currently
|
||||||
// constrained to be identical in the int16 interface.
|
// constrained to be identical in the int16 interface.
|
||||||
processing_config = formats_.api_format;
|
processing_config = formats_.api_format;
|
||||||
|
@ -1198,9 +1200,8 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
|
||||||
// Ensure that not both the AEC and AECM are active at the same time.
|
// Ensure that not both the AEC and AECM are active at the same time.
|
||||||
// TODO(peah): Simplify once the public API Enable functions for these
|
// TODO(peah): Simplify once the public API Enable functions for these
|
||||||
// are moved to APM.
|
// are moved to APM.
|
||||||
RTC_DCHECK_LE(!!submodules_.echo_controller +
|
RTC_DCHECK_LE(
|
||||||
!!submodules_.echo_control_mobile,
|
!!submodules_.echo_controller + !!submodules_.echo_control_mobile, 1);
|
||||||
1);
|
|
||||||
|
|
||||||
AudioBuffer* capture_buffer = capture_.capture_audio.get(); // For brevity.
|
AudioBuffer* capture_buffer = capture_.capture_audio.get(); // For brevity.
|
||||||
AudioBuffer* linear_aec_buffer = capture_.linear_aec_output.get();
|
AudioBuffer* linear_aec_buffer = capture_.linear_aec_output.get();
|
||||||
|
|
Loading…
Reference in a new issue