gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. 20764275919d2ec05aeb


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. 20764275919d2ec05aeb3a876339e6c752e06c91
Date: Wed, 20 Oct 2010 09:44:51 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  20764275919d2ec05aeb3a876339e6c752e06c91 (commit)
       via  f325040bdf84a25e82d0db27145ba84d142d9983 (commit)
      from  d778ca9331ad8cebca89a0f890384a2a77c6929f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=20764275919d2ec05aeb3a876339e6c752e06c91


commit 20764275919d2ec05aeb3a876339e6c752e06c91
Merge: f325040 d778ca9
Author: Sandro Santilli <address@hidden>
Date:   Wed Oct 20 11:44:41 2010 +0200

    Merge branch 'master' of ssh://address@hidden/srv/git/gnash


http://git.savannah.gnu.org/cgit//commit/?id=f325040bdf84a25e82d0db27145ba84d142d9983


commit f325040bdf84a25e82d0db27145ba84d142d9983
Author: Sandro Santilli <address@hidden>
Date:   Wed Oct 20 11:41:12 2010 +0200

    Have Gui::advanceMovie return true or false based on whether frame 
advancement occurred. Use this information from dump-gui to decide whether or 
not to write a video frame.

diff --git a/gui/dump.cpp b/gui/dump.cpp
index 65d61b7..4311635 100644
--- a/gui/dump.cpp
+++ b/gui/dump.cpp
@@ -29,6 +29,7 @@
 
 #include "log.h"
 
+#include "WallClockTimer.h"
 #include "gui.h"
 #include "rc.h"
 #include "sound_handler.h"
@@ -152,71 +153,33 @@ bool
 DumpGui::run()
 {
 
-    struct timeval tv;
+    log_debug("DumpGui entering main loop with interval of %d", _interval);
 
-    // TODO:  Polling is awful; should be an OS-agnostic u-sec callback
-    //        timer system for C++ out there (boost?).   This code is
-    //        from the fb gui, and made a bit nicer by lengthening the
-    //        usleep values with educated guesses.  It's possible for
-    //        slow systems to fall behind with this code, which would
-    //        cause the audio stream to get out of sync (bad?).
+    WallClockTimer timer;
 
-    double timer_start;
-    unsigned int sleep_usecs;
-
-    if (gettimeofday(&tv, NULL) == 0) {
-        timer_start = static_cast<double>(tv.tv_sec) +
-       static_cast<double>(tv.tv_usec) / 1000000.0;
-    }
-    else {
-        log_error(_("Unable to call gettimeofday."));
-        return false;
-    }
-    
     _terminate_request = false;
 
-    // first frame
-    Gui::advance_movie(this);
-    writeFrame();
-
-    double timer_current = timer_start;
-    double timer_nextframe = timer_start;
-    double interval_s = static_cast<double>(_interval) / 1000.0;
-    double timer_exit = timer_start + (static_cast<double>(_timeout) / 1000.0);
-
     while (!_terminate_request) {
-  
-        timer_nextframe += interval_s;
-
-        // polling loop
-        while (timer_current < timer_nextframe) {
-            // sleep for 95% of remaining usecs, floored at 50
-            sleep_usecs = static_cast<int>(((timer_nextframe - timer_current) 
* 950000.0));
-            gnashSleep((sleep_usecs < 50) ? 50 : sleep_usecs);
-            if (gettimeofday(&tv, NULL) == 0) {
-                timer_current = static_cast<double>(tv.tv_sec) +
-               static_cast<double>(tv.tv_usec) / 1000000.0;
-            } else {
-                log_error(_("Unable to call gettimeofday."));
-                return false;
-            }
-        }
 
         // advance movie now
-        Gui::advance_movie(this);
-        writeFrame();
+        if ( advanceMovie() ) {
+            ++_framecount;
+            writeFrame();
+        }
+  
+        gnashSleep(_interval);
 
         // check if we've reached a timeout
-        if (_timeout && (timer_current > timer_exit)) {
+        if (_timeout && timer.elapsed() > _timeout ) {
             _terminate_request = true;
         }
     }
 
-    if ((timer_current - timer_start) != 0.0) {
-        std::cout << "TIME=" << (timer_current - timer_start) << std::endl;
-        std::cout << "FPS_ACTUAL=" << 
-            (static_cast<double>((_framecount-1)) / (timer_current - 
timer_start)) << std::endl;
-    }
+    boost::uint32_t total_time = timer.elapsed();
+    double fps = _framecount*1000.0 / total_time;
+
+    std::cout << "TIME=" << total_time << std::endl;
+    std::cout << "FPS_ACTUAL=" << fps << std::endl;
     
     // In this Gui, quit() does not exit, but it is necessary to catch the
     // last frame for screenshots.
@@ -256,7 +219,6 @@ DumpGui::writeFrame()
 
     _fileStream.write(reinterpret_cast<char*>(_offscreenbuf.get()),
             _offscreenbuf_size);
-    ++_framecount;
 }
 
 void
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 564b7c8..1212905 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -934,7 +934,7 @@ Gui::advanceMovie()
 {
 
     if (isStopped()) {
-        return true;
+        return false;
     }
 
     if (!_started) {
@@ -949,7 +949,7 @@ Gui::advanceMovie()
     
 #ifndef REVIEW_ALL_FRAMES
     // Advance movie by one frame
-    bool advanced = m->advance();
+    const bool advanced = m->advance();
 #else
     const size_t cur_frame = m->getRootMovie()->get_current_frame();
     const size_t tot_frames = m->getRootMovie()->get_frame_count();
@@ -1014,7 +1014,7 @@ Gui::advanceMovie()
         ++_advances;
     }
 
-       return true;
+       return advanced;
 }
 
 void
diff --git a/gui/gui.h b/gui/gui.h
index 0bb84ef..6565a3e 100644
--- a/gui/gui.h
+++ b/gui/gui.h
@@ -328,13 +328,26 @@ public:
     void updateStageMatrix();
 
     /// \brief
-    /// Advances the movie to the next frame. This is to take place after the
+    /// Give movie an heart-beat.
+    //
+    /// This is to take place after the
     /// interval specified in the call to setInterval().
+    ///
+    /// Wheter or not this beat advanced the movie to the next frame
+    /// depends on elapsed time since last advancement.
+    ///
+    /// @return true if this beat resulted in actual frame advancement.
+    ///
     bool advanceMovie();
 
     /// Convenience static wrapper around advanceMovie for callbacks happiness.
+    //
+    /// NOTE: this function always return TRUE, for historical reasons.
+    /// TODO: bring code up-to-date to drop this legacy return code..
+    ///       
     static bool advance_movie(Gui* gui) {
-        return gui->advanceMovie();
+        gui->advanceMovie();
+        return true;
     }
 
     /// Force immediate redraw

-----------------------------------------------------------------------

Summary of changes:
 gui/dump.cpp |   68 ++++++++++++---------------------------------------------
 gui/gui.cpp  |    6 ++--
 gui/gui.h    |   17 ++++++++++++-
 3 files changed, 33 insertions(+), 58 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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