APM: Fix benign race in MaybeInitializeCapture()
MaybeInitializeCapture may overwrite the render configuration of a concurrent render reinitialization, leading to a second render reinitialization on the next render processing call. See bug description for details. Tested: Verified bitexactness offline (single-threaded) on a large number of aecdumps. Bug: webrtc:14495 Change-Id: I9b70b454ce1c27859c3414c9c9ec89b7bbe35559 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/277380 Reviewed-by: Per Åhgren <peah@webrtc.org> Commit-Queue: Sam Zackrisson <saza@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38241}
This commit is contained in:
parent
8da45ad5f6
commit
5ed1752843
@ -728,18 +728,20 @@ int AudioProcessingImpl::MaybeInitializeCapture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (processing_config.input_stream() != input_config) {
|
if (processing_config.input_stream() != input_config) {
|
||||||
processing_config.input_stream() = input_config;
|
|
||||||
reinitialization_required = true;
|
reinitialization_required = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processing_config.output_stream() != output_config) {
|
if (processing_config.output_stream() != output_config) {
|
||||||
processing_config.output_stream() = output_config;
|
|
||||||
reinitialization_required = true;
|
reinitialization_required = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reinitialization_required) {
|
if (reinitialization_required) {
|
||||||
MutexLock lock_render(&mutex_render_);
|
MutexLock lock_render(&mutex_render_);
|
||||||
MutexLock lock_capture(&mutex_capture_);
|
MutexLock lock_capture(&mutex_capture_);
|
||||||
|
// Reread the API format since the render format may have changed.
|
||||||
|
processing_config = formats_.api_format;
|
||||||
|
processing_config.input_stream() = input_config;
|
||||||
|
processing_config.output_stream() = output_config;
|
||||||
RETURN_ON_ERR(InitializeLocked(processing_config));
|
RETURN_ON_ERR(InitializeLocked(processing_config));
|
||||||
}
|
}
|
||||||
return kNoError;
|
return kNoError;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user