Mixer: Consolidate all GUI update timeouts into one to avoid unnecessary X events.

This commit is contained in:
Jonathan Moore Liles 2013-06-17 19:26:04 -07:00
parent 72a1e2a5cf
commit bbffb98981
12 changed files with 81 additions and 68 deletions

View File

@ -873,6 +873,22 @@ Chain::port_connect ( jack_port_id_t a, jack_port_id_t b, int connect )
}
}
void
Chain::update ( void )
{
for ( int i = 0; i < controls_pack->children(); ++i )
{
Controller_Module *cm = (Controller_Module*)controls_pack->child( i );
cm->update();
}
for ( int i = 0; i < modules(); i++ )
{
Module *m = module(i);
m->update();
}
}
void
Chain::update_connection_status ( void *v )
{

View File

@ -95,6 +95,7 @@ public:
Chain ( );
virtual ~Chain ( );
void update ( void );
void draw ( void );
void resize ( int X, int Y, int W, int H );

View File

@ -47,10 +47,6 @@
const float CONTROL_UPDATE_FREQ = 0.2f;
Controller_Module::Controller_Module ( bool is_default ) : Module( is_default, 50, 100, name() )
{
// label( "" );
@ -70,15 +66,11 @@ Controller_Module::Controller_Module ( bool is_default ) : Module( is_default, 5
end();
Fl::add_timeout( CONTROL_UPDATE_FREQ, update_cb, this );
log_create();
}
Controller_Module::~Controller_Module ( )
{
Fl::remove_timeout( update_cb, this );
log_destroy();
/* shutdown JACK port, if we have one */
@ -427,16 +419,8 @@ Controller_Module::connect_to ( Port *p )
}
void
Controller_Module::update_cb ( void *v )
Controller_Module::update ( void )
{
((Controller_Module*)v)->update_cb();
}
void
Controller_Module::update_cb ( void )
{
Fl::repeat_timeout( CONTROL_UPDATE_FREQ, update_cb, this );
/* we only need this in CV (JACK) mode, because with other forms
* of control the change happens in the GUI thread and we know it */
if ( mode() != CV )

View File

@ -32,9 +32,6 @@ class Fl_Valuator;
class Controller_Module : public Module
{
static void update_cb ( void *v );
void update_cb ( void );
bool _pad;
volatile float control_value;
@ -87,6 +84,8 @@ public:
LOG_CREATE_FUNC( Controller_Module );
virtual void update ( void );
void process ( nframes_t nframes );
void draw ( void )

View File

@ -40,10 +40,6 @@
const float CONTROL_UPDATE_FREQ = 0.1f;
Meter_Indicator_Module::Meter_Indicator_Module ( bool is_default )
: Module ( is_default, 50, 100, name() )
{
@ -71,8 +67,6 @@ Meter_Indicator_Module::Meter_Indicator_Module ( bool is_default )
align( (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_INSIDE ) );
clear_visible_focus();
Fl::add_timeout( CONTROL_UPDATE_FREQ, update_cb, this );
}
Meter_Indicator_Module::~Meter_Indicator_Module ( )
@ -83,8 +77,6 @@ Meter_Indicator_Module::~Meter_Indicator_Module ( )
control_value = NULL;
}
Fl::remove_timeout( update_cb, this );
log_destroy();
}
@ -140,16 +132,8 @@ Meter_Indicator_Module::set ( Log_Entry &e )
void
Meter_Indicator_Module::update_cb ( void *v )
Meter_Indicator_Module::update ( void )
{
((Meter_Indicator_Module*)v)->update_cb();
}
void
Meter_Indicator_Module::update_cb ( void )
{
Fl::repeat_timeout( CONTROL_UPDATE_FREQ, update_cb, this );
if ( control_input[0].connected() )
{
// A little hack to detect that the connected module's number

View File

@ -30,8 +30,6 @@ class Meter_Indicator_Module : public Module
{
Fl_Scalepack *dpm_pack;
static void update_cb ( void *v );
void update_cb ( void );
bool _pad;
@ -41,6 +39,8 @@ class Meter_Indicator_Module : public Module
public:
virtual void update ( void );
void disable_context_menu ( bool b ) { _disable_context_menu = b; }
void handle_control_changed ( Port *p );

View File

@ -32,10 +32,6 @@
const float METER_UPDATE_FREQ = 0.2f;
Meter_Module::Meter_Module ( )
: Module ( 50, 100, name() )
{
@ -60,8 +56,6 @@ Meter_Module::Meter_Module ( )
add_port( p );
Fl::add_timeout( METER_UPDATE_FREQ, update_cb, this );
log_create();
}
@ -70,24 +64,14 @@ Meter_Module::~Meter_Module ( )
if ( control_value )
delete[] control_value;
Fl::remove_timeout( update_cb, this );
log_destroy();
}
void
Meter_Module::update_cb ( void *v )
Meter_Module::update ( void )
{
((Meter_Module*)v)->update_cb();
}
void
Meter_Module::update_cb ( void )
{
Fl::repeat_timeout( METER_UPDATE_FREQ, update_cb, this );
for ( int i = dpm_pack->children(); i--; )
{
((DPM*)dpm_pack->child( i ))->value( control_value[i] );

View File

@ -29,9 +29,6 @@ class Meter_Module : public Module
volatile float *control_value;
static void update_cb ( void *v );
void update_cb ( void );
public:
Meter_Module ( );
@ -44,6 +41,8 @@ public:
LOG_CREATE_FUNC( Meter_Module );
virtual void update ( void );
protected:
virtual int handle ( int m );

View File

@ -48,8 +48,6 @@
#include "OSC/Endpoint.H"
#include <lo/lo.h>
const double STATUS_UPDATE_FREQ = 0.2f;
extern char *user_config_dir;
extern char *instance_name;
@ -60,12 +58,6 @@ extern char *instance_name;
extern NSM_Client *nsm;
/* static void update_cb( void *v ) { */
/* Fl::repeat_timeout( STATUS_UPDATE_FREQ, update_cb, v ); */
/* ((Mixer*)v)->update(); */
/* } */
/************************/
@ -294,6 +286,18 @@ void Mixer::cb_menu(Fl_Widget* o) {
{
fl_theme_chooser();
}
else if (! strcmp( picked, "&Options/&Display/Update Frequency/15 Hz" ) )
{
update_frequency( 15.0f );
}
else if (! strcmp( picked, "&Options/&Display/Update Frequency/30 Hz" ) )
{
update_frequency( 30.0f );
}
else if (! strcmp( picked, "&Options/&Display/Update Frequency/60 Hz" ) )
{
update_frequency( 60.0f );
}
else if ( ! strcmp( picked, "&Help/&About" ) )
{
About_Dialog ab( PIXMAP_PATH "/non-mixer/icon-256x256.png" );
@ -333,6 +337,32 @@ void Mixer::cb_menu(Fl_Widget* o, void* v) {
((Mixer*)(v))->cb_menu(o);
}
void Mixer::update_frequency ( float v )
{
_update_interval = 1.0f / v;
Fl::remove_timeout( &Mixer::update_cb );
Fl::add_timeout( _update_interval, &Mixer::update_cb, this );
}
void
Mixer::update_cb ( void *v )
{
((Mixer*)v)->update_cb();
}
void
Mixer::update_cb ( void )
{
Fl::repeat_timeout( _update_interval, &Mixer::update_cb, this );
for ( int i = 0; i < mixer_strips->children(); i++ )
{
((Mixer_Strip*)mixer_strips->child(i))->update();
}
}
static void
progress_cb ( int p, void *v )
{
@ -420,6 +450,9 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
o->add( "&Mixer/&Import Strip" );
o->add( "&Mixer/Paste", FL_CTRL + 'v', 0, 0 );
o->add( "&View/&Theme", 0, 0, 0 );
/* o->add( "&Options/&Display/Update Frequency/60 Hz", 0, 0, 0, FL_MENU_RADIO ); */
/* o->add( "&Options/&Display/Update Frequency/30 Hz", 0, 0, 0, FL_MENU_RADIO); */
/* o->add( "&Options/&Display/Update Frequency/15 Hz", 0, 0, 0, FL_MENU_RADIO | FL_MENU_VALUE ); */
o->add( "&Help/&Manual" );
o->add( "&Help/&About" );
o->callback( cb_menu, this );
@ -468,7 +501,7 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
end();
// Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );
update_frequency( 15 );
update_menu();

View File

@ -44,6 +44,8 @@ public:
private:
float _update_interval;
int _rows;
Fl_Color system_colors[3];
@ -73,7 +75,12 @@ private:
static int osc_non_hello ( const char *, const char *, lo_arg **, int , lo_message msg, void * );
static void update_cb ( void * );
void update_cb ( void );
public:
void update_frequency ( float f );
virtual int handle ( int m );

View File

@ -361,6 +361,10 @@ void
Mixer_Strip::update ( void )
{
THREAD_ASSERT( UI );
meter_indicator->update();
gain_controller->update();
_chain->update();
}
void

View File

@ -74,6 +74,8 @@ public:
/* true if this module was added by default and not under normal user control */
bool is_default ( void ) const { return _is_default; }
void is_default ( bool v ) { _is_default = v; }
virtual void update ( void ) {}
class Port
{