Changeset 190815 in webkit


Ignore:
Timestamp:
Oct 9, 2015, 12:58:42 PM (10 years ago)
Author:
bshafiei@apple.com
Message:

Roll out r190434. rdar://problem/22865007

Location:
branches/safari-601.1.46-branch
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-601.1.46-branch/LayoutTests/ChangeLog

    r190814 r190815  
     12015-10-09  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Roll out r190434.
     4
    152015-10-09  Babak Shafiei  <bshafiei@apple.com>
    26
  • branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt

    r190792 r190815  
    77EVENT(playing)
    88EXPECTED (video.paused == 'false') OK
    9 RUN(internals.beginMediaSessionInterruption('System'))
     9RUN(internals.beginMediaSessionInterruption())
    1010
    1111100ms timer fired...
     
    1717
    1818EXPECTED (video.paused == 'false') OK
    19 RUN(internals.beginMediaSessionInterruption('System'))
     19RUN(internals.beginMediaSessionInterruption())
    2020
    2121100ms timer fired...
  • branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play.html

    r190792 r190815  
    1313                    testExpected("video.paused", false);
    1414                    state = "interrupted";
    15                     run("internals.beginMediaSessionInterruption('System')");;
     15                    run("internals.beginMediaSessionInterruption()");;
    1616                    setTimeout(checkState, 100);
    1717                    consoleWrite("");
  • branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play-expected.txt

    r190792 r190815  
    66
    77EVENT(playing)
    8 RUN(internals.beginMediaSessionInterruption('System'))
     8RUN(internals.beginMediaSessionInterruption())
    99
    1010100ms timer fired...
  • branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play.html

    r190792 r190815  
    88            function playing()
    99            {
    10                 run("internals.beginMediaSessionInterruption('System')");;
     10                run("internals.beginMediaSessionInterruption()");;
    1111                setTimeout(checkState, 100);
    1212            }
  • branches/safari-601.1.46-branch/Source/WebCore/ChangeLog

    r190813 r190815  
     12015-10-09  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Roll out r190434.
     4
    152015-10-09  Babak Shafiei  <bshafiei@apple.com>
    26
  • branches/safari-601.1.46-branch/Source/WebCore/Modules/webaudio/AudioContext.h

    r190792 r190815  
    323323    virtual bool canReceiveRemoteControlCommands() const override { return false; }
    324324    virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override { }
    325     bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override { return false; }
     325    virtual bool overrideBackgroundPlaybackRestriction() const override { return false; }
    326326
    327327    // EventTarget
  • branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp

    r190792 r190815  
    63286328void HTMLMediaElement::suspendPlayback()
    63296329{
    6330     LOG(Media, "HTMLMediaElement::suspendPlayback(%p) - paused = %s", this, boolString(paused()));
     6330    LOG(Media, "HTMLMediaElement::pausePlayback(%p) - paused = %s", this, boolString(paused()));
    63316331    if (!paused())
    63326332        pause();
     
    63356335void HTMLMediaElement::mayResumePlayback(bool shouldResume)
    63366336{
    6337     LOG(Media, "HTMLMediaElement::mayResumePlayback(%p) - paused = %s", this, boolString(paused()));
     6337    LOG(Media, "HTMLMediaElement::resumePlayback(%p) - paused = %s", this, boolString(paused()));
    63386338    if (paused() && shouldResume)
    63396339        play();
     
    63776377}
    63786378
    6379 bool HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType type) const
    6380 {
    6381     if (type != PlatformMediaSession::EnteringBackground)
    6382         return false;
    6383 
     6379bool HTMLMediaElement::overrideBackgroundPlaybackRestriction() const
     6380{
    63846381#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    63856382    if (m_player && m_player->isCurrentPlaybackTargetWireless())
  • branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.h

    r190792 r190815  
    726726    virtual bool canReceiveRemoteControlCommands() const override { return true; }
    727727    virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override;
    728     bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override;
     728    virtual bool overrideBackgroundPlaybackRestriction() const override;
    729729
    730730    virtual void pageMutedStateDidChange() override;
  • branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp

    r190792 r190815  
    4040static const char* stateName(PlatformMediaSession::State state)
    4141{
    42 #define STATE_CASE(state) case PlatformMediaSession::state: return #state
     42#define CASE(state) case PlatformMediaSession::state: return #state
    4343    switch (state) {
    44     STATE_CASE(Idle);
    45     STATE_CASE(Playing);
    46     STATE_CASE(Paused);
    47     STATE_CASE(Interrupted);
    48     }
    49 
    50     ASSERT_NOT_REACHED();
    51     return "";
    52 }
    53 
    54 static const char* interruptionName(PlatformMediaSession::InterruptionType type)
    55 {
    56 #define INTERRUPTION_CASE(type) case PlatformMediaSession::type: return #type
    57     switch (type) {
    58     INTERRUPTION_CASE(SystemSleep);
    59     INTERRUPTION_CASE(EnteringBackground);
    60     INTERRUPTION_CASE(SystemInterruption);
    61     INTERRUPTION_CASE(SuspendedUnderLock);
    62     }
    63    
     44    CASE(Idle);
     45    CASE(Playing);
     46    CASE(Paused);
     47    CASE(Interrupted);
     48    }
     49
    6450    ASSERT_NOT_REACHED();
    6551    return "";
     
    9480}
    9581
    96 void PlatformMediaSession::beginInterruption(InterruptionType type)
    97 {
    98     LOG(Media, "PlatformMediaSession::beginInterruption(%p), state = %s, interruption type = %s, interruption count = %i", this, stateName(m_state), interruptionName(type), m_interruptionCount);
    99 
    100     if (++m_interruptionCount > 1)
    101         return;
    102 
    103     if (client().shouldOverrideBackgroundPlaybackRestriction(type))
    104         return;
    105 
     82void PlatformMediaSession::doInterruption()
     83{
    10684    m_stateToRestore = state();
    10785    m_notifyingClient = true;
     
    10987    client().suspendPlayback();
    11088    m_notifyingClient = false;
     89}
     90
     91bool PlatformMediaSession::shouldDoInterruption(InterruptionType type)
     92{
     93    return type != EnteringBackground || !client().overrideBackgroundPlaybackRestriction();
     94}
     95
     96void PlatformMediaSession::beginInterruption(InterruptionType type)
     97{
     98    LOG(Media, "PlatformMediaSession::beginInterruption(%p), state = %s, interruption count = %i", this, stateName(m_state), m_interruptionCount);
     99
     100    if (++m_interruptionCount > 1 || !shouldDoInterruption(type))
     101        return;
     102
     103    doInterruption();
     104}
     105
     106void PlatformMediaSession::forceInterruption(InterruptionType type)
     107{
     108    LOG(Media, "PlatformMediaSession::forceInterruption(%p), state = %s, interruption count = %i", this, stateName(m_state), m_interruptionCount);
     109
     110    // beginInterruption() must have been called before calling this function.
     111    if (!m_interruptionCount) {
     112        ASSERT_NOT_REACHED();
     113        return;
     114    }
     115
     116    // The purpose of this function is to override the decision which was made by
     117    // beginInterruption(). If it was decided to interrupt the media session there,
     118    // then nothing should be done here.
     119    if (shouldDoInterruption(type))
     120        return;
     121
     122    doInterruption();
    111123}
    112124
  • branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.h

    r190812 r190815  
    7575        EnteringBackground,
    7676        SystemInterruption,
    77         SuspendedUnderLock,
    7877    };
    7978    enum EndInterruptionFlags {
     
    8281    };
    8382
     83    void doInterruption();
     84    bool shouldDoInterruption(InterruptionType);
    8485    void beginInterruption(InterruptionType);
     86    void forceInterruption(InterruptionType);
    8587    void endInterruption(EndInterruptionFlags);
    8688
     
    178180    virtual bool elementIsHidden() const { return false; }
    179181
    180     virtual bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const = 0;
     182    virtual bool overrideBackgroundPlaybackRestriction() const = 0;
    181183
    182184    virtual void wirelessRoutesAvailableDidChange() { }
  • branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp

    r190812 r190815  
    290290}
    291291
     292void PlatformMediaSessionManager::applicationDidEnterBackground(bool isSuspendedUnderLock) const
     293{
     294    LOG(Media, "PlatformMediaSessionManager::applicationDidEnterBackground");
     295
     296    if (!isSuspendedUnderLock)
     297        return;
     298
     299    Vector<PlatformMediaSession*> sessions = m_sessions;
     300    for (auto* session : sessions) {
     301        if (m_restrictions[session->mediaType()] & BackgroundProcessPlaybackRestricted)
     302            session->forceInterruption(PlatformMediaSession::EnteringBackground);
     303    }
     304}
     305
    292306void PlatformMediaSessionManager::applicationWillEnterForeground() const
    293307{
     
    311325        return;
    312326
    313     if (session.state() != PlatformMediaSession::Interrupted)
    314         session.beginInterruption(PlatformMediaSession::EnteringBackground);
     327    if (session.state() != PlatformMediaSession::Interrupted && session.shouldDoInterruption(PlatformMediaSession::EnteringBackground))
     328        session.doInterruption();
    315329}
    316330
  • branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h

    r190812 r190815  
    5757    WEBCORE_EXPORT void applicationWillEnterForeground() const;
    5858    WEBCORE_EXPORT void applicationWillEnterBackground() const;
     59    WEBCORE_EXPORT void applicationDidEnterBackground(bool isSuspendedUnderLock) const;
    5960
    6061    void stopAllMediaPlaybackForDocument(const Document*);
  • branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h

    r190812 r190815  
    4949    void externalOutputDeviceAvailableDidChange();
    5050    virtual bool hasWirelessTargetsAvailable() override;
    51     void applicationDidEnterBackground(bool isSuspendedUnderLock);
    5251
    5352private:
  • branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm

    r190812 r190815  
    249249}
    250250
    251 void MediaSessionManageriOS::applicationDidEnterBackground(bool isSuspendedUnderLock)
    252 {
    253     LOG(Media, "MediaSessionManageriOS::applicationDidEnterBackground");
    254 
    255     if (!isSuspendedUnderLock)
    256         return;
    257 
    258     Vector<PlatformMediaSession*> sessions = this->sessions();
    259     for (auto* session : sessions) {
    260         if (restrictions(session->mediaType()) & BackgroundProcessPlaybackRestricted)
    261             session->beginInterruption(PlatformMediaSession::SuspendedUnderLock);
    262     }
    263 }
    264 
    265 
    266251} // namespace WebCore
    267252
  • branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.cpp

    r190813 r190815  
    26152615
    26162616#if ENABLE(VIDEO)
    2617 void Internals::beginMediaSessionInterruption(const String& interruptionString, ExceptionCode& ec)
    2618 {
    2619     PlatformMediaSession::InterruptionType interruption = PlatformMediaSession::SystemInterruption;
    2620 
    2621     if (equalIgnoringCase(interruptionString, "System"))
    2622         interruption = PlatformMediaSession::SystemInterruption;
    2623     else if (equalIgnoringCase(interruptionString, "SystemSleep"))
    2624         interruption = PlatformMediaSession::SystemSleep;
    2625     else if (equalIgnoringCase(interruptionString, "EnteringBackground"))
    2626         interruption = PlatformMediaSession::EnteringBackground;
    2627     else {
    2628         ec = INVALID_ACCESS_ERR;
    2629         return;
    2630     }
    2631 
     2617void Internals::beginMediaSessionInterruption()
     2618{
    26322619    PlatformMediaSessionManager::sharedManager().beginInterruption(PlatformMediaSession::SystemInterruption);
    26332620}
  • branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.h

    r190812 r190815  
    383383
    384384#if ENABLE(VIDEO)
    385     void beginMediaSessionInterruption(const String&, ExceptionCode&);
     385    void beginMediaSessionInterruption();
    386386    void endMediaSessionInterruption(const String&);
    387387    void applicationWillEnterForeground() const;
  • branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.idl

    r190812 r190815  
    350350    [Conditional=MEDIA_SOURCE] DOMString[] bufferedSamplesForTrackID(SourceBuffer buffer, DOMString trackID);
    351351
    352     [Conditional=VIDEO, RaisesException] void beginMediaSessionInterruption(DOMString interruptionType);
     352    [Conditional=VIDEO] void beginMediaSessionInterruption();
    353353    [Conditional=VIDEO] void endMediaSessionInterruption(DOMString flags);
    354354    [Conditional=VIDEO] void applicationWillEnterForeground();
Note: See TracChangeset for help on using the changeset viewer.