[vlc-devel] commit: Implemented an fps(50) limiter in projectM. (Laurent Aimar )

git version control git at videolan.org
Sun Dec 13 13:53:42 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Dec 13 13:35:03 2009 +0100| [f01725371c62a398ac2e71059b3a1add3d4a365c] | committer: Laurent Aimar 

Implemented an fps(50) limiter in projectM.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f01725371c62a398ac2e71059b3a1add3d4a365c
---

 modules/visualization/projectm.cpp |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/modules/visualization/projectm.cpp b/modules/visualization/projectm.cpp
index 260fe7d..229b0ab 100644
--- a/modules/visualization/projectm.cpp
+++ b/modules/visualization/projectm.cpp
@@ -24,6 +24,9 @@
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
+#ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS
+#endif
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
@@ -318,6 +321,7 @@ static void *Thread( void *p_data )
     int i_last_height = 0;
     for( ;; )
     {
+        const mtime_t i_deadline = mdate() + CLOCK_FREQ / 50; /* 50 fps max */
         /* Manage the events */
         vout_ManageDisplay( p_sys->p_vd, true );
         if( p_sys->p_vd->cfg->display.width  != i_last_width ||
@@ -344,16 +348,16 @@ static void *Thread( void *p_data )
 
         p_sys->p_projectm->renderFrame();
 
+        /* */
+        vlc_restorecancel( cancel );
+        mwait( i_deadline );
+        cancel = vlc_savecancel();
+
         if( !vout_opengl_Lock(gl) )
         {
             vout_opengl_Swap( gl );
             vout_opengl_Unlock( gl );
         }
-
-        /* TODO: use a fps limiter */
-        vlc_restorecancel( cancel );
-        msleep( 10000 );
-        cancel = vlc_savecancel();
     }
     vlc_cleanup_pop();
     abort();




More information about the vlc-devel mailing list