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
Chain::sample_rate_change ( nframes_t nframes, void *v )
{
((Chain*)v)->sample_rate_change( nframes );
return ((Chain*)v)->sample_rate_change( nframes );
}
int

View File

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

View File

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

View File

@ -309,7 +309,7 @@ void Mixer::cb_menu(Fl_Widget* o) {
}
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();
}

View File

@ -306,20 +306,14 @@ Module::handle_control_changed ( Port *p )
p->send_feedback();
}
bool
Module::Port::connected_osc ( void ) const
{
if ( _scaled_signal )
return _scaled_signal->connected();
else
return false;
}
void
Module::Port::learn_osc ( void )
{
_scaled_signal->learn_connection();
}
/* bool */
/* Module::Port::connected_osc ( void ) const */
/* { */
/* if ( _scaled_signal ) */
/* return _scaled_signal->connected(); */
/* else */
/* return false; */
/* } */
char *
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 + 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() )

View File

@ -123,8 +123,6 @@ public:
static int osc_control_change_exact ( float v, void *user_data );
static int osc_control_change_cv ( float v, void *user_data );
void learn_osc ( void );
Hints hints;
Port ( Module *module, Direction direction, Type type, const char *name = 0 )
@ -334,14 +332,14 @@ public:
return false;
}
bool
is_being_controlled_osc ( void ) const
{
for ( nframes_t i = control_input.size(); i--; )
if ( control_input[i].connected_osc() )
return true;
return false;
}
/* bool */
/* is_being_controlled_osc ( void ) const */
/* { */
/* for ( nframes_t i = control_input.size(); i--; ) */
/* if ( control_input[i].connected_osc() ) */
/* return true; */
/* return false; */
/* } */
virtual const char *name ( void ) const = 0;
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];
/* p->learn_osc(); */
if ( p->connected() )
/* can only bind once */
return;

View File

@ -110,37 +110,12 @@ namespace OSC
_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
Signal::value ( float f )
{
if ( f == _value )
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;
if ( direction() == Output )
@ -156,55 +131,49 @@ namespace OSC
// free(s);
}
else if ( direction() == Input )
{
DMESSAGE( "Sending value feedback for signal %s...", path() );
for ( std::list<Signal*>::iterator i = _incoming.begin();
i != _incoming.end();
++i )
{
DMESSAGE( "Sending value feedback to %s %s %f", lo_address_get_url( (*i)->_peer->addr), (*i)->path() , f);
_endpoint->send( (*i)->_peer->addr,
(*i)->path(),
f );
}
}
/* else if ( direction() == Input ) */
/* { */
/* DMESSAGE( "Sending value feedback for signal %s...", path() ); */
/* for ( std::list<Signal*>::iterator i = _incoming.begin(); */
/* i != _incoming.end(); */
/* ++i ) */
/* { */
/* DMESSAGE( "Sending value feedback to %s %s %f", lo_address_get_url( (*i)->_peer->addr), (*i)->path() , f); */
/* _endpoint->send( (*i)->_peer->addr, */
/* (*i)->path(), */
/* f ); */
/* } */
/* } */
}
void
Signal::learn_connection ( void )
{
_endpoint->_learn_signal = this;
}
/* char * */
/* Signal::get_output_connection_peer_name_and_path ( int n ) */
/* { */
/* Signal *t = NULL; */
char *
Signal::get_output_connection_peer_name_and_path ( int n )
{
Signal *t = NULL;
/* int j = 0; */
/* for ( std::list<Signal*>::const_iterator i = _outgoing.begin(); */
/* i != _outgoing.end(); */
/* ++i, ++j ) */
/* { */
/* if ( j == n ) */
/* { */
/* t = *i; */
/* break; */
/* } */
/* } */
int j = 0;
for ( std::list<Signal*>::const_iterator i = _outgoing.begin();
i != _outgoing.end();
++i, ++j )
{
if ( j == n )
{
t = *i;
break;
}
}
if ( t )
{
char *r;
asprintf( &r, "%s%s", t->_peer->name, t->path() );
return r;
}
else
return NULL;
}
/* if ( t ) */
/* { */
/* char *r; */
/* asprintf( &r, "%s%s", t->_peer->name, t->path() ); */
/* return r; */
/* } */
/* else */
/* return NULL; */
/* } */
/* */
void
@ -222,7 +191,6 @@ namespace OSC
_peer_scan_complete_userdata = 0;
_server = 0;
_name = 0;
_learn_signal = 0;
owner = 0;
}
@ -402,8 +370,6 @@ namespace OSC
if ( s->_direction == Signal::Input )
{
/* s->_incoming.remove( ps ); */
DMESSAGE( "Peer %s has disconnected from signal %s", our_name, their_name );
ep->del_translation( their_name );
@ -456,14 +422,6 @@ namespace OSC
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 );
if ( ! o )
@ -474,34 +432,6 @@ namespace OSC
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 )
ep->_peer_signal_notification_callback( o, Signal::Removed, ep->_peer_signal_notification_userdata );
@ -596,13 +526,11 @@ namespace OSC
{
Signal *o;
float f = 0.0;
Endpoint *ep = NULL;
if ( ! strcmp( types, "f" ) )
{
/* accept a value for signal named in path */
o = (Signal*)user_data;
ep = o->_endpoint;
f = argv[0]->f;
}
else if ( ! types || 0 == types[0] )
@ -895,79 +823,26 @@ namespace OSC
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
Endpoint::disconnect_signal ( OSC::Signal *s, const char *signal_path )
{
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 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 true;
}
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
Endpoint::connect_signal( OSC::Signal *s, const char *signal_path )
{
@ -1163,37 +1038,6 @@ namespace OSC
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! */
_signals.remove( o );

View File

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

View File

@ -266,21 +266,21 @@ Control_Sequence::get_unjournaled ( Log_Entry &e ) const
{
e.add( ":interpolation", _interpolation );
if ( _osc_output() && _osc_output()->connected() )
{
DMESSAGE( "OSC Output connections: %i", _osc_output()->noutput_connections() );
/* if ( _osc_output() && _osc_output()->connected() ) */
/* { */
/* DMESSAGE( "OSC Output connections: %i", _osc_output()->noutput_connections() ); */
for ( int i = 0; i < _osc_output()->noutput_connections(); ++i )
{
char *s;
/* for ( int i = 0; i < _osc_output()->noutput_connections(); ++i ) */
/* { */
/* 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() );
}
@ -537,30 +537,30 @@ Control_Sequence::menu_cb ( const Fl_Menu_ *m )
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) );
connect_osc();
}
else
{
timeline->osc->disconnect_signal( _osc_output(), path );
/* else */
/* { */
/* timeline->osc->disconnect_signal( _osc_output(), path ); */
for ( std::list<char*>::iterator i = _persistent_osc_connections.begin();
i != _persistent_osc_connections.end();
++i )
{
if ( !strcmp( *i, path ) )
{
free( *i );
i = _persistent_osc_connections.erase( i );
break;
}
}
/* for ( std::list<char*>::iterator i = _persistent_osc_connections.begin(); */
/* i != _persistent_osc_connections.end(); */
/* ++i ) */
/* { */
/* if ( !strcmp( *i, path ) ) */
/* { */
/* free( *i ); */
/* i = _persistent_osc_connections.erase( i ); */
/* break; */
/* } */
/* } */
//free( path );
}
/* //free( path ); */
/* } */
}
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();
}
@ -644,7 +644,7 @@ static const char *peer_prefix;
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