Video playback is using more power
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Aug 2018 23:49:11 +0000 (23:49 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Aug 2018 23:49:11 +0000 (23:49 +0000)
commitf5831310b08c03d2d5a14abbafad17a0bddc339f
treed039bdc844528b7efda7306a6884dab522f8326c
parentc6288b93b2f08d1742eb8d4dd814132378a34bb2
Video playback is using more power
https://bugs.webkit.org/show_bug.cgi?id=188452
Source/WebCore:

<rdar://problem/42298937>

Reviewed by Eric Carlson.

Test: TestWebKitAPI/Tests/WebKitCocoa/PreferredAudioBufferSize.mm

When the meaning of PlatformMediaSession::Video changed to "video-only", we failed to update
MediaSessionManagerCocoa::updateSessionState() to use the new PlatformMediaSession::VideoAudio
enum, so Video-only sessions were getting the higher audio buffer size (where it's not needed)
and Video-and-Audio sessions were getting the default value.

To enable testing, add a preferredAudioBufferSize property to Internals. Also, the getter for
AudioSession::preferredBufferSize was using the wrong CoreAudio property address, and was
always returning 0.

* platform/audio/AudioSession.h:
* platform/audio/cocoa/MediaSessionManagerCocoa.cpp:
(MediaSessionManagerCocoa::updateSessionState):
* platform/audio/mac/AudioSessionMac.cpp:
(WebCore::AudioSession::preferredBufferSize const):
* testing/Internals.cpp:
(WebCore::Internals::preferredAudioBufferSize const):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

Reviewed by Eric Carlson.

* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _setLowPowerVideoAudioBufferSizeEnabled:]):
(-[WKPreferences _lowPowerVideoAudioBufferSizeEnabled]):

Tools:

<rdar://problem/42298937>

Reviewed by Eric Carlson.

* TestWebKitAPI/Tests/WebKitCocoa/PreferredAudioBufferSize.mm:
(PreferredAudioBufferSize::createView):
(PreferredAudioBufferSize::preferredAudioBufferSize const):
(TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234743 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/audio/AudioSession.h
Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp
Source/WebCore/platform/audio/mac/AudioSessionMac.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/PreferredAudioBufferSize.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKitCocoa/audio-with-web-audio.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKitCocoa/video-with-audio-and-web-audio.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKitCocoa/web-audio-only.html [new file with mode: 0644]