diff --git a/mixer/src/Mixer.C b/mixer/src/Mixer.C index ca3f6f6..eddc8cf 100644 --- a/mixer/src/Mixer.C +++ b/mixer/src/Mixer.C @@ -53,8 +53,6 @@ const double STATUS_UPDATE_FREQ = 0.2f; -const double OSC_INTERVAL = 1.0 / 20.0; /* 20 hz */ - extern char *user_config_dir; extern char *instance_name; @@ -89,8 +87,11 @@ static int osc_add_strip ( const char *path, const char *, lo_arg **, int , lo_m { OSC_DMSG(); + Fl::lock(); ((Mixer*)(OSC_ENDPOINT())->owner)->command_add_strip(); + Fl::unlock(); + OSC_REPLY_OK(); return 0; @@ -478,21 +479,11 @@ Mixer::init_osc ( const char *osc_port ) osc_endpoint->add_method( "/non/mixer/add_strip", "", osc_add_strip, osc_endpoint, "" ); -// osc_endpoint->start(); - - /* poll so we can keep OSC handlers running in the GUI thread and avoid extra sync */ - Fl::add_timeout( OSC_INTERVAL, check_osc, this ); + osc_endpoint->start(); return 0; } -void -Mixer::check_osc ( void * v ) -{ - ((Mixer*)v)->osc_endpoint->check(); - Fl::repeat_timeout( OSC_INTERVAL, check_osc, v ); - -} Mixer::~Mixer ( ) { diff --git a/mixer/src/Mixer.H b/mixer/src/Mixer.H index 1df1b28..698f2ef 100644 --- a/mixer/src/Mixer.H +++ b/mixer/src/Mixer.H @@ -26,6 +26,8 @@ #include #include "Mixer_Strip.H" +#include "Thread.H" + class Fl_Blinker; class Fl_Flowpack; class Fl_Menu_Bar; @@ -41,7 +43,7 @@ public: Fl_Blinker *sm_blinker; private: - + int _rows; Fl_Color system_colors[3]; @@ -98,8 +100,6 @@ public: Mixer ( int X, int Y, int W, int H, const char *L ); virtual ~Mixer(); - static void check_osc ( void * v ); - void reply_to_finger ( lo_message msg ); void announce ( const char *nash_url, const char *process_name ); diff --git a/mixer/src/Module.C b/mixer/src/Module.C index 03c4089..ec64049 100644 --- a/mixer/src/Module.C +++ b/mixer/src/Module.C @@ -314,6 +314,8 @@ Module::Port::osc_control_change_exact ( float v, void *user_data ) { Module::Port *p = (Module::Port*)user_data; + Fl::lock(); + float f = v; if ( p->hints.ranged ) @@ -326,6 +328,8 @@ Module::Port::osc_control_change_exact ( float v, void *user_data ) p->control_value( f ); + Fl::unlock(); + // mixer->osc_endpoint->send( lo_message_get_source( msg ), "/reply", path, f ); return 0; @@ -338,6 +342,8 @@ Module::Port::osc_control_change_cv ( float v, void *user_data ) float f = v; + Fl::lock(); + // clamp value to control voltage range. if ( f > 1.0 ) f = 1.0; @@ -353,9 +359,10 @@ Module::Port::osc_control_change_cv ( float v, void *user_data ) f = ( f * scale ) + offset; } - + p->control_value( f ); + Fl::unlock(); // mixer->osc_endpoint->send( lo_message_get_source( msg ), "/reply", path, f ); return 0;