From: Laurent Aimar Date: Sun, 13 Dec 2009 12:35:03 +0000 (+0100) Subject: Implemented an fps(50) limiter in projectM. X-Git-Tag: 1.1.0-ff~1981 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=f01725371c62a398ac2e71059b3a1add3d4a365c;p=vlc Implemented an fps(50) limiter in projectM. --- 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();