| Index: content/browser/media/audio_stream_monitor.cc
|
| diff --git a/content/browser/media/audio_stream_monitor.cc b/content/browser/media/audio_stream_monitor.cc
|
| index 2f6a7e45ce0eb1205a10417d1d81cc7d1cf712bd..b19e82ff462721faa426802e6eeb471422e52616 100644
|
| --- a/content/browser/media/audio_stream_monitor.cc
|
| +++ b/content/browser/media/audio_stream_monitor.cc
|
| @@ -30,7 +30,8 @@ AudioStreamMonitor* AudioStreamMonitorFromRenderFrame(int render_process_id,
|
| AudioStreamMonitor::AudioStreamMonitor(WebContents* contents)
|
| : web_contents_(contents),
|
| clock_(&default_tick_clock_),
|
| - was_recently_audible_(false)
|
| + was_recently_audible_(false),
|
| + is_audible_(false)
|
| {
|
| DCHECK(web_contents_);
|
| }
|
| @@ -42,6 +43,11 @@ bool AudioStreamMonitor::WasRecentlyAudible() const {
|
| return was_recently_audible_;
|
| }
|
|
|
| +bool AudioStreamMonitor::IsCurrentlyAudible() const {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + return is_audible_;
|
| +}
|
| +
|
| // static
|
| void AudioStreamMonitor::StartMonitoringStream(
|
| int render_process_id,
|
| @@ -124,6 +130,9 @@ void AudioStreamMonitor::StopMonitoringStreamOnUIThread(int render_process_id,
|
| }
|
|
|
| void AudioStreamMonitor::Poll() {
|
| + bool was_audible = is_audible_;
|
| + is_audible_ = false;
|
| +
|
| for (StreamPollCallbackMap::const_iterator it = poll_callbacks_.begin();
|
| it != poll_callbacks_.end();
|
| ++it) {
|
| @@ -132,12 +141,17 @@ void AudioStreamMonitor::Poll() {
|
| // information except for "is it audible?"
|
| const float power_dbfs = it->second.Run().first;
|
| const float kSilenceThresholdDBFS = -72.24719896f;
|
| +
|
| if (power_dbfs >= kSilenceThresholdDBFS) {
|
| last_blurt_time_ = clock_->NowTicks();
|
| + is_audible_ = true;
|
| MaybeToggle();
|
| break; // No need to poll remaining streams.
|
| }
|
| }
|
| +
|
| + if (is_audible_ != was_audible)
|
| + web_contents_->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
|
| }
|
|
|
| void AudioStreamMonitor::MaybeToggle() {
|
|
|