Browse Source

Mixer: Listen for OSC messages in a thread instead of polling.

tags/non-daw-v1.2.0
Jonathan Moore Liles 13 years ago
parent
commit
6673f7057a
3 changed files with 15 additions and 17 deletions
  1. +4
    -13
      mixer/src/Mixer.C
  2. +3
    -3
      mixer/src/Mixer.H
  3. +8
    -1
      mixer/src/Module.C

+ 4
- 13
mixer/src/Mixer.C View File

@@ -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 ( )
{


+ 3
- 3
mixer/src/Mixer.H View File

@@ -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 );


+ 8
- 1
mixer/src/Module.C View File

@@ -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…
Cancel
Save