Commit 18cf26b2 authored by Hongchan Choi's avatar Hongchan Choi Committed by Chromium LUCI CQ

Add MutexTryLocker in AudioBufferSourceHandler::PropagateSilence()

The access to |shared_buffer_| in AudioBufferSourceHandler needs to be
controlled by |process_lock_|. This CL adds one into PropagateSilence()
method.


Bug: 1167472
Test: ToT crashes with the repro case, but it doesn't with this patch.
Change-Id: I52f95d52889c9b809507c88a16c61f0e85b36f3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2638097
Commit-Queue: Hongchan Choi <hongchan@chromium.org>
Reviewed-by: default avatarRaymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845334}
parent f2b4ad78
...@@ -653,7 +653,21 @@ double AudioBufferSourceHandler::GetMinPlaybackRate() { ...@@ -653,7 +653,21 @@ double AudioBufferSourceHandler::GetMinPlaybackRate() {
} }
bool AudioBufferSourceHandler::PropagatesSilence() const { bool AudioBufferSourceHandler::PropagatesSilence() const {
return !IsPlayingOrScheduled() || HasFinished() || !shared_buffer_.get(); DCHECK(Context()->IsAudioThread());
if (!IsPlayingOrScheduled() || HasFinished())
return true;
// Protect |shared_buffer_| with tryLock because it can be accessed by the
// main thread.
MutexTryLocker try_locker(process_lock_);
if (try_locker.Locked()) {
return !shared_buffer_.get();
} else {
// Can't get lock. Assume |shared_buffer_| exists, so return false to
// indicate this node is (or might be) outputting non-zero samples.
return false;
}
} }
void AudioBufferSourceHandler::HandleStoppableSourceNode() { void AudioBufferSourceHandler::HandleStoppableSourceNode() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment