Video sometimes flickers when playing to AppleTV
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jul 2018 21:49:49 +0000 (21:49 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jul 2018 21:49:49 +0000 (21:49 +0000)
commit1f79fa268f7f84a17de517ae7ea3fe61deda4649
tree7c5a6b974b6c674a32e8db9094ab353ee7687d74
parent823c30c743f4400e1a0bd1ec3d65a1417e841829
Video sometimes flickers when playing to AppleTV
https://bugs.webkit.org/show_bug.cgi?id=187193
<rdar://problem/40153865>

Reviewed by Jer Noble and Youenn Fablet.
Source/WebCore:

No new tests, existing test updated.

Delay 100ms before changing the iOS audio session category because it is an expensive and
potentially disruptive operation, and changing an audio or video element configuration
can result in several quick, ultimately unnecessary, category changes.

* platform/audio/PlatformMediaSession.cpp:
(WebCore::PlatformMediaSession::clientWillBeginPlayback): Add logging.

* platform/audio/PlatformMediaSessionManager.cpp:
(WebCore::PlatformMediaSessionManager::PlatformMediaSessionManager): Initialize timer.
(WebCore::PlatformMediaSessionManager::removeSession): Deactivate audio session when there
are no sessions.
(WebCore::PlatformMediaSessionManager::updateSessionStateTimerFired): New, update session now.
(WebCore::PlatformMediaSessionManager::updateSessionState): Add parameter.
* platform/audio/PlatformMediaSessionManager.h:

* platform/audio/cocoa/MediaSessionManagerCocoa.cpp:
(PlatformMediaSessionManager::updateSessionState): Defer update if it isn't supposed to happen
immediately.

* platform/audio/ios/AudioSessionIOS.mm:
(WebCore::AudioSession::setCategory): Drive-by: setting the audio category to nil is a noop,
so don't waste time doing it.
(WebCore::AudioSession::tryToSetActive): Allow other apps to resume playback when we deactivate
the audio session.

* platform/Timer.h:
(WebCore::DeferrableOneShotTimer): Add WTF_MAKE_FAST_ALLOCATED so it can be used in a unique_ptr.

LayoutTests:

* platform/mac/media/audio-session-category-audio-autoplay.html: Update as audio category
doesn't change immediately.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233435 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/platform/mac/media/audio-session-category-audio-autoplay.html
Source/WebCore/ChangeLog
Source/WebCore/platform/Timer.h
Source/WebCore/platform/audio/PlatformMediaSession.cpp
Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
Source/WebCore/platform/audio/PlatformMediaSessionManager.h
Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp
Source/WebCore/platform/audio/ios/AudioSessionIOS.mm