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

Issue 478543003: Use AudioStreamMonitor to control power save blocking. (Closed)

Created:
6 years, 4 months ago by DaleCurtis
Modified:
6 years, 3 months ago
CC:
chromium-reviews, creis+watch_chromium.org, posciak+watch_chromium.org, nasko+codewatch_chromium.org, mcasas+watch_chromium.org, feature-media-reviews_chromium.org, darin-cc_chromium.org, wjia+watch_chromium.org, miu+watch_chromium.org, sky
Project:
chromium
Visibility:
Public.

Description

Use AudioStreamMonitor to control power save blocking. Prevents looping, soundless videos from preventing system sleep if they're in a background tab. We don't want soundless videos in the main tab to allow sleeping as they'll impact the muted video + captions use case. Reworks WebContentsImpl to track active media players and whether the attached WebContents is visible. When visible and there's an active video player, it will create a power save blocker. One blocker is shared for all active media players for simplicity. Reworks AudioStreamMonitor to handle the PowerSaveBlocker for audio such that one is only created when non-silent audio is present. To prevent splitting power blocking duties across chrome/ and content/, AudioStreamMonitor now lives in content/. WebContents exposes a WasRecentlyAudible() method for the existing tab audio indicator. BUG=43667, 367785 TEST=manual. Committed: https://crrev.com/484d29dcb45ca362fc9049c37dd3a51e11492f14 Cr-Commit-Position: refs/heads/master@{#294303}

Patch Set 1 : Compile. #

Total comments: 9

Patch Set 2 : Combo! #

Patch Set 3 : Move it! #

Total comments: 3

Patch Set 4 : Move it with style! #

Total comments: 24

Patch Set 5 : Cleanup. #

Total comments: 14

Patch Set 6 : Comments. #

Total comments: 6

Patch Set 7 : Rebase. Comments. #

Patch Set 8 : Drop UserData. #

Patch Set 9 : Simplify OS_CHROMEOS exclusions. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+538 lines, -804 lines) Patch
M chrome/browser/media/OWNERS View 1 2 3 4 5 1 chunk +0 lines, -1 line 0 comments Download
M chrome/browser/media/audio_stream_monitor.h View 1 2 1 chunk +0 lines, -113 lines 0 comments Download
M chrome/browser/media/audio_stream_monitor.cc View 1 2 1 chunk +0 lines, -86 lines 0 comments Download
D chrome/browser/media/audio_stream_monitor_unittest.cc View 1 2 1 chunk +0 lines, -278 lines 0 comments Download
M chrome/browser/media/media_capture_devices_dispatcher.h View 1 2 3 4 1 chunk +0 lines, -9 lines 0 comments Download
M chrome/browser/media/media_capture_devices_dispatcher.cc View 1 2 3 4 5 6 5 chunks +0 lines, -88 lines 0 comments Download
M chrome/browser/ui/tabs/tab_utils.cc View 1 2 2 chunks +2 lines, -4 lines 0 comments Download
M chrome/chrome_browser.gypi View 1 2 3 4 5 6 7 1 chunk +0 lines, -2 lines 0 comments Download
M chrome/chrome_tests_unit.gypi View 1 2 3 4 5 6 7 1 chunk +0 lines, -1 line 0 comments Download
M content/browser/media/OWNERS View 1 2 3 4 5 1 chunk +3 lines, -0 lines 0 comments Download
A + content/browser/media/audio_stream_monitor.h View 1 2 3 4 5 6 7 6 chunks +64 lines, -24 lines 0 comments Download
A + content/browser/media/audio_stream_monitor.cc View 1 2 3 4 5 6 7 5 chunks +84 lines, -8 lines 0 comments Download
A + content/browser/media/audio_stream_monitor_unittest.cc View 1 2 3 4 5 6 7 8 chunks +77 lines, -58 lines 0 comments Download
M content/browser/renderer_host/media/audio_renderer_host.cc View 1 2 3 4 5 6 3 chunks +24 lines, -33 lines 0 comments Download
M content/browser/web_contents/web_contents_impl.h View 1 2 3 4 5 6 7 8 7 chunks +46 lines, -14 lines 0 comments Download
M content/browser/web_contents/web_contents_impl.cc View 1 2 3 4 5 6 7 8 10 chunks +126 lines, -39 lines 0 comments Download
M content/browser/web_contents/web_contents_impl_unittest.cc View 1 2 3 4 5 6 7 8 2 chunks +88 lines, -0 lines 0 comments Download
M content/content_browser.gypi View 1 2 3 4 5 6 7 1 chunk +2 lines, -0 lines 0 comments Download
M content/content_tests.gypi View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M content/public/browser/media_observer.h View 1 2 1 chunk +0 lines, -21 lines 0 comments Download
M content/public/browser/web_contents.h View 1 2 1 chunk +3 lines, -0 lines 0 comments Download
M media/audio/audio_output_controller.h View 1 2 3 4 5 chunks +15 lines, -7 lines 0 comments Download
M media/audio/audio_output_controller.cc View 1 2 3 4 5 chunks +3 lines, -18 lines 0 comments Download

Messages

Total messages: 46 (5 generated)
DaleCurtis
Not ready for commit, just looking for discussion on this approach. miu@ discussed this in ...
6 years, 4 months ago (2014-08-21 19:48:35 UTC) #1
scherkus (not reviewing)
I find it mildly amusing that you link to bug 43667 yet your CL description ...
6 years, 4 months ago (2014-08-21 21:30:36 UTC) #2
DaleCurtis
On 2014/08/21 21:30:36, scherkus wrote: > I find it mildly amusing that you link to ...
6 years, 4 months ago (2014-08-21 21:38:33 UTC) #3
scherkus (not reviewing)
https://codereview.chromium.org/478543003/diff/20001/content/browser/web_contents/web_contents_impl.cc File content/browser/web_contents/web_contents_impl.cc (right): https://codereview.chromium.org/478543003/diff/20001/content/browser/web_contents/web_contents_impl.cc#newcode3013 content/browser/web_contents/web_contents_impl.cc:3013: PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, "Playing video"); FYI this is prevent display sleep ...
6 years, 4 months ago (2014-08-21 21:42:55 UTC) #4
DaleCurtis
Ah, I didn't notice the difference in those two fields. Two possible alternatives: - We ...
6 years, 4 months ago (2014-08-22 22:14:20 UTC) #5
DaleCurtis
To rephrase, the suggested approaches yield: video only: no longer gets a sleep blocker. audio ...
6 years, 4 months ago (2014-08-22 22:24:16 UTC) #6
DaleCurtis
(notably this wouldn't fix the skybox.com issue since they are playing a 48kHz audio stream ...
6 years, 4 months ago (2014-08-22 22:44:33 UTC) #7
miu
https://codereview.chromium.org/478543003/diff/20001/chrome/browser/media/audio_stream_monitor.cc File chrome/browser/media/audio_stream_monitor.cc (right): https://codereview.chromium.org/478543003/diff/20001/chrome/browser/media/audio_stream_monitor.cc#newcode83 chrome/browser/media/audio_stream_monitor.cc:83: #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) Hmm...I'm wondering whether this is ...
6 years, 3 months ago (2014-08-25 19:34:53 UTC) #8
DaleCurtis
I'm wondering if instead we might want a two part approach: 1. When a tab ...
6 years, 3 months ago (2014-08-27 21:37:17 UTC) #9
DaleCurtis
PTAL. I've switched to the combo approach outlined since I think that most fairly resolves ...
6 years, 3 months ago (2014-08-28 00:55:19 UTC) #10
miu
https://codereview.chromium.org/478543003/diff/20001/chrome/browser/media/audio_stream_monitor.cc File chrome/browser/media/audio_stream_monitor.cc (right): https://codereview.chromium.org/478543003/diff/20001/chrome/browser/media/audio_stream_monitor.cc#newcode83 chrome/browser/media/audio_stream_monitor.cc:83: #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) On 2014/08/28 00:55:19, DaleCurtis wrote: ...
6 years, 3 months ago (2014-08-28 04:11:58 UTC) #11
DaleCurtis
dalecurtis@chromium.org changed reviewers: + jam@chromium.org
6 years, 3 months ago (2014-08-28 18:51:43 UTC) #12
DaleCurtis
sky, jam: Are you guys okay with moving AudioStreamMonitor into content/ and exposing a new ...
6 years, 3 months ago (2014-08-28 18:51:43 UTC) #13
sky
On Thu, Aug 28, 2014 at 11:51 AM, <dalecurtis@chromium.org> wrote: > sky, jam: Are you ...
6 years, 3 months ago (2014-08-28 23:04:39 UTC) #14
jam
On 2014/08/28 18:51:43, DaleCurtis wrote: > sky, jam: Are you guys okay with moving AudioStreamMonitor ...
6 years, 3 months ago (2014-08-28 23:45:05 UTC) #15
DaleCurtis
Specifically, I was thinking AudioStreamMonitor would move into content/browser/media and WebContents would expose a content/public ...
6 years, 3 months ago (2014-08-29 00:49:55 UTC) #16
jam
On 2014/08/29 00:49:55, DaleCurtis wrote: > Specifically, I was thinking AudioStreamMonitor would move into > ...
6 years, 3 months ago (2014-08-29 17:20:50 UTC) #17
DaleCurtis
Yuri kindly informed me of some misconceptions I had. The WebContents may change RenderProcessHostImpls over ...
6 years, 3 months ago (2014-08-29 18:19:41 UTC) #18
DaleCurtis
Okay all moved. PTAL, but no rush, I won't be back until Wednesday. https://codereview.chromium.org/478543003/diff/80001/content/browser/media/audio_stream_monitor.cc File ...
6 years, 3 months ago (2014-08-29 23:56:47 UTC) #19
DaleCurtis
Yuri showed me --similirity=10, so the latest patch set got the move detection correctly! Please ...
6 years, 3 months ago (2014-08-29 23:59:26 UTC) #20
jam
content lgtm with nits https://codereview.chromium.org/478543003/diff/100001/content/browser/media/audio_stream_monitor.cc File content/browser/media/audio_stream_monitor.cc (right): https://codereview.chromium.org/478543003/diff/100001/content/browser/media/audio_stream_monitor.cc#newcode22 content/browser/media/audio_stream_monitor.cc:22: content::WebContents* const web_contents = nit: ...
6 years, 3 months ago (2014-09-02 19:50:33 UTC) #21
miu
https://codereview.chromium.org/478543003/diff/100001/chrome/chrome_tests_unit.gypi File chrome/chrome_tests_unit.gypi (left): https://codereview.chromium.org/478543003/diff/100001/chrome/chrome_tests_unit.gypi#oldcode1036 chrome/chrome_tests_unit.gypi:1036: 'browser/media/cast_transport_host_filter_unittest.cc', I don't think you meant to delete this ...
6 years, 3 months ago (2014-09-02 21:04:40 UTC) #22
DaleCurtis
Just comment updates. Please reply. https://codereview.chromium.org/478543003/diff/100001/content/browser/media/audio_stream_monitor.cc File content/browser/media/audio_stream_monitor.cc (right): https://codereview.chromium.org/478543003/diff/100001/content/browser/media/audio_stream_monitor.cc#newcode36 content/browser/media/audio_stream_monitor.cc:36: // TODO(dalecurtis): ???? DEFINE_WEB_CONTENTS_USER_DATA_KEY ...
6 years, 3 months ago (2014-09-03 18:48:55 UTC) #23
miu
https://codereview.chromium.org/478543003/diff/100001/content/browser/media/audio_stream_monitor.cc File content/browser/media/audio_stream_monitor.cc (right): https://codereview.chromium.org/478543003/diff/100001/content/browser/media/audio_stream_monitor.cc#newcode36 content/browser/media/audio_stream_monitor.cc:36: // TODO(dalecurtis): ???? DEFINE_WEB_CONTENTS_USER_DATA_KEY won't link, On 2014/09/03 18:48:55, ...
6 years, 3 months ago (2014-09-03 22:41:53 UTC) #24
DaleCurtis
PTAL. All power management is back in WebContentsImpl, so things have changed a bit since ...
6 years, 3 months ago (2014-09-04 21:59:06 UTC) #25
miu
https://codereview.chromium.org/478543003/diff/120001/content/browser/media/OWNERS File content/browser/media/OWNERS (right): https://codereview.chromium.org/478543003/diff/120001/content/browser/media/OWNERS#newcode20 content/browser/media/OWNERS:20: per-file media_stream_capture_indicator*=miu@chromium.org Don't need this 2nd line (no media_stream_capture_indicator.* ...
6 years, 3 months ago (2014-09-05 18:20:25 UTC) #26
DaleCurtis
https://codereview.chromium.org/478543003/diff/120001/content/browser/web_contents/web_contents_impl.cc File content/browser/web_contents/web_contents_impl.cc (right): https://codereview.chromium.org/478543003/diff/120001/content/browser/web_contents/web_contents_impl.cc#newcode1087 content/browser/web_contents/web_contents_impl.cc:1087: video_power_save_blocker_.reset(); On 2014/09/05 18:20:25, miu wrote: > Seems like ...
6 years, 3 months ago (2014-09-05 18:30:15 UTC) #27
miu
https://codereview.chromium.org/478543003/diff/120001/content/browser/web_contents/web_contents_impl.cc File content/browser/web_contents/web_contents_impl.cc (right): https://codereview.chromium.org/478543003/diff/120001/content/browser/web_contents/web_contents_impl.cc#newcode1087 content/browser/web_contents/web_contents_impl.cc:1087: video_power_save_blocker_.reset(); On 2014/09/05 18:30:14, DaleCurtis wrote: > On 2014/09/05 ...
6 years, 3 months ago (2014-09-05 18:44:31 UTC) #28
DaleCurtis
https://codereview.chromium.org/478543003/diff/120001/content/browser/media/OWNERS File content/browser/media/OWNERS (right): https://codereview.chromium.org/478543003/diff/120001/content/browser/media/OWNERS#newcode20 content/browser/media/OWNERS:20: per-file media_stream_capture_indicator*=miu@chromium.org On 2014/09/05 18:20:25, miu wrote: > Don't ...
6 years, 3 months ago (2014-09-05 22:13:35 UTC) #29
miu
lgtm https://codereview.chromium.org/478543003/diff/120001/content/browser/web_contents/web_contents_impl.cc File content/browser/web_contents/web_contents_impl.cc (right): https://codereview.chromium.org/478543003/diff/120001/content/browser/web_contents/web_contents_impl.cc#newcode1087 content/browser/web_contents/web_contents_impl.cc:1087: video_power_save_blocker_.reset(); On 2014/09/05 22:13:35, DaleCurtis wrote: > Done. ...
6 years, 3 months ago (2014-09-06 02:51:00 UTC) #30
DaleCurtis
jam, scherkus: Ping? sky to CC since jam@ is owner for all.
6 years, 3 months ago (2014-09-09 00:41:23 UTC) #32
scherkus (not reviewing)
nits and questions lgtm otherwise https://codereview.chromium.org/478543003/diff/140001/content/browser/media/audio_stream_monitor.cc File content/browser/media/audio_stream_monitor.cc (right): https://codereview.chromium.org/478543003/diff/140001/content/browser/media/audio_stream_monitor.cc#newcode44 content/browser/media/audio_stream_monitor.cc:44: CONTENT_EXPORT int WebContentsUserData<AudioStreamMonitor>::kLocatorKey = ...
6 years, 3 months ago (2014-09-09 21:07:41 UTC) #33
DaleCurtis
https://codereview.chromium.org/478543003/diff/140001/content/browser/media/audio_stream_monitor.cc File content/browser/media/audio_stream_monitor.cc (right): https://codereview.chromium.org/478543003/diff/140001/content/browser/media/audio_stream_monitor.cc#newcode44 content/browser/media/audio_stream_monitor.cc:44: CONTENT_EXPORT int WebContentsUserData<AudioStreamMonitor>::kLocatorKey = 0; On 2014/09/09 21:07:41, scherkus ...
6 years, 3 months ago (2014-09-10 00:51:15 UTC) #34
jam
lgtm
6 years, 3 months ago (2014-09-10 18:29:27 UTC) #35
DaleCurtis
I ended up having to drop the WebContentsUserData, I couldn't figure out a clean way ...
6 years, 3 months ago (2014-09-10 22:20:10 UTC) #37
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patchset/478543003/200001
6 years, 3 months ago (2014-09-10 23:18:18 UTC) #39
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patchset/478543003/220001
6 years, 3 months ago (2014-09-11 01:16:44 UTC) #42
commit-bot: I haz the power
Committed patchset #9 (id:220001) as 2a3da1f4c387720dc12c21784ec9af2a1df99100
6 years, 3 months ago (2014-09-11 02:53:09 UTC) #43
commit-bot: I haz the power
Patchset 9 (id:??) landed as https://crrev.com/484d29dcb45ca362fc9049c37dd3a51e11492f14 Cr-Commit-Position: refs/heads/master@{#294303}
6 years, 3 months ago (2014-09-11 03:09:28 UTC) #44
DaleCurtis
Hmm, this got reverted due to some DCHECK failures here: https://codereview.chromium.org/562863002/ Not sure why it ...
6 years, 3 months ago (2014-09-11 18:02:13 UTC) #45
DaleCurtis
6 years, 3 months ago (2014-09-11 19:38:40 UTC) #46
Message was sent while issue was closed.
Turns out the new DCHECKs exposed some bugs, I'll revert the revert after the
fixes land:

https://codereview.chromium.org/564943002/

Powered by Google App Engine
This is Rietveld 408576698