Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: media/audio/audio_input_controller.cc

Issue 2954323002: Fixed AudioInputController muted state related tsan bug. (Closed)
Patch Set: Rebased Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_input_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_input_controller.cc
diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc
index c048bf3b44abc72816e99aab51817f5824a2e79d..b860937d1f470418cfe2adc5d98731f9859db9a1 100644
--- a/media/audio/audio_input_controller.cc
+++ b/media/audio/audio_input_controller.cc
@@ -200,7 +200,7 @@ AudioInputController::AudioInputController(
AudioInputController::~AudioInputController() {
DCHECK(!audio_callback_);
DCHECK(!stream_);
- DCHECK(!check_muted_state_timer_.IsRunning());
+ DCHECK(!check_muted_state_timer_);
}
// static
@@ -364,10 +364,12 @@ void AudioInputController::DoCreateForStream(
is_muted_ = stream_->IsMuted();
handler_->OnCreated(this, is_muted_);
- check_muted_state_timer_.Start(
+ // Start a new repeating timer to keep the muted state updated.
+ check_muted_state_timer_.emplace();
+ check_muted_state_timer_->Start(
FROM_HERE, base::TimeDelta::FromSeconds(kCheckMutedStateIntervalSeconds),
this, &AudioInputController::CheckMutedState);
- DCHECK(check_muted_state_timer_.IsRunning());
+ DCHECK(check_muted_state_timer_->IsRunning());
}
void AudioInputController::DoRecord() {
@@ -397,7 +399,8 @@ void AudioInputController::DoClose() {
if (!stream_)
return;
- check_muted_state_timer_.Stop();
+ // Stop and destroy the mute check timer.
+ check_muted_state_timer_.reset();
std::string log_string;
static const char kLogStringPrefix[] = "AIC::DoClose:";
« no previous file with comments | « media/audio/audio_input_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698