ftime weirdness
#1
hi,

i'm trying to add support for live555 library (latest version 2006-02-25). compilation and linking went fine but i'm stuck with a problem
involving the function ftime(). here is an exemple to reproduce
the problem. edit file osdep/gettimeofday.c (mplayer tree):
Quote:#include "../config.h"

#ifndef have_gettimeofday
#include <sys/time.h>
#include <sys/timeb.h>
void gettimeofday(struct timeval* t,void* timezone)
{       struct timeb timebuffer;
       ftime( &timebuffer );
       t->tv_sec=timebuffer.time;
       t->tv_usec=1000*timebuffer.millitm;
printf("gettimeofday: %li %li\n", t->tv_sec, t->tv_usec);
 double test = (double) (t->tv_sec + t->tv_usec/1000000.0);
printf("test: %f\n", test);
}
#endif
edit mplayer.c in function mplayer_init (line 1299) to make a call
to gettimeofday():
Quote:   blit_frame=0;
#endif //!_xbox

struct timeval t;
gettimeofday(&t);

 srand((int) time(null));

 mp_msg_init();
 mp_msg_set_level(msgl_status);
this code should make a double containing seconds.miliseconds
when compiled as a windows exe, everything is ok. i get the
following log:
Quote:gettimeofday: 1140981237 787000
test: 1140981237.787000
mplayer dev-cvs-060224-08:44-3.4.5 &copy; 2000-2004 mplayer team
cpu: intel pentium 4/xeon/celeron foster (family: 8, stepping: 9)
when compiled as mplayer.dll and executed on my xbox, xbmc.log
tells me:
Quote:26-02-2006 19:37:58 debug   msg:mplayer_init()
26-02-2006 19:37:58 debug   msg:enable mplayer osd
26-02-2006 19:37:58 debug   msg:gettimeofday: 1140979078 699000
26-02-2006 19:37:58 debug   msg:test: 1140979072.000000
26-02-2006 19:37:58 debug   msg:mplayer dev-cvs-060223-20:02-3.4.5 &copy; 2000-2004 mplayer team
the result of the sum stored in the double test is false. does the
timeb struct have different sizes on windows and on my xbox ?
that would explain the corruption of the sum.
is there a way to fix that problem as the function gettimeofday()
(so does ftime()) and the trick to store the result in a double is called
everytime in the live555 library.

thanks.
Reply

Logout Mark Read Team Forum Stats Members Help
ftime weirdness0