Browse Source

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

tags/non-daw-v1.2.0
Jonathan Moore Liles 12 years ago
parent
commit
bbffb98981
12 changed files with 81 additions and 68 deletions
  1. +16
    -0
      mixer/src/Chain.C
  2. +1
    -0
      mixer/src/Chain.H
  3. +1
    -17
      mixer/src/Controller_Module.C
  4. +2
    -3
      mixer/src/Controller_Module.H
  5. +1
    -17
      mixer/src/Meter_Indicator_Module.C
  6. +2
    -2
      mixer/src/Meter_Indicator_Module.H
  7. +1
    -17
      mixer/src/Meter_Module.C
  8. +2
    -3
      mixer/src/Meter_Module.H
  9. +42
    -9
      mixer/src/Mixer.C
  10. +7
    -0
      mixer/src/Mixer.H
  11. +4
    -0
      mixer/src/Mixer_Strip.C
  12. +2
    -0
      mixer/src/Module.H

+ 16
- 0
mixer/src/Chain.C 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 void
Chain::update_connection_status ( void *v ) Chain::update_connection_status ( void *v )
{ {


+ 1
- 0
mixer/src/Chain.H View File

@@ -95,6 +95,7 @@ public:
Chain ( ); Chain ( );
virtual ~Chain ( ); virtual ~Chain ( );


void update ( void );
void draw ( void ); void draw ( void );
void resize ( int X, int Y, int W, int H ); void resize ( int X, int Y, int W, int H );




+ 1
- 17
mixer/src/Controller_Module.C 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() ) Controller_Module::Controller_Module ( bool is_default ) : Module( is_default, 50, 100, name() )
{ {
// label( "" ); // label( "" );
@@ -70,15 +66,11 @@ Controller_Module::Controller_Module ( bool is_default ) : Module( is_default, 5


end(); end();


Fl::add_timeout( CONTROL_UPDATE_FREQ, update_cb, this );

log_create(); log_create();
} }


Controller_Module::~Controller_Module ( ) Controller_Module::~Controller_Module ( )
{ {
Fl::remove_timeout( update_cb, this );

log_destroy(); log_destroy();


/* shutdown JACK port, if we have one */ /* shutdown JACK port, if we have one */
@@ -427,16 +419,8 @@ Controller_Module::connect_to ( Port *p )
} }


void 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 /* 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 */ * of control the change happens in the GUI thread and we know it */
if ( mode() != CV ) if ( mode() != CV )


+ 2
- 3
mixer/src/Controller_Module.H View File

@@ -32,9 +32,6 @@ class Fl_Valuator;
class Controller_Module : public Module class Controller_Module : public Module
{ {


static void update_cb ( void *v );
void update_cb ( void );

bool _pad; bool _pad;


volatile float control_value; volatile float control_value;
@@ -87,6 +84,8 @@ public:


LOG_CREATE_FUNC( Controller_Module ); LOG_CREATE_FUNC( Controller_Module );


virtual void update ( void );

void process ( nframes_t nframes ); void process ( nframes_t nframes );


void draw ( void ) void draw ( void )


+ 1
- 17
mixer/src/Meter_Indicator_Module.C View File

@@ -40,10 +40,6 @@




const float CONTROL_UPDATE_FREQ = 0.1f;


Meter_Indicator_Module::Meter_Indicator_Module ( bool is_default ) Meter_Indicator_Module::Meter_Indicator_Module ( bool is_default )
: Module ( is_default, 50, 100, name() ) : 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 ) ); align( (Fl_Align)(FL_ALIGN_CENTER | FL_ALIGN_INSIDE ) );


clear_visible_focus(); clear_visible_focus();

Fl::add_timeout( CONTROL_UPDATE_FREQ, update_cb, this );
} }


Meter_Indicator_Module::~Meter_Indicator_Module ( ) Meter_Indicator_Module::~Meter_Indicator_Module ( )
@@ -83,8 +77,6 @@ Meter_Indicator_Module::~Meter_Indicator_Module ( )
control_value = NULL; control_value = NULL;
} }


Fl::remove_timeout( update_cb, this );

log_destroy(); log_destroy();
} }


@@ -140,16 +132,8 @@ Meter_Indicator_Module::set ( Log_Entry &e )


void 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() ) if ( control_input[0].connected() )
{ {
// A little hack to detect that the connected module's number // A little hack to detect that the connected module's number


+ 2
- 2
mixer/src/Meter_Indicator_Module.H View File

@@ -30,8 +30,6 @@ class Meter_Indicator_Module : public Module
{ {
Fl_Scalepack *dpm_pack; Fl_Scalepack *dpm_pack;


static void update_cb ( void *v );
void update_cb ( void );


bool _pad; bool _pad;


@@ -41,6 +39,8 @@ class Meter_Indicator_Module : public Module


public: public:


virtual void update ( void );

void disable_context_menu ( bool b ) { _disable_context_menu = b; } void disable_context_menu ( bool b ) { _disable_context_menu = b; }


void handle_control_changed ( Port *p ); void handle_control_changed ( Port *p );


+ 1
- 17
mixer/src/Meter_Module.C View File

@@ -32,10 +32,6 @@




const float METER_UPDATE_FREQ = 0.2f;


Meter_Module::Meter_Module ( ) Meter_Module::Meter_Module ( )
: Module ( 50, 100, name() ) : Module ( 50, 100, name() )
{ {
@@ -60,8 +56,6 @@ Meter_Module::Meter_Module ( )


add_port( p ); add_port( p );


Fl::add_timeout( METER_UPDATE_FREQ, update_cb, this );

log_create(); log_create();
} }


@@ -70,24 +64,14 @@ Meter_Module::~Meter_Module ( )
if ( control_value ) if ( control_value )
delete[] control_value; delete[] control_value;


Fl::remove_timeout( update_cb, this );

log_destroy(); log_destroy();
} }




void 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--; ) for ( int i = dpm_pack->children(); i--; )
{ {
((DPM*)dpm_pack->child( i ))->value( control_value[i] ); ((DPM*)dpm_pack->child( i ))->value( control_value[i] );


+ 2
- 3
mixer/src/Meter_Module.H View File

@@ -29,9 +29,6 @@ class Meter_Module : public Module


volatile float *control_value; volatile float *control_value;


static void update_cb ( void *v );
void update_cb ( void );

public: public:


Meter_Module ( ); Meter_Module ( );
@@ -44,6 +41,8 @@ public:


LOG_CREATE_FUNC( Meter_Module ); LOG_CREATE_FUNC( Meter_Module );


virtual void update ( void );

protected: protected:


virtual int handle ( int m ); virtual int handle ( int m );


+ 42
- 9
mixer/src/Mixer.C View File

@@ -48,8 +48,6 @@
#include "OSC/Endpoint.H" #include "OSC/Endpoint.H"
#include <lo/lo.h> #include <lo/lo.h>


const double STATUS_UPDATE_FREQ = 0.2f;

extern char *user_config_dir; extern char *user_config_dir;
extern char *instance_name; extern char *instance_name;


@@ -60,12 +58,6 @@ extern char *instance_name;


extern NSM_Client *nsm; 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(); 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" ) ) else if ( ! strcmp( picked, "&Help/&About" ) )
{ {
About_Dialog ab( PIXMAP_PATH "/non-mixer/icon-256x256.png" ); 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); ((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 static void
progress_cb ( int p, void *v ) 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/&Import Strip" );
o->add( "&Mixer/Paste", FL_CTRL + 'v', 0, 0 ); o->add( "&Mixer/Paste", FL_CTRL + 'v', 0, 0 );
o->add( "&View/&Theme", 0, 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/&Manual" );
o->add( "&Help/&About" ); o->add( "&Help/&About" );
o->callback( cb_menu, this ); o->callback( cb_menu, this );
@@ -468,7 +501,7 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :


end(); end();


// Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );
update_frequency( 15 );


update_menu(); update_menu();




+ 7
- 0
mixer/src/Mixer.H View File

@@ -44,6 +44,8 @@ public:


private: private:


float _update_interval;

int _rows; int _rows;


Fl_Color system_colors[3]; 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 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: public:

void update_frequency ( float f );
virtual int handle ( int m ); virtual int handle ( int m );




+ 4
- 0
mixer/src/Mixer_Strip.C View File

@@ -361,6 +361,10 @@ void
Mixer_Strip::update ( void ) Mixer_Strip::update ( void )
{ {
THREAD_ASSERT( UI ); THREAD_ASSERT( UI );

meter_indicator->update();
gain_controller->update();
_chain->update();
} }


void void


+ 2
- 0
mixer/src/Module.H View File

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


class Port class Port
{ {


Loading…
Cancel
Save