Prevent a race condition in CastAudioOutputStream
- Prevent race condition in CastAudioOutputStream to prevent FillNextBuffer() from calling AudioSourceCallback::OnMoreData() after AudioOutputStream::Close() is called. - FillNextBuffer() will now acquire running_lock_ for the entirety of its scope. - CastAudioOutputStream::Close() will synchronously block on running_lock_ until FillNextBuffer() has completed before setting running_ to false and continuing its close sequence. - Subsequent calls to FillNextBuffer() will early return without calling AudioSourceCallback::OnMoreData(). - Add infrastructure in CastAudioOutputStream unittests to pause and resume the audio thread. - Add a test in CastAudioOutputStream unittests to ensure that a call to Close() will synchronously prevent any further callbacks. mutex synchronization is removed, race condition is difficult to reproduce in real-world testing. Bug: 138695782 Test: Builds, unit tests pass, new unit test passes and fails when the Change-Id: I11cdd64c0987298ba3fc6a9090359bd2715e6f03 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761483Reviewed-by:Olga Sharonova <olka@chromium.org> Reviewed-by:
Kenneth MacKay <kmackay@chromium.org> Reviewed-by:
Yuri Wiitala <miu@chromium.org> Commit-Queue: Hari Nandagopal <hnandagopal@google.com> Cr-Commit-Position: refs/heads/master@{#691784}
Showing
Please register or sign in to comment