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

Changeset 179869 in webkit


Ignore:
Timestamp:
Feb 10, 2015, 7:47:51 AM (12 years ago)
Author:
eric.carlson@apple.com
Message:

[iOS] don't get out of sync when interrupt/resume calls are not balanced
https://bugs.webkit.org/show_bug.cgi?id=141310

Reviewed by Jer Noble.

Source/WebCore:

No new tests, updated media/video-interruption-with-resume-allowing-play.html.

  • platform/audio/MediaSession.cpp:

(WebCore::MediaSession::beginInterruption): Count interruptions.
(WebCore::MediaSession::endInterruption): Ignore calls when m_interruptionCount is already zero.

  • platform/audio/MediaSession.h:

LayoutTests:

  • media/video-interruption-with-resume-allowing-play-expected.txt:
  • media/video-interruption-with-resume-allowing-play.html: Updated to test unbalanced calls

to begin/end interruption.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r179868 r179869  
     12015-02-10  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [iOS] don't get out of sync when interrupt/resume calls are not balanced
     4        https://bugs.webkit.org/show_bug.cgi?id=141310
     5
     6        Reviewed by Jer Noble.
     7
     8        * media/video-interruption-with-resume-allowing-play-expected.txt:
     9        * media/video-interruption-with-resume-allowing-play.html: Updated to test unbalanced calls
     10            to begin/end interruption.
     11
    1122015-02-10  Marcos Chavarría Teijeiro  <chavarria1991@gmail.com>
    213
  • trunk/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt

    r163390 r179869  
    1616EXPECTED (video.paused == 'false') OK
    1717
     18EXPECTED (video.paused == 'false') OK
     19RUN(internals.beginMediaSessionInterruption())
     20
     21100ms timer fired...
     22EXPECTED (video.paused == 'true') OK
     23RUN(internals.endMediaSessionInterruption('MayResumePlaying'))
     24
     25EVENT(playing)
     26EXPECTED (video.paused == 'false') OK
     27
    1828END OF TEST
    1929
  • trunk/LayoutTests/media/video-interruption-with-resume-allowing-play.html

    r163390 r179869  
    55        <script>
    66            var state = 0;
     7            var resumeCount = 0;
    78
    89            function checkState()
     
    1617                    consoleWrite("");
    1718                    break;
     19
    1820                case "interrupted":
    1921                    consoleWrite("100ms timer fired...");
     
    2325                    consoleWrite("");
    2426                    break;
     27
    2528                case "resuming":
    2629                    testExpected("video.paused", false);
    2730                    consoleWrite("");
    28                     endTest();
     31                    if (++resumeCount == 2)
     32                        endTest();
     33                    state = "playing";
     34                    setTimeout(checkState, 100);
    2935                    break;
    3036                }
  • trunk/Source/WebCore/ChangeLog

    r179866 r179869  
     12015-02-10  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [iOS] don't get out of sync when interrupt/resume calls are not balanced
     4        https://bugs.webkit.org/show_bug.cgi?id=141310
     5
     6        Reviewed by Jer Noble.
     7
     8        No new tests, updated media/video-interruption-with-resume-allowing-play.html.
     9
     10        * platform/audio/MediaSession.cpp:
     11        (WebCore::MediaSession::beginInterruption): Count interruptions.
     12        (WebCore::MediaSession::endInterruption): Ignore calls when m_interruptionCount is already zero.
     13        * platform/audio/MediaSession.h:
     14
    1152015-02-10  Carlos Garcia Campos  <cgarcia@igalia.com>
    216
  • trunk/Source/WebCore/platform/audio/MediaSession.cpp

    r176459 r179869  
    8282void MediaSession::beginInterruption(InterruptionType type)
    8383{
    84     LOG(Media, "MediaSession::beginInterruption(%p), state = %s", this, stateName(m_state));
    85 
    86     if (type == EnteringBackground && client().overrideBackgroundPlaybackRestriction())
     84    LOG(Media, "MediaSession::beginInterruption(%p), state = %s, interruption count = %i", this, stateName(m_state), m_interruptionCount);
     85
     86    if (++m_interruptionCount > 1 || (type == EnteringBackground && client().overrideBackgroundPlaybackRestriction()))
    8787        return;
    8888
     
    9696void MediaSession::endInterruption(EndInterruptionFlags flags)
    9797{
    98     LOG(Media, "MediaSession::endInterruption(%p) - flags = %i, stateToRestore = %s", this, (int)flags, stateName(m_stateToRestore));
     98    LOG(Media, "MediaSession::endInterruption(%p) - flags = %i, stateToRestore = %s, interruption count = %i", this, (int)flags, stateName(m_stateToRestore), m_interruptionCount);
     99
     100    if (!m_interruptionCount) {
     101        LOG(Media, "MediaSession::endInterruption(%p) - !! ignoring spurious interruption end !!", this);
     102        return;
     103    }
     104
     105    if (--m_interruptionCount)
     106        return;
    99107
    100108    State stateToRestore = m_stateToRestore;
  • trunk/Source/WebCore/platform/audio/MediaSession.h

    r176459 r179869  
    123123    State m_state;
    124124    State m_stateToRestore;
     125    int m_interruptionCount { 0 };
    125126    bool m_notifyingClient;
    126127};
Note: See TracChangeset for help on using the changeset viewer.