From f01725371c62a398ac2e71059b3a1add3d4a365c Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sun, 13 Dec 2009 13:35:03 +0100 Subject: [PATCH] Implemented an fps(50) limiter in projectM. --- modules/visualization/projectm.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/visualization/projectm.cpp b/modules/visualization/projectm.cpp index 260fe7d3a8..229b0abbed 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 #include @@ -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(); -- 2.39.2