Re: [AD] Timer patch

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Kittycat suggested i add explicit casting. I also caught a redefinition of double interval inside the loop. So here's a delta patch. Also now that the interface is based on double.. would it not make sense to change the counters to double rather than as longs (with microsecond precision). Doing this might save accumulating error and will certainly eliminate a lot of casting.

-- Ryan Dickie

On Jan 29, 2008 7:37 PM, Ryan Dickie <goalieca@xxxxxxxxxx> wrote:
On Jan 29, 2008 4:52 PM, Peter Wang <novalazy@xxxxxxxxxx> wrote:
On 2008-01-29, Ryan Dickie <goalieca@xxxxxxxxxx> wrote:
> On Jan 29, 2008 3:34 PM, Ryan Dickie <goalieca@xxxxxxxxxx> wrote:
 >
> > I have made those style changes (and found some dead code as well). See
> > attachment
> >
> > -- Ryan Dickie
> >
>
> Trent tested it out on windows for me. We found a silly typo in the
> wtime.cpatch. I've fixed it. See attached

For future reference, you can use the interdiff program from patchutils
to generate relative diffs.

http://cyberelk.net/tim/software/patchutils/

Peter


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
--
https://lists.sourceforge.net/lists/listinfo/alleg-developers


I've attached another patch for the periodic timers. I've switched them to doubles as well. I did not touch the windows one. The unix timer utimernu.c is now built entirely on portable allegro functions. This code should work for windows as well provided we get windows using a more accurate time and sleep function.

I might have missed this as well in my first patch. No compiler warnings were given but timestamp is probably set using al_current_time(). I switched it to a double.

--- include/allegro5/events.h    (revision 9954)
+++ include/allegro5/events.h    (working copy)
@@ -142,7 +142,7 @@
 #define _AL_EVENT_HEADER(srctype)                    \
    ALLEGRO_EVENT_TYPE type;                          \
    srctype *source;                                  \
-   unsigned long timestamp;                          \
+   double timestamp;                          \
    signed int _refcount;            /* internal */   \
    union ALLEGRO_EVENT *_next;      /* internal */   \
    union ALLEGRO_EVENT *_next_free  /* internal */

-- Ryan Dickie

diff -u src/unix/utimernu.c src/unix/utimernu.c
--- src/unix/utimernu.c	(working copy)
+++ src/unix/utimernu.c	(working copy)
@@ -87,7 +87,7 @@
 
    double old_time = al_current_time();
    double new_time;
-   double interval = 0x8000 / 1000000;
+   double interval = (double) 0x8000 / (double) 1000000;
 
    while (!_al_thread_should_stop(self)) {
       al_rest(interval);
@@ -96,7 +96,7 @@
       {
          /* Calculate actual time elapsed.  */
          new_time = al_current_time();
-         double interval = new_time - old_time;
+         interval = new_time - old_time;
          old_time = new_time;
 
          /* Handle a tick.  */
@@ -115,7 +115,7 @@
  */
 static double timer_thread_handle_tick(double interval)
 {
-   double new_delay = 0x8000 / 1000000;
+   double new_delay = (double) 0x8000 / (double) 1000000;
    unsigned int i;
 
    for (i = 0; i < _al_vector_size(&active_timers); i++) {


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/