Do not cache media time until media engine returns a non-zero value
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Feb 2014 18:43:49 +0000 (18:43 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Feb 2014 18:43:49 +0000 (18:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128976

Reviewed by Jer Noble.

No new tests, covered by existing tests.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::refreshCachedTime): Don't mark the cached time as valid
    until it is non-zero.

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

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h

index 893a7b6..1024ece 100644 (file)
@@ -1,3 +1,16 @@
+2014-02-18  Eric Carlson  <eric.carlson@apple.com>
+
+        Do not cache media time until media engine returns a non-zero value
+        https://bugs.webkit.org/show_bug.cgi?id=128976
+
+        Reviewed by Jer Noble.
+
+        No new tests, covered by existing tests.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::refreshCachedTime): Don't mark the cached time as valid
+            until it is non-zero.
+
 2014-02-18  Mihai Tica  <mitica@adobe.com>
 
         [CSS Blending] Add -webkit-blend-mode support for SVG.
index 1dd2534..ef08354 100644 (file)
@@ -2439,10 +2439,18 @@ bool HTMLMediaElement::seeking() const
 void HTMLMediaElement::refreshCachedTime() const
 {
     m_cachedTime = m_player->currentTime();
+    if (!m_cachedTime) {
+        // Do not use m_cachedTime until the media engine returns a non-zero value because we can't
+        // estimate current time until playback actually begins.
+        invalidateCachedTime();
+        return;
+    }
+
+    LOG(Media, "HTMLMediaElement::refreshCachedTime - caching time %f", m_cachedTime);
     m_clockTimeAtLastCachedTimeUpdate = monotonicallyIncreasingTime();
 }
 
-void HTMLMediaElement::invalidateCachedTime()
+void HTMLMediaElement::invalidateCachedTime() const
 {
     LOG(Media, "HTMLMediaElement::invalidateCachedTime");
 
index b8a46db..ee8a28a 100644 (file)
@@ -653,7 +653,7 @@ private:
     virtual void mediaCanStart() override;
 
     void setShouldDelayLoadEvent(bool);
-    void invalidateCachedTime();
+    void invalidateCachedTime() const;
     void refreshCachedTime() const;
 
     bool hasMediaControls() const;