OSC Signal cleanups.

This commit is contained in:
Jonathan Moore Liles 2013-07-14 14:12:44 -07:00
parent cfd451c4d6
commit 70856a6e8e
10 changed files with 100 additions and 276 deletions

View File

@ -840,7 +840,7 @@ Chain::buffer_size ( nframes_t nframes )
int int
Chain::sample_rate_change ( nframes_t nframes, void *v ) Chain::sample_rate_change ( nframes_t nframes, void *v )
{ {
((Chain*)v)->sample_rate_change( nframes ); return ((Chain*)v)->sample_rate_change( nframes );
} }
int int

View File

@ -380,6 +380,8 @@ JACK_Module::add_jack_output ( const char *prefix, int n )
} }
delete po; delete po;
return true;
} }
bool bool

View File

@ -59,7 +59,7 @@ protected:
protected: protected:
int _connection_handle_outputs[2][2]; unsigned int _connection_handle_outputs[2][2];
public: public:

View File

@ -309,7 +309,7 @@ void Mixer::cb_menu(Fl_Widget* o) {
} }
else if ( ! strcmp( picked, "&Remote Control/Clear All Mappings" ) ) else if ( ! strcmp( picked, "&Remote Control/Clear All Mappings" ) )
{ {
if ( 1 == fl_ask( "This will remove all mappings, are you sure?") ) if ( 1 == fl_choice( "This will remove all mappings, are you sure?", "No", "Yes", NULL ) )
{ {
command_clear_mappings(); command_clear_mappings();
} }

View File

@ -306,20 +306,14 @@ Module::handle_control_changed ( Port *p )
p->send_feedback(); p->send_feedback();
} }
bool /* bool */
Module::Port::connected_osc ( void ) const /* Module::Port::connected_osc ( void ) const */
{ /* { */
if ( _scaled_signal ) /* if ( _scaled_signal ) */
return _scaled_signal->connected(); /* return _scaled_signal->connected(); */
else /* else */
return false; /* return false; */
} /* } */
void
Module::Port::learn_osc ( void )
{
_scaled_signal->learn_connection();
}
char * char *
Module::Port::generate_osc_path () Module::Port::generate_osc_path ()
@ -639,7 +633,7 @@ Module::draw_box ( int tx, int ty, int tw, int th )
{ {
fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + 4, 5, 5, is_being_controlled() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + 4, 5, 5, is_being_controlled() ? FL_YELLOW : fl_inactive( FL_YELLOW ) );
fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + th - 8, 5, 5, is_being_controlled_osc() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); /* fl_draw_box( FL_ROUNDED_BOX, tx + 4, ty + th - 8, 5, 5, is_being_controlled_osc() ? FL_YELLOW : fl_inactive( FL_YELLOW ) ); */
} }
if ( control_output.size() ) if ( control_output.size() )

View File

@ -123,8 +123,6 @@ public:
static int osc_control_change_exact ( float v, void *user_data ); static int osc_control_change_exact ( float v, void *user_data );
static int osc_control_change_cv ( float v, void *user_data ); static int osc_control_change_cv ( float v, void *user_data );
void learn_osc ( void );
Hints hints; Hints hints;
Port ( Module *module, Direction direction, Type type, const char *name = 0 ) Port ( Module *module, Direction direction, Type type, const char *name = 0 )
@ -334,14 +332,14 @@ public:
return false; return false;
} }
bool /* bool */
is_being_controlled_osc ( void ) const /* is_being_controlled_osc ( void ) const */
{ /* { */
for ( nframes_t i = control_input.size(); i--; ) /* for ( nframes_t i = control_input.size(); i--; ) */
if ( control_input[i].connected_osc() ) /* if ( control_input[i].connected_osc() ) */
return true; /* return true; */
return false; /* return false; */
} /* } */
virtual const char *name ( void ) const = 0; virtual const char *name ( void ) const = 0;
virtual const char *basename ( void ) const { return "Module"; } virtual const char *basename ( void ) const { return "Module"; }

View File

@ -410,8 +410,6 @@ Module_Parameter_Editor::bind_control ( int i )
{ {
Module::Port *p = &_module->control_input[i]; Module::Port *p = &_module->control_input[i];
/* p->learn_osc(); */
if ( p->connected() ) if ( p->connected() )
/* can only bind once */ /* can only bind once */
return; return;

View File

@ -110,37 +110,12 @@ namespace OSC
_path = new_path; _path = new_path;
} }
bool
Signal::is_connected_to ( const OSC::Signal *s ) const
{
for ( std::list<Signal*>::const_iterator i = _outgoing.begin();
i != _outgoing.end();
++i )
{
/* if ( (*i)->_peer == s->_peer && */
/* (*i)->id() == s->id() ) */
/* return true; */
}
return false;
}
void void
Signal::value ( float f ) Signal::value ( float f )
{ {
if ( f == _value ) if ( f == _value )
return; return;
/* for ( std::list<Signal*>::const_iterator i = _outgoing.begin(); */
/* i != _outgoing.end(); */
/* ++i ) */
/* { */
/* /\* FIXME: won't work for loopback *\/ */
/* if ( (*i)->_value != f ) */
/* { */
/* (*i)->_value = f; */
_value = f; _value = f;
if ( direction() == Output ) if ( direction() == Output )
@ -156,55 +131,49 @@ namespace OSC
// free(s); // free(s);
} }
else if ( direction() == Input ) /* else if ( direction() == Input ) */
{ /* { */
DMESSAGE( "Sending value feedback for signal %s...", path() ); /* DMESSAGE( "Sending value feedback for signal %s...", path() ); */
for ( std::list<Signal*>::iterator i = _incoming.begin(); /* for ( std::list<Signal*>::iterator i = _incoming.begin(); */
i != _incoming.end(); /* i != _incoming.end(); */
++i ) /* ++i ) */
{ /* { */
DMESSAGE( "Sending value feedback to %s %s %f", lo_address_get_url( (*i)->_peer->addr), (*i)->path() , f); /* DMESSAGE( "Sending value feedback to %s %s %f", lo_address_get_url( (*i)->_peer->addr), (*i)->path() , f); */
_endpoint->send( (*i)->_peer->addr, /* _endpoint->send( (*i)->_peer->addr, */
(*i)->path(), /* (*i)->path(), */
f ); /* f ); */
} /* } */
} /* } */
} }
void /* char * */
Signal::learn_connection ( void ) /* Signal::get_output_connection_peer_name_and_path ( int n ) */
{ /* { */
_endpoint->_learn_signal = this; /* Signal *t = NULL; */
}
char * /* int j = 0; */
Signal::get_output_connection_peer_name_and_path ( int n ) /* for ( std::list<Signal*>::const_iterator i = _outgoing.begin(); */
{ /* i != _outgoing.end(); */
Signal *t = NULL; /* ++i, ++j ) */
/* { */
/* if ( j == n ) */
/* { */
/* t = *i; */
/* break; */
/* } */
/* } */
int j = 0; /* if ( t ) */
for ( std::list<Signal*>::const_iterator i = _outgoing.begin(); /* { */
i != _outgoing.end(); /* char *r; */
++i, ++j ) /* asprintf( &r, "%s%s", t->_peer->name, t->path() ); */
{
if ( j == n )
{
t = *i;
break;
}
}
if ( t )
{
char *r;
asprintf( &r, "%s%s", t->_peer->name, t->path() );
return r;
}
else
return NULL;
}
/* return r; */
/* } */
/* else */
/* return NULL; */
/* } */
/* */
void void
@ -222,7 +191,6 @@ namespace OSC
_peer_scan_complete_userdata = 0; _peer_scan_complete_userdata = 0;
_server = 0; _server = 0;
_name = 0; _name = 0;
_learn_signal = 0;
owner = 0; owner = 0;
} }
@ -402,8 +370,6 @@ namespace OSC
if ( s->_direction == Signal::Input ) if ( s->_direction == Signal::Input )
{ {
/* s->_incoming.remove( ps ); */
DMESSAGE( "Peer %s has disconnected from signal %s", our_name, their_name ); DMESSAGE( "Peer %s has disconnected from signal %s", our_name, their_name );
ep->del_translation( their_name ); ep->del_translation( their_name );
@ -456,14 +422,6 @@ namespace OSC
Endpoint *ep = (Endpoint*)user_data; Endpoint *ep = (Endpoint*)user_data;
/* Peer *p = ep->find_peer_by_address( lo_message_get_source( msg ) ); */
/* if ( ! p ) */
/* { */
/* WARNING( "Got signal remove notification from unknown peer." ); */
/* return 0; */
/* } */
Signal *o = ep->find_signal_by_path( name ); Signal *o = ep->find_signal_by_path( name );
if ( ! o ) if ( ! o )
@ -474,34 +432,6 @@ namespace OSC
DMESSAGE( "Signal %s:%s was removed", o->_peer->name, o->path() ); DMESSAGE( "Signal %s:%s was removed", o->_peer->name, o->path() );
/* /\* disconnect it *\/ */
/* if ( o->_outgoing.size() ) */
/* { */
/* for ( std::list<Signal*>::iterator i = o->_outgoing.begin(); */
/* i != o->_outgoing.end(); */
/* ) */
/* { */
/* Signal *s = *i; */
/* /\* avoid messing up iterator *\/ */
/* ++i; */
/* ep->disconnect_signal( o, s ); */
/* } */
/* } */
/* if ( o->_incoming.size() ) */
/* { */
/* for ( std::list<Signal*>::iterator i = o->_incoming.begin(); */
/* i != o->_incoming.end(); */
/* ) */
/* { */
/* Signal *s = *i; */
/* /\* avoid messing up iterator *\/ */
/* ++i; */
/* ep->disconnect_signal( s, o ); */
/* } */
/* } */
if ( ep->_peer_signal_notification_callback ) if ( ep->_peer_signal_notification_callback )
ep->_peer_signal_notification_callback( o, Signal::Removed, ep->_peer_signal_notification_userdata ); ep->_peer_signal_notification_callback( o, Signal::Removed, ep->_peer_signal_notification_userdata );
@ -596,13 +526,11 @@ namespace OSC
{ {
Signal *o; Signal *o;
float f = 0.0; float f = 0.0;
Endpoint *ep = NULL;
if ( ! strcmp( types, "f" ) ) if ( ! strcmp( types, "f" ) )
{ {
/* accept a value for signal named in path */ /* accept a value for signal named in path */
o = (Signal*)user_data; o = (Signal*)user_data;
ep = o->_endpoint;
f = argv[0]->f; f = argv[0]->f;
} }
else if ( ! types || 0 == types[0] ) else if ( ! types || 0 == types[0] )
@ -895,79 +823,26 @@ namespace OSC
return NULL; return NULL;
} }
bool
Endpoint::disconnect_signal ( OSC::Signal *s, OSC::Signal *d )
{
/* if ( ! s->is_connected_to( d ) ) */
/* return false; */
if ( d->_peer )
{
MESSAGE( "Disconnecting signal output \"%s\" from %s:%s", s->path(), d->_peer->name, d->_path );
/* send( d->_peer->addr, "/signal/disconnect", */
/* s->_id, /\* our signal id *\/ */
/* d->_id /\* their signal id *\/ ); */
}
else
{
/* MESSAGE( "Disconnecting signal output \"%s\" to (unknown):%i", s->path(), d->_id ); */
}
s->_outgoing.remove( d );
d->_incoming.remove( s );
return true;
}
bool bool
Endpoint::disconnect_signal ( OSC::Signal *s, const char *signal_path ) Endpoint::disconnect_signal ( OSC::Signal *s, const char *signal_path )
{ {
if ( s->_direction == Signal::Output ) if ( s->_direction == Signal::Output )
{ {
/* Peer *p = find_peer_by_name( peer_name ); */ for ( std::list<Peer*>::iterator i = _peers.begin();
i != _peers.end();
++i )
{
send( (*i)->addr, "/signal/disconnect",
s->path(),
signal_path);
}
/* if ( ! p ) */ return true;
/* return false; */
Signal *ps = find_signal_by_path( signal_path );
if ( ! ps )
return false;
if ( ! s->is_connected_to( ps ) )
return false;
return disconnect_signal( s, ps );
} }
return false; return false;
} }
/* bool */
/* Endpoint::connect_signal ( OSC::Signal *s, OSC::Signal *d ) */
/* { */
/* /\* if ( s->is_connected_to( d ) ) *\/ */
/* /\* { *\/ */
/* /\* return false; *\/ */
/* /\* } *\/ */
/* MESSAGE( "Connecting signal output \"%s\" to %s:%s", s->path(), d->_peer->name, d->path() ); */
/* s->_outgoing.push_back( d ); */
/* /\* make a record of it ourselves *\/ */
/* d->_incoming.push_back( s ); */
/* send( d->_peer->addr, "/signal/connect", */
/* s->path(), */
/* d->path() ); */
/* return true; */
/* } */
bool bool
Endpoint::connect_signal( OSC::Signal *s, const char *signal_path ) Endpoint::connect_signal( OSC::Signal *s, const char *signal_path )
{ {
@ -1163,37 +1038,6 @@ namespace OSC
o->path() ); o->path() );
} }
Endpoint *ep = this;
/* /\* disconnect it *\/ */
/* if ( o->_outgoing.size() ) */
/* { */
/* for ( std::list<Signal*>::iterator i = o->_outgoing.begin(); */
/* i != o->_outgoing.end(); */
/* ) */
/* { */
/* Signal *s = *i; */
/* /\* avoid messing up iterator *\/ */
/* ++i; */
/* ep->disconnect_signal( o, s ); */
/* } */
/* } */
/* if ( o->_incoming.size() ) */
/* { */
/* for ( std::list<Signal*>::iterator i = o->_incoming.begin(); */
/* i != o->_incoming.end(); */
/* ) */
/* { */
/* Signal *s = *i; */
/* /\* avoid messing up iterator *\/ */
/* ++i; */
/* ep->disconnect_signal( s, o ); */
/* } */
/* } */
/* FIXME: clear loopback connections first! */ /* FIXME: clear loopback connections first! */
_signals.remove( o ); _signals.remove( o );

View File

@ -157,9 +157,6 @@ namespace OSC
float _value; float _value;
std::list<Signal*> _outgoing;
std::list<Signal*> _incoming;
Direction _direction; Direction _direction;
signal_handler _handler; signal_handler _handler;
@ -178,12 +175,6 @@ namespace OSC
Signal ( const char *path, Direction dir ); Signal ( const char *path, Direction dir );
~Signal ( ); ~Signal ( );
int noutput_connections() { return _outgoing.size(); }
bool connected ( void ) const { return _outgoing.size() + _incoming.size(); }
char * get_output_connection_peer_name_and_path ( int n );
Direction direction ( void ) const { return _direction; } Direction direction ( void ) const { return _direction; }
void parameter_limits ( float min, float max, float default_value ) void parameter_limits ( float min, float max, float default_value )
@ -214,8 +205,6 @@ namespace OSC
bool is_connected_to ( const Signal *s ) const; bool is_connected_to ( const Signal *s ) const;
void learn_connection ( void );
friend class Endpoint; friend class Endpoint;
}; };
@ -242,7 +231,6 @@ namespace OSC
Thread _thread; Thread _thread;
friend class Signal; friend class Signal;
Signal *_learn_signal;
// lo_server_thread _st; // lo_server_thread _st;
lo_server _server; lo_server _server;

View File

@ -266,21 +266,21 @@ Control_Sequence::get_unjournaled ( Log_Entry &e ) const
{ {
e.add( ":interpolation", _interpolation ); e.add( ":interpolation", _interpolation );
if ( _osc_output() && _osc_output()->connected() ) /* if ( _osc_output() && _osc_output()->connected() ) */
{ /* { */
DMESSAGE( "OSC Output connections: %i", _osc_output()->noutput_connections() ); /* DMESSAGE( "OSC Output connections: %i", _osc_output()->noutput_connections() ); */
for ( int i = 0; i < _osc_output()->noutput_connections(); ++i ) /* for ( int i = 0; i < _osc_output()->noutput_connections(); ++i ) */
{ /* { */
char *s; /* char *s; */
s = _osc_output()->get_output_connection_peer_name_and_path(i); /* s = _osc_output()->get_output_connection_peer_name_and_path(i); */
e.add( ":osc-output", s ); /* e.add( ":osc-output", s ); */
free( s ); /* free( s ); */
} /* } */
} /* } */
e.add( ":mode", mode() ); e.add( ":mode", mode() );
} }
@ -537,30 +537,30 @@ Control_Sequence::menu_cb ( const Fl_Menu_ *m )
const char *path = ((OSC::Signal*)m->mvalue()->user_data())->path(); const char *path = ((OSC::Signal*)m->mvalue()->user_data())->path();
if ( ! _osc_output()->is_connected_to( ((OSC::Signal*)m->mvalue()->user_data()) ) ) /* if ( ! _osc_output()->is_connected_to( ((OSC::Signal*)m->mvalue()->user_data()) ) ) */
{ {
_persistent_osc_connections.push_back( strdup(path) ); _persistent_osc_connections.push_back( strdup(path) );
connect_osc(); connect_osc();
} }
else /* else */
{ /* { */
timeline->osc->disconnect_signal( _osc_output(), path ); /* timeline->osc->disconnect_signal( _osc_output(), path ); */
for ( std::list<char*>::iterator i = _persistent_osc_connections.begin(); /* for ( std::list<char*>::iterator i = _persistent_osc_connections.begin(); */
i != _persistent_osc_connections.end(); /* i != _persistent_osc_connections.end(); */
++i ) /* ++i ) */
{ /* { */
if ( !strcmp( *i, path ) ) /* if ( !strcmp( *i, path ) ) */
{ /* { */
free( *i ); /* free( *i ); */
i = _persistent_osc_connections.erase( i ); /* i = _persistent_osc_connections.erase( i ); */
break; /* break; */
} /* } */
} /* } */
//free( path ); /* //free( path ); */
} /* } */
} }
else if ( ! strcmp( picked, "Interpolation/Linear" ) ) else if ( ! strcmp( picked, "Interpolation/Linear" ) )
@ -618,7 +618,7 @@ Control_Sequence::connect_osc ( void )
} }
} }
header()->outputs_indicator->value( _osc_output() && _osc_output()->connected() ); /* header()->outputs_indicator->value( _osc_output() && _osc_output()->connected() ); */
timeline->osc_thread->unlock(); timeline->osc_thread->unlock();
} }
@ -644,7 +644,7 @@ static const char *peer_prefix;
void void
Control_Sequence::update_osc_connection_state ( void ) Control_Sequence::update_osc_connection_state ( void )
{ {
header()->outputs_indicator->value( _osc_output() && _osc_output()->connected() ); /* header()->outputs_indicator->value( _osc_output() && _osc_output()->connected() ); */
} }
void void