| Index: content/browser/media/audio_stream_monitor.h
|
| diff --git a/content/browser/media/audio_stream_monitor.h b/content/browser/media/audio_stream_monitor.h
|
| index 12f06055c54970fda0d454eae788c1a6346439aa..ced46683efbfb3dcf17b91245bd65ac183fde2f4 100644
|
| --- a/content/browser/media/audio_stream_monitor.h
|
| +++ b/content/browser/media/audio_stream_monitor.h
|
| @@ -34,18 +34,15 @@ class WebContents;
|
| // to turn on/off repeatedly and annoy the user. AudioStreamMonitor sends UI
|
| // update notifications only when needed, but may be queried at any time.
|
| //
|
| +// When power level monitoring is not available, audibility is approximated
|
| +// with having active audio streams.
|
| +//
|
| // Each WebContentsImpl owns an AudioStreamMonitor.
|
| class CONTENT_EXPORT AudioStreamMonitor {
|
| public:
|
| explicit AudioStreamMonitor(WebContents* contents);
|
| ~AudioStreamMonitor();
|
|
|
| - // Indicates if audio stream monitoring is available. It's only available if
|
| - // AudioOutputController can and will monitor output power levels.
|
| - static bool monitoring_available() {
|
| - return media::AudioOutputController::will_monitor_audio_levels();
|
| - }
|
| -
|
| // Returns true if audio has recently been audible from the tab. This is
|
| // usually called whenever the tab data model is refreshed; but there are
|
| // other use cases as well (e.g., the OOM killer uses this to de-prioritize
|
| @@ -89,6 +86,13 @@ class CONTENT_EXPORT AudioStreamMonitor {
|
| kHoldOnMilliseconds = 2000
|
| };
|
|
|
| + // Indicates if monitoring of audio stream power level is available.
|
| + // It's only available if AudioOutputController can and will monitor
|
| + // output power levels.
|
| + static bool power_level_monitoring_available() {
|
| + return media::AudioOutputController::will_monitor_audio_levels();
|
| + }
|
| +
|
| // Helper methods for starting and stopping monitoring which lookup the
|
| // identified renderer and forward calls to the correct AudioStreamMonitor.
|
| static void StartMonitoringHelper(
|
| @@ -119,6 +123,11 @@ class CONTENT_EXPORT AudioStreamMonitor {
|
| // on, |off_timer_| is started to re-invoke this method in the future.
|
| void MaybeToggle();
|
|
|
| + // Helper functions to track number of active streams when power level
|
| + // monitoring is not available.
|
| + void OnStreamAdded();
|
| + void OnStreamRemoved();
|
| +
|
| // The WebContents instance to receive indicator toggle notifications. This
|
| // pointer should be valid for the lifetime of AudioStreamMonitor.
|
| WebContents* const web_contents_;
|
| @@ -154,6 +163,10 @@ class CONTENT_EXPORT AudioStreamMonitor {
|
| // future.
|
| base::OneShotTimer off_timer_;
|
|
|
| + // Number of active streams to be used as a proxy for audibility when power
|
| + // level monitoring is not available.
|
| + size_t active_streams_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(AudioStreamMonitor);
|
| };
|
|
|
|
|