Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use WeakPtrs with AudioDeviceListenerWin
There is a potential race condition on shutdown if there is a device change as AudioManagerWin is destroyed. This CL fixes the issue by using WeakPtrs. The use of WeakPtrs is nuanced and intentional here, to accommodate for different threading situations: - When the audio service is run out of process, there is no issue, as there is only one thread, and WeakPtrs can be used without afterthought. - When the audio service is run in process, there is a main thread on which the AudioManagerWin is created & destroyed, and the Audio thread on which the AudioManagerWin operates. We make sure to allocate and invalidate WeakPtrs on the audio thread, before the WeakPtrFactory is destroyed on the main thread, to avoid threading issues. crbug.com/1458623 will aim to remove kAudioServiceOutOfProcess and simplify this by only running audio out of process. Bug: 1449929 Change-Id: I1d73e47cd4819dea4e154d8b5d52d59afd270171 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4635284 Commit-Queue: Thomas Guilbert <tguilbert@chromium.org> Reviewed-by: Olga Sharonova <olka@chromium.org> Cr-Commit-Position: refs/heads/main@{#1163850}
- Loading branch information