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

Unified Diff: media/audio/audio_input_controller.cc

Issue 2919793002: Detect AudioInputStream muting and propagate to MediaStreamAudioSource. (Closed)
Patch Set: Reworked test again, to make tsan2 happy. 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') | media/audio/audio_input_controller_unittest.cc » ('j') | 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 996b937aac5b15481f50bc059607e0040c13533e..e3d994fe64570ee6aa36e90cca0456f80e5bede1 100644
--- a/media/audio/audio_input_controller.cc
+++ b/media/audio/audio_input_controller.cc
@@ -26,6 +26,7 @@ namespace media {
namespace {
const int kMaxInputChannels = 3;
+constexpr int kCheckMutedStateIntervalSeconds = 1;
#if defined(AUDIO_POWER_MONITORING)
// Time in seconds between two successive measurements of audio power levels.
@@ -199,6 +200,7 @@ AudioInputController::AudioInputController(
AudioInputController::~AudioInputController() {
DCHECK(!audio_callback_);
DCHECK(!stream_);
+ DCHECK(!check_muted_state_timer_.IsRunning());
}
// static
@@ -358,6 +360,14 @@ void AudioInputController::DoCreateForStream(
// Finally, keep the stream pointer around, update the state and notify.
stream_ = stream_to_control;
handler_->OnCreated(this);
+
+ // Check the current muted state and start the repeating timer to keep that
+ // updated.
+ CheckMutedState();
+ check_muted_state_timer_.Start(
+ FROM_HERE, base::TimeDelta::FromSeconds(kCheckMutedStateIntervalSeconds),
+ this, &AudioInputController::CheckMutedState);
+ DCHECK(check_muted_state_timer_.IsRunning());
}
void AudioInputController::DoRecord() {
@@ -387,9 +397,12 @@ void AudioInputController::DoClose() {
if (!stream_)
return;
+ check_muted_state_timer_.Stop();
+
std::string log_string;
static const char kLogStringPrefix[] = "AIC::DoClose:";
+ // Allow calling unconditionally and bail if we don't have a stream to close.
if (audio_callback_) {
stream_->Stop();
@@ -665,6 +678,17 @@ bool AudioInputController::CheckAudioPower(const AudioBus* source,
#endif
}
+void AudioInputController::CheckMutedState() {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+ DCHECK(stream_);
+ const bool new_state = stream_->IsMuted();
+ if (new_state != is_muted_) {
+ is_muted_ = new_state;
+ // We don't log OnMuted here, but leave that for AudioInputRendererHost.
+ handler_->OnMuted(this, is_muted_);
+ }
+}
+
// static
AudioInputController::StreamType AudioInputController::ParamsToStreamType(
const AudioParameters& params) {
« no previous file with comments | « media/audio/audio_input_controller.h ('k') | media/audio/audio_input_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698