CVSROOT: /cvsroot/gnash
Module name: gnash
Changes by: Udo Giacomozzi <udog> 07/07/03 15:17:32
Modified files:
. : ChangeLog
gui : NullGui.cpp
Log message:
implement proper timing
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3649&r2=1.3650
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/NullGui.cpp?cvsroot=gnash&r1=1.10&r2=1.11
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnash/gnash/ChangeLog,v
retrieving revision 1.3649
retrieving revision 1.3650
diff -u -b -r1.3649 -r1.3650
--- ChangeLog 3 Jul 2007 09:59:15 -0000 1.3649
+++ ChangeLog 3 Jul 2007 15:17:32 -0000 1.3650
@@ -1,5 +1,9 @@
2007-07-03 Udo Giacomozzi <address@hidden>
+ * gui/NullGui.cpp: implement correct timing
+
+2007-07-03 Udo Giacomozzi <address@hidden>
+
* gui/gui.{cpp,h}: add min/avg/max fps printing and total play time
* libbase/GC.h: include assert.h
Index: gui/NullGui.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/gui/NullGui.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- gui/NullGui.cpp 2 Jul 2007 22:10:16 -0000 1.10
+++ gui/NullGui.cpp 3 Jul 2007 15:17:32 -0000 1.11
@@ -35,6 +35,7 @@
#include <sys/time.h> // for gettimeofday
#include <time.h> // for gettimeofday
#include <errno.h> // for reporting gettimeofday errors
+#include "tu_timer.h"
namespace gnash
{
@@ -43,7 +44,7 @@
NullGui::run()
{
struct timeval tv;
-
+ unsigned long prevtimer=0;
if (gettimeofday(&tv, NULL))
{
@@ -52,25 +53,48 @@
}
unsigned long int start_timer = tv.tv_sec*1000 + tv.tv_usec / 1000;
+ prevtimer = start_timer;
+
while (true)
{
- if ( _timeout )
+
+ unsigned long int timer=0;
+
+ while (1)
{
+
if (gettimeofday(&tv, NULL))
{
cerr << "Could not get time of day: " <<
strerror(errno) << endl;
return false;
}
- unsigned long int timer = tv.tv_sec*1000 + tv.tv_usec /
1000;
+ timer = tv.tv_sec*1000 + tv.tv_usec / 1000;
+
+
+ if ( _timeout )
+ {
if ( timer - start_timer > _timeout)
{
break;
}
}
- // sleep for _interval milliseconds
- // TODO: use the timer value to trigger advances
- usleep(_interval*1000);
+ if (_interval==1)
+ break; // special exception for 1 ms interval (run as fast as
possible)
+
+ if (timer - prevtimer >= _interval)
+ break; // next frame, please!
+
+ if (timer < prevtimer) // time glitch protection
+ prevtimer = timer;
+
+ usleep(1);
+
+ }
+
+ prevtimer = timer;
+
+
Gui::advance_movie(this);
// when runnign gnash with -1 switch ::advance_movie() will
call ::quit()
_______________________________________________
Gnash-commit mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/gnash-commit