diff --git a/nonlib/JACK/Client.C b/nonlib/JACK/Client.C index c9de7a9..9cffe31 100644 --- a/nonlib/JACK/Client.C +++ b/nonlib/JACK/Client.C @@ -186,6 +186,11 @@ namespace JACK void Client::thaw_ports ( void ) { + /* Sort ports for the sake of clients (e.g. patchage), for + * whom the order of creation may matter (for display) */ + + _active_ports.sort(); + for ( std::list < JACK::Port * >::iterator i = _active_ports.begin(); i != _active_ports.end(); ++i ) diff --git a/nonlib/JACK/Port.C b/nonlib/JACK/Port.C index a6ef7a3..abdd71b 100644 --- a/nonlib/JACK/Port.C +++ b/nonlib/JACK/Port.C @@ -100,6 +100,15 @@ namespace JACK } + /* sort input before output and then by alpha */ + bool + Port::operator < ( const Port & rhs ) const + { + if ( type() == rhs.type() ) + return strcmp( name(), rhs.name() ); + else + return type() == Port::Input; + } static const char * @@ -224,6 +233,15 @@ namespace JACK return jack_port_get_connections( _port ); } + Port::type_e + Port::type ( void ) const + { + if ( _freezer ) + return _freezer->direction; + else + return jack_port_flags( _port ) == JackPortIsOutput ? Output : Input; + } + /** Restore the connections returned by connections() */ bool Port::connections ( const char **port_names ) diff --git a/nonlib/JACK/Port.H b/nonlib/JACK/Port.H index 273a2f0..712ec45 100644 --- a/nonlib/JACK/Port.H +++ b/nonlib/JACK/Port.H @@ -39,6 +39,8 @@ namespace JACK public: + bool operator < ( const Port & rhs ) const; + enum type_e { Output, Input }; static int max_name ( void ); @@ -56,10 +58,7 @@ namespace JACK bool valid ( void ) const { return _port; } bool connected ( void ) const { return jack_port_connected( _port ); } - type_e type ( void ) const - { - return jack_port_flags( _port ) == JackPortIsOutput ? Output : Input; - } + type_e type ( void ) const; const char * name ( void ) const { return _name; } bool name ( const char *name ); bool name ( const char *base, int n, const char *type=0 );