Title: [179869] trunk
Revision
179869
Author
[email protected]
Date
2015-02-10 07:47:51 -0800 (Tue, 10 Feb 2015)

Log 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.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (179868 => 179869)


--- trunk/LayoutTests/ChangeLog	2015-02-10 14:42:26 UTC (rev 179868)
+++ trunk/LayoutTests/ChangeLog	2015-02-10 15:47:51 UTC (rev 179869)
@@ -1,3 +1,14 @@
+2015-02-10  Eric Carlson  <[email protected]>
+
+        [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.
+
+        * 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.
+
 2015-02-10  Marcos Chavarría Teijeiro  <[email protected]>
 
         Unreviewed GTK Gardening.

Modified: trunk/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt (179868 => 179869)


--- trunk/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt	2015-02-10 14:42:26 UTC (rev 179868)
+++ trunk/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt	2015-02-10 15:47:51 UTC (rev 179869)
@@ -15,5 +15,15 @@
 EVENT(playing)
 EXPECTED (video.paused == 'false') OK
 
+EXPECTED (video.paused == 'false') OK
+RUN(internals.beginMediaSessionInterruption())
+
+100ms timer fired...
+EXPECTED (video.paused == 'true') OK
+RUN(internals.endMediaSessionInterruption('MayResumePlaying'))
+
+EVENT(playing)
+EXPECTED (video.paused == 'false') OK
+
 END OF TEST
 

Modified: trunk/LayoutTests/media/video-interruption-with-resume-allowing-play.html (179868 => 179869)


--- trunk/LayoutTests/media/video-interruption-with-resume-allowing-play.html	2015-02-10 14:42:26 UTC (rev 179868)
+++ trunk/LayoutTests/media/video-interruption-with-resume-allowing-play.html	2015-02-10 15:47:51 UTC (rev 179869)
@@ -4,6 +4,7 @@
         <script src=""
         <script>
             var state = 0;
+            var resumeCount = 0;
 
             function checkState()
             {
@@ -15,6 +16,7 @@
                     setTimeout(checkState, 100);
                     consoleWrite("");
                     break;
+
                 case "interrupted":
                     consoleWrite("100ms timer fired...");
                     testExpected("video.paused", true);
@@ -22,10 +24,14 @@
                     run("internals.endMediaSessionInterruption('MayResumePlaying')");
                     consoleWrite("");
                     break;
+
                 case "resuming":
                     testExpected("video.paused", false);
                     consoleWrite("");
-                    endTest();
+                    if (++resumeCount == 2)
+                        endTest();
+                    state = "playing";
+                    setTimeout(checkState, 100);
                     break;
                 }
             }

Modified: trunk/Source/WebCore/ChangeLog (179868 => 179869)


--- trunk/Source/WebCore/ChangeLog	2015-02-10 14:42:26 UTC (rev 179868)
+++ trunk/Source/WebCore/ChangeLog	2015-02-10 15:47:51 UTC (rev 179869)
@@ -1,3 +1,17 @@
+2015-02-10  Eric Carlson  <[email protected]>
+
+        [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.
+
+        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:
+
 2015-02-10  Carlos Garcia Campos  <[email protected]>
 
         [GTK] GMutexLocker build issue

Modified: trunk/Source/WebCore/platform/audio/MediaSession.cpp (179868 => 179869)


--- trunk/Source/WebCore/platform/audio/MediaSession.cpp	2015-02-10 14:42:26 UTC (rev 179868)
+++ trunk/Source/WebCore/platform/audio/MediaSession.cpp	2015-02-10 15:47:51 UTC (rev 179869)
@@ -81,9 +81,9 @@
 
 void MediaSession::beginInterruption(InterruptionType type)
 {
-    LOG(Media, "MediaSession::beginInterruption(%p), state = %s", this, stateName(m_state));
+    LOG(Media, "MediaSession::beginInterruption(%p), state = %s, interruption count = %i", this, stateName(m_state), m_interruptionCount);
 
-    if (type == EnteringBackground && client().overrideBackgroundPlaybackRestriction())
+    if (++m_interruptionCount > 1 || (type == EnteringBackground && client().overrideBackgroundPlaybackRestriction()))
         return;
 
     m_stateToRestore = state();
@@ -95,8 +95,16 @@
 
 void MediaSession::endInterruption(EndInterruptionFlags flags)
 {
-    LOG(Media, "MediaSession::endInterruption(%p) - flags = %i, stateToRestore = %s", this, (int)flags, stateName(m_stateToRestore));
+    LOG(Media, "MediaSession::endInterruption(%p) - flags = %i, stateToRestore = %s, interruption count = %i", this, (int)flags, stateName(m_stateToRestore), m_interruptionCount);
 
+    if (!m_interruptionCount) {
+        LOG(Media, "MediaSession::endInterruption(%p) - !! ignoring spurious interruption end !!", this);
+        return;
+    }
+
+    if (--m_interruptionCount)
+        return;
+
     State stateToRestore = m_stateToRestore;
     m_stateToRestore = Idle;
     setState(Paused);

Modified: trunk/Source/WebCore/platform/audio/MediaSession.h (179868 => 179869)


--- trunk/Source/WebCore/platform/audio/MediaSession.h	2015-02-10 14:42:26 UTC (rev 179868)
+++ trunk/Source/WebCore/platform/audio/MediaSession.h	2015-02-10 15:47:51 UTC (rev 179869)
@@ -122,6 +122,7 @@
     Timer m_clientDataBufferingTimer;
     State m_state;
     State m_stateToRestore;
+    int m_interruptionCount { 0 };
     bool m_notifyingClient;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to