<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[55657] trunk/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/55657">55657</a></dd>
<dt>Author</dt> <dd>philn@webkit.org</dd>
<dt>Date</dt> <dd>2010-03-08 00:13:58 -0800 (Mon, 08 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>2010-03-04  Philippe Normand  &lt;pnormand@igalia.com&gt;

        Reviewed by Eric Seidel.

        [GStreamer] replace g_idle_add / g_timeout_add calls with Timers in the gstreamer player
        https://bugs.webkit.org/show_bug.cgi?id=35735

        Replaced g_idle_add calls with Timers immediately started once
        only. The g_timeout_add was replaced by a periodic Timer.

        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
        (WebCore::MediaPlayerPrivate::MediaPlayerPrivate):
        (WebCore::MediaPlayerPrivate::~MediaPlayerPrivate):
        (WebCore::MediaPlayerPrivate::volumeChangedTimerFired):
        (WebCore::MediaPlayerPrivate::volumeChanged):
        (WebCore::MediaPlayerPrivate::processBufferingStats):
        (WebCore::MediaPlayerPrivate::fillTimerFired):
        (WebCore::MediaPlayerPrivate::maxTimeLoaded):
        (WebCore::MediaPlayerPrivate::updateStates):
        (WebCore::MediaPlayerPrivate::muteChangedTimerFired):
        (WebCore::MediaPlayerPrivate::muteChanged):
        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamercpp">trunk/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp</a></li>
<li><a href="#trunkWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerh">trunk/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (55656 => 55657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2010-03-08 06:55:55 UTC (rev 55656)
+++ trunk/WebCore/ChangeLog        2010-03-08 08:13:58 UTC (rev 55657)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2010-03-04  Philippe Normand  &lt;pnormand@igalia.com&gt;
+
+        Reviewed by Eric Seidel.
+
+        [GStreamer] replace g_idle_add / g_timeout_add calls with Timers in the gstreamer player
+        https://bugs.webkit.org/show_bug.cgi?id=35735
+
+        Replaced g_idle_add calls with Timers immediately started once
+        only. The g_timeout_add was replaced by a periodic Timer.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivate::MediaPlayerPrivate):
+        (WebCore::MediaPlayerPrivate::~MediaPlayerPrivate):
+        (WebCore::MediaPlayerPrivate::volumeChangedTimerFired):
+        (WebCore::MediaPlayerPrivate::volumeChanged):
+        (WebCore::MediaPlayerPrivate::processBufferingStats):
+        (WebCore::MediaPlayerPrivate::fillTimerFired):
+        (WebCore::MediaPlayerPrivate::maxTimeLoaded):
+        (WebCore::MediaPlayerPrivate::updateStates):
+        (WebCore::MediaPlayerPrivate::muteChangedTimerFired):
+        (WebCore::MediaPlayerPrivate::muteChanged):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+
</ins><span class="cx"> 2010-03-07  David Levin  &lt;levin@chromium.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Chromium Linux build fix.
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamercpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (55656 => 55657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp        2010-03-08 06:55:55 UTC (rev 55656)
+++ trunk/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp        2010-03-08 08:13:58 UTC (rev 55657)
</span><span class="lines">@@ -177,13 +177,6 @@
</span><span class="cx">     mp-&gt;volumeChanged();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-gboolean notifyVolumeIdleCallback(gpointer data)
-{
-    MediaPlayerPrivate* mp = reinterpret_cast&lt;MediaPlayerPrivate*&gt;(data);
-    mp-&gt;volumeChangedCallback();
-    return FALSE;
-}
-
</del><span class="cx"> void mediaPlayerPrivateMuteChangedCallback(GObject *element, GParamSpec *pspec, gpointer data)
</span><span class="cx"> {
</span><span class="cx">     // This is called when playbin receives the notify::mute signal.
</span><span class="lines">@@ -191,19 +184,6 @@
</span><span class="cx">     mp-&gt;muteChanged();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-gboolean notifyMuteIdleCallback(gpointer data)
-{
-    MediaPlayerPrivate* mp = reinterpret_cast&lt;MediaPlayerPrivate*&gt;(data);
-    mp-&gt;muteChangedCallback();
-    return FALSE;
-}
-
-gboolean bufferingTimeoutCallback(gpointer data)
-{
-    MediaPlayerPrivate* mp = reinterpret_cast&lt;MediaPlayerPrivate*&gt;(data);
-    return mp-&gt;queryBufferingStats();
-}
-
</del><span class="cx"> static float playbackPosition(GstElement* playbin)
</span><span class="cx"> {
</span><span class="cx"> 
</span><span class="lines">@@ -307,11 +287,9 @@
</span><span class="cx">     , m_seeking(false)
</span><span class="cx">     , m_playbackRate(1)
</span><span class="cx">     , m_errorOccured(false)
</span><del>-    , m_volumeIdleId(0)
</del><span class="cx">     , m_mediaDuration(0)
</span><del>-    , m_muteIdleId(0)
</del><span class="cx">     , m_startedBuffering(false)
</span><del>-    , m_fillTimeoutId(0)
</del><ins>+    , m_fillTimer(this, &amp;MediaPlayerPrivate::fillTimerFired)
</ins><span class="cx">     , m_maxTimeLoaded(0)
</span><span class="cx">     , m_fillStatus(0)
</span><span class="cx"> {
</span><span class="lines">@@ -321,21 +299,9 @@
</span><span class="cx"> 
</span><span class="cx"> MediaPlayerPrivate::~MediaPlayerPrivate()
</span><span class="cx"> {
</span><del>-    if (m_fillTimeoutId) {
-        g_source_remove(m_fillTimeoutId);
-        m_fillTimeoutId = 0;
-    }
</del><ins>+    if (m_fillTimer.isActive())
+        m_fillTimer.stop();
</ins><span class="cx"> 
</span><del>-    if (m_volumeIdleId) {
-        g_source_remove(m_volumeIdleId);
-        m_volumeIdleId = 0;
-    }
-
-    if (m_muteIdleId) {
-        g_source_remove(m_muteIdleId);
-        m_muteIdleId = 0;
-    }
-
</del><span class="cx">     if (m_buffer)
</span><span class="cx">         gst_buffer_unref(m_buffer);
</span><span class="cx">     m_buffer = 0;
</span><span class="lines">@@ -591,7 +557,7 @@
</span><span class="cx">     g_object_set(m_playBin, &quot;volume&quot;, static_cast&lt;double&gt;(volume), NULL);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MediaPlayerPrivate::volumeChangedCallback()
</del><ins>+void MediaPlayerPrivate::volumeChangedTimerFired(Timer&lt;MediaPlayerPrivate&gt;*)
</ins><span class="cx"> {
</span><span class="cx">     double volume;
</span><span class="cx">     g_object_get(m_playBin, &quot;volume&quot;, &amp;volume, NULL);
</span><span class="lines">@@ -600,9 +566,8 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivate::volumeChanged()
</span><span class="cx"> {
</span><del>-    if (m_volumeIdleId)
-        g_source_remove(m_volumeIdleId);
-    m_volumeIdleId = g_idle_add((GSourceFunc) notifyVolumeIdleCallback, this);
</del><ins>+    Timer&lt;MediaPlayerPrivate&gt; volumeChangedTimer(this, &amp;MediaPlayerPrivate::volumeChangedTimerFired);
+    volumeChangedTimer.startOneShot(0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivate::setRate(float rate)
</span><span class="lines">@@ -688,20 +653,20 @@
</span><span class="cx">     if (!m_startedBuffering) {
</span><span class="cx">         m_startedBuffering = true;
</span><span class="cx"> 
</span><del>-        if (m_fillTimeoutId &gt; 0)
-            g_source_remove(m_fillTimeoutId);
</del><ins>+        if (m_fillTimer.isActive())
+            m_fillTimer.stop();
</ins><span class="cx"> 
</span><del>-        m_fillTimeoutId = g_timeout_add(200, (GSourceFunc) bufferingTimeoutCallback, this);
</del><ins>+        m_fillTimer.startRepeating(0.2);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool MediaPlayerPrivate::queryBufferingStats()
</del><ins>+void MediaPlayerPrivate::fillTimerFired(Timer&lt;MediaPlayerPrivate&gt;*)
</ins><span class="cx"> {
</span><span class="cx">     GstQuery* query = gst_query_new_buffering(GST_FORMAT_PERCENT);
</span><span class="cx"> 
</span><span class="cx">     if (!gst_element_query(m_playBin, query)) {
</span><span class="cx">         gst_query_unref(query);
</span><del>-        return TRUE;
</del><ins>+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     gint64 start, stop;
</span><span class="lines">@@ -728,16 +693,15 @@
</span><span class="cx"> 
</span><span class="cx">     if (m_fillStatus != 100.0) {
</span><span class="cx">         updateStates();
</span><del>-        return TRUE;
</del><ins>+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Media is now fully loaded. It will play even if network
</span><span class="cx">     // connection is cut. Buffering is done, remove the fill source
</span><span class="cx">     // from the main loop.
</span><del>-    m_fillTimeoutId = 0;
</del><ins>+    m_fillTimer.stop();
</ins><span class="cx">     m_startedBuffering = false;
</span><span class="cx">     updateStates();
</span><del>-    return FALSE;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> float MediaPlayerPrivate::maxTimeSeekable() const
</span><span class="lines">@@ -759,7 +723,7 @@
</span><span class="cx">         return 0.0;
</span><span class="cx"> 
</span><span class="cx">     float loaded = m_maxTimeLoaded;
</span><del>-    if (!loaded &amp;&amp; !m_fillTimeoutId)
</del><ins>+    if (!loaded &amp;&amp; !m_fillTimer.isActive())
</ins><span class="cx">         loaded = duration();
</span><span class="cx">     LOG_VERBOSE(Media, &quot;maxTimeLoaded: %f&quot;, loaded);
</span><span class="cx">     return loaded;
</span><span class="lines">@@ -850,7 +814,7 @@
</span><span class="cx">             m_paused = true;
</span><span class="cx"> 
</span><span class="cx">         // Is on-disk buffering in progress?
</span><del>-        if (m_fillTimeoutId) {
</del><ins>+        if (m_fillTimer.isActive()) {
</ins><span class="cx">             m_networkState = MediaPlayer::Loading;
</span><span class="cx">             // Buffering has just started, we should now have enough
</span><span class="cx">             // data to restart playback if it was internally paused by
</span><span class="lines">@@ -1114,7 +1078,7 @@
</span><span class="cx">     g_object_set(m_playBin, &quot;mute&quot;, muted, NULL);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MediaPlayerPrivate::muteChangedCallback()
</del><ins>+void MediaPlayerPrivate::muteChangedTimerFired(Timer&lt;MediaPlayerPrivate&gt;*)
</ins><span class="cx"> {
</span><span class="cx">     gboolean muted;
</span><span class="cx">     g_object_get(m_playBin, &quot;mute&quot;, &amp;muted, NULL);
</span><span class="lines">@@ -1123,10 +1087,8 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivate::muteChanged()
</span><span class="cx"> {
</span><del>-    if (m_muteIdleId)
-        g_source_remove(m_muteIdleId);
-
-    m_muteIdleId = g_idle_add((GSourceFunc) notifyMuteIdleCallback, this);
</del><ins>+    Timer&lt;MediaPlayerPrivate&gt; muteChangedTimer(this, &amp;MediaPlayerPrivate::muteChangedTimerFired);
+    muteChangedTimer.startOneShot(0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivate::loadingFailed(MediaPlayer::NetworkState error)
</span></span></pre></div>
<a id="trunkWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (55656 => 55657)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h        2010-03-08 06:55:55 UTC (rev 55656)
+++ trunk/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h        2010-03-08 08:13:58 UTC (rev 55657)
</span><span class="lines">@@ -80,15 +80,15 @@
</span><span class="cx"> 
</span><span class="cx">             void setVolume(float);
</span><span class="cx">             void volumeChanged();
</span><del>-            void volumeChangedCallback();
</del><ins>+            void volumeChangedTimerFired(Timer&lt;MediaPlayerPrivate&gt;*);
</ins><span class="cx"> 
</span><span class="cx">             bool supportsMuting() const;
</span><span class="cx">             void setMuted(bool);
</span><span class="cx">             void muteChanged();
</span><del>-            void muteChangedCallback();
</del><ins>+            void muteChangedTimerFired(Timer&lt;MediaPlayerPrivate&gt;*);
</ins><span class="cx"> 
</span><span class="cx">             void setPreload(MediaPlayer::Preload);
</span><del>-            bool queryBufferingStats();
</del><ins>+            void fillTimerFired(Timer&lt;MediaPlayerPrivate&gt;*);
</ins><span class="cx"> 
</span><span class="cx">             MediaPlayer::NetworkState networkState() const;
</span><span class="cx">             MediaPlayer::ReadyState readyState() const;
</span><span class="lines">@@ -160,11 +160,9 @@
</span><span class="cx">             bool m_seeking;
</span><span class="cx">             float m_playbackRate;
</span><span class="cx">             bool m_errorOccured;
</span><del>-            guint m_volumeIdleId;
</del><span class="cx">             gfloat m_mediaDuration;
</span><del>-            guint m_muteIdleId;
</del><span class="cx">             bool m_startedBuffering;
</span><del>-            guint m_fillTimeoutId;
</del><ins>+            Timer&lt;MediaPlayerPrivate&gt; m_fillTimer;
</ins><span class="cx">             float m_maxTimeLoaded;
</span><span class="cx">             gdouble m_fillStatus;
</span><span class="cx">     };
</span></span></pre>
</div>
</div>

</body>
</html>