Title: [150435] trunk/Source/WebCore
- Revision
- 150435
- Author
- [email protected]
- Date
- 2013-05-21 04:35:54 -0700 (Tue, 21 May 2013)
Log Message
[GStreamer] cleanup duration query
https://bugs.webkit.org/show_bug.cgi?id=116228
Reviewed by Philippe Normand.
Covered by existing tests.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::duration):
We can also cache the duration here if the query succeeds.
(MediaPlayerPrivateGStreamer::updateStates):
Don't query when we are in GST_STATE_READY state because it never succeeds.
Do it instead when we reached a stable state.
(MediaPlayerPrivateGStreamer::cacheDuration): Return early if it is already
cached. Recaching is not necessary and now we call it a lot of times.
Only look into the state if the query failed.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
(MediaPlayerPrivateGStreamer): Made m_mediaDuration mutable to be
able to cache it in duration(). Internal cached values is one of
the sensible uses of mutable.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (150434 => 150435)
--- trunk/Source/WebCore/ChangeLog 2013-05-21 10:55:57 UTC (rev 150434)
+++ trunk/Source/WebCore/ChangeLog 2013-05-21 11:35:54 UTC (rev 150435)
@@ -1,3 +1,26 @@
+2013-05-21 Balazs Kelemen <[email protected]>
+
+ [GStreamer] cleanup duration query
+ https://bugs.webkit.org/show_bug.cgi?id=116228
+
+ Reviewed by Philippe Normand.
+
+ Covered by existing tests.
+
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::MediaPlayerPrivateGStreamer::duration):
+ We can also cache the duration here if the query succeeds.
+ (MediaPlayerPrivateGStreamer::updateStates):
+ Don't query when we are in GST_STATE_READY state because it never succeeds.
+ Do it instead when we reached a stable state.
+ (MediaPlayerPrivateGStreamer::cacheDuration): Return early if it is already
+ cached. Recaching is not necessary and now we call it a lot of times.
+ Only look into the state if the query failed.
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+ (MediaPlayerPrivateGStreamer): Made m_mediaDuration mutable to be
+ able to cache it in duration(). Internal cached values is one of
+ the sensible uses of mutable.
+
2013-05-21 Patrick Gansterer <[email protected]>
Build fix for !USE(ACCELERATED_COMPOSITING) after r150307.
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (150434 => 150435)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2013-05-21 10:55:57 UTC (rev 150434)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2013-05-21 11:35:54 UTC (rev 150435)
@@ -450,7 +450,8 @@
LOG_MEDIA_MESSAGE("Duration: %" GST_TIME_FORMAT, GST_TIME_ARGS(timeLength));
- return static_cast<double>(timeLength) / GST_SECOND;
+ m_mediaDuration = static_cast<double>(timeLength) / GST_SECOND;
+ return m_mediaDuration;
// FIXME: handle 3.14.9.5 properly
}
@@ -1099,17 +1100,16 @@
case GST_STATE_CHANGE_SUCCESS:
LOG_MEDIA_MESSAGE("State: %s, pending: %s", gst_element_state_get_name(state), gst_element_state_get_name(pending));
- m_resetPipeline = state <= GST_STATE_READY;
+ if (state <= GST_STATE_READY) {
+ m_resetPipeline = true;
+ m_mediaDuration = 0;
+ } else
+ cacheDuration();
// Try to figure out ready and network states.
if (state == GST_STATE_READY) {
m_readyState = MediaPlayer::HaveMetadata;
m_networkState = MediaPlayer::Empty;
- // Cache the duration without emiting the durationchange
- // event because it's taken care of by the media element
- // in this precise case.
- if (!m_isEndReached)
- cacheDuration();
} else if ((state == GST_STATE_NULL) || (maxTimeLoaded() == duration())) {
m_networkState = MediaPlayer::Loaded;
m_readyState = MediaPlayer::HaveEnoughData;
@@ -1376,23 +1376,19 @@
void MediaPlayerPrivateGStreamer::cacheDuration()
{
- // Reset cached media duration
- m_mediaDuration = 0;
+ if (m_mediaDuration || !m_mediaDurationKnown)
+ return;
- // And re-cache it if possible.
- GstState state;
- GstStateChangeReturn getStateResult = gst_element_get_state(m_playBin.get(), &state, 0, 0);
float newDuration = duration();
-
- if (state > GST_STATE_READY && getStateResult == GST_STATE_CHANGE_SUCCESS) {
- // Don't set m_mediaDurationKnown yet if the pipeline is not
- // stable. This allows duration() query to fail at least once
- // before playback starts and duration becomes known.
- m_mediaDurationKnown = !std::isinf(newDuration);
+ if (std::isinf(newDuration)) {
+ // Only pretend that duration is not available if the the query failed in a stable pipeline state.
+ GstState state;
+ if (gst_element_get_state(m_playBin.get(), &state, 0, 0) == GST_STATE_CHANGE_SUCCESS && state > GST_STATE_READY)
+ m_mediaDurationKnown = false;
+ return;
}
- if (!std::isinf(newDuration))
- m_mediaDuration = newDuration;
+ m_mediaDuration = newDuration;
}
void MediaPlayerPrivateGStreamer::durationChanged()
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (150434 => 150435)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h 2013-05-21 10:55:57 UTC (rev 150434)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h 2013-05-21 11:35:54 UTC (rev 150435)
@@ -147,7 +147,7 @@
bool m_buffering;
float m_playbackRate;
bool m_errorOccured;
- gfloat m_mediaDuration;
+ mutable gfloat m_mediaDuration;
bool m_startedBuffering;
Timer<MediaPlayerPrivateGStreamer> m_fillTimer;
float m_maxTimeLoaded;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes