From: Charles Brej Date: Sun, 12 Oct 2008 19:53:56 +0000 (+0100) Subject: Set appropreate wakeup_time to stop using 100% CPU. X-Git-Tag: 0.6.0~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea1ba09015221dd6d65beda67d4e57cf2f7dec16;p=thirdparty%2Fplymouth.git Set appropreate wakeup_time to stop using 100% CPU. --- diff --git a/src/libply/ply-event-loop.c b/src/libply/ply-event-loop.c index 31d6016f..ac200bbe 100644 --- a/src/libply/ply-event-loop.c +++ b/src/libply/ply-event-loop.c @@ -893,7 +893,9 @@ ply_event_loop_stop_watching_for_timeout (ply_event_loop_t *loop, void *user_data) { ply_list_node_t *node; - + + loop->wakeup_time = PLY_EVENT_LOOP_NO_TIMED_WAKEUP; + node = ply_list_get_first_node (loop->timeout_watches); while (node != NULL) { @@ -908,6 +910,12 @@ ply_event_loop_stop_watching_for_timeout (ply_event_loop_t *loop, ply_list_remove_node (loop->timeout_watches, node); free (timeout_watch); } + else { + if (fabs (loop->wakeup_time - PLY_EVENT_LOOP_NO_TIMED_WAKEUP) <= 0) + loop->wakeup_time = timeout_watch->timeout; + else + loop->wakeup_time = MIN (loop->wakeup_time, timeout_watch->timeout); + } node = next_node; } @@ -1122,6 +1130,7 @@ ply_event_loop_handle_timeouts (ply_event_loop_t *loop) now = ply_get_timestamp (); node = ply_list_get_first_node (loop->timeout_watches); + loop->wakeup_time=PLY_EVENT_LOOP_NO_TIMED_WAKEUP; while (node != NULL) { ply_list_node_t *next_node; @@ -1137,12 +1146,16 @@ ply_event_loop_handle_timeouts (ply_event_loop_t *loop) free (watch); ply_list_remove_node (loop->timeout_watches, node); } + else { + if (fabs (loop->wakeup_time - PLY_EVENT_LOOP_NO_TIMED_WAKEUP) <= 0) + loop->wakeup_time = watch->timeout; + else + loop->wakeup_time = MIN (loop->wakeup_time, watch->timeout); + } node = next_node; } - if (ply_list_get_length (loop->timeout_watches) == 0) - loop->wakeup_time = PLY_EVENT_LOOP_NO_TIMED_WAKEUP; } static void diff --git a/src/plugins/splash/solar/plugin.c b/src/plugins/splash/solar/plugin.c index 83b4b778..9dd0522f 100644 --- a/src/plugins/splash/solar/plugin.c +++ b/src/plugins/splash/solar/plugin.c @@ -57,13 +57,13 @@ #include #ifndef FRAMES_PER_SECOND -#define FRAMES_PER_SECOND 20 +#define FRAMES_PER_SECOND 50 #endif -#define FLARE_FRAMES_PER_SECOND 10 +#define FLARE_FRAMES_PER_SECOND 25 #define FLARE_COUNT 60 #define FLARE_LINE_COUNT 4 -#define HALO_BLUR 6 +#define HALO_BLUR 4 /*you can comment one or both of these out*/ /*#define SHOW_PLANETS */ @@ -755,11 +755,6 @@ start_animation (ply_boot_splash_plugin_t *plugin) ply_frame_buffer_get_size (plugin->frame_buffer, &area); plugin->now = ply_get_timestamp (); - ply_event_loop_watch_for_timeout (plugin->loop, - 1.0 / FRAMES_PER_SECOND, - (ply_event_loop_timeout_handler_t) - on_timeout, plugin); - setup_solar (plugin); on_timeout (plugin); ply_window_draw_area (plugin->window, area.x, area.y, area.width, area.height); @@ -945,7 +940,7 @@ void highlight_image (ply_image_t *highlighted_image, ply_image_t *orig_image, i for (subx=min_x; subx>24; if (current>best) best=current; }