Skip to content

Commit

Permalink
Check context status before creating new platform destination
Browse files Browse the repository at this point in the history
RealtimeAudioDestinationHandler::SetSinkDescriptor creates new
destination platofrm without validating context status. This can
reactivate the audio rendering thread when AudioContext is already in
closed state.

(cherry picked from commit 0f9bb9a)

Bug: 1500856
Change-Id: If1fd531324b56fcdc38d315fd84d4cec577a14bc
Test: Locally confirmed with ASAN
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5021160
Reviewed-by: Alvin Ji <alvinji@chromium.org>
Commit-Queue: Alvin Ji <alvinji@chromium.org>
Reviewed-by: Hongchan Choi <hongchan@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1223168}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5038792
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Hongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/branch-heads/6045@{#1382}
Cr-Branched-From: 905e8bd-refs/heads/main@{#1204232}
  • Loading branch information
Alvin Ji authored and Chromium LUCI CQ committed Nov 16, 2023
1 parent 0bd2fbb commit e0ade19
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,17 @@ void RealtimeAudioDestinationHandler::SetSinkDescriptor(
GetCallbackBufferSize()));
DCHECK(IsMainThread());

// After the context is closed, `SetSinkDescriptor` request will be ignored
// because it will trigger the recreation of the platform destination. This in
// turn can activate the audio rendering thread.
AudioContext* context = static_cast<AudioContext*>(Context());
CHECK(context);
if (context->ContextState() == AudioContext::kClosed) {
std::move(callback).Run(
media::OutputDeviceStatus::OUTPUT_DEVICE_STATUS_ERROR_INTERNAL);
return;
}

// Create a pending AudioDestination to replace the current one.
scoped_refptr<AudioDestination> pending_platform_destination =
AudioDestination::Create(
Expand Down

0 comments on commit e0ade19

Please sign in to comment.