Mixer: Listen for OSC messages in a thread instead of polling.
This commit is contained in:
parent
c74cd04bab
commit
6673f7057a
|
@ -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 ( )
|
||||
{
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include <FL/Fl_Pack.H>
|
||||
#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 );
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue