⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249008 in webkit


Ignore:
Timestamp:
Aug 22, 2019, 8:45:26 AM (7 years ago)
Author:
Kocsen Chung
Message:

Cherry-pick r248962. rdar://problem/54579627

Adopt AVSystemController_ActiveAudioRouteDidChangeNotification
https://bugs.webkit.org/show_bug.cgi?id=200992
<rdar://problem/54408993>

Reviewed by Eric Carlson.

When the system notifies us that the active audio route has changed in such a way
that necessitates pausing, pause all media sessions, exempting those that are
associated with WebRTC, since "pausing" an active audio conference isn't really
possible.

  • Modules/mediastream/MediaStream.h:
  • platform/audio/PlatformMediaSession.cpp: (WebCore::PlatformMediaSession::shouldOverridePauseDuringRouteChange const):
  • platform/audio/PlatformMediaSession.h: (WebCore::PlatformMediaSessionClient::shouldOverridePauseDuringRouteChange const):
  • platform/audio/ios/MediaSessionManagerIOS.h:
  • platform/audio/ios/MediaSessionManagerIOS.mm: (WebCore::MediaSessionManageriOS::activeRouteDidChange): (-[WebMediaSessionHelper initWithCallback:]): (-[WebMediaSessionHelper activeAudioRouteDidChange:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248962 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-608-branch/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-608-branch/Source/WebCore/ChangeLog

    r248988 r249008  
     12019-08-21  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r248962. rdar://problem/54579627
     4
     5    Adopt AVSystemController_ActiveAudioRouteDidChangeNotification
     6    https://bugs.webkit.org/show_bug.cgi?id=200992
     7    <rdar://problem/54408993>
     8   
     9    Reviewed by Eric Carlson.
     10   
     11    When the system notifies us that the active audio route has changed in such a way
     12    that necessitates pausing, pause all media sessions, exempting those that are
     13    associated with WebRTC, since "pausing" an active audio conference isn't really
     14    possible.
     15   
     16    * Modules/mediastream/MediaStream.h:
     17    * platform/audio/PlatformMediaSession.cpp:
     18    (WebCore::PlatformMediaSession::shouldOverridePauseDuringRouteChange const):
     19    * platform/audio/PlatformMediaSession.h:
     20    (WebCore::PlatformMediaSessionClient::shouldOverridePauseDuringRouteChange const):
     21    * platform/audio/ios/MediaSessionManagerIOS.h:
     22    * platform/audio/ios/MediaSessionManagerIOS.mm:
     23    (WebCore::MediaSessionManageriOS::activeRouteDidChange):
     24    (-[WebMediaSessionHelper initWithCallback:]):
     25    (-[WebMediaSessionHelper activeAudioRouteDidChange:]):
     26   
     27   
     28    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     29
     30    2019-08-21  Jer Noble  <jer.noble@apple.com>
     31
     32            Adopt AVSystemController_ActiveAudioRouteDidChangeNotification
     33            https://bugs.webkit.org/show_bug.cgi?id=200992
     34            <rdar://problem/54408993>
     35
     36            Reviewed by Eric Carlson.
     37
     38            When the system notifies us that the active audio route has changed in such a way
     39            that necessitates pausing, pause all media sessions, exempting those that are
     40            associated with WebRTC, since "pausing" an active audio conference isn't really
     41            possible.
     42
     43            * Modules/mediastream/MediaStream.h:
     44            * platform/audio/PlatformMediaSession.cpp:
     45            (WebCore::PlatformMediaSession::shouldOverridePauseDuringRouteChange const):
     46            * platform/audio/PlatformMediaSession.h:
     47            (WebCore::PlatformMediaSessionClient::shouldOverridePauseDuringRouteChange const):
     48            * platform/audio/ios/MediaSessionManagerIOS.h:
     49            * platform/audio/ios/MediaSessionManagerIOS.mm:
     50            (WebCore::MediaSessionManageriOS::activeRouteDidChange):
     51            (-[WebMediaSessionHelper initWithCallback:]):
     52            (-[WebMediaSessionHelper activeAudioRouteDidChange:]):
     53
    1542019-08-21  Kocsen Chung  <kocsen_chung@apple.com>
    255
  • branches/safari-608-branch/Source/WebCore/Modules/mediastream/MediaStream.h

    r246470 r249008  
    166166    Document* hostingDocument() const final { return document(); }
    167167    bool processingUserGestureForMedia() const final;
     168    bool shouldOverridePauseDuringRouteChange() const { return true; }
    168169
    169170    // ActiveDOMObject API.
  • branches/safari-608-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp

    r245712 r249008  
    394394}
    395395
     396bool PlatformMediaSession::shouldOverridePauseDuringRouteChange() const
     397{
     398    return m_client.shouldOverridePauseDuringRouteChange();
     399}
     400
    396401#if !RELEASE_LOG_DISABLED
    397402WTFLogChannel& PlatformMediaSession::logChannel() const
  • branches/safari-608-branch/Source/WebCore/platform/audio/PlatformMediaSession.h

    r247118 r249008  
    193193
    194194    bool canPlayConcurrently(const PlatformMediaSession&) const;
     195    bool shouldOverridePauseDuringRouteChange() const;
    195196
    196197protected:
     
    262263    virtual void processIsSuspendedChanged() { }
    263264
     265    virtual bool shouldOverridePauseDuringRouteChange() const { return false; }
     266
    264267protected:
    265268    virtual ~PlatformMediaSessionClient() = default;
  • branches/safari-608-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h

    r245947 r249008  
    5151    void carPlayServerDied();
    5252    void updateCarPlayIsConnected(Optional<bool>&&);
     53    void activeRouteDidChange(Optional<bool>&&);
    5354#endif
    5455
  • branches/safari-608-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm

    r245947 r249008  
    6161SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_CarPlayIsConnectedNotificationParameter, NSString *)
    6262SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_ServerConnectionDiedNotification, NSString *)
     63SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_ActiveAudioRouteDidChangeNotification, NSString *)
     64SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_ActiveAudioRouteDidChangeNotificationParameter_ShouldPause, NSString *)
    6365#endif
    6466
     
    223225
    224226    setIsPlayingToAutomotiveHeadUnit([[[getAVSystemControllerClass() sharedAVSystemController] attributeForKey:getAVSystemController_CarPlayIsConnectedAttribute()] boolValue]);
     227}
     228
     229void MediaSessionManageriOS::activeRouteDidChange(Optional<bool>&& shouldPause)
     230{
     231    if (!shouldPause || !shouldPause.value())
     232        return;
     233
     234    forEachSession([](auto& session) {
     235        if (!session.shouldOverridePauseDuringRouteChange())
     236            session.pauseSession();
     237    });
    225238}
    226239#endif
     
    255268    if (canLoadAVSystemController_CarPlayIsConnectedDidChangeNotification())
    256269        [center addObserver:self selector:@selector(carPlayIsConnectedDidChange:) name:getAVSystemController_CarPlayIsConnectedDidChangeNotification() object:nil];
     270    if (canLoadAVSystemController_ActiveAudioRouteDidChangeNotification())
     271        [center addObserver:self selector:@selector(activeAudioRouteDidChange:) name:getAVSystemController_ActiveAudioRouteDidChangeNotification() object:nil];
    257272#endif
    258273
     
    485500    });
    486501}
     502
     503- (void)activeAudioRouteDidChange:(NSNotification *)notification
     504{
     505    if (!_callback)
     506        return;
     507
     508    UNUSED_PARAM(notification);
     509    Optional<bool> shouldPause;
     510    if (notification && canLoadAVSystemController_ActiveAudioRouteDidChangeNotificationParameter_ShouldPause()) {
     511        NSNumber* nsShouldPause = [notification.userInfo valueForKey:getAVSystemController_ActiveAudioRouteDidChangeNotificationParameter_ShouldPause()];
     512        if (nsShouldPause)
     513            shouldPause = nsShouldPause.boolValue;
     514    }
     515
     516    callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), shouldPause = WTFMove(shouldPause)]() mutable {
     517        if (auto* callback = protectedSelf->_callback)
     518            callback->activeRouteDidChange(WTFMove(shouldPause));
     519    });
     520
     521}
    487522#endif // HAVE(CELESTIAL)
    488523@end
Note: See TracChangeset for help on using the changeset viewer.