[maemo-commits] [maemo-commits] r17705 - in projects/haf/trunk/hildon-welcome: . debian src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Mar 17 12:52:18 EET 2009
- Previous message: [maemo-commits] r17704 - in projects/haf/trunk/libmatchbox2: . matchbox/client-types matchbox/core
- Next message: [maemo-commits] r17706 - projects/haf/tags/hildon-welcome
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: schulhof Date: 2009-03-17 12:52:10 +0200 (Tue, 17 Mar 2009) New Revision: 17705 Modified: projects/haf/trunk/hildon-welcome/configure.ac projects/haf/trunk/hildon-welcome/debian/changelog projects/haf/trunk/hildon-welcome/src/main.c Log: Modified: projects/haf/trunk/hildon-welcome/configure.ac =================================================================== --- projects/haf/trunk/hildon-welcome/configure.ac 2009-03-17 10:43:27 UTC (rev 17704) +++ projects/haf/trunk/hildon-welcome/configure.ac 2009-03-17 10:52:10 UTC (rev 17705) @@ -1,5 +1,5 @@ # Mandatory, inits autoconf -AC_INIT(hildon-welcome, 0.13) +AC_INIT(hildon-welcome, 0.14) # Tests that source dir exists AC_CONFIG_SRCDIR([src/main.c]) @@ -7,8 +7,6 @@ # Initialize automake AM_INIT_AUTOMAKE -AC_CANONICAL_HOST - AC_PROG_CC AC_PROG_INSTALL AC_C_CONST Modified: projects/haf/trunk/hildon-welcome/debian/changelog =================================================================== --- projects/haf/trunk/hildon-welcome/debian/changelog 2009-03-17 10:43:27 UTC (rev 17704) +++ projects/haf/trunk/hildon-welcome/debian/changelog 2009-03-17 10:52:10 UTC (rev 17705) @@ -1,3 +1,10 @@ +hildon-welcome (0.14-1) unstable; urgency=low + + * Steel timeouts against sudden date changes into the future with a per-timeout GTimer + * Use a global GTimer to give debug/warning/error messages timestamps + + -- Gabriel Schulhof <gabriel.schulhof at nokia.com> Fri, 13 Mar 2009 13:34:17 +0200 + hildon-welcome (0.13-1) unstable; urgency=low * Added command line parsing for 3 options: -a for audio pipeline, -v for video pipeline, Modified: projects/haf/trunk/hildon-welcome/src/main.c =================================================================== --- projects/haf/trunk/hildon-welcome/src/main.c 2009-03-17 10:43:27 UTC (rev 17704) +++ projects/haf/trunk/hildon-welcome/src/main.c 2009-03-17 10:52:10 UTC (rev 17705) @@ -34,7 +34,7 @@ #endif /* HAVE_MCE */ #include "conffile.h" -#define KILL_TO_LENGTH_MS 45000 +#define KILL_TO_LENGTH_MS 30000 #define DEFAULT_VIDEO_PIPELINE_STR " playbin2 uri=file://%s " /* " flags=99 " <-- doesn't work with still images */ #define DEFAULT_AUDIO_PIPELINE_STR " filesrc location=%s ! decodebin2 ! autoaudiosink " @@ -43,27 +43,64 @@ static char *video_pipeline_str = DEFAULT_VIDEO_PIPELINE_STR; static char *audio_pipeline_str = DEFAULT_AUDIO_PIPELINE_STR; static char *shush_pipeline_str = DEFAULT_SHUSH_PIPELINE_STR; +static GTimer *global_timer = NULL; -static GTimer *timer = NULL; - typedef struct { + GTimer *timer; + guint to_ms; GstElement *pipeline; guint timeout_id; - char *error; + const char *error; } TimeoutParams; static gboolean post_eos(TimeoutParams *tp) { + if (tp->timer) { + double diff_ms = ((double)(tp->to_ms)) - (g_timer_elapsed(tp->timer, NULL) * 1000.0); + if (diff_ms > 0) { + g_warning("[%lf]: post_eos: False alarm! %lf ms () left\n", g_timer_elapsed(global_timer, NULL), diff_ms); + tp->timeout_id = g_timeout_add((guint)diff_ms, (GSourceFunc)post_eos, tp); + return FALSE; + } + } if (tp->error) - g_error("[%lf]: post_eos: %s", g_timer_elapsed(timer, NULL), tp->error); + g_error("[%lf]: post_eos: %s", g_timer_elapsed(global_timer, NULL), tp->error); gst_bus_post(gst_pipeline_get_bus(GST_PIPELINE(tp->pipeline)), gst_message_new_eos(GST_OBJECT(tp->pipeline))); + tp->timeout_id = 0; + if (tp->timer) { + g_timer_destroy(tp->timer); + tp->timer = NULL; + } return FALSE; } static void +post_eos_timeout_add(guint to_ms, GstElement *pipeline, char *error, TimeoutParams *params) +{ + params->to_ms = to_ms; + params->pipeline = pipeline; + params->error = error; + params->timer = g_timer_new(); + params->timeout_id = g_timeout_add(to_ms, (GSourceFunc)post_eos, params); +} + +static void +post_eos_timeout_remove(TimeoutParams *params) +{ + if (params->timeout_id) { + g_source_remove(params->timeout_id); + params->timeout_id = 0; + } + if (params->timer) { + g_timer_destroy(params->timer); + params->timer = NULL; + } +} + +static void wait_for_eos(GstElement *pipeline, Window dst_window, int duration, TimeoutParams *play_to) { GError *err = NULL; @@ -77,14 +114,14 @@ switch(GST_MESSAGE_TYPE(message)) { case GST_MESSAGE_ASYNC_DONE: - g_debug("[%lf]: wait_for_eos: Ready to play: duration = %d\n", g_timer_elapsed(timer, NULL), duration); + g_debug("[%lf]: wait_for_eos: Ready to play: duration = %d\n", g_timer_elapsed(global_timer, NULL), duration); if ((duration > 500) && !(play_to->timeout_id)) - play_to->timeout_id = g_timeout_add(duration, (GSourceFunc)post_eos, play_to); + post_eos_timeout_add(duration, pipeline, NULL, play_to); break; case GST_MESSAGE_ERROR: gst_message_parse_error(message, &err, &debug); - g_warning("[%lf]: wait_for_eos: %s: %s %s\n", g_timer_elapsed(timer, NULL), GST_MESSAGE_TYPE_NAME(message), err ? err->message : "", debug ? debug : ""); + g_warning("[%lf]: wait_for_eos: %s: %s %s\n", g_timer_elapsed(global_timer, NULL), GST_MESSAGE_TYPE_NAME(message), err ? err->message : "", debug ? debug : ""); if (err) g_error_free(err); g_free(debug); @@ -92,7 +129,7 @@ case GST_MESSAGE_EOS: keep_looping = FALSE; gst_element_set_state(pipeline, GST_STATE_PAUSED); - g_debug("[%lf]: wait_for_eos: Gst message: %s", g_timer_elapsed(timer, NULL), GST_MESSAGE_TYPE_NAME(message)); + g_debug("[%lf]: wait_for_eos: Gst message: %s", g_timer_elapsed(global_timer, NULL), GST_MESSAGE_TYPE_NAME(message)); break; case GST_MESSAGE_ELEMENT: @@ -131,7 +168,7 @@ GstElement* pipeline = NULL; GString *pipeline_str = g_string_new(""); - g_debug("[%lf]: play_logo: playing (video = '%s', audio = '%s', duration = '%d')", g_timer_elapsed(timer, NULL), video, audio, duration); + g_debug("[%lf]: play_logo: playing (video = '%s', audio = '%s', duration = '%d')", g_timer_elapsed(global_timer, NULL), video, audio, duration); if (video && video[0]) g_string_append_printf(pipeline_str, video_pipeline_str, video); @@ -147,16 +184,16 @@ g_string_free(pipeline_str, TRUE); if (pipeline) { - TimeoutParams kill_to = { pipeline, 0, "Absolute timeout reached!\n" }, play_to = { pipeline, 0, NULL }; + TimeoutParams kill_to, play_to; - kill_to.timeout_id = g_timeout_add(KILL_TO_LENGTH_MS, (GSourceFunc)post_eos, &kill_to); + post_eos_timeout_add(KILL_TO_LENGTH_MS, pipeline, "Absolute timeout reached!\n", &kill_to); gst_element_set_state(pipeline, GST_STATE_PLAYING); unblank_screen(); wait_for_eos(pipeline, dst_window, duration, &play_to); - if (kill_to.timeout_id) g_source_remove(kill_to.timeout_id); - if (play_to.timeout_id) g_source_remove(play_to.timeout_id); + post_eos_timeout_remove(&kill_to); + post_eos_timeout_remove(&play_to); } return pipeline; @@ -238,12 +275,12 @@ gst_init(&argc, &argv); - timer = g_timer_new(); + global_timer = g_timer_new(); if (!(display = XOpenDisplay(NULL))) - g_error("[%lf]: main: Failed to open display\n", g_timer_elapsed(timer, NULL)); + g_error("[%lf]: main: Failed to open display\n", g_timer_elapsed(global_timer, NULL)); if ((dst_window = DefaultRootWindow(display)) == 0) - g_error("[%lf]: Failed to obtain root window\n", g_timer_elapsed(timer, NULL)); + g_error("[%lf]: Failed to obtain root window\n", g_timer_elapsed(global_timer, NULL)); if ((xcomposite_window = XCompositeGetOverlayWindow(display, dst_window)) != 0) dst_window = xcomposite_window; @@ -275,7 +312,7 @@ gst_deinit(); - g_timer_destroy(timer); + g_timer_destroy(global_timer); return 0; }
- Previous message: [maemo-commits] r17704 - in projects/haf/trunk/libmatchbox2: . matchbox/client-types matchbox/core
- Next message: [maemo-commits] r17706 - projects/haf/tags/hildon-welcome
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]