Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 850943002: Remove MediaPlayer::invalidTime() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/html/MediaController.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 , m_duration(std::numeric_limits<double>::quiet_NaN()) 343 , m_duration(std::numeric_limits<double>::quiet_NaN())
344 , m_lastTimeUpdateEventWallTime(0) 344 , m_lastTimeUpdateEventWallTime(0)
345 , m_lastTimeUpdateEventMovieTime(0) 345 , m_lastTimeUpdateEventMovieTime(0)
346 , m_defaultPlaybackStartPosition(0) 346 , m_defaultPlaybackStartPosition(0)
347 , m_loadState(WaitingForSource) 347 , m_loadState(WaitingForSource)
348 , m_deferredLoadState(NotDeferred) 348 , m_deferredLoadState(NotDeferred)
349 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) 349 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired)
350 , m_webLayer(nullptr) 350 , m_webLayer(nullptr)
351 , m_preload(MediaPlayer::Auto) 351 , m_preload(MediaPlayer::Auto)
352 , m_displayMode(Unknown) 352 , m_displayMode(Unknown)
353 , m_cachedTime(MediaPlayer::invalidTime()) 353 , m_cachedTime(std::numeric_limits<double>::quiet_NaN())
354 , m_fragmentEndTime(MediaPlayer::invalidTime()) 354 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN())
355 , m_pendingActionFlags(0) 355 , m_pendingActionFlags(0)
356 , m_userGestureRequiredForPlay(false) 356 , m_userGestureRequiredForPlay(false)
357 , m_playing(false) 357 , m_playing(false)
358 , m_shouldDelayLoadEvent(false) 358 , m_shouldDelayLoadEvent(false)
359 , m_haveFiredLoadedData(false) 359 , m_haveFiredLoadedData(false)
360 , m_autoplaying(true) 360 , m_autoplaying(true)
361 , m_muted(false) 361 , m_muted(false)
362 , m_paused(true) 362 , m_paused(true)
363 , m_seeking(false) 363 , m_seeking(false)
364 , m_sentStalledEvent(false) 364 , m_sentStalledEvent(false)
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 scheduleEvent(EventTypeNames::loadedmetadata); 1845 scheduleEvent(EventTypeNames::loadedmetadata);
1846 1846
1847 bool jumped = false; 1847 bool jumped = false;
1848 if (m_defaultPlaybackStartPosition > 0) { 1848 if (m_defaultPlaybackStartPosition > 0) {
1849 seek(m_defaultPlaybackStartPosition); 1849 seek(m_defaultPlaybackStartPosition);
1850 jumped = true; 1850 jumped = true;
1851 } 1851 }
1852 m_defaultPlaybackStartPosition = 0; 1852 m_defaultPlaybackStartPosition = 0;
1853 1853
1854 double initialPlaybackPosition = fragmentParser.startTime(); 1854 double initialPlaybackPosition = fragmentParser.startTime();
1855 if (initialPlaybackPosition == MediaPlayer::invalidTime()) 1855 if (std::isnan(initialPlaybackPosition))
1856 initialPlaybackPosition = 0; 1856 initialPlaybackPosition = 0;
1857 1857
1858 if (!jumped && initialPlaybackPosition > 0) { 1858 if (!jumped && initialPlaybackPosition > 0) {
1859 m_sentEndEvent = false; 1859 m_sentEndEvent = false;
1860 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFrag mentStart); 1860 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFrag mentStart);
1861 seek(initialPlaybackPosition); 1861 seek(initialPlaybackPosition);
1862 jumped = true; 1862 jumped = true;
1863 } 1863 }
1864 1864
1865 if (m_mediaController) { 1865 if (m_mediaController) {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 { 2096 {
2097 if (!webMediaPlayer() || m_readyState < HAVE_METADATA) 2097 if (!webMediaPlayer() || m_readyState < HAVE_METADATA)
2098 return; 2098 return;
2099 2099
2100 m_cachedTime = webMediaPlayer()->currentTime(); 2100 m_cachedTime = webMediaPlayer()->currentTime();
2101 } 2101 }
2102 2102
2103 void HTMLMediaElement::invalidateCachedTime() 2103 void HTMLMediaElement::invalidateCachedTime()
2104 { 2104 {
2105 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime(%p)", this); 2105 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime(%p)", this);
2106 m_cachedTime = MediaPlayer::invalidTime(); 2106 m_cachedTime = std::numeric_limits<double>::quiet_NaN();
2107 } 2107 }
2108 2108
2109 // playback state 2109 // playback state
2110 double HTMLMediaElement::currentTime() const 2110 double HTMLMediaElement::currentTime() const
2111 { 2111 {
2112 if (m_defaultPlaybackStartPosition) 2112 if (m_defaultPlaybackStartPosition)
2113 return m_defaultPlaybackStartPosition; 2113 return m_defaultPlaybackStartPosition;
2114 2114
2115 if (m_readyState == HAVE_NOTHING) 2115 if (m_readyState == HAVE_NOTHING)
2116 return 0; 2116 return 0;
2117 2117
2118 if (m_seeking) { 2118 if (m_seeking) {
2119 WTF_LOG(Media, "HTMLMediaElement::currentTime(%p) - seeking, returning % f", this, m_lastSeekTime); 2119 WTF_LOG(Media, "HTMLMediaElement::currentTime(%p) - seeking, returning % f", this, m_lastSeekTime);
2120 return m_lastSeekTime; 2120 return m_lastSeekTime;
2121 } 2121 }
2122 2122
2123 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { 2123 if (!std::isnan(m_cachedTime) && m_paused) {
2124 #if LOG_CACHED_TIME_WARNINGS 2124 #if LOG_CACHED_TIME_WARNINGS
2125 static const double minCachedDeltaForWarning = 0.01; 2125 static const double minCachedDeltaForWarning = 0.01;
2126 double delta = m_cachedTime - webMediaPlayer()->currentTime(); 2126 double delta = m_cachedTime - webMediaPlayer()->currentTime();
2127 if (delta > minCachedDeltaForWarning) 2127 if (delta > minCachedDeltaForWarning)
2128 WTF_LOG(Media, "HTMLMediaElement::currentTime(%p) - WARNING, cached time is %f seconds off of media time when paused", this, delta); 2128 WTF_LOG(Media, "HTMLMediaElement::currentTime(%p) - WARNING, cached time is %f seconds off of media time when paused", this, delta);
2129 #endif 2129 #endif
2130 return m_cachedTime; 2130 return m_cachedTime;
2131 } 2131 }
2132 2132
2133 refreshCachedTime(); 2133 refreshCachedTime();
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 return; 2486 return;
2487 2487
2488 m_previousProgressTime = WTF::currentTime(); 2488 m_previousProgressTime = WTF::currentTime();
2489 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER E); 2489 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER E);
2490 } 2490 }
2491 2491
2492 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) 2492 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*)
2493 { 2493 {
2494 ASSERT(m_player); 2494 ASSERT(m_player);
2495 2495
2496 if (m_fragmentEndTime != MediaPlayer::invalidTime() && currentTime() >= m_fr agmentEndTime && directionOfPlayback() == Forward) { 2496 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) {
2497 m_fragmentEndTime = MediaPlayer::invalidTime(); 2497 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN();
2498 if (!m_mediaController && !m_paused) { 2498 if (!m_mediaController && !m_paused) {
2499 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra gmentEnd); 2499 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra gmentEnd);
2500 // changes paused to true and fires a simple event named pause at th e media element. 2500 // changes paused to true and fires a simple event named pause at th e media element.
2501 pause(); 2501 pause();
2502 } 2502 }
2503 } 2503 }
2504 2504
2505 if (!m_seeking) 2505 if (!m_seeking)
2506 scheduleTimeupdateEvent(true); 2506 scheduleTimeupdateEvent(true);
2507 2507
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
4115 4115
4116 #if ENABLE(WEB_AUDIO) 4116 #if ENABLE(WEB_AUDIO)
4117 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 4117 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
4118 { 4118 {
4119 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 4119 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
4120 audioSourceProvider()->setClient(nullptr); 4120 audioSourceProvider()->setClient(nullptr);
4121 } 4121 }
4122 #endif 4122 #endif
4123 4123
4124 } 4124 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/MediaController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698