]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Interpolate stored boot time with default time
authorRay Strode <rstrode@redhat.com>
Thu, 25 Sep 2008 21:45:30 +0000 (17:45 -0400)
committerRay Strode <rstrode@redhat.com>
Mon, 29 Sep 2008 03:40:31 +0000 (23:40 -0400)
This is so we get a smooth progress bar after
/var/lib/plymouth/boot-duration is read.

src/ply-boot-splash.c

index eb29eb1d2eea5adf784e04aa0365163ae1c272e6..2e47c61f5279c6027080c0d603859e566e75d123 100644 (file)
@@ -18,6 +18,7 @@
  * 02111-1307, USA.
  *
  * Written by: Ray Strode <rstrode@redhat.com>
+ *             Soeren Sandmann <sandmann@redhat.com>
  */
 #include "config.h"
 #include "ply-boot-splash.h"
@@ -205,14 +206,26 @@ static void
 ply_boot_splash_update_progress (ply_boot_splash_t *splash)
 {
   double time_in_seconds;
+  double default_percentage;
   double percentage;
 
   assert (splash != NULL);
 
   time_in_seconds = ply_get_timestamp () - splash->start_time;
 
-  percentage = CLAMP (time_in_seconds / splash->boot_duration,
-                      0.0, 1.0);
+  default_percentage = time_in_seconds / DEFAULT_BOOT_DURATION;
+  percentage = time_in_seconds / splash->boot_duration;
+
+  /* We intepolate the percentage between the real percentage (based
+   * on what's stored on disk) with the default percentage (based on
+   * a 60 second boot time)
+   *
+   * This is because we initially assume 60 seconds until / is mounted,
+   * and we don't want any large jumps
+   */
+  percentage = percentage * percentage + default_percentage * (1.0 - percentage);
+
+  percentage = CLAMP (percentage, 0.0, 1.0);
 
   if (splash->plugin_interface->on_boot_progress != NULL)
     splash->plugin_interface->on_boot_progress (splash->plugin,