gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r9907: Initial stage in fixing sleep


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9907: Initial stage in fixing sleep compatibility. Will hopefully allow windows
Date: Fri, 03 Oct 2008 11:50:19 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9907
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2008-10-03 11:50:19 +0200
message:
  Initial stage in fixing sleep compatibility. Will hopefully allow windows
  build to complete.
added:
  libbase/GnashSleep.h
modified:
  gui/NullGui.cpp
  gui/dump.cpp
  gui/fb.cpp
  libbase/LoadThread.cpp
  libbase/Makefile.am
  libbase/curl_adapter.cpp
  libcore/parser/SWFMovieDefinition.cpp
  libmedia/MediaParser.cpp
  utilities/processor.cpp
    ------------------------------------------------------------
    revno: 9906.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Fri 2008-10-03 11:39:44 +0200
    message:
      Add a header file for sleep compatibility. This uses ifdefs at the moment,
      but will use boost::thread::sleep instead if it proves better.
      
      Use gnashSleep method instead of usleep and sleep, drop #ifdefs outside
      libbase.
    added:
      libbase/GnashSleep.h
    modified:
      gui/NullGui.cpp
      gui/dump.cpp
      gui/fb.cpp
      libbase/LoadThread.cpp
      libbase/Makefile.am
      libbase/curl_adapter.cpp
      libcore/parser/SWFMovieDefinition.cpp
      libmedia/MediaParser.cpp
      utilities/processor.cpp
=== modified file 'gui/NullGui.cpp'
--- a/gui/NullGui.cpp   2008-01-21 20:55:39 +0000
+++ b/gui/NullGui.cpp   2008-10-03 09:39:44 +0000
@@ -22,14 +22,8 @@
 
 #include "NullGui.h"
 
-#if defined(_WIN32) || defined(WIN32)
-# include <windows.h>
-# define usleep(x) Sleep(x/1000)
-#else
-# include <unistd.h> // for usleep
-#endif
-
 #include "SystemClock.h"
+#include "GnashSleep.h"
 
 //#include <iostream>
 
@@ -53,8 +47,7 @@
     long rem = _interval-spent;
     if ( rem > 0 )
     {
-      //std::cout << "spent: " << spent << " - rem: " << rem << std::endl;
-      usleep( rem * 1000 );
+      gnashSleep( rem * 1000 );
     }
 
     if ( _timeout && now > _timeout)

=== modified file 'gui/dump.cpp'
--- a/gui/dump.cpp      2008-08-03 09:16:22 +0000
+++ b/gui/dump.cpp      2008-10-03 09:39:44 +0000
@@ -34,6 +34,7 @@
 #include "gnash.h" // for get_sound_handler
 #include "render_handler.h"
 #include "VM.h"
+#include "GnashSleep.h"
 
 #include <iostream>
 #include <string>
@@ -189,7 +190,7 @@
         while (timer_current < timer_nextframe) {
             // sleep for 95% of remaining usecs, floored at 50
             sleep_usecs = (int)((timer_nextframe - timer_current) * 950000.0);
-            usleep((sleep_usecs < 50) ? 50 : sleep_usecs);
+            gnashSleep((sleep_usecs < 50) ? 50 : sleep_usecs);
             if (gettimeofday(&tv, NULL) == 0) {
                 timer_current = (double)tv.tv_sec + (double)tv.tv_usec / 
1000000.0;
             } else {

=== modified file 'gui/fb.cpp'
--- a/gui/fb.cpp        2008-05-27 15:54:46 +0000
+++ b/gui/fb.cpp        2008-10-03 09:39:44 +0000
@@ -90,6 +90,7 @@
 
 #include "render_handler.h"
 #include "render_handler_agg.h"
+#include "GnashSleep.h" // for gnashSleep
 
 #include <linux/input.h>    // for /dev/input/event*
 
@@ -377,7 +378,7 @@
     
     while ((timer-prevtimer)*1000 < _interval) {
     
-      usleep(1); // task switch
+      gnashSleep(1); // task switch
       
       check_mouse(); // TODO: Exit delay loop on mouse events! 
       check_keyboard(); // TODO: Exit delay loop on keyboard events!
@@ -763,7 +764,7 @@
   
   // read response (if any)
   while (count>0) {
-    usleep(250*1000); // 250 ms inter-char timeout (simple method)
+    gnashSleep(250*1000); // 250 ms inter-char timeout (simple method)
     // TODO: use select() instead
     
     n = read(input_fd, buf, count);

=== added file 'libbase/GnashSleep.h'
--- a/libbase/GnashSleep.h      1970-01-01 00:00:00 +0000
+++ b/libbase/GnashSleep.h      2008-10-03 09:39:44 +0000
@@ -0,0 +1,46 @@
+// GnashSleep.h -- How do you sleep?
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+#ifndef GNASH_SLEEP_H
+#define GNASH_SLEEP_H
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h"
+#endif
+
+// Headers for sleep
+#if defined(_WIN32) || defined(WIN32)
+# include <windows.h>
+#else
+# include <unistd.h>
+#endif
+
+namespace gnash {
+
+inline void gnashSleep(size_t useconds)
+{
+#if defined(_WIN32) || defined(WIN32)
+    Sleep(useconds / 1000);
+#else
+    usleep(useconds);
+#endif
+}
+
+} // namespace gnash
+
+#endif

=== modified file 'libbase/LoadThread.cpp'
--- a/libbase/LoadThread.cpp    2008-06-10 07:29:34 +0000
+++ b/libbase/LoadThread.cpp    2008-10-03 09:39:44 +0000
@@ -19,13 +19,7 @@
 
 #include "LoadThread.h"
 #include "log.h"
-
-#if defined(_WIN32) || defined(WIN32)
-# include <windows.h>  // for sleep()
-# define usleep(x) Sleep(x/1000)
-#else
-# include "unistd.h" // for usleep()
-#endif
+#include "GnashSleep.h"
 
 namespace gnash {
 
@@ -121,7 +115,7 @@
 
        while ( (!_completed) && (!cancelRequested()) && _loadPosition < 
static_cast<long>(pos) )
        {
-               usleep(100000); // 1/10 second WATCH FOR TIMEOUTS !
+               gnashSleep(100000); // 1/10 second WATCH FOR TIMEOUTS !
        }
 
        if (_loadPosition >= static_cast<long>(pos))
@@ -329,7 +323,7 @@
 
                // If the read() fuction needs to get access to the stream we 
take a break. 
                if (lt->_needAccess) {
-                       usleep(100000); // 1/10 second
+                       gnashSleep(100000); // 1/10 second
                }
        }
 }

=== modified file 'libbase/Makefile.am'
--- a/libbase/Makefile.am       2008-09-16 11:29:16 +0000
+++ b/libbase/Makefile.am       2008-10-03 09:39:44 +0000
@@ -132,6 +132,7 @@
        GnashImagePng.h \
        GnashImageGif.h \
        GnashImageJpeg.h \
+       GnashSleep.h \
        gmemory.h \
        log.h \
        ogl.h \

=== modified file 'libbase/curl_adapter.cpp'
--- a/libbase/curl_adapter.cpp  2008-10-01 18:17:27 +0000
+++ b/libbase/curl_adapter.cpp  2008-10-03 09:39:44 +0000
@@ -30,6 +30,7 @@
 #include "IOChannel.h"
 #include "log.h"
 #include "WallClockTimer.h"
+#include "GnashSleep.h"
 
 #include <iostream> // std::cerr
 #include <boost/thread/mutex.hpp>
@@ -210,7 +211,7 @@
        while ( (code=curl_share_cleanup(_shandle)) != CURLSHE_OK )
        {
                log_error("Failed cleaning up share handle: %s. Will try again 
in a second.", curl_share_strerror(code));
-               sleep(1);
+               gnashSleep(1000000);
        }
        _shandle = 0;
        curl_global_cleanup();

=== modified file 'libcore/parser/SWFMovieDefinition.cpp'
--- a/libcore/parser/SWFMovieDefinition.cpp     2008-10-02 16:12:12 +0000
+++ b/libcore/parser/SWFMovieDefinition.cpp     2008-10-03 09:39:44 +0000
@@ -41,6 +41,7 @@
 #include "GnashException.h" // for parser exception
 #include "ControlTag.h"
 #include "sound_definition.h" // for sound_sample
+#include "GnashSleep.h"
 #include <boost/bind.hpp>
 #include <boost/version.hpp>
 
@@ -68,11 +69,6 @@
 // Debug threads locking
 #undef DEBUG_THREADS_LOCKING
 
-#if defined(_WIN32) || defined(WIN32)
-#      include <windows.h>
-# define usleep(x) Sleep(x/1000)
-#endif
-
 namespace gnash
 {
 
@@ -846,7 +842,7 @@
                }
 
                // take a breath to give other threads more time to advance
-               usleep(naptime);
+               gnashSleep(naptime);
 
        }
 

=== modified file 'libmedia/MediaParser.cpp'
--- a/libmedia/MediaParser.cpp  2008-10-01 14:00:35 +0000
+++ b/libmedia/MediaParser.cpp  2008-10-03 09:39:44 +0000
@@ -21,13 +21,8 @@
 #include "MediaParser.h"
 #include "log.h"
 
-#include <unistd.h>             // for usleep()
 #include <boost/bind.hpp>
-
-#ifdef _WIN32
-#include <windows.h>
-#define usleep(usec) ((void) Sleep((usec) / 1000))
-#endif
+#include "GnashSleep.h" // for usleep.
 
 namespace gnash {
 namespace media {
@@ -355,7 +350,7 @@
        while (!parserThreadKillRequested())
        {
                parseNextChunk();
-               usleep(100); // no rush....
+        gnashSleep(100); // no rush....
        }
 }
 

=== modified file 'utilities/processor.cpp'
--- a/utilities/processor.cpp   2008-09-09 03:43:09 +0000
+++ b/utilities/processor.cpp   2008-10-03 09:39:44 +0000
@@ -50,13 +50,9 @@
 #include "StringPredicates.h"
 #include "smart_ptr.h"
 #include "IOChannel.h" // for proper dtor call
+#include "GnashSleep.h" // for usleep comptibility.
 
 extern "C"{
-       #include <unistd.h>
-#ifdef _WIN32
-#include <windows.h>
-#define usleep(t) Sleep((t) / 1000)
-#endif
 #ifdef HAVE_GETOPT_H
        #include <getopt.h>
 #endif
@@ -417,8 +413,8 @@
     long clockAdvance = fpsDelay/1000;
     long localDelay = delay == -1 ? fpsDelay : delay; // microseconds
 
-    log_debug("Will sleep %ld microseconds between iterations - fps is %g, 
clockAdvance is %lu", 
-                        localDelay, fps, clockAdvance);
+    log_debug("Will sleep %ld microseconds between iterations - "
+            "fps is %g, clockAdvance is %lu", localDelay, fps, clockAdvance);
 
     // Use a clock advanced at every iteration to match exact FPS speed.
     ManualClock cl;
@@ -440,8 +436,9 @@
         return md;
     }
 
-    log_debug("iteration, timer: %lu, localDelay: %ld\n", cl.elapsed(), 
localDelay);
-    usleep(localDelay);
+    log_debug("iteration, timer: %lu, localDelay: %ld\n",
+            cl.elapsed(), localDelay);
+    gnashSleep(localDelay);
     
     resetLastAdvanceTimer();
     int        kick_count = 0;
@@ -543,8 +540,9 @@
            resetLastAdvanceTimer();
        }
 
-       log_debug("iteration, timer: %lu, localDelay: %ld\n", cl.elapsed(), 
localDelay);
-       usleep(localDelay);
+       log_debug("iteration, timer: %lu, localDelay: %ld\n",
+            cl.elapsed(), localDelay);
+    gnashSleep(localDelay);
     }
     
     return md;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]