Author: lewing
Date: 2008-01-22 12:31:05 -0500 (Tue, 22 Jan 2008)
New Revision: 93551

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/clock.cpp
Log:
2008-01-22  Larry Ewing  <[EMAIL PROTECTED]>

        * clock.cpp: Tweak clock timing and smoothing.  Increase timer
        priority so that ticks get deliver when we want them this doesn't
        change the smoothing calculation but it can raise the actual fps
        by assuring all our clocks are delivered.  Change smoothing alpha
        from 0.3 to 0.03 to improve noise immunity.  Don't reset the timer
        unless our new calculated timeout differs from our old by at least
        1/50 of a second.  Resetting the clock on every tick had the
        effect adding the drawing time to the tick time for every tick
        since the timeout starts over at zero.


Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2008-01-22 17:17:47 UTC (rev 93550)
+++ trunk/moon/src/ChangeLog    2008-01-22 17:31:05 UTC (rev 93551)
@@ -1,3 +1,15 @@
+2008-01-22  Larry Ewing  <[EMAIL PROTECTED]>
+
+       * clock.cpp: Tweak clock timing and smoothing.  Increase timer
+       priority so that ticks get deliver when we want them this doesn't
+       change the smoothing calculation but it can raise the actual fps
+       by assuring all our clocks are delivered.  Change smoothing alpha
+       from 0.3 to 0.03 to improve noise immunity.  Don't reset the timer
+       unless our new calculated timeout differs from our old by at least
+       1/50 of a second.  Resetting the clock on every tick had the
+       effect adding the drawing time to the tick time for every tick
+       since the timeout starts over at zero.
+
 2008-01-21  Jeffrey Stedfast  <[EMAIL PROTECTED]>
 
        * pipeline.cpp (Mp3FrameReader::ReadFrame): If the bitrate was

Modified: trunk/moon/src/clock.cpp
===================================================================
--- trunk/moon/src/clock.cpp    2008-01-22 17:17:47 UTC (rev 93550)
+++ trunk/moon/src/clock.cpp    2008-01-22 17:31:05 UTC (rev 93551)
@@ -168,7 +168,7 @@
        if (gtk_timeout != -1)
                return;
 
-       gtk_timeout = gtk_timeout_add (frequency, 
SystemTimeSource::tick_timeout, this);
+       gtk_timeout = g_timeout_add_full (G_PRIORITY_HIGH, frequency, 
SystemTimeSource::tick_timeout, this, NULL);
 }
 
 void
@@ -385,9 +385,8 @@
           see http://en.wikipedia.org/wiki/Exponential_smoothing.
        */
 #if USE_SMOOTHING
-#define SMOOTHING_ALPHA 0.30 /* we probably want to play with this value 
some.. - toshok */
+#define SMOOTHING_ALPHA 0.03 /* we probably want to play with this value 
some.. - toshok */
 
-
        TimeSpan xt = post_tick - pre_tick;
 
        /* the s(0) case */
@@ -401,17 +400,21 @@
        TimeSpan current_smoothed = (TimeSpan)(SMOOTHING_ALPHA * xt + (1 - 
SMOOTHING_ALPHA) * previous_smoothed);
 
        /* current_smoothed now contains the prediction for what our next delay 
should be */
+       
+       
+       int suggested_timeout = current_smoothed / 10000;
+       if (suggested_timeout < FPS_TO_DELAY (max_fps))
+               suggested_timeout= FPS_TO_DELAY (max_fps);
+       else if (suggested_timeout > FPS_TO_DELAY (MINIMUM_FPS))
+               suggested_timeout = FPS_TO_DELAY (MINIMUM_FPS);
 
-       current_timeout = current_smoothed / 10000;
-       if (current_timeout < FPS_TO_DELAY (max_fps))
-               current_timeout = FPS_TO_DELAY (max_fps);
-       else if (current_timeout > FPS_TO_DELAY (MINIMUM_FPS))
-               current_timeout = FPS_TO_DELAY (MINIMUM_FPS);
-
        //      printf ("new timeout is %dms (%.2ffps)\n", current_timeout, 
DELAY_TO_FPS (current_timeout));
+       
+       if (ABS(suggested_timeout - current_timeout) > 20) {
+               source->SetTimerFrequency (current_timeout);
+               current_timeout = suggested_timeout;
+       }
 
-       source->SetTimerFrequency (current_timeout);
-
        previous_smoothed = current_smoothed;
 
 #if SHOW_SMOOTHING_COST

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to